gluproject - wrong values when camera is zoomed?

gluproject - wrong values when camera is zoomed?

Post by web » Mon, 10 Feb 2003 19:55:18



Hello all; I am trying to create a lens flare & have the following code:

gluproject(globallightposx,globallightposy,globallightposz,modelview,project

The calculations are perfect if my camera's Z coordinate is 0. But, if I
zoom in or out the object in 3d space gets scewed away from the window
coordinates created by gluproject.

Has anyone had this happen before?

My camera works like so:

   glTranslatef(-camerax,-cameray,-cameraz);
   glRotatef(cameraangle,camerarotx,cameraroty,camerarotz);        // Rotate
The Camera

I have tried

   gluLookAt(camerax,cameray,cameraz, -cameraDx,-cameraDy,0,0,1,0);
   glRotatef(cameraangle,camerarotx,cameraroty,camerarotz);        // Rotate
The Camera

But that gave the same results.

Any help would be much appreciated!

-Rob

 
 
 

gluproject - wrong values when camera is zoomed?

Post by web » Mon, 10 Feb 2003 21:14:09


Lol, found my problem; last night I set my 3d scene to 1024x768 just playing
around; but left my 2d ortho gui at 800x600; thats why the values werent
converting properly

Works perfectly now though :)

-Rob


Quote:> Hello all; I am trying to create a lens flare & have the following code:

gluproject(globallightposx,globallightposy,globallightposz,modelview,project

> The calculations are perfect if my camera's Z coordinate is 0. But, if I
> zoom in or out the object in 3d space gets scewed away from the window
> coordinates created by gluproject.

> Has anyone had this happen before?

> My camera works like so:

>    glTranslatef(-camerax,-cameray,-cameraz);
>    glRotatef(cameraangle,camerarotx,cameraroty,camerarotz);        //
Rotate
> The Camera

> I have tried

>    gluLookAt(camerax,cameray,cameraz, -cameraDx,-cameraDy,0,0,1,0);
>    glRotatef(cameraangle,camerarotx,cameraroty,camerarotz);        //
Rotate
> The Camera

> But that gave the same results.

> Any help would be much appreciated!

> -Rob


 
 
 

gluproject - wrong values when camera is zoomed?

Post by Alex Mizrah » Tue, 11 Feb 2003 03:04:31


Hello, web!
You wrote  on Sun, 9 Feb 2003 04:14:09 -0800:

 w> Lol, found my problem; last night I set my 3d scene to 1024x768 just
 w> playing around; but left my 2d ortho gui at 800x600; thats why the
 w> values werent converting properly

 w> Works perfectly now though :)

that proofs another time that hard-coded constants are a bad programming
style that can cost a lot of time..


 
 
 

1. Using Z value returned by gluProject

gluProject returns x, y and z in screen coordinates.  I want to use the z value to compute the z
position in eye coordinates.  I think the z value being returned will always be 0 to 1.  If I use
the following formula (far clip - near clip) * z + near clip, will I get what I am after or will
this calculate a z value which is further away do to the projection matrix?  I am going to have to
use gluProject in any case, is there a better way to get the z value than gluProject?

Thanks:

--

Software Consultant     www.vianova.com/~vianova
Via Nova                OpenGL, Open Inventor products for Windows 95/NT
Dallas, Texas

2. tape backup

3. What's wrong with this zoom - frac.zip (0/1)

4. PowerMac-version of PoV-Ray?

5. What's wrong with this zoom - frac.zip (1/1)

6. Problem printing JPEG images

7. What am I doing wrong?

8. GL emulators for X-Windows

9. what am I doing wrong?

10. EGA Pages: What Am I doing wrong??

11. Bug, or am I doing something wrong

12. What am I doing wrong?

13. JPEGs, what am I doing wrong?