FreeWRL/FreeX3D  3.0.0
Frustum.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 #ifndef __FREEWRL_FRUSTUM_H__
29 #define __FREEWRL_FRUSTUM_H__
30 
31 /* for Extents and BoundingBoxen */
32 #define EXTENT_MAX_X _extent[0]
33 #define EXTENT_MIN_X _extent[1]
34 #define EXTENT_MAX_Y _extent[2]
35 #define EXTENT_MIN_Y _extent[3]
36 #define EXTENT_MAX_Z _extent[4]
37 #define EXTENT_MIN_Z _extent[5]
38 
39 #define RECORD_DISTANCE \
40  {\
41  ttrenderstate rs = renderstate();\
42  if (rs->render_geom && (!rs->render_blend)) {record_ZBufferDistance (X3D_NODE(node)); }\
43  }
44 
45 /* no occlusion queries right now - need to work on the shader implementation
46  of occlusion culling */
47 
48 // OLD_IPHONE_AQUA #if defined (AQUA)
49 // OLD_IPHONE_AQUA #define OCCLUSION
50 // OLD_IPHONE_AQUA #define VISIBILITYOCCLUSION
51 // OLD_IPHONE_AQUA #define SHAPEOCCLUSION
52 // OLD_IPHONE_AQUA #else
53 
54  #undef OCCLUSION
55  #undef VISIBILITYOCCLUSION
56  #undef SHAPEOCCLUSION
57 
58 // OLD_IPHONE_AQUA #endif
59 
60 
61 
62 
63 int newOcclude(void);
64 
65 
66 #ifdef OCCLUSION
67 #define OCCLUSIONTEST \
68  /* a value of ZERO means that it HAS visible children - helps with initialization */ \
69  if ((renderstate()->render_geom!=0) | (renderstate()->render_sensitive!=0)) { \
70  /* printf ("OCCLUSIONTEST node %d fl %x\n",node, node->_renderFlags & VF_hasVisibleChildren); */ \
71  if ((node->_renderFlags & VF_hasVisibleChildren) == 0) { \
72  /* printf ("WOW - we do NOT need to do this transform but doing it %x!\n",(node->_renderFlags)); \
73  printf (" vp %d geom %d light %d sens %d blend %d prox %d col %d\n", \
74  render_vp,render_geom,render_light,render_sensitive,render_blend,render_proximity,render_collision); */ \
75  return; \
76  } \
77  }
78 #else
79 #define OCCLUSIONTEST
80 #endif
81 
82 
83 void beginOcclusionQuery(struct X3D_VisibilitySensor* node, int render_geometry);
84 void endOcclusionQuery(struct X3D_VisibilitySensor* node, int render_geometry);
85 
86 /*
87 #define BEGINOCCLUSIONQUERY \
88  if (render_geom) { \
89  if (potentialOccluderCount < OccQuerySize) { \
90  printf ("beginOcclusionQuery, potoc %d occQ %d\n",potentialOccluderCount, OccQuerySize, node->__occludeCheckCount); \
91  if (node->__occludeCheckCount < 0) { \
92  printf ("beginOcclusionQuery, query %u, node %s\n",potentialOccluderCount, stringNodeType(node->_nodeType)); \
93  FW_GL_BEGIN_QUERY(GL_SAMPLES_PASSED, OccQueries[potentialOccluderCount]); \
94  occluderNodePointer[potentialOccluderCount] = (void *)node; \
95  } \
96  } \
97  }
98 
99 #define ENDOCCLUSIONQUERY \
100  if (render_geom) { \
101  if (potentialOccluderCount < OccQuerySize) { \
102  if (node->__occludeCheckCount < 0) { \
103  printf ("glEndQuery node %u\n",node); \
104  FW_GL_END_QUERY(GL_SAMPLES_PASSED); \
105  potentialOccluderCount++; \
106  } \
107  } \
108  }
109 */
110 
111 void moveAndRotateThisPoint(struct point_XYZ *mypt, double x, double y, double z, double *MM);
112 void setExtent(float maxx, float minx, float maxy, float miny, float maxz, float minz, struct X3D_Node *me);
113 void printmatrix(GLDOUBLE* mat);
114 void propagateExtent(struct X3D_Node *me);
115 void record_ZBufferDistance(struct X3D_Node *node);
116 void OcclusionStartofRenderSceneUpdateScene(void);
117 void OcclusionCulling (void);
118 void zeroOcclusion(void);
119 
120 int is_Switchchild_inrange(struct X3D_Switch *node, struct X3D_Node *me);
121 int is_GeoLODchild_inrange (struct X3D_GeoLOD* gpnode, struct X3D_Node *me);
122 int is_CADLayerchild_inrange(struct X3D_CADLayer *node, struct X3D_Node *me);
123 
124 
125 #endif /* __FREEWRL_FRUSTUM_H__ */