Hi,
I am simulating a basketball with x and y cordinates at zero, and it is translating directly towards the eye, along the -z axis (i.e., it does not follow a parabolic path).
After each refresh, the basketball travels some distance along the z axis, depending on its speed. I want the basketball to be simulated at its actual visual angle for each distance on the z axis. So, if I am sitting at a fixed 60cm away from the screen, I want the basketball to be simulated at its correct visual angle.
I’ve looked at the red-book, which does discuss this issue (p. 133-134), but I do not understand how calculating the visual angle of an object that I know the size of (e.g., the diameter of a basketball is 24cm), is translated to the angle variable in gluPerspective.
Can anyone provide an explanation please or point me to a good reference for this topic?
Then you want to fix a fov and get the aspect ratio correct. Aspect ratio can be calculated by dividing your screen width by screen height. in pixels.
I usually go with this:
gluPerspective( 45.0, 800/600, near, far );
Originally posted by shosking:
[b]
“If I get your question correctly, you want the basketball to occupy the field of view completely at every frame, right?”
no, i want the ball to occupy the correct visual angle for its instantaneous distance as it would occupy in the “real world”. [/b]
Originally posted by bleh: Hey man, post in the advanced board. This is for begginners.
Actually this is a beginners question. It seems complex because of the maths involved, but uses basic OpenGL in implementation. Advanced topics usually include multitexturing, extensions, ARBs and a whole slew of other stuff that I know nothing about. In short, things that deal with OpenGL complexity, and not just complexity in general programming or maths.
Well that’s just my opinion. The persons who use the advanced section regularly couldsay more on the subject.
Originally posted by shosking:
[b]
“If I get your question correctly, you want the basketball to occupy the field of view completely at every frame, right?”
no, i want the ball to occupy the correct visual angle for its instantaneous distance as it would occupy in the “real world”. [/b]
In other words you want it like a camera at a fixed location filming the shot and you can see the ball arc through the air on it’s way to the basket?
If that is the case it’s the maths you want. You’ll have to assign the ball some attributes to record it’s location and speed and calculate the effect of gravity on it’s motion. You’ll also have to know it’s starting and endig position so that you can set a field of view that will capture its full range of motion.
thanks for all the helfull replies. i’ve got it all working now, including a parabolic path based on numerical intergration.l I was confusing world and sreen based coordinates. Now the whole display appears to be scaled 1:1 with “real objects”
simon