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