## Re: [Freeglut-developer] Glut peculiarity?

 Re: [Freeglut-developer] Glut peculiarity? From: Rick C. Hodgin - 2010-09-24 09:03:29 ```Dee, Thank you for your quick responses. I understand the math condition which happens as division-by-zero being not defined. But I'm also a programmer, and I know that this orientation would not be unused in practice (using something like 0,100,0 with 0,1,0 as upvector), so I'm thinking this should be tested for in gluLookAt rather than me, and everybody else, writing code to verify that our values are in line. Even something simple like this pseudo-code: if upvector=y and x=0 and z=0 then set x=0.0000001 if upvector=z and x=0 and y=0 then set y=0.0000001 if upvector=x and y=0 and z=0 then set z=0.0000001 Or something similar, done as a test up-front in the gluLookAt() function, to force the "logically correct" values to be something actually viewable in math terms, rather than displaying an empty, un-rendered scene, which was just annoying for me to try to figure out the cause of by the way. :-) Just my programmer brain thinking. :-) Thanks, Dee, for all your help. - Rick On Fri, 2010-09-24 at 16:55 +0800, Diederick C. Niehorster wrote: > Hi Rick, > > I'm not aware of good glulookat tutorials, sorry. But have a look at a > picture like this, > http://www.felixgers.de/teaching/jogl/gluLookAt.html, which describes > the inputs to glulookat. > > I must say my math is not strong enough to explain this clearly, but > you generated a degenerate case by defining a viewing direction that > is exactly parallel to the camera's up vector. Internally (see > ogl-sample\gfx\lib\glu\libutil\project.c in > http://oss.sgi.com/projects/ogl-sample/), a cross product between the > viewing vector and the up vector is used to compute the modelview > matrix. A cross product of two parallel vectors is (0,0,0), when > normalized this leads to an undefined value (0/0). > > If you look along X or along Z, you'd want the upvector to be along Y > indeed, as you had in your example. If you look along Y however, you > would want to have an upvector that is not exactly along Y, maybe one > oriented along X or Z. e.g. > gluLookAt(gfViewX, gfViewY, gfViewZ, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0); > Should work fine with X,Y,Z = 0,100,0 == Looking directly at origin from above > Then try > gluLookAt(gfViewX, gfViewY, gfViewZ, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0); > and see how your view of the scene at the origin changed, you'll then > see the point of the upvector. > > Hope that helps! > Best, > Dee > > On Fri, Sep 24, 2010 at 16:34, Rick C. Hodgin wrote: > > On Fri, 2010-09-24 at 16:26 +0800, Diederick C. Niehorster wrote: > >> Nope, thats nothing because of freeglut (did you actually try any > >> other window manager and did not see this?) > > > > I don't have access to any other Window manager that supports 3D, only > > virtual machines running in VMware, and my graphics card is not > > supported by it at present. > > > >> The problem is that if gfViewX and gfViewZ are 0.0 and the upvector is > >> (0,1,0), the point looked at in the plane orthogonal to the upvector > >> is the same as the observer position in that plane. The camera > >> orientation in that plane is then thus undefined. Translating the > >> point looked at along Z or X, thus in the plane orthogonal the > >> upvector, even by a very little bit indeed fixes this. > > > > I do not understand this. From my thinking, X is left/right, Y is > > up/down, Z is to/fro, and if I have the following values, then I am > > looking at these directions: > > > > X,Y,Z = 0,0,100 == Looking directly at origin from front, 100 away > > X,Y,Z = 0,100,0 == Looking directly at origin from above > > X,Y,Z = 100,0,0 == Looking directly at origin from the side > > > > I don't understand what I'm missing because changing these values to > > 0.01 means I'm barely looking at original from off the axis, and then it > > is able to determine where I'm looking? But when it is exactly on the > > axis it doesn't know? > > > > Is there a FAQ or something I can read about this because I'm surely > > confused. :-) Thanks again! > > > > - Rick > > > >> Best, > >> Dee > >> > >> On Fri, Sep 24, 2010 at 15:59, Rick C. Hodgin wrote: > >> > I'm running freeglut on ubuntu 10.04. I had set this up in my app: > >> > > >> > gluLookAt(gfViewX, gfViewY, gfViewZ, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); > >> > > >> > If I had gfViewX set to 0.0, then I could not use any value for gfViewY > >> > that would display anything, though values for gfViewZ worked. If I > >> > chaned gfViewX to 0.01 even, then any value I used for gfViewY works > >> > fine. > >> > > >> > Is this a freeglut issue? Why can't this X value be 0.0? Thanks. > >> > > >> > - Rick > >> > > >> > > >> > > >> > ------------------------------------------------------------------------------ > >> > Nokia and AT&T present the 2010 Calling All Innovators-North America contest > >> > Create new apps & games for the Nokia N8 for consumers in U.S. and Canada > >> > \$10 million total in prizes - \$4M cash, 500 devices, nearly \$6M in marketing > >> > Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store > >> > http://p.sf.net/sfu/nokia-dev2dev > >> > _______________________________________________ > >> > Freeglut-developer mailing list > >> > Freeglut-developer@... > >> > https://lists.sourceforge.net/lists/listinfo/freeglut-developer > >> > > >> > >> ------------------------------------------------------------------------------ > >> Nokia and AT&T present the 2010 Calling All Innovators-North America contest > >> Create new apps & games for the Nokia N8 for consumers in U.S. and Canada > >> \$10 million total in prizes - \$4M cash, 500 devices, nearly \$6M in marketing > >> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store > >> http://p.sf.net/sfu/nokia-dev2dev > >> _______________________________________________ > >> Freeglut-developer mailing list > >> Freeglut-developer@... > >> https://lists.sourceforge.net/lists/listinfo/freeglut-developer > > > > > > > > ------------------------------------------------------------------------------ > > Nokia and AT&T present the 2010 Calling All Innovators-North America contest > > Create new apps & games for the Nokia N8 for consumers in U.S. and Canada > > \$10 million total in prizes - \$4M cash, 500 devices, nearly \$6M in marketing > > Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store > > http://p.sf.net/sfu/nokia-dev2dev > > _______________________________________________ > > Freeglut-developer mailing list > > Freeglut-developer@... > > https://lists.sourceforge.net/lists/listinfo/freeglut-developer > > > > ------------------------------------------------------------------------------ > Nokia and AT&T present the 2010 Calling All Innovators-North America contest > Create new apps & games for the Nokia N8 for consumers in U.S. and Canada > \$10 million total in prizes - \$4M cash, 500 devices, nearly \$6M in marketing > Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store > http://p.sf.net/sfu/nokia-dev2dev > _______________________________________________ > Freeglut-developer mailing list > Freeglut-developer@... > https://lists.sourceforge.net/lists/listinfo/freeglut-developer ```