FreeWRL/FreeX3D  3.0.0
headers.h
1 /*
2 
3 
4 Global includes.
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_HEADERS_H__
30 #define __FREEWRL_HEADERS_H__
31 
32 #define int_t intptr_t
33 
34 extern char *BrowserName;
35 const char* freewrl_get_browser_program();
36 
37 void Multi_String_print(struct Multi_String *url);
38 
39 /* see if an inputOnly "set_" field has changed */
40 #define IO_FLOAT -2335549.0f
41 
42 /* specification versions, for close adherence to requested spec levels */
43 #define SPEC_VRML 0x01
44 #define SPEC_X3D30 0x02
45 #define SPEC_X3D31 0x04
46 #define SPEC_X3D32 0x08
47 #define SPEC_X3D33 0x10
48 #define SPEC_X3D34 0x20
49 #define SPEC_VRML1 0x01 /* same as SPEC_VRML */
50 
51 
52 
53 int viewer_iside();
54 /* children fields path optimizations */
55 #define CHILDREN_COUNT int nc = node->_sortedChildren.n;
56 #define RETURN_FROM_CHILD_IF_NOT_FOR_ME \
57  /* any children at all? */ \
58  if (nc==0) return; \
59  /* should we go down here? */ \
60  /* printf ("Group, rb %x VF_B %x, rg %x VF_G %x\n",render_blend, VF_Blend, render_geom, VF_Geom); */ \
61  {\
62  ttrenderstate rs = renderstate(); \
63  if (rs->render_blend == VF_Blend) \
64  if ((node->_renderFlags & VF_Blend) != VF_Blend) { \
65  return; \
66  } \
67  if (rs->render_proximity == VF_Proximity) \
68  if ((node->_renderFlags & VF_Proximity) != VF_Proximity) { \
69  return; \
70  } \
71  if (rs->render_light == VF_globalLight) \
72  if ((node->_renderFlags & VF_globalLight) != VF_globalLight) { \
73  return; \
74  } \
75  }
76 
77 
78 /* Size of static array */
79 #define ARR_SIZE(arr) (int)(sizeof(arr)/sizeof((arr)[0]))
80 
81 extern char *BrowserName;
82 extern char *BrowserFullPath;
83 
84 /* To allow BOOL for boolean values */
85 #define BOOL int
86 
87 /* rendering constants used in SceneGraph, etc. */
88 #define VF_Viewpoint 0x0001
89 #define VF_Geom 0x0002
90 #define VF_localLight 0x0004
91 #define VF_Sensitive 0x0008
92 #define VF_Blend 0x0010
93 #define VF_Proximity 0x0020
94 #define VF_Collision 0x0040
95 #define VF_globalLight 0x0080
96 #define VF_hasVisibleChildren 0x0100
97 #define VF_shouldSortChildren 0x0200
98 #define VF_Other 0x0400
99 #define VF_Picking 0x1000
100 #define VF_HideLeft 0x2000 /*stereo don't draw on left side, used for stereovision experiments*/
101 #define VF_HideRight 0x4000 /*stereo don't draw on right side*/
102 #define VF_USE 0x8000 /*for 2-node scenarios like pickingsensor and transform sensor, signals a node_USE to save its modelview matrix for do_handling*/
103 #define VF_Cube 0x10000 //when generating generatedcubemap texture to fbo (don't render generatedcubemap parent nodes)
104 
105 /* for z depth buffer calculations */
106 #define DEFAULT_NEARPLANE 0.07
107 #define DEFAULT_FARPLANE 21000.0
108 #define DEFAULT_BACKGROUNDPLANE 18000.0 /* approx 80% of DEFAULT_FARPLANE */
109 extern double geoHeightinZAxis;
110 
111 
112 /* Routing - complex types */
113 #define ROUTING_SFNODE -23
114 #define ROUTING_MFNODE -10
115 #define ROUTING_SFIMAGE -12
116 #define ROUTING_MFSTRING -13
117 #define ROUTING_MFFLOAT -14
118 #define ROUTING_MFROTATION -15
119 #define ROUTING_MFINT32 -16
120 #define ROUTING_MFCOLOR -17
121 #define ROUTING_MFVEC2F -18
122 #define ROUTING_MFVEC3F -19
123 #define ROUTING_MFVEC3D -20
124 #define ROUTING_MFDOUBLE -21
125 #define ROUTING_SFSTRING -22
126 #define ROUTING_MFMATRIX4F -30
127 #define ROUTING_MFMATRIX4D -31
128 #define ROUTING_MFVEC2D -32
129 #define ROUTING_MFVEC4F -33
130 #define ROUTING_MFVEC4D -34
131 #define ROUTING_MFMATRIX3F -35
132 #define ROUTING_MFMATRIX3D -36
133 
134 
135 
136 /* compile simple nodes (eg, Cone, LineSet) into an internal format. Check out
137  CompileC in VRMLRend.pm, and look for compile_* functions in code. General
138  meshes are rendered using the PolyRep scheme, which also compiles into OpenGL
139  calls, using the PolyRep (and, stream_PolyRep) methodology */
140 
141 
142 
143 #define NODE_CHANGE_INIT_VAL 153 /* node->_change is set to this when created */
144 #define COMPILE_POLY_IF_REQUIRED(a,b,c,d,e) \
145  if(!node->_intern || node->_change != (node->_intern)->irep_change) { \
146  compileNode ((void *)compile_polyrep, node, a,b,c,d,e); \
147  } \
148  if (!node->_intern) return;
149 
150 #define COMPILE_IF_REQUIRED { struct X3D_Virt *v; \
151  if (node->_ichange != node->_change) { \
152  v = virtTable[node->_nodeType]; \
153  if (v->compile) { \
154  compileNode (v->compile, (void *)node, NULL, NULL, NULL, NULL, NULL); \
155  } else {printf ("huh - have COMPIFREQD, but v->compile null for %s at %s:%d\n",stringNodeType(node->_nodeType),__FILE__,__LINE__);} \
156  } \
157  if (node->_ichange == 0) return; \
158  }
159 
160 #define COMPILE_IF_REQUIRED_RETURN_NULL_ON_ERROR { struct X3D_Virt *v; \
161  if (node->_ichange != node->_change) { \
162  v = virtTable[node->_nodeType]; \
163  if (v->compile) { \
164  compileNode (v->compile, (void *)node, NULL, NULL, NULL, NULL, NULL); \
165  } else {printf ("huh - have COMPIFREQD, but v->compile null for %s at %s:%d\n",stringNodeType(node->_nodeType),__FILE__,__LINE__);} \
166  } \
167  if (node->_ichange == 0) return NULL; \
168  }
169 
170 #define COMPILE_TCNODE { \
171  struct X3D_Virt *v; \
172  if (myTCnode->_ichange != myTCnode->_change) { \
173  v = virtTable[myTCnode->_nodeType]; \
174  if (v->compile) { \
175  compileNode (v->compile, (void *)myTCnode, NULL, NULL, NULL, NULL, NULL); \
176  myTCnode->_ichange = myTCnode->_change; \
177  } else {printf ("huh - have COMPIFREQD, but v->compile null for %s at %s:%d\n",stringNodeType(myTCnode->_nodeType),__FILE__,__LINE__);} \
178  } \
179  if (myTCnode->_ichange == 0) return; \
180 }
181 
182 
183 
184 /* convert a PROTO node (which will be a Group node) into a node. eg, for Materials - this is a possible child
185 node for ANY node that takes something other than a Group */
186 
187 #define offsetPointer_deref(t, me, offs) ((t)(((char*)(me))+offs))
188 
189 /* before Brotos/Proto
190 #define POSSIBLE_PROTO_EXPANSION(type,inNode,outNode) \
191  if (inNode == NULL) outNode = NULL; \
192  else {if (X3D_NODE(inNode)->_nodeType == NODE_Group) { \
193  if (X3D_GROUP(inNode)->children.n>0) { \
194  outNode = (type)(X3D_GROUP(inNode)->children.p[0]); \
195  } else outNode = NULL; \
196  } else outNode = (type)inNode; };
197 */
198 
199 struct X3D_Node* getTypeNode(struct X3D_Node *node);
200 
201 //with Proto for Brotos
202 #define POSSIBLE_PROTO_EXPANSION(type,inNode,outNode) \
203  outNode = (type)getTypeNode(inNode);
204 
205 #define MARK_NODE_COMPILED node->_ichange = node->_change;
206 #define NODE_NEEDS_COMPILING (node->_ichange != node->_change)
207 #define ROOTNODE_NEEDS_COMPILING (rootNode()->_ichange != rootNode()->_change)
208 /* end of compile simple nodes code */
209 
210 
211 #define MARK_SFFLOAT_INOUT_EVENT(good,save,offset) \
212  if (!APPROX(good,save)) { \
213  MARK_EVENT(X3D_NODE(node), offset);\
214  save = good; \
215  }
216 
217 #define MARK_SFTIME_INOUT_EVENT(good,save,offset) \
218  if (!APPROX(good,save)) { \
219  MARK_EVENT(X3D_NODE(node), offset);\
220  save = good; \
221  }
222 
223 #define MARK_SFINT32_INOUT_EVENT(good,save,offset) \
224  if (good!=save) { \
225  MARK_EVENT(X3D_NODE(node), offset);\
226  save = good; \
227  }
228 
229 #define MARK_SFBOOL_INOUT_EVENT(good,save,offset) \
230  if (good!=save) { \
231  MARK_EVENT(X3D_NODE(node), offset);\
232  save = good; \
233  }
234 
235 
236 #define MARK_SFVEC3F_INOUT_EVENT(good,save,offset) \
237  if ((!APPROX(good.c[0],save.c[0])) || (!APPROX(good.c[1],save.c[1])) || (!APPROX(good.c[2],save.c[2]))) { \
238  MARK_EVENT(X3D_NODE(node), offset);\
239  memcpy (&save.c, &good.c, sizeof (struct SFColor));\
240  }
241 
242 #define MARK_SFVEC3D_INOUT_EVENT(good,save,offset) \
243  if ((!APPROX(good.c[0],save.c[0])) || (!APPROX(good.c[1],save.c[1])) || (!APPROX(good.c[2],save.c[2]))) { \
244  MARK_EVENT(X3D_NODE(node), offset);\
245  memcpy (&save.c, &good.c, sizeof (struct SFVec3d));\
246  }
247 
248 
249 /* make sure that the SFNODE "save" field is not deleted when scenegraph is removed (dup pointer problem) */
250 #define MARK_SFNODE_INOUT_EVENT(good,save,offset) \
251  if (good != save) { \
252  MARK_EVENT(X3D_NODE(node), offset);\
253  save = good; \
254  }
255 
256 
257 #define MARK_MFNODE_INOUT_EVENT_PRE_JULY29_2015(good,save,offset) \
258  /* assumes that the good pointer has been updated */ \
259  if (good.p != save.p) { \
260  MARK_EVENT(X3D_NODE(node), offset);\
261  save.n = good.n; \
262  save.p = good.p; \
263  }
264 
265 #define MARK_MFNODE_INOUT_EVENT(good,save,offset) \
266  /* assumes that the good pointer has been updated - the old version crashed during exit due to freeing a .p twice*/ \
267  if (good.p != save.p) { \
268  MARK_EVENT(X3D_NODE(node), offset);\
269  save.n = 0; \
270  FREE_IF_NZ(save.p); \
271  save.p = NULL; \
272  if(good.n && good.p){ \
273  save.p = MALLOCV(good.n * sizeof(void*)); \
274  memcpy(save.p,good.p,good.n * sizeof(void*)); \
275  save.n = good.n; \
276  } \
277  }
278 
279 /* for deciding on using set_ SF fields, with nodes with explicit "set_" fields... note that MF fields are handled by
280 the EVIN_AND_FIELD_SAME MACRO */
281 
282 #define USE_SET_SFVEC3D_IF_CHANGED(setField,regField) \
283 if (!APPROX (node->setField.c[0],node->regField.c[0]) || \
284  !APPROX(node->setField.c[1],node->regField.c[1]) || \
285  !APPROX(node->setField.c[2],node->regField.c[2]) ) { \
286  /* now, is the setField at our default value?? if not, we just use the regField */ \
287  if (APPROX(node->setField.c[0], IO_FLOAT) && APPROX(node->setField.c[1],IO_FLOAT) && APPROX(node->setField.c[2],IO_FLOAT)) { \
288  /* printf ("just use regField\n"); */ \
289  } else { \
290  /* printf ("use the setField as the real poistion field\n"); */ \
291  memcpy (node->regField.c, node->setField.c, sizeof (struct SFVec3d)); \
292  } \
293 }
294 
295 #define USE_SET_SFROTATION_IF_CHANGED(setField,regField) \
296 if (!APPROX (node->setField.c[0],node->regField.c[0]) || \
297  !APPROX(node->setField.c[1],node->regField.c[1]) || \
298  !APPROX(node->setField.c[2],node->regField.c[2]) || \
299  !APPROX(node->setField.c[3],node->regField.c[3]) ) { \
300  /* now, is the setField at our default value?? if not, we just use the regField */ \
301  if (APPROX(node->setField.c[0], IO_FLOAT) && APPROX(node->setField.c[1],IO_FLOAT) && APPROX(node->setField.c[2],IO_FLOAT) && APPROX(node->setField.c[3],IO_FLOAT)) { \
302  /* printf ("just use SFRotation regField\n"); */ \
303  } else { \
304  /* printf ("use the setField SFRotation as the real poistion field\n"); */ \
305  memcpy (node->regField.c, node->setField.c, sizeof (struct SFRotation)); \
306  } \
307 }
308 
309 
310 
311 
312 int find_key (int kin, float frac, float *keys);
313 void startOfLoopNodeUpdates(void);
314 //extern int HaveSensitive;
315 void zeroVisibilityFlag(void);
316 void setField_fromJavascript (struct X3D_Node *ptr, char *field, char *value, int isXML);
317 unsigned int setField_FromEAI (char *ptr);
318 
319 #define EXTENTTOBBOX
320 #define INITIALIZE_EXTENT { node->EXTENT_MAX_X = (float) -10000.0; \
321  node->EXTENT_MAX_Y = (float) -10000.0; \
322  node->EXTENT_MAX_Z = (float) -10000.0; \
323  node->EXTENT_MIN_X = (float) 10000.0; \
324  node->EXTENT_MIN_Y = (float) 10000.0; \
325  node->EXTENT_MIN_Z = (float) 10000.0; }
326 
327 /********************************
328  Verbosity
329 *********************************/
330 #if defined(DEBUG) || defined(FW_DEBUG)
331  /* define verbosity that should be forced-on when debug is set */
332 
333 
334 #else
335 #undef SETFIELDVERBOSE
336 /* Parsing & Lexing */
337 #undef CPARSERVERBOSE
338 
339 /* Java Class invocation */
340 #undef JSVRMLCLASSESVERBOSE
341 
342 /* child node parsing */
343 #undef CHILDVERBOSE
344 
345 /* routing */
346 #undef CRVERBOSE
347 
348 /* Javascript */
349 #undef JSVERBOSE
350 
351 /* sensitive events */
352 #undef SEVERBOSE
353 
354 /* Text nodes */
355 #undef TEXTVERBOSE
356 
357 /* Texture processing */
358 #undef TEXVERBOSE
359 
360 /* streaming from VRML to OpenGL internals. */
361 #undef STREAM_POLY_VERBOSE
362 
363 /* collision */
364 #undef COLLISIONVERBOSE
365 
366 /* Capabilities of x3dv and x3d */
367 #undef CAPABILITIESVERBOSE
368 
369 #endif /* end of ifdef DEBUG */
370 
371 /* number of tesselated coordinates allowed */
372 #define TESS_MAX_COORDS 200000
373 
374 #define offset_of(p_type,field) ((unsigned int)(&(((p_type)NULL)->field)-NULL))
375 
376 #define UNUSED(v) ((void) v)
377 #define ISUSED(v) ((void) v)
378 
379 #define PI 3.14159265358979323846
380 #define PIF 3.1415926535f
381 
382 /* return TRUE if numbers are very close */
383 #define APPROX(a,b) (fabs((a)-(b))<0.00000001)
384 /* defines for raycasting: */
385 
386 #define NORMAL_VECTOR_LENGTH_TOLERANCE 0.00001
387 /* (test if the vector part of a rotation is normalized) */
388 #define IS_ROTATION_VEC_NOT_NORMAL(rot) ( \
389  fabs(1-sqrt(rot.c[0]*rot.c[0]+rot.c[1]*rot.c[1]+rot.c[2]*rot.c[2])) \
390  >NORMAL_VECTOR_LENGTH_TOLERANCE \
391 )
392 
393 /* defines for raycasting: */
394 #define XEQ (APPROX(t_r1.x,t_r2.x))
395 #define YEQ (APPROX(t_r1.y,t_r2.y))
396 #define ZEQ (APPROX(t_r1.z,t_r2.z))
397 /* xrat(a) = ratio to reach coordinate a on axis x */
398 #define XRAT(a) (((a)-t_r1.x)/(t_r2.x-t_r1.x))
399 #define YRAT(a) (((a)-t_r1.y)/(t_r2.y-t_r1.y))
400 #define ZRAT(a) (((a)-t_r1.z)/(t_r2.z-t_r1.z))
401 /* mratx(r) = x-coordinate gotten by multiplying by given ratio */
402 #define MRATX(a) (t_r1.x + (a)*(t_r2.x-t_r1.x))
403 #define MRATY(a) (t_r1.y + (a)*(t_r2.y-t_r1.y))
404 #define MRATZ(a) (t_r1.z + (a)*(t_r2.z-t_r1.z))
405 
406 /* POLYREP stuff */
407 #define POINT_FACES 16 /* give me a point, and it is in up to xx faces */
408 
409 /* Function Prototypes */
410 
411 void render_node(struct X3D_Node *node);
412 
413 void rayhit(float rat, float cx,float cy,float cz, float nx,float ny,float nz,
414 float tx,float ty, char *descr) ;
415 
416 void fwnorprint (float *norm);
417 
418 
419 /* not defined anywhere: */
420 /* void Extru_init_tex_cap_vals(); */
421 
422 
423 /* from the PNG examples */
424 unsigned char *readpng_get_image(double display_exponent, int *pChannels,
425  unsigned long *pRowbytes);
426 
427 /* Used to determine in Group, etc, if a child is a local light; do comparison with this */
428 void LocalLight_Rend(void *nod_);
429 
430 void saveLightState2(int *ls);
431 void restoreLightState2(int ls);
432 int numberOfLights();
433 void refreshLightUniforms();
434 #define LOCAL_LIGHT_SAVE int lastlight; //savedlight[8];
435 /*
436 Saved version by Doug Sanden(?)
437 void saveLightState(int *);
438 void restoreLightState(int *);
439 #define LOCAL_LIGHT_CHILDREN(a) \
440  if ((node->_renderFlags & VF_localLight)==VF_localLight){saveLightState(savedlight); localLightChildren(a);}
441 
442 #define LOCAL_LIGHT_OFF if ((node->_renderFlags & VF_localLight)==VF_localLight) { \
443  restoreLightState(savedlight); }
444 */
445 
446 /* comments rearranged by John Stewart to get around compiler warnings
447 //#define LOCAL_LIGHT_CHILDREN(a) \
448 // if ((node->_renderFlags & VF_localLight)==VF_localLight && renderstate()->render_light != VF_globalLight){ \
449 // saveLightState2(&lastlight);\
450 // localLightChildren(a);}
451 //
452 //#define LOCAL_LIGHT_OFF \
453 // if ((node->_renderFlags & VF_localLight)==VF_localLight && renderstate()->render_light != VF_globalLight) { \
454 // if(numberOfLights() > lastlight) {\
455 // setLightChangedFlag(numberOfLights()-1); \
456 // refreshLightUniforms();\
457 // }\
458 // restoreLightState2(lastlight); \
459 // }
460 */
461 
462 
463 void prep_sibAffectors(struct X3D_Node *parent, struct Multi_Node* affectors);
464 void fin_sibAffectors(struct X3D_Node *parent, struct Multi_Node* affectors);
465 
466 void normalize_ifs_face (float *point_normal,
467  struct point_XYZ *facenormals,
468  int *pointfaces,
469  int mypoint,
470  int curpoly,
471  float creaseAngle);
472 
473 
474 
475 #define RUNNINGONAMD64 (sizeof(void *) == 8)
476 
477 /* Text node system fonts. On startup, freewrl checks to see where the fonts
478  * are stored
479  */
480 //extern float AC_LastDuration[];
481 
482 //extern int SoundEngineStarted;
483 
484 /* used to determine whether we have transparent materials. */
485 //extern int have_transparency;
486 
487 
488 /* current time */
489 //extern double TickTime;
490 //extern double lastTime;
491 double TickTime();
492 double lastTime();
493 
494 /* number of triangles this rendering loop */
495 //extern int trisThisLoop;
496 
497 /* saved rayhit and hyperhit */
498 //extern struct SFColor ray_save_posn, hyp_save_posn, hyp_save_norm;
499 
500 /* set a node to be sensitive */
501 void setSensitive(struct X3D_Node *parent,struct X3D_Node *me);
502 
503 /* bindable nodes */
504 extern GLint viewport[]; //true static
505 //extern struct sNaviInfo naviinfo;
506 
507 
508 extern double defaultExamineDist;
509 
510 
511 /* Sending events back to Browser (eg, Anchor) */
512 extern int wantEAI;
513 
514 void *returnInterpolatorPointer (int nodeType);
515 
516 /* SAI code node interface return values The meanings of
517  these numbers can be found in the SAI java code */
518 #define X3DBoundedObject 1
519 #define X3DBounded2DObject 2
520 #define X3DURLObject 3
521 #define X3DAppearanceNode 10
522 #define X3DAppearanceChildNode 11
523 #define X3DMaterialNode 12
524 #define X3DTextureNode 13
525 #define X3DTexture2DNode 14
526 #define X3DTexture3DNode 15
527 #define X3DTextureTransformNode 16
528 #define X3DTextureTransform2DNode 17
529 #define X3DGeometryNode 18
530 #define X3DTextNode 19
531 #define X3DParametricGeometryNode 20
532 #define X3DGeometricPropertyNode 21
533 #define X3DColorNode 22
534 #define X3DCoordinateNode 23
535 #define X3DNormalNode 24
536 #define X3DTextureCoordinateNode 25
537 #define X3DFontStyleNode 26
538 #define X3DProtoInstance 27
539 #define X3DChildNode 28
540 #define X3DBindableNode 29
541 #define X3DBackgroundNode 30
542 #define X3DGroupingNode 31
543 #define X3DShapeNode 32
544 #define X3DInterpolatorNode 33
545 #define X3DLightNode 34
546 #define X3DScriptNode 35
547 #define X3DSensorNode 36
548 #define X3DEnvironmentalSensorNode 37
549 #define X3DKeyDeviceSensorNode 38
550 #define X3DNetworkSensorNode 39
551 #define X3DPointingDeviceSensorNode 40
552 #define X3DDragSensorNode 41
553 #define X3DTouchSensorNode 42
554 #define X3DSequencerNode 43
555 #define X3DTimeDependentNode 44
556 #define X3DSoundSourceNode 45
557 #define X3DTriggerNode 46
558 #define X3DInfoNode 47
559 #define X3DShaderNode 48
560 #define X3DVertexAttributeNode 49
561 #define X3DProgrammableShaderObject 50
562 #define X3DUrlObject 51
563 #define X3DEnvironmentTextureNode 52
564 #define X3DSFNode 53 /* this is an "X3DNode" in the spec, but it conflicts with an internal def. */
565 #define X3DProductStructureChildNode 54
566 #define X3DComposedGeometryNode 55
567 #define X3DNurbsControlCurveNode 56
568 #define X3DNurbsSurfaceGeometryNode 57
569 #define X3DViewportNode 58
570 #define X3DLayerNode 59
571 #define X3DLayerSetNode 60
572 #define X3DLayoutNode 61
573 #define X3DNBodyCollidableNode 62
574 #define X3DRigidJointNode 63
575 #define X3DChaserNode 64
576 #define X3DDamperNode 65
577 #define X3DParticleEmitterNode 66
578 #define X3DParticlePhysicsModelNode 67
579 #define X3DComposableVolumeRenderStyleNode 68
580 #define X3DVolumeDataNode 69
581 
582 
583 BOOL isManagedField(int mode, int type, BOOL isPublic);
584 
585 void AddRemoveChildren (struct X3D_Node *parent, struct Multi_Node *tn, struct X3D_Node * *nodelist, int len, int ar, char * where, int lin);
586 unsigned long upper_power_of_two(unsigned long v);
587 void update_node(struct X3D_Node *ptr);
588 //void update_renderFlag(struct X3D_Node *ptr, int flag);
589 void UPDATE_RENDERFLAG(struct X3D_Node *ptr, int flag,char *fi, int li);
590 #define update_renderFlag(aaa,bbb) UPDATE_RENDERFLAG(aaa,bbb,__FILE__,__LINE__)
591 
592 int get_touched_flag(uintptr_t fptr, uintptr_t actualscript);
593 void getMultiElementtype(char *strp, struct Multi_Vec3f *tn, int eletype);
594 void CRoutes_RemoveSimple(struct X3D_Node* from, int fromOfs,
595  struct X3D_Node* to, int toOfs, int len);
596  void CRoutes_RemoveSimpleB(struct X3D_Node* from, int fromIndex,
597  struct X3D_Node* to, int toIndex, int len);
598 void CRoutes_RegisterSimple(struct X3D_Node* from, int fromOfs,
599  struct X3D_Node* to, int toOfs, int len);
600  void CRoutes_RegisterSimpleB(
601  struct X3D_Node* from, int fromIndex,
602  struct X3D_Node* to, int toIndex,
603  int type);
604 void CRoutes_Register(int adrem, struct X3D_Node *from,
605  int fromoffset,
606  struct X3D_Node *to,
607  int toOffset,
608  int length,
609  void *intptr,
610  int scrdir,
611  void* extra);
612 void CRoutes_free(void);
613 void propagate_events(void);
614 int getRoutesCount(void);
615 void getField_ToJavascript (int num, int fromoffset);
616 void add_first(struct X3D_Node * node);
617 void add_physics(struct X3D_Node * node);
618 void registerTexture(struct X3D_Node * node);
619 int checkNode(struct X3D_Node *node, char *fn, int line);
620 
621 
622 void do_first(void);
623 void process_eventsProcessed(void);
624 
625 
626 void getEAI_MFStringtype (struct Multi_String *from, struct Multi_String *to);
627 
628 
629 
630 /* menubar stuff */
631 void frontendUpdateButtons(void); /* used only if we are not able to multi-thread OpenGL */
632 /* IS -- moved these into libFreeWRL.h as front-ends call some of them directly
633 void setMenuButton_collision (int val) ;
634 void setMenuButton_headlight (int val) ;
635 void setMenuButton_navModes (int type) ;
636 void setMenuButton_texSize (int size); */
637 void setConsoleMessage(char *stat) ;
638 void fwl_reload(void);
639 
640 void fwl_do_rawKeyPress(int key, int type);
641 
642 int convert_typetoInt (const char *type); /* convert a string, eg "SFBOOL" to type, eg SFBOOL */
643 
644 //extern double BrowserFPS;
645 //extern double BrowserSpeed;
646 void render_polyrep(void *node);
647 
648 //extern int CRoutesExtra; /* let EAI see param of routing table - Listener data. */
649 
650 /* types of scripts. */
651 #define NOSCRIPT 0
652 #define JAVASCRIPT 1
653 #define SHADERSCRIPT 4
654 
655 /* printf is defined by perl; causes segfault in threaded freewrl */
656 #ifdef printf
657 #undef printf
658 #endif
659 #ifdef die
660 #undef die
661 #endif
662 
663 //extern struct X3D_Group *rootNode;
664 struct X3D_Node *rootNode();
665 void setRootNode(struct X3D_Node *rn);
666 typedef struct void3 {
667  void *one;
668  void *two;
669  void *three;
670 } void3;
671 struct Vector *libraries();
672 void setLibraries(struct Vector *);
673 void addLibrary(char *url, struct X3D_Proto *library, void* res);
674 void3 *librarySearch(char *absoluteUniUrlNoPound);
675 
676 extern int isPerlParsing(void);
677 /* extern int isURLLoaded(void); /\* initial scene loaded? Robert Sim *\/ */
678 extern int isTextureParsing(void);
679 extern void loadMovieTexture(struct X3D_MovieTexture *node, void *param);
680 extern void loadMultiTexture(struct X3D_MultiTexture *node);
681 extern void loadBackgroundTextures (struct X3D_Background *node);
682 extern void loadTextureBackgroundTextures (struct X3D_TextureBackground *node);
683 extern GLfloat boxtex[], boxnorms[], BackgroundVert[];
684 extern GLfloat Backnorms[];
685 
686 extern void new_tessellation(void);
687 extern void initializePerlThread(void);
688 //extern void setWantEAI(int flag);
689 extern void setPluginPipe(const char *optarg);
690 extern void setPluginFD(const char *optarg);
691 extern void setPluginInstance(const char *optarg);
692 
693 extern int isPerlinitialized(void);
694 
695 extern char *getInputURL(void);
696 extern char *lastReadFile; /* name last file read in */
697 struct sCollisionInfo* CollisionInfo();
698 struct sFallInfo* FallInfo();
699 
700 extern void xs_init(void);
701 
702 //extern int navi_tos;
703 extern void checkAndAllocMemTables(int *texture_num, int increment);
704 extern void storeMPGFrameData(int latest_texture_number, int h_size, int v_size,
705  int mt_repeatS, int mt_repeatT, char *Image);
706 void mpg_main(char *filename, int *x,int *y,int *depth,int *frameCount,char **ptr);
707 void removeFilenameFromPath (char *path);
708 
709 int EAI_CreateVrml(const char *tp, const char *inputstring, struct X3D_Node *ectx, struct X3D_Group *node);
710 int EAI_CreateX3d(const char *tp, const char *inputstring, struct X3D_Node *ectx, struct X3D_Group *where);
711 void EAI_Route(char cmnd, const char *tf);
712 
713 void handle_aqua(const int mev, const unsigned int button, int x, int y);
714 
715 #define overMark 23425
716 
717 /* mimic X11 events in WIN32 ; FIXME: establish a cleaner interface for this */
718 #define KeyChar 1
719 
720 // OLD_IPHONE_AQUA #if defined(AQUA) || defined(_MSC_VER) || defined(_ANDROID) || defined(ANDROIDNDK)
721 #if defined(_MSC_VER) || defined(_ANDROID) || defined(ANDROIDNDK)
722 #ifndef _MIMIC_X11_SCREEN_BUTTONS
723  #define _MIMIC_X11_SCREEN_BUTTONS
724  #define KeyPress 2
725  #define KeyRelease 3
726  #define ButtonPress 4
727  #define ButtonRelease 5
728  #define MotionNotify 6
729  #define MapNotify 19
730  #endif
731 #endif
732 
733 /* extern void setSnapSeq(); */
734 extern void setEAIport(int pnum);
735 /* extern void setKeyString(const char *str); */
736 extern void setNoCollision();
737 /* extern void setSeqFile(const char* file); */
738 /* extern void setMaxImages(int max); */
739 extern void setBrowserFullPath(const char *str);
740 extern void setInstance(uintptr_t instance);
741 
742 extern const char *getLibVersion();
743 extern int doBrowserAction ();
744 
745 
746 extern char *myPerlInstallDir;
747 
748 /* for Extents and BoundingBoxen */
749 #define EXTENT_MAX_X _extent[0]
750 #define EXTENT_MIN_X _extent[1]
751 #define EXTENT_MAX_Y _extent[2]
752 #define EXTENT_MIN_Y _extent[3]
753 #define EXTENT_MAX_Z _extent[4]
754 #define EXTENT_MIN_Z _extent[5]
755 
756 void freewrlDie(const char *format);
757 
758 /* children stuff moved out of VRMLRend.pm and VRMLC.pm for v1.08 */
759 
760 //extern int render_sensitive,render_vp,render_light,render_proximity,render_other,verbose,render_blend,render_geom,render_collision;
761 typedef struct trenderstate{
762 int render_sensitive,render_picking,render_vp,render_light,render_proximity,render_other,verbose,render_blend,render_geom,render_collision,render_cube;
763 }* ttrenderstate;
764 //extern struct trenderstate renderstate;
765 ttrenderstate renderstate();
766 
767 int SAI_IntRetCommand (char cmnd, const char *fn);
768 char * SAI_StrRetCommand (char cmnd, const char *fn);
769 char *EAI_GetTypeName (unsigned int uretval);
770 char* EAI_GetValue(unsigned int nodenum, const char *fieldname, const char *nodename);
771 
772 void add_parent(struct X3D_Node *node_, struct X3D_Node *parent_,char *file, int line);
773 void remove_parent(struct X3D_Node *child, struct X3D_Node *parent);
774 void EAI_readNewWorld(char *inputstring);
775 
776 
777 
778 void make_genericfaceset(struct X3D_IndexedFaceSet *this_);
779 #define rendray_Text render_ray_polyrep
780 #define rendray_ElevationGrid render_ray_polyrep
781 #define collide_ElevationGrid collide_genericfaceset
782 #define rendray_Extrusion render_ray_polyrep
783 #define rendray_IndexedFaceSet render_ray_polyrep
784 #define make_IndexedFaceSet make_genericfaceset
785 #define make_ElevationGrid make_genericfaceset
786 #define rendray_ElevationGrid render_ray_polyrep
787 
788 /* Component Rendering nodes */
789 #define rendray_IndexedTriangleSet render_ray_polyrep
790 #define rendray_IndexedTriangleFanSet render_ray_polyrep
791 #define rendray_IndexedTriangleStripSet render_ray_polyrep
792 #define rendray_IndexedQuadSet render_ray_polyrep
793 #define rendray_QuadSet render_ray_polyrep
794 #define rendray_TriangleSet render_ray_polyrep
795 #define rendray_TriangleFanSet render_ray_polyrep
796 #define rendray_TriangleStripSet render_ray_polyrep
797 #define collide_IndexedFaceSet collide_genericfaceset
798 #define collide_IndexedTriangleFanSet collide_genericfaceset
799 #define collide_IndexedTriangleSet collide_genericfaceset
800 #define collide_IndexedTriangleStripSet collide_genericfaceset
801 #define collide_IndexedQuadSet collide_genericfaceset
802 #define collide_QuadSet collide_genericfaceset
803 #define collide_TriangleFanSet collide_genericfaceset
804 #define collide_TriangleSet collide_genericfaceset
805 #define collide_TriangleStripSet collide_genericfaceset
806 #define make_IndexedTriangleFanSet make_genericfaceset
807 #define make_IndexedTriangleSet make_genericfaceset
808 #define make_IndexedTriangleStripSet make_genericfaceset
809 #define make_IndexedQuadSet make_genericfaceset
810 #define make_QuadSet make_genericfaceset
811 #define make_TriangleFanSet make_genericfaceset
812 #define make_TriangleSet make_genericfaceset
813 #define make_TriangleStripSet make_genericfaceset
814 #define rendray_GeoElevationGrid render_ray_polyrep
815 #define collide_GeoElevationGrid collide_genericfaceset
816 #define make_GeoElevationGrid make_genericfaceset
817 
818 
819 /* Event Utilities Component */
820 void do_BooleanFilter (void *node);
821 void do_BooleanSequencer (void *node);
822 void do_BooleanToggle (void *node);
823 void do_BooleanTrigger (void *node);
824 void do_IntegerSequencer (void *node);
825 void do_IntegerTrigger (void *node);
826 void do_TimeTrigger (void *node);
827 
828 
829 #define ADD_PARENT(a,b) add_parent(a,b,__FILE__,__LINE__)
830 //#define NODE_ADD_PARENT(a) ADD_PARENT(a,X3D_NODE(ptr))
831 //#define NODE_REMOVE_PARENT(a) ADD_PARENT(a,X3D_NODE(ptr)) //dug9 looks wrong, but not used
832 
833 
834 #define LIGHTING_ON if (!tg->RenderFuncs.lightingOn) {tg->RenderFuncs.lightingOn=TRUE;}
835 #define LIGHTING_OFF if(tg->RenderFuncs.lightingOn) {tg->RenderFuncs.lightingOn=FALSE;}
836 
837 #define LIGHTING_INITIALIZE gglobal()->RenderFuncs.lightingOn=TRUE;
838 
839 void zeroAllBindables(void);
840 
841 int inputParse(unsigned type, char *inp, int bind, int returnifbusy,
842  void *ptr, unsigned ofs, int *complete,
843  int zeroBind);
844 void compileNode (void (*nodefn)(void *, void *, void *, void *, void *, void *), void *node, void *a, void *b, void *c, void *d, void *e);
845 void destroyCParserData();
846 //extern struct VRMLParser* savedParser;
847 
848 void getMovieTextureOpenGLFrames(int *highest, int *lowest,int myIndex);
849 int ConsoleMessage(const char *fmt, ...);
850 void closeConsoleMessage(void);
851 
852 
853 void outOfMemory(const char *message);
854 
855 void killErrantChildren(void);
856 
857 void kill_routing(void);
858 void kill_bindables(void);
859 void kill_javascript(void);
860 void kill_oldWorld(int kill_EAI, int kill_JavaScript, char *file, int line);
861 void reset_Browser();
862 void kill_clockEvents(void);
863 //void kill_openGLTextures(void);
864 void kill_X3DDefs(void);
865 //extern int currentFileVersion;
866 
867 int countCommas (char *instr);
868 void dirlightChildren(struct Multi_Node ch);
869 void normalChildren(struct Multi_Node ch);
870 void checkParentLink (struct X3D_Node *node,struct X3D_Node *parent);
871 
872 /* background colour */
873 void setglClearColor (float *val);
874 void doglClearColor(void);
875 extern int cc_changed;
876 
877 /* int mapFieldTypeToInernaltype (indexT kwIndex); msvc has problem perhaps with typedef typdef unsigned int indexT*/
878 int mapFieldTypeToInernaltype (unsigned int kwIndex);
879 void resetSensorEvents();
880 
881 
882 /* META data, component, profile stuff */
883 void handleMetaDataStringString(struct Uni_String *val1,struct Uni_String *val2);
884 void handleUnitDataStringString(char *categoryname,char *unitname, double conversionfactor);
885 void handleProfile(int myp);
886 void handleComponent(int com, int lev);
887 void handleExport (char *node, char *as);
888 void handleImport (char *nodeName,char *nodeImport, char *as);
889 void handleVersion (const char *versionString);
890 
891 
892 /* free memory */
893 void registerX3DNode(struct X3D_Node * node);
894 
895 void doNotRegisterThisNodeForDestroy(struct X3D_Node * nodePtr);
896 
897 struct Multi_Vec3f *getCoordinate (struct X3D_Node *node, char *str);
898 
899 void replaceWorldNeeded(char* str);
900 
901 /* X3D C parser */
902 int X3DParse(struct X3D_Node *ectx, struct X3D_Node *parent, const char *inputstring);
903 void *createNewX3DNode (int nt);
904 void *createNewX3DNode0 (int nt);
905 void *createNewX3DNodeB(int nt, int intable, void *executionContext);
906 
907 char *findFIELDNAMESfromNodeOffset0(struct X3D_Node *node, int offset);
908 #include <stdio.h>
909 void print_routes(FILE* fp);
910 void print_DEFed_node_names_and_pointers(FILE* fp);
911 
912 //updateStatusBar(void);
913 void profile_start(char *);
914 void profile_end(char *);
915 void profile_print_all();
916 
917 
918 /*pack 4 flags into one int, using char */
919 char ciflag_get(int flags, int index);
920 int ciflag_set(int flags, char flag, int index );
921 int indexChildrenName(struct X3D_Node *node);
922 struct Multi_Node *childrenField(struct X3D_Node *node);
923 int offsetofChildren(struct X3D_Node *node);
924 
925 //for Tess.c and Component_Text - the Opengl redbook gluTessBeginPolygon(,data) tesselator combiner callback data
926 typedef struct text_combiner_data {
927  //so we can add the new point to our own data
928  float *coords;
929  int *counter;
930  int *ria;
931  int *riaindex;
933 typedef struct polyrep_combiner_data {
934  //so we can add the new point to our own data
935  float *coords;
936  int *counter;
937  int *ria;
938  int *riaindex;
940 #endif /* __FREEWRL_HEADERS_H__ */
Definition: headers.h:666
Definition: Vector.h:36
Definition: Viewer.h:174