Blender V2.61 - r43446
Defines | Functions | Variables

material.c File Reference

#include <string.h>
#include <math.h>
#include <stddef.h>
#include "MEM_guardedalloc.h"
#include "DNA_curve_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_customdata_types.h"
#include "DNA_ID.h"
#include "DNA_meta_types.h"
#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BLI_math.h"
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "BLI_bpath.h"
#include "BLI_string.h"
#include "BKE_animsys.h"
#include "BKE_displist.h"
#include "BKE_global.h"
#include "BKE_icons.h"
#include "BKE_image.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_mesh.h"
#include "BKE_node.h"
#include "BKE_curve.h"
#include "GPU_material.h"

Go to the source code of this file.

Defines

#define GS(a)   (*((short *)(a)))
#define MAT_BGE_DISPUTED   -99999

Functions

void init_def_material (void)
void free_material (Material *ma)
void init_material (Material *ma)
Materialadd_material (const char *name)
Materialcopy_material (Material *ma)
Materiallocalize_material (Material *ma)
static void extern_local_material (Material *ma)
void make_local_material (Material *ma)
void extern_local_matarar (struct Material **matar, short totcol)
Material *** give_matarar (Object *ob)
short * give_totcolp (Object *ob)
Material *** give_matarar_id (ID *id)
short * give_totcolp_id (ID *id)
static void data_delete_material_index_id (ID *id, short index)
void material_append_id (ID *id, Material *ma)
Materialmaterial_pop_id (ID *id, int index_i, int remove_material_slot)
Materialgive_current_material (Object *ob, short act)
IDmaterial_from (Object *ob, short act)
Materialgive_node_material (Material *ma)
void resize_object_material (Object *ob, const short totcol)
void test_object_materials (ID *id)
void assign_material_id (ID *id, Material *ma, short act)
void assign_material (Object *ob, Material *ma, short act)
void assign_matarar (struct Object *ob, struct Material ***matar, short totcol)
short find_material_index (Object *ob, Material *ma)
int object_add_material_slot (Object *ob)
static void do_init_render_material (Material *ma, int r_mode, float *amb)
static void init_render_nodetree (bNodeTree *ntree, Material *basemat, int r_mode, float *amb)
void init_render_material (Material *mat, int r_mode, float *amb)
void init_render_materials (Main *bmain, int r_mode, float *amb)
void end_render_material (Material *mat)
void end_render_materials (Main *bmain)
static int material_in_nodetree (bNodeTree *ntree, Material *mat)
int material_in_material (Material *parmat, Material *mat)
void automatname (Material *ma)
int object_remove_material_slot (Object *ob)
void ramp_blend (int type, float r_col[3], const float fac, const float col[3])
void clear_matcopybuf (void)
void free_matcopybuf (void)
void copy_matcopybuf (Material *ma)
void paste_matcopybuf (Material *ma)
static int encode_tfaceflag (MTFace *tf, int convertall)
static void decode_tfaceflag (Material *ma, int flag, int convertall)
static int check_tfaceneedmaterial (int flag)
static int integer_getdigits (int number)
static void calculate_tface_materialname (char *matname, char *newname, int flag)
static short mesh_getmaterialnumber (Mesh *me, Material *ma)
static short mesh_addmaterial (Mesh *me, Material *ma)
static void set_facetexture_flags (Material *ma, Image *image)
static short convert_tfacenomaterial (Main *main, Mesh *me, MTFace *tf, int flag)
static void convert_tfacematerial (Main *main, Material *ma)
int do_version_tface (Main *main, int fileload)

Variables

Material defmaterial
static char colname_array [125][20]
static Material matcopybuf
static short matcopied = 0

Detailed Description

Definition in file material.c.


Define Documentation

#define GS (   a)    (*((short *)(a)))
#define MAT_BGE_DISPUTED   -99999

Definition at line 1779 of file material.c.

Referenced by do_version_tface().


Function Documentation

Material* add_material ( const char *  name) [read]
void assign_matarar ( struct Object ob,
struct Material ***  matar,
short  totcol 
)
void assign_material ( Object ob,
Material ma,
short  act 
)
void assign_material_id ( ID id,
Material ma,
short  act 
)
void automatname ( Material ma)
static void calculate_tface_materialname ( char *  matname,
char *  newname,
int  flag 
) [static]

Definition at line 1610 of file material.c.

References BLI_snprintf(), integer_getdigits(), and MAX_ID_NAME.

Referenced by convert_tfacematerial().

static int check_tfaceneedmaterial ( int  flag) [static]

Definition at line 1567 of file material.c.

References TF_ALPHA, TF_DYNAMIC, TF_LIGHT, TF_OBCOL, TF_SHAREDCOL, TF_SHAREDVERT, and TF_TEX.

Referenced by do_version_tface().

void clear_matcopybuf ( void  )

Definition at line 1402 of file material.c.

References matcopied.

Referenced by WM_init().

static void convert_tfacematerial ( Main main,
Material ma 
) [static]
static short convert_tfacenomaterial ( Main main,
Mesh me,
MTFace tf,
int  flag 
) [static]
void copy_matcopybuf ( Material ma)
Material* copy_material ( Material ma) [read]
static void data_delete_material_index_id ( ID id,
short  index 
) [static]
static void decode_tfaceflag ( Material ma,
int  flag,
int  convertall 
) [static]
static void do_init_render_material ( Material ma,
int  r_mode,
float *  amb 
) [static]
int do_version_tface ( Main main,
int  fileload 
)
static int encode_tfaceflag ( MTFace tf,
int  convertall 
) [static]
void end_render_material ( Material mat)
void end_render_materials ( Main bmain)

Definition at line 1019 of file material.c.

References end_render_material(), ListBase::first, Material::id, Main::mat, ID::next, and ID::us.

Referenced by RE_Database_Free().

void extern_local_matarar ( struct Material **  matar,
short  totcol 
)

Definition at line 443 of file material.c.

References i, and id_lib_extern().

Referenced by expand_local_mesh(), extern_local_curve(), extern_local_mball(), and extern_local_object().

static void extern_local_material ( Material ma) [static]

Definition at line 275 of file material.c.

References i, id_lib_extern(), MAX_MTEX, Material::mtex, and MTex::tex.

Referenced by make_local_material().

short find_material_index ( Object ob,
Material ma 
)

Definition at line 856 of file material.c.

References give_matarar(), give_totcolp(), and NULL.

void free_matcopybuf ( void  )
void free_material ( Material ma)
Material* give_current_material ( Object ob,
short  act 
) [read]
Material*** give_matarar ( Object ob) [read]
Material*** give_matarar_id ( ID id) [read]

Definition at line 494 of file material.c.

References GS, ID_CU, ID_MB, ID_ME, ID::name, and NULL.

Referenced by assign_material_id(), material_append_id(), and material_pop_id().

Material* give_node_material ( Material ma) [read]
short* give_totcolp ( Object ob)
short* give_totcolp_id ( ID id)

Definition at line 510 of file material.c.

References GS, ID_CU, ID_MB, ID_ME, ID::name, and NULL.

Referenced by assign_material_id(), material_append_id(), material_pop_id(), and test_object_materials().

void init_def_material ( void  )

Definition at line 74 of file material.c.

References init_material().

Referenced by main().

void init_material ( Material ma)

Definition at line 111 of file material.c.

References Material::adapt_thresh_mir, Material::adapt_thresh_tra, Material::alpha, GameSettings::alpha_blend, Material::amb, Material::ang, Material::b, Material::darkness, VolumeSettings::density, VolumeSettings::density_scale, VolumeSettings::depth_cutoff, Material::dist_mir, VolumeSettings::emission, VolumeSettings::emission_col, GameSettings::face_orientation, Material::fadeto_mir, GameSettings::flag, Material::flareboost, Material::flarec, Material::flaresize, Material::fresnel_mir, Material::fresnel_mir_i, Material::fresnel_tra, Material::fresnel_tra_i, Material::friction, Material::g, Material::game, GEMAT_BACKCULL, Material::gloss_mir, Material::gloss_tra, Material::har, Material::hasize, Material::linec, MA_APPROX_OCCLUSION, MA_RAYBIAS, MA_RAYMIR_FADETOSKY, MA_SHADBUF, MA_SHADOW, MA_SPHERE, MA_TANGENT_STR, MA_TRACEBLE, MA_VOL_PRECACHESHADING, MA_VOL_SHADE_SHADED, MA_VOL_STEP_RANDOMIZED, MA_ZTRANSP, Material::mirb, Material::mirg, Material::mirr, Material::mode, VolumeSettings::ms_diff, VolumeSettings::ms_intensity, VolumeSettings::ms_spread, NULL, Material::param, Material::pr_lamp, Material::pr_type, VolumeSettings::precache_resolution, Material::preview, Material::r, Material::rampfac_col, Material::rampfac_spec, Material::ray_depth, Material::ray_depth_tra, Material::ref, VolumeSettings::reflection, VolumeSettings::reflection_col, Material::refrac, Material::ringc, Material::rms, Material::roughness, Material::samp_gloss_mir, Material::samp_gloss_tra, VolumeSettings::scattering, Material::seed2, Material::shad_alpha, Material::shade_flag, VolumeSettings::shade_type, VolumeSettings::shadeflag, Material::spec, Material::specb, Material::specg, Material::specr, Material::spectra, Material::sss_back, Material::sss_col, Material::sss_colfac, Material::sss_error, Material::sss_front, Material::sss_ior, Material::sss_radius, Material::sss_scale, Material::sss_texfac, Material::starc, VolumeSettings::stepsize, VolumeSettings::stepsize_type, Material::strand_end, Material::strand_sta, Material::subsize, VolumeSettings::transmission_col, Material::tx_falloff, Material::tx_limit, and Material::vol.

Referenced by add_material(), and init_def_material().

void init_render_material ( Material mat,
int  r_mode,
float *  amb 
)
void init_render_materials ( Main bmain,
int  r_mode,
float *  amb 
)
static void init_render_nodetree ( bNodeTree ntree,
Material basemat,
int  r_mode,
float *  amb 
) [static]
static int integer_getdigits ( int  number) [static]

Definition at line 1598 of file material.c.

References i.

Referenced by calculate_tface_materialname(), and convert_tfacenomaterial().

Material* localize_material ( Material ma) [read]
void make_local_material ( Material ma)
void material_append_id ( ID id,
Material ma 
)
ID* material_from ( Object ob,
short  act 
) [read]

Definition at line 641 of file material.c.

References Object::data, Object::matbits, NULL, and Object::totcol.

int material_in_material ( Material parmat,
Material mat 
)

Definition at line 1044 of file material.c.

References material_in_nodetree(), Material::nodetree, and Material::use_nodes.

Referenced by zbuffer_sss().

static int material_in_nodetree ( bNodeTree ntree,
Material mat 
) [static]
Material* material_pop_id ( ID id,
int  index_i,
int  remove_material_slot 
) [read]
static short mesh_addmaterial ( Mesh me,
Material ma 
) [static]
static short mesh_getmaterialnumber ( Mesh me,
Material ma 
) [static]

Definition at line 1622 of file material.c.

References Mesh::mat, and Mesh::totcol.

Referenced by convert_tfacematerial(), and convert_tfacenomaterial().

int object_add_material_slot ( Object ob)

Definition at line 876 of file material.c.

References Object::actcol, assign_material(), FALSE, MAXMAT, NULL, Object::totcol, and TRUE.

Referenced by material_slot_add_exec().

int object_remove_material_slot ( Object ob)
void paste_matcopybuf ( Material ma)
void ramp_blend ( int  type,
float  r_col[3],
const float  fac,
const float  col[3] 
)
void resize_object_material ( Object ob,
const short  totcol 
)
static void set_facetexture_flags ( Material ma,
Image image 
) [static]
void test_object_materials ( ID id)

Variable Documentation

char colname_array[125][20] [static]
Initial value:
 {
"Black","DarkRed","HalfRed","Red","Red",
"DarkGreen","DarkOlive","Brown","Chocolate","OrangeRed",
"HalfGreen","GreenOlive","DryOlive","Goldenrod","DarkOrange",
"LightGreen","Chartreuse","YellowGreen","Yellow","Gold",
"Green","LawnGreen","GreenYellow","LightOlive","Yellow",
"DarkBlue","DarkPurple","HotPink","VioletPink","RedPink",
"SlateGray","DarkGrey","PalePurple","IndianRed","Tomato",
"SeaGreen","PaleGreen","GreenKhaki","LightBrown","LightSalmon",
"SpringGreen","PaleGreen","MediumOlive","YellowBrown","LightGold",
"LightGreen","LightGreen","LightGreen","GreenYellow","PaleYellow",
"HalfBlue","DarkSky","HalfMagenta","VioletRed","DeepPink",
"SteelBlue","SkyBlue","Orchid","LightHotPink","HotPink",
"SeaGreen","SlateGray","MediumGrey","Burlywood","LightPink",
"SpringGreen","Aquamarine","PaleGreen","Khaki","PaleOrange",
"SpringGreen","SeaGreen","PaleGreen","PaleWhite","YellowWhite",
"LightBlue","Purple","MediumOrchid","Magenta","Magenta",
"RoyalBlue","SlateBlue","MediumOrchid","Orchid","Magenta",
"DeepSkyBlue","LightSteelBlue","LightSkyBlue","Violet","LightPink",
"Cyan","DarkTurquoise","SkyBlue","Grey","Snow",
"Mint","Mint","Aquamarine","MintCream","Ivory",
"Blue","Blue","DarkMagenta","DarkOrchid","Magenta",
"SkyBlue","RoyalBlue","LightSlateBlue","MediumOrchid","Magenta",
"DodgerBlue","SteelBlue","MediumPurple","PalePurple","Plum",
"DeepSkyBlue","PaleBlue","LightSkyBlue","PalePurple","Thistle",
"Cyan","ColdBlue","PaleTurquoise","GhostWhite","White"
}

Definition at line 1056 of file material.c.

Referenced by automatname().

short matcopied = 0 [static]

Definition at line 1400 of file material.c.

Referenced by clear_matcopybuf(), copy_matcopybuf(), free_matcopybuf(), and paste_matcopybuf().

Material matcopybuf [static]

Definition at line 1399 of file material.c.