Thread: [Plib-users] sgFrustum setting to the same as opengl
Brought to you by:
sjbaker
From: Oliver B. <sh...@ih...> - 2000-05-10 02:34:39
|
I have a function for setting up a view frustum I want to know if its getting the right values to be setup the same as the opengl one ... I am getting some wierd results in my landscape renderer - If I roll around etc everything dissapears but I cant see whats going wrong ... here is the setup code ... void View::Set(float angle, float near, float far) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); // Reset The Projection Matrix gluPerspective(angle, 640.0/480.0, near, far); // Calculate The Aspect Ratio Of The Window glMatrixMode(GL_MODELVIEW); frustum.setFOV(angle, angle) ; frustum.setNearFar(near, far) ; GetGLError("View::Set()"); } the code which acts wierd looks like : center=bounds.getCenter(); sgFullXformPnt3(tform, center, land->camera->rotation); tform[0]-=land->camera->position[0]; tform[1]-=land->camera->position[1]; tform[2]-=land->camera->position[2]; temp->setCenter(tform); temp->setRadius(bounds.getRadius()); if(!land->view->frustum.contains(temp)) return; and the code for setting up the bouds sphere is : for(a=0; a<4; a++) bounds.extend(&land->Vertices[Vertex[a]*3]); Thanks a heap Oliver Batchelor |
From: Steve B. <sjb...@ai...> - 2000-05-10 03:22:16
|
Oliver Batchelor wrote: > > I have a function for setting up a view frustum I want to know if > its getting the right values to be setup the same as the opengl one > ... > I am getting some wierd results in my landscape renderer - > If I roll around etc everything dissapears but I cant see whats > going wrong ... > > here is the setup code ... > > void View::Set(float angle, float near, float far) { > glMatrixMode(GL_PROJECTION); > glLoadIdentity(); // Reset The Projection Matrix > > gluPerspective(angle, 640.0/480.0, near, far); // Calculate The Aspect Ratio Of The Window > glMatrixMode(GL_MODELVIEW); > > frustum.setFOV(angle, angle) ; ^^^^^^^^^^^^ That's going to set the HFOV and VFOV to the same values - but you (seem to) have a 640x480 window. Try using (angle,-1) - and we'll compute the second angle for you assuming a 3:4 aspect ratio. Dunno if that's enough to account for your wierdness. You could also use a sgFrustum::getMat4 to grab the matrix out of the sgFrustum - then you can use glLoadMatrix to put it onto the projection stack - no messing with gluPerspective - and it guarantees a good match. -- Steve Baker http://web2.airmail.net/sjbaker1 sjb...@ai... (home) http://www.woodsoup.org/~sbaker sj...@ht... (work) |
From: Oliver B. <sh...@ih...> - 2000-05-10 04:11:49
|
view.cpp:42: no matching function for call to `sgFrustum::getMat4 ()' all the other sg functions work fine so ? On Wed, 10 May 2000, you wrote: > Oliver Batchelor wrote: > > > > I have a function for setting up a view frustum I want to know if > > its getting the right values to be setup the same as the opengl one > > ... > > I am getting some wierd results in my landscape renderer - > > If I roll around etc everything dissapears but I cant see whats > > going wrong ... > > > > here is the setup code ... > > > > void View::Set(float angle, float near, float far) { > > glMatrixMode(GL_PROJECTION); > > glLoadIdentity(); // Reset The Projection Matrix > > > > gluPerspective(angle, 640.0/480.0, near, far); // Calculate The Aspect Ratio Of The Window > > glMatrixMode(GL_MODELVIEW); > > > > frustum.setFOV(angle, angle) ; > ^^^^^^^^^^^^ > That's going to set the HFOV and VFOV to the > same values - but you (seem to) have a 640x480 > window. Try using (angle,-1) - and we'll compute > the second angle for you assuming a 3:4 aspect > ratio. > > Dunno if that's enough to account for your wierdness. > > You could also use a sgFrustum::getMat4 to grab the matrix out > of the sgFrustum - then you can use glLoadMatrix to put it > onto the projection stack - no messing with gluPerspective - and > it guarantees a good match. > > -- > Steve Baker http://web2.airmail.net/sjbaker1 > sjb...@ai... (home) http://www.woodsoup.org/~sbaker > sj...@ht... (work) > > _______________________________________________ > plib-users mailing list > pli...@li... > http://lists.sourceforge.net/mailman/listinfo/plib-users |
From: Steve B. <sjb...@ai...> - 2000-05-10 04:27:48
|
Oliver Batchelor wrote: > view.cpp:42: no matching function for call to `sgFrustum::getMat4 ()' > all the other sg functions work fine so ? Well, sg.h, line 871 inside the sgFrustum definition: void getMat4 ( sgMat4 dst ) { sgCopyMat4 ( dst, mat ) ; } ...um - I wonder if that was added sometime recently? What PLIB version do you have? -- Steve Baker http://web2.airmail.net/sjbaker1 sjb...@ai... (home) http://www.woodsoup.org/~sbaker sj...@ht... (work) |
From: Oliver B. <sh...@ih...> - 2000-05-10 04:14:32
|
oops sorry it is in there I looked in the header file ... so why it does that I dont know .. |
From: Oliver B. <sh...@ih...> - 2000-05-10 04:37:45
|
A stray old version of plib was sitting somewhere where it shouldnt have been - I still get the wierdness even after that frustum code so it cant be that ... I transform the "center" of each quad then I put it into a new sphere with the required radius then i test if its in the frustum but when I turn around to face the origin they all dissapear but come back if I roll upside down ... I am transforming with the same matrix as given to opengl then subtracting the camera position as given to gltranslate I cant see what im doing wrong :( Oliver On Wed, 10 May 2000, you wrote: > oops sorry > it is in there I looked in the header file ... so why it does that I > dont know .. > > _______________________________________________ > plib-users mailing list > pli...@li... > http://lists.sourceforge.net/mailman/listinfo/plib-users |