ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/view.C
(Generate patch)

Comparing libgender/view.C (file contents):
Revision 1.47 by root, Sun Oct 10 19:50:37 2004 UTC vs.
Revision 1.48 by root, Mon Oct 11 00:05:48 2004 UTC

77 77
78 GLdouble aspect = (GLdouble)w/h; 78 GLdouble aspect = (GLdouble)w/h;
79 GLdouble ymax = z_near * tan (fov * (M_PI / 360.0)); 79 GLdouble ymax = z_near * tan (fov * (M_PI / 360.0));
80 80
81 glFrustum (-ymax * aspect, ymax * aspect, -ymax, ymax, z_near, z_far); 81 glFrustum (-ymax * aspect, ymax * aspect, -ymax, ymax, z_near, z_far);
82
83 perspfact = z_near / ymax * 0.5 * (GLdouble)h;
82 84
83 d = normalize (d);//D 85 d = normalize (d);//D
84 u = normalize (u);//D 86 u = normalize (u);//D
85 87
86 vec3 rz = -d; 88 vec3 rz = -d;
92 m(1,0) = ry.x; m(1,1) = ry.y; m(1,2) = ry.z; m(1,3) = 0; 94 m(1,0) = ry.x; m(1,1) = ry.y; m(1,2) = ry.z; m(1,3) = 0;
93 m(2,0) = rz.x; m(2,1) = rz.y; m(2,2) = rz.z; m(2,3) = 0; 95 m(2,0) = rz.x; m(2,1) = rz.y; m(2,2) = rz.z; m(2,3) = 0;
94 m(3,0) = 0; m(3,1) = 0; m(3,2) = 0; m(3,3) = 1; 96 m(3,0) = 0; m(3,1) = 0; m(3,2) = 0; m(3,3) = 1;
95 97
96 diagfact = abs (rz.x) + abs (rz.y) + abs (rz.z); 98 diagfact = abs (rz.x) + abs (rz.y) + abs (rz.z);
99 //printf ("diagfact = %f\n", diagfact);
97 diagfact = sqrtf (3.);//D WHY??? 100 diagfact = sqrtf (3.);//D WHY???
98 //printf ("diagfact = %f\n", diagfact);
99 101
100 glMultMatrixf (m); 102 glMultMatrixf (m);
101 glTranslatef (-p.x, -p.y, -p.z); 103 glTranslatef (-p.x, -p.y, -p.z);
102 104
103 glGetFloatv (GL_PROJECTION_MATRIX, m); 105 glGetFloatv (GL_PROJECTION_MATRIX, m);
133 135
134 occ_queries.clear (); 136 occ_queries.clear ();
135 137
136 z_far = nz_far; 138 z_far = nz_far;
137 c_far = nc_far; 139 c_far = nc_far;
140
141 if (z_far < z_near)
142 z_far = z_near * 2.;
143
138 reset_projection (); 144 reset_projection ();
139 145
140 nc_far = nz_far = z_near + 1.F; 146 nc_far = nz_far = z_near + 1.F;
141 world.detect_visibility (*this); 147 world.detect_visibility (*this);
142 148
143 printf ("far %f cf %f RCP %f,%f,%f +%f\n", z_far, c_far, 149 printf ("far %f cf %f CAM (%d,%d,%d)\n", z_far, c_far, orig.x, orig.y, orig.z);//D
144 frustum.r.n.x,
145 frustum.r.n.y,
146 frustum.r.n.z,
147 frustum.r.d
148 );//D
149} 150}
150 151
151void view::end () 152void view::end ()
152{ 153{
153 vislist.clear (); 154 vislist.clear ();
180 //cgGLEnableProfile (fsh_profile); 181 //cgGLEnableProfile (fsh_profile);
181 } 182 }
182 183
183 for (vector<octant *>::iterator i = vislist.begin (); i != vislist.end (); ++i) 184 for (vector<octant *>::iterator i = vislist.begin (); i != vislist.end (); ++i)
184 { 185 {
186 octant *o = *i;
187
185 visibility_state &vs = vismap[*i]; 188 visibility_state &vs = vismap[o];
186 bool oq = mode == LIGHTED 189 bool oq = mode == LIGHTED
187 && vs.last + 1. < timer.now 190 && vs.last + 1. < timer.now
188 && (vs.visibility == visibility_state::PARTIAL 191 && (vs.visibility == visibility_state::PARTIAL
189 || vs.visibility == visibility_state::FULL); 192 || vs.visibility == visibility_state::FULL);
190 193
191 if (oq) 194 if (oq)
192 begin_occ_query (**i); 195 begin_occ_query (*o);
193 196
194 (*i)->display (*this); 197 o->display (*this);
195 198
196 if (oq) 199 if (oq) // && o->fill) WHY???
197 { 200 {
198 glColorMask (0, 0, 0, 0); 201 glColorMask (0, 0, 0, 0);
199 (*i)->draw_bbox (*this); 202 o->draw_bbox (*this);
200 glColorMask (1, 1, 1, 0); 203 glColorMask (1, 1, 1, 0);
201 } 204 }
202 205
203 if (oq) 206 if (oq)
204 end_occ_query (); 207 end_occ_query ();
208 211
209 if (mode == view::DEPTH) 212 if (mode == view::DEPTH)
210 { 213 {
211 glEnable (GL_DEPTH_CLAMP_NV); 214 glEnable (GL_DEPTH_CLAMP_NV);
212 glDepthMask (0); 215 glDepthMask (0);
213 glColorMask (0, 0, 0, 0);
214 glDepthFunc (GL_LESS); 216 glDepthFunc (GL_LESS);
215 if (mode == view::LIGHTED) glDepthFunc (GL_LEQUAL);
216 if (mode == view::LIGHTED) glColorMask (1, 1, 1, 0);
217 glDisable (GL_LIGHTING);
218 //cgGLDisableProfile (vsh_profile);
219 //cgGLDisableProfile (fsh_profile);
220
221#if 0
222 static int count; count++;
223 if (farlist.size ())
224 printf ("%d: size %d\n", count, farlist.size ());
225#endif
226 217
227 for (vector<octant *>::iterator i = farlist.begin (); i != farlist.end (); ++i) 218 for (vector<octant *>::iterator i = farlist.begin (); i != farlist.end (); ++i)
228 { 219 {
229 if (mode == view::DEPTH) begin_occ_query (**i); 220 begin_occ_query (**i);
230 if (mode == view::LIGHTED) glColor3f ((((long)*i >> 6) & 15) / 31. + 0.5,0,0);
231 (*i)->draw_bbox (*this); 221 (*i)->draw_bbox (*this);
232 if (mode == view::DEPTH) end_occ_query (); 222 end_occ_query ();
233 } 223 }
234 224
235 glDisable (GL_DEPTH_CLAMP_NV); 225 glDisable (GL_DEPTH_CLAMP_NV);
236 glDepthMask (1);
237 } 226 }
238 227
239 glColorMask (1, 1, 1, 0); 228 glColorMask (1, 1, 1, 0);
240 glDepthMask (1); 229 glDepthMask (1);
241 230

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines