#### Archived

This topic is now archived and is closed to further replies.

# Troubles with 3d camera coordinate system

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

## Recommended Posts

Okay, this is my code for moving the viewing angle of the camera, where xrot, yrot, and zrot are the rotation speed around the x, y, and z axes, respectively. My problem comes with the yrot part of the math. I use xrot for looking up/down, and it works perfectly, but when I use yrot to rotate side to side, instead of the path being perfectly circular, it changes the angle of my view to where instead of the circle looking flat from the side view, it slightly archs at the end of the circle. So, can anyone help me with this problem? vect1.x = cview.x - cpos.x; vect1.y = cview.y - cpos.y; vect1.z = cview.z - cpos.z; if(xrot) { cview.z = (float)(cpos.z+sin(xrot)*vect1.y+cos(xrot)*vect1.z); cview.y = (float)(cpos.y+cos(xrot)*vect1.y-sin(xrot)*vect1.z); } if(yrot) { cview.z = (float)(cpos.z+sin(yrot)*vect1.x+cos(yrot)*vect1.z); cview.x = (float)(cpos.x+cos(yrot)*vect1.x-sin(yrot)*vect1.z); } if(zrot) { cview.x = (float)(cpos.x+sin(zrot)*vect1.y+cos(zrot)*vect1.x); cview.y = (float)(cpos.y+cos(zrot)*vect1.y-sin(zrot)*vect1.x); } Edited by - KoosKoos on December 11, 2001 9:01:15 AM

##### Share on other sites
  vect1.x = cview.x - cpos.x; vect1.y = cview.y - cpos.y; vect1.z = cview.z - cpos.z; if(xrot) //These Dont seem right{cview.z = (float)(cpos.z+sin(xrot)*vect1.y+cos(xrot)*vect1.z);cview.y = (float)(cpos.y+cos(xrot)*vect1.y-sin(xrot)*vect1.z);}if(yrot) //These Dont seem right{cview.z = (float)(cpos.z+sin(yrot)*vect1.x+cos(yrot)*vect1.z);cview.x = (float)(cpos.x+cos(yrot)*vect1.x-sin(yrot)*vect1.z);}if(zrot) //These Dont seem right{cview.x = (float)(cpos.x+sin(zrot)*vect1.y+cos(zrot)*vect1.x);cview.y = (float)(cpos.y+cos(zrot)*vect1.y-sin(zrot)*vect1.x);}

1. 1
2. 2
3. 3
Rutin
22
4. 4
JoeJ
16
5. 5

• 14
• 29
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631774
• Total Posts
3002292
×

## Important Information

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!