FreeWRL / FreeX3D 4.3.0
Component_Shape.h
1/*
2
3
4Proximity 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
44Sept 25, 2016:
45shaderflags 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
62typedef struct {
63int base;
64int effects;
65int usershaders;
66int volume;
68
69shaderflagsstruct getShaderFlags();
71
72
73
74#define NO_APPEARANCE_SHADER 0x0001
75#define MATERIAL_APPEARANCE_SHADER 0x0002
76#define TWO_MATERIAL_APPEARANCE_SHADER 0x0004
77#define ONE_TEX_APPEARANCE_SHADER 0x0008
78#define MULTI_TEX_APPEARANCE_SHADER 0x0010
79
80/* PolyRep (etc) color field present */
81#define COLOUR_MATERIAL_SHADER 0x00020
82
83/* - fillProperties present */
84#define FILL_PROPERTIES_SHADER 0x00040
85
86/* - lines, points */
87#define HAVE_LINEPOINTS_COLOR 0x0080
88#define HAVE_LINEPOINTS_APPEARANCE 0x00100
89
90/* TextureCoordinateGenerator */
91#define HAVE_TEXTURECOORDINATEGENERATOR 0x00200
92
93/* CubeMapTexturing */
94#define HAVE_CUBEMAP_TEXTURE 0x00400
95/* more OR-able flags for compositing shaders */
96#define FOG_APPEARANCE_SHADER 0X00800
97#define HAVE_FOG_COORDS 0x01000
98#define TEXTURE_REPLACE_PRIOR 0x02000
99#define TEXALPHA_REPLACE_PRIOR 0x04000
100#define CPV_REPLACE_PRIOR 0x08000
101#define SHADINGSTYLE_FLAT 0x10000
102#define SHADINGSTYLE_GOURAUD 0x20000
103#define SHADINGSTYLE_PHONG 0x40000
104#define SHADINGSTYLE_WIRE 0x80000
105#define MAT_FIRST 0x100000
106#define WANT_ANAGLYPH 0x200000
107#define TEX3D_SHADER 0X400000
108#define TEX3D_LAYER_SHADER 0x800000
109#define CLIPPLANE_SHADER 0x1000000
110#define PARTICLE_SHADER 0X2000000
111#define HAVE_UNLIT_COLOR 0x4000000
112#define HAVE_PROJECTIVETEXTURE 0X8000000
113//can go up to 2^32 - for future components like volume, particle, hanim
114
115//goes into flags.volume
116#define SHADERFLAGS_VOLUME_DATA_BASIC 0x001
117#define SHADERFLAGS_VOLUME_DATA_SEGMENT 0x002
118#define SHADERFLAGS_VOLUME_DATA_ISO 0x004
119#define SHADERFLAGS_VOLUME_DATA_ISO_MODE3 0x008
120//#define SHADERFLAGS_VOLUME_STYLE_OPACITY 0x001
121//#define SHADERFLAGS_VOLUME_STYLE_BLENDED 0x002
122//#define SHADERFLAGS_VOLUME_STYLE_BOUNDARY 0x004
123//#define SHADERFLAGS_VOLUME_STYLE_CARTOON 0x008
124//#define SHADERFLAGS_VOLUME_STYLE_COMPOSED 0x010
125//#define SHADERFLAGS_VOLUME_STYLE_EDGE 0x020
126//#define SHADERFLAGS_VOLUME_STYLE_PROJECTION 0x040
127//#define SHADERFLAGS_VOLUME_STYLE_SHADED 0x080
128//#define SHADERFLAGS_VOLUME_STYLE_SILHOUETTE 0x100
129//#define SHADERFLAGS_VOLUME_STYLE_TONE 0x200
130
131#define SHADERFLAGS_VOLUME_STYLE_DEFAULT 1
132#define SHADERFLAGS_VOLUME_STYLE_OPACITY 2
133#define SHADERFLAGS_VOLUME_STYLE_BLENDED 3
134#define SHADERFLAGS_VOLUME_STYLE_BOUNDARY 4
135#define SHADERFLAGS_VOLUME_STYLE_CARTOON 5
136#define SHADERFLAGS_VOLUME_STYLE_COMPOSED 6
137#define SHADERFLAGS_VOLUME_STYLE_EDGE 7
138#define SHADERFLAGS_VOLUME_STYLE_PROJECTION 8
139#define SHADERFLAGS_VOLUME_STYLE_SHADED 9
140#define SHADERFLAGS_VOLUME_STYLE_SILHOUETTE 10
141#define SHADERFLAGS_VOLUME_STYLE_TONE 11
142/*******************************************************/
143
144
146 float emission[4];
147 float ambient[4];
148 float diffuse[4];
149 float specular[4];
150 float shininess;
151};
152
154 /* material properties for current shape */
155 struct fw_MaterialParameters fw_FrontMaterial;
156 struct fw_MaterialParameters fw_BackMaterial;
157
158 /* which shader is active; 0 = no shader active */
159 s_shader_capabilities_t *currentShaderProperties;
160
161 float transparency;
162 GLfloat emissionColour[3];
163 GLint cubeFace; /* for cubemapping, if 0, not cube mapping */
164 int cullFace; /* is this single-sided or two-sided? Simply used to reduce calls to
165 GL_ENABLE(GL_CULL_FACE), etc */
166
167 /* for FillProperties, and LineProperties, line type (NOT pointsize) */
168 int algorithm;
169 bool hatchedBool;
170 bool filledBool;
171 GLfloat hatchPercent[2];
172 GLfloat hatchScale[2];
173 GLfloat hatchColour[4];
174
175 // points now specified in shader, not via an opengl call
176 GLfloat pointSize;
177
178 //TextureCoordinateGenerator value - a "TCGT_XXX" type
179 int texCoordGeneratorType;
180};
181
182struct matpropstruct* getAppearanceProperties();
183void setUserShaderNode(struct X3D_Node *me);
184
185#define MIN_NODE_TRANSPARENCY 0.0f
186#define MAX_NODE_TRANSPARENCY 0.99f /* if 1.0, then occlusion culling will cause flashing */
187
188#define RENDER_MATERIAL_SUBNODES(which) \
189 { struct X3D_Node *tmpN; \
190 POSSIBLE_PROTO_EXPANSION(struct X3D_Node *, which,tmpN) \
191 if(tmpN) { \
192 render_node(tmpN); \
193 } \
194 }
195
196
197#define SET_SHADER_SELECTED_FALSE(x3dNode) \
198 switch (X3D_NODE(x3dNode)->_nodeType) { \
199 case NODE_ComposedShader: \
200 X3D_COMPOSEDSHADER(x3dNode)->isSelected = FALSE; \
201 break; \
202 case NODE_ProgramShader: \
203 X3D_PROGRAMSHADER(x3dNode)->isSelected = FALSE; \
204 break; \
205 case NODE_PackagedShader: \
206 X3D_PROGRAMSHADER(x3dNode)->isSelected = FALSE; \
207 break; \
208 default: { \
209 /* this is NOT a shader; should we say something, or just \
210 ignore? Lets ignore, for now */ \
211 } \
212 }
213
214#define SET_FOUND_GOOD_SHADER(x3dNode) \
215 switch (X3D_NODE(x3dNode)->_nodeType) { \
216 case NODE_ComposedShader: \
217 foundGoodShader = X3D_COMPOSEDSHADER(x3dNode)->isValid; \
218 X3D_COMPOSEDSHADER(x3dNode)->isSelected = foundGoodShader; \
219 break; \
220 case NODE_ProgramShader: \
221 foundGoodShader = X3D_PROGRAMSHADER(x3dNode)->isValid; \
222 X3D_PROGRAMSHADER(x3dNode)->isSelected = foundGoodShader; \
223 break; \
224 case NODE_PackagedShader: \
225 foundGoodShader = X3D_PROGRAMSHADER(x3dNode)->isValid; \
226 X3D_PACKAGEDSHADER(x3dNode)->isSelected = foundGoodShader; \
227 break; \
228 default: { \
229 /* this is NOT a shader; should we say something, or just \
230 ignore? Lets ignore, for now */ \
231 } \
232 }
233#endif /* __FREEWRL_SCENEGRAPH_SHAPE_H__ */