• Announcements

Archived

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

Troubles with 3d camera coordinate system

Recommended Posts

KoosKoos    122
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

  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);}