Welcome to mirror list, hosted at ThFree Co, Russian Federation.

BL_Material.h « Ketsji « gameengine « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 83f9b601e0d1583e2cb8ab650d87c0a5bd7e44f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183

/** \file BL_Material.h
 *  \ingroup ketsji
 */

#ifndef __BL_MATERIAL_H__
#define __BL_MATERIAL_H__

#include "STR_String.h"
#include "MT_Point2.h"
#include "DNA_meshdata_types.h"

#ifdef WITH_CXX_GUARDEDALLOC
#include "MEM_guardedalloc.h"
#endif

// --
struct MTex;
struct Material;
struct Image;
struct MTFace;
struct MTex;
struct Material;
struct EnvMap;
// --

/** max units
 * this will default to users available units
 * to build with more available, just increment this value
 * although the more you add the slower the search time will be.
 * we will go for eight, which should be enough
 */
#define MAXTEX			8	//match in RAS_TexVert & RAS_OpenGLRasterizer

// different mapping modes
class BL_Mapping
{
public:
	int mapping;
	float scale[3];
	float offsets[3];
	int projplane[3];
	STR_String objconame;
	STR_String uvCoName;
};

// base material struct
class BL_Material
{
private:
	int num_users;
	bool share;

public:
	// -----------------------------------
	BL_Material();
	void Initialize();

	int IdMode;
	unsigned int ras_mode;
	bool glslmat;

	STR_String texname[MAXTEX];
	unsigned int flag[MAXTEX];
	int tile,tilexrep[MAXTEX],tileyrep[MAXTEX];
	STR_String matname;
	STR_String mtexname[MAXTEX];
	int materialindex;

	float matcolor[4];
	float speccolor[3];
	short alphablend, pad;

	float hard, spec_f;
	float alpha, emit, color_blend[MAXTEX], ref;
	float amb;

	int blend_mode[MAXTEX];

	int num_enabled;
	
	BL_Mapping	mapping[MAXTEX];
	STR_String	imageId[MAXTEX];


	Material*			material;
	MTFace				tface; /* copy of the derived meshes tface */
	Image*				img[MAXTEX];
	EnvMap*				cubemap[MAXTEX];

	unsigned int rgb[4];

	void SetSharedMaterial(bool v);
	bool IsShared();
	void SetUsers(int num);
	
	
#ifdef WITH_CXX_GUARDEDALLOC
	MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_Material")
#endif
};

// BL_Material::IdMode
enum BL_IdMode {
	DEFAULT_BLENDER=-1,
	TEXFACE,
	ONETEX,
	TWOTEX,
	GREATERTHAN2
};

// BL_Material::blend_mode[index]
enum BL_BlendMode
{
	BLEND_MIX=1,
	BLEND_ADD,
	BLEND_SUB,
	BLEND_MUL,
	BLEND_SCR
};

// -------------------------------------
// BL_Material::flag[index]
enum BL_flag
{
	MIPMAP=1,		// set to use mipmaps
	CALCALPHA=2,	// additive
	USEALPHA=4,		// use actual alpha channel
	TEXALPHA=8,		// use alpha combiner functions
	TEXNEG=16,		// negate blending
	/*HASIPO=32,*/	// unused, commeted for now.
	USENEGALPHA=64
};

// BL_Material::ras_mode
enum BL_ras_mode
{
	// POLY_VIS=1,
	COLLIDER=2,
	ZSORT=4,
	ALPHA=8,
	// TRIANGLE=16,
	USE_LIGHT=32,
	WIRE=64,
	CAST_SHADOW=128,
	TEX=256,
	TWOSIDED=512,
	ONLY_SHADOW=1024,
};

// -------------------------------------
// BL_Material::mapping[index]::mapping
enum BL_MappingFlag
{
	USEENV	=1,
	// --
	USEREFL	=2,
	USEOBJ	=4,
	USENORM	=8,
	USEORCO =16,
	USEUV	=32,
	USETANG	=64,
	DISABLE =128,
	USECUSTOMUV=256
};

// BL_Material::BL_Mapping::projplane
enum BL_MappingProj
{
	PROJN=0,
	PROJX,
	PROJY,
	PROJZ
};

// ------------------------------------
//extern void initBL_Material(BL_Material* mat);
extern MTex* getMTexFromMaterial(Material *mat, int index);
// ------------------------------------

#endif