FreeWRL / FreeX3D
4.3.0
Component_Shape.h
1
/*
2
3
4
Proximity sensor macro.
5
6
*/
7
8
/****************************************************************************
9
This file is part of the FreeWRL/FreeX3D Distribution.
10
11
Copyright 2009 CRC Canada. (http://www.crc.gc.ca)
12
13
FreeWRL/FreeX3D is free software: you can redistribute it and/or modify
14
it under the terms of the GNU Lesser Public License as published by
15
the Free Software Foundation, either version 3 of the License, or
16
(at your option) any later version.
17
18
FreeWRL/FreeX3D is distributed in the hope that it will be useful,
19
but WITHOUT ANY WARRANTY; without even the implied warranty of
20
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
GNU General Public License for more details.
22
23
You should have received a copy of the GNU General Public License
24
along with FreeWRL/FreeX3D. If not, see <http://www.gnu.org/licenses/>.
25
****************************************************************************/
26
27
28
29
#ifndef __FREEWRL_SCENEGRAPH_SHAPE_H__
30
#define __FREEWRL_SCENEGRAPH_SHAPE_H__
31
32
33
/*******************************************************/
34
35
36
/*
37
38
Bit-wise operations here - these can be OR'd together to
39
create the specific shader we want.
40
41
DO NOT MESS UP THE BITS! (look at these in binary for
42
proper or-ing of the values)
43
44
Sept 25, 2016:
45
shaderflags changed from int to struct { int, int, int }
46
{
47
base, built from bit flags, and is also a fallback if userShader is desired but doesn't compile
48
effect (castle Effect)
49
user shader number (programmableShader)
50
}
51
- Could have done one long long int with 3 ranges, or int[3] instead; struct seems handy.
52
- In general needed more breathing room, especially for new effects which are bit mask or-able together, unlike
53
user shaders that do only one user shader at a time
54
- now to test if its a usershader, just test if .usershaders != 0 (they start at 1)
55
- need to memset(,0,) the struct if creating fresh
56
- if need more bits in the future, add another member or change one to longlong
57
and look for places where we see if its == ie in opengl_utils.c
58
if (me->whichOne.base == rq_cap0.base && me->whichOne.effects == rq_cap0.effects && me->whichOne.usershaders == rq_cap0.usershaders) {
59
60
*/
61
62
typedef
struct
{
63
int
base;
64
int
effects;
65
int
usershaders;
66
int
volume;
67
}
shaderflagsstruct
;
68
69
shaderflagsstruct
getShaderFlags();
70
void
popShaderFlags(
void
);
71
void
pushShaderFlags(
shaderflagsstruct
);
72
s_shader_capabilities_t
*getMyShaders(
shaderflagsstruct
);
73
74
75
76
#define NO_APPEARANCE_SHADER 0x0001
77
#define MATERIAL_APPEARANCE_SHADER 0x0002
78
#define TWO_MATERIAL_APPEARANCE_SHADER 0x0004
79
#define ONE_TEX_APPEARANCE_SHADER 0x0008
80
#define MULTI_TEX_APPEARANCE_SHADER 0x0010
81
82
/* PolyRep (etc) color field present */
83
#define COLOUR_MATERIAL_SHADER 0x00020
84
85
/* - fillProperties present */
86
#define FILL_PROPERTIES_SHADER 0x00040
87
88
/* - lines, points */
89
#define HAVE_LINEPOINTS_COLOR 0x0080
90
#define HAVE_LINEPOINTS_APPEARANCE 0x00100
91
92
/* TextureCoordinateGenerator */
93
#define HAVE_TEXTURECOORDINATEGENERATOR 0x00200
94
95
/* CubeMapTexturing */
96
#define HAVE_CUBEMAP_TEXTURE 0x00400
97
/* more OR-able flags for compositing shaders */
98
#define FOG_APPEARANCE_SHADER 0X00800
99
#define HAVE_FOG_COORDS 0x01000
100
#define TEXTURE_REPLACE_PRIOR 0x02000
101
#define TEXALPHA_REPLACE_PRIOR 0x04000
102
#define CPV_REPLACE_PRIOR 0x08000
103
#define SHADINGSTYLE_FLAT 0x10000
104
#define SHADINGSTYLE_GOURAUD 0x20000
105
#define SHADINGSTYLE_PHONG 0x40000
106
#define SHADINGSTYLE_WIRE 0x80000
107
#define MAT_FIRST 0x100000
108
#define WANT_ANAGLYPH 0x200000
109
#define TEX3D_SHADER 0X400000
110
#define TEX3D_LAYER_SHADER 0x800000
111
#define CLIPPLANE_SHADER 0x1000000
112
#define PARTICLE_SHADER 0X2000000
113
#define HAVE_UNLIT_COLOR 0x4000000
114
#define HAVE_PROJECTIVETEXTURE 0X8000000
115
//can go up to 2^32 - for future components like volume, particle, hanim
116
117
//goes into flags.volume
118
#define SHADERFLAGS_VOLUME_DATA_BASIC 0x001
119
#define SHADERFLAGS_VOLUME_DATA_SEGMENT 0x002
120
#define SHADERFLAGS_VOLUME_DATA_ISO 0x004
121
#define SHADERFLAGS_VOLUME_DATA_ISO_MODE3 0x008
122
//#define SHADERFLAGS_VOLUME_STYLE_OPACITY 0x001
123
//#define SHADERFLAGS_VOLUME_STYLE_BLENDED 0x002
124
//#define SHADERFLAGS_VOLUME_STYLE_BOUNDARY 0x004
125
//#define SHADERFLAGS_VOLUME_STYLE_CARTOON 0x008
126
//#define SHADERFLAGS_VOLUME_STYLE_COMPOSED 0x010
127
//#define SHADERFLAGS_VOLUME_STYLE_EDGE 0x020
128
//#define SHADERFLAGS_VOLUME_STYLE_PROJECTION 0x040
129
//#define SHADERFLAGS_VOLUME_STYLE_SHADED 0x080
130
//#define SHADERFLAGS_VOLUME_STYLE_SILHOUETTE 0x100
131
//#define SHADERFLAGS_VOLUME_STYLE_TONE 0x200
132
133
#define SHADERFLAGS_VOLUME_STYLE_DEFAULT 1
134
#define SHADERFLAGS_VOLUME_STYLE_OPACITY 2
135
#define SHADERFLAGS_VOLUME_STYLE_BLENDED 3
136
#define SHADERFLAGS_VOLUME_STYLE_BOUNDARY 4
137
#define SHADERFLAGS_VOLUME_STYLE_CARTOON 5
138
#define SHADERFLAGS_VOLUME_STYLE_COMPOSED 6
139
#define SHADERFLAGS_VOLUME_STYLE_EDGE 7
140
#define SHADERFLAGS_VOLUME_STYLE_PROJECTION 8
141
#define SHADERFLAGS_VOLUME_STYLE_SHADED 9
142
#define SHADERFLAGS_VOLUME_STYLE_SILHOUETTE 10
143
#define SHADERFLAGS_VOLUME_STYLE_TONE 11
144
/*******************************************************/
145
146
147
struct
fw_MaterialParameters
{
148
float
emission[4];
149
float
ambient[4];
150
float
diffuse[4];
151
float
specular[4];
152
float
shininess;
153
};
154
155
struct
matpropstruct
{
156
/* material properties for current shape */
157
struct
fw_MaterialParameters
fw_FrontMaterial;
158
struct
fw_MaterialParameters
fw_BackMaterial;
159
160
/* which shader is active; 0 = no shader active */
161
s_shader_capabilities_t
*currentShaderProperties;
162
163
float
transparency;
164
GLfloat emissionColour[3];
165
GLint cubeFace;
/* for cubemapping, if 0, not cube mapping */
166
int
cullFace;
/* is this single-sided or two-sided? Simply used to reduce calls to
167
GL_ENABLE(GL_CULL_FACE), etc */
168
169
/* for FillProperties, and LineProperties, line type (NOT pointsize) */
170
int
algorithm;
171
bool
hatchedBool;
172
bool
filledBool;
173
GLfloat hatchPercent[2];
174
GLfloat hatchScale[2];
175
GLfloat hatchColour[4];
176
177
// points now specified in shader, not via an opengl call
178
GLfloat pointSize;
179
180
//TextureCoordinateGenerator value - a "TCGT_XXX" type
181
int
texCoordGeneratorType;
182
};
183
184
struct
matpropstruct
* getAppearanceProperties();
185
void
setUserShaderNode(
struct
X3D_Node
*me);
186
187
#define MIN_NODE_TRANSPARENCY 0.0f
188
#define MAX_NODE_TRANSPARENCY 0.99f
/* if 1.0, then occlusion culling will cause flashing */
189
190
#define RENDER_MATERIAL_SUBNODES(which) \
191
{ struct X3D_Node *tmpN; \
192
POSSIBLE_PROTO_EXPANSION(struct X3D_Node *, which,tmpN) \
193
if(tmpN) { \
194
render_node(tmpN); \
195
} \
196
}
197
198
199
#define SET_SHADER_SELECTED_FALSE(x3dNode) \
200
switch (X3D_NODE(x3dNode)->_nodeType) { \
201
case NODE_ComposedShader: \
202
X3D_COMPOSEDSHADER(x3dNode)->isSelected = FALSE; \
203
break; \
204
case NODE_ProgramShader: \
205
X3D_PROGRAMSHADER(x3dNode)->isSelected = FALSE; \
206
break; \
207
case NODE_PackagedShader: \
208
X3D_PROGRAMSHADER(x3dNode)->isSelected = FALSE; \
209
break; \
210
default: { \
211
/* this is NOT a shader; should we say something, or just \
212
ignore? Lets ignore, for now */
\
213
} \
214
}
215
216
#define SET_FOUND_GOOD_SHADER(x3dNode) \
217
switch (X3D_NODE(x3dNode)->_nodeType) { \
218
case NODE_ComposedShader: \
219
foundGoodShader = X3D_COMPOSEDSHADER(x3dNode)->isValid; \
220
X3D_COMPOSEDSHADER(x3dNode)->isSelected = foundGoodShader; \
221
break; \
222
case NODE_ProgramShader: \
223
foundGoodShader = X3D_PROGRAMSHADER(x3dNode)->isValid; \
224
X3D_PROGRAMSHADER(x3dNode)->isSelected = foundGoodShader; \
225
break; \
226
case NODE_PackagedShader: \
227
foundGoodShader = X3D_PROGRAMSHADER(x3dNode)->isValid; \
228
X3D_PACKAGEDSHADER(x3dNode)->isSelected = foundGoodShader; \
229
break; \
230
default: { \
231
/* this is NOT a shader; should we say something, or just \
232
ignore? Lets ignore, for now */
\
233
} \
234
}
235
#endif
/* __FREEWRL_SCENEGRAPH_SHAPE_H__ */
X3D_Node
Definition
Structs.h:2589
fw_MaterialParameters
Definition
Component_Shape.h:147
matpropstruct
Definition
Component_Shape.h:155
s_shader_capabilities
Definition
display.h:345
shaderflagsstruct
Definition
Component_Shape.h:62
src
lib
scenegraph
Component_Shape.h
Generated by
1.11.0