Jump to content
  • Advertisement
Sign in to follow this  
svnstrk

spherical camera movement

This topic is 3002 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi,

im having trouble trying to simulate camera movement based on spherical coordinate. so it basically moved around the azimuth and altitude following this pattern

http://en.wikipedia.org/wiki/File:Coord_system_SZ_0.svg

i set a and d to increase and decrease the azimuth respectively. s and w to increase. the radius is constant 1. after i got the spherical coordinate, i change the spherical coordinate to cartesian corrdinate using this equation

http://en.wikipedia.org/wiki/Spherical_coordinate_system#Cartesian_coordinates

and i simply set the lookat value using the cartesian i just got

gluLookAt (cameraCartesianPos.x, cameraCartesianPos.y, cameraCartesianPos.z,
cameraLookAt.x, cameraLookAt.y,cameraLookAt.z,
cameraUp.x, cameraUp.y, cameraUp.z);

the cameraLookat will always stay at 0, 0, 0. Im not sure about the up value and currently im using the value 0, 1, 0 (pointing up).

now im not sure how to describe the problem but it seems like the altitude does not behaving right. when im at azimuth 0, changes on altitude does not change anything. at azimuth 90 (perhaps) the altitude reach the max point (top of the hemisphere). Im not sure where i did wrong, the calculation seems right for me.

Any help on this one? or perhaps any info how to do a hemisphere to orbit the camera around the scene?


thanks in advaance

Share this post


Link to post
Share on other sites
Advertisement
There are various ways spherical coordinates can be converted to Cartesian coordinates; maybe you're using the wrong method given how your coordinate system is oriented.

If you need further help, perhaps you could post your spherical-to-Cartesian conversion code.

Share this post


Link to post
Share on other sites
hi,

for example i have a specific spherical coordinate(with constant radius 1), i convert it to cartesian using this code

double xOutput = x * getSinValue(y) * getCosValue(z);
double yOutput = x * getSinValue(y) * getSinValue(z);
double zOutput = x * getCosValue(y);

return Vector3D(xOutput, yOutput, zOutput);

getSinValue and getCosValue is a standard sin and cos function. The output value is then set into gluLookAt method

gluLookAt (cameraCartesianPos.x, cameraCartesianPos.y, cameraCartesianPos.z,
cameraLookAt.x, cameraLookAt.y,cameraLookAt.z,
cameraUp.x, cameraUp.y, cameraUp.z);

with CameraLookAt value 0, 0, 0. i think one of the problem is try to find out the up value (i set it to 0, 1, 0). But i think there are than that.

any hint?

thanks in advance

Share this post


Link to post
Share on other sites
It looks like your conversion code considers Z to be up, but you want Y to be up. So, you'll (most likely) need to revise the conversion code accordingly.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!