FreeWRL / FreeX3D 4.3.0
Frustum.h
1/*
2
3
4Global 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
63int 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
83void beginOcclusionQuery(struct X3D_VisibilitySensor* node, int render_geometry);
84void 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
111void moveAndRotateThisPoint(struct point_XYZ *mypt, double x, double y, double z, double *MM);
112void setExtent(float maxx, float minx, float maxy, float miny, float maxz, float minz, struct X3D_Node *me);
113void printmatrix(GLDOUBLE* mat);
114void propagateExtent(struct X3D_Node *me);
115void record_ZBufferDistance(struct X3D_Node *node);
116void OcclusionStartofRenderSceneUpdateScene(void);
117void OcclusionCulling (void);
118void zeroOcclusion(void);
119
120int is_Switchchild_inrange(struct X3D_Switch *node, struct X3D_Node *me);
121int is_GeoLODchild_inrange (struct X3D_GeoLOD* gpnode, struct X3D_Node *me);
122int is_CADLayerchild_inrange(struct X3D_CADLayer *node, struct X3D_Node *me);
123
124
125//extent6f {xmax,xmin,ymax,ymin,zmax,zmin}
126float *extent6f_constructor(float *extent6, float xmin,float xmax, float ymin,float ymax, float zmin,float zmax);
127float *extent6f_clear(float *extent6);
128int extent6f_isSet(float *extent6);
129float *extent6f_copy(float *eout6, float *ein6);
130void extent6f_to_vec3f(float *extent6, float *pmin, float *pmax);
131void extent6f_from_vec3f2(float *extent6, float *pmin, float *pmax);
132void extent6f_to_box3f8(float *extent6, float *p3f8);
133float *extent6f_from_box3fn(float *extent6,float *p, int n);
134float *extent6f_union_extent6f(float *extent6, float *ein6);
135float *extent6f_intersect_extent6f(float *extent6, float *eina, float *einb);
136float *extent6f_union_vec3f(float *extent6, float *p3);
137float *extent6f_scale3f(float *eout6, float *ein6, float *s3);
138float *extent6f_translate3f(float *eout6, float *ein6, float *p3);
139float *extent6f_translate3d(float *eout6, float *ein6, double *p3);
140float *extent6f_get_center3f(float *extent6, float *center3);
141float extent6f_get_maxsize(float *extent6);
142float extent6f_get_maxradius(float *extent6);
143float *extent6f_rotate4f(float *eout6, float *ein6, float *vrot4);
144float *extent6f_rotate4d(float *eout6, float *ein6, double *vrot4);
145float *extent6f_mattransform4d(float *eout6,float *ein6, double *mat4);
146void extent6f_printf(float *extent6);
147void extent6f_draw(float *extent); //in CursorDraw.c
148
149
150#endif /* __FREEWRL_FRUSTUM_H__ */