Camera Rotation Issue.....

Started by
8 comments, last by chaoticseedx 18 years, 6 months ago
alright i just put this code in that will move the screen around in my 3d enviroment with the mouse, now 1st problem which ive been up all night trying to figure out is that it wont rotate around in a full 360deg circle only 180deg then stops!!!! 2nd problem is when i have both x and y look coords enabled so you can look all around instead of just left and right or up and down, when you move the mouse around the camera will roll and not be evenly horizontal know what i mean?? Heres the code for my prog that rotates the camera!!!

void Camera::RotateCamera(float AngleDir, float xSpeed, float ySpeed, float zSpeed)
{
    float xNewLookDirection = 0, yNewLookDirection = 0, zNewLookDirection = 0;
    float xLookDirection = 0, yLookDirection = 0, zLookDirection = 0;
    float CosineAngle = 0, SineAngle = 0;

   // First we will need to calculate the cos and sine of our angle.  I creaetd two macros to
   // do this in the CCamera.h header file called GET_COS and GET_SINE.  To use the macros
   // we just send in the variable we ant to store the results and the angle we need to
   // calculate.
	GET_COS(CosineAngle, AngleDir);
    GET_SINE(SineAngle, AngleDir);

	// Next get the look direction (where we are looking) just like in the move camera function.
    xLookDirection = _look.x - _pos.x;
	yLookDirection = _look.y - _pos.y;
	zLookDirection = _look.z - _pos.z;

   // Normalize the direction.
   float dp = 1 /(float)sqrt(xLookDirection * xLookDirection + yLookDirection * yLookDirection +
                             zLookDirection * zLookDirection);
   xLookDirection *= dp;
   yLookDirection *= dp;
   zLookDirection *= dp;

	// Calculate the new X position.
	xNewLookDirection = (CosineAngle + (1 - CosineAngle) * xSpeed) * xLookDirection;
	xNewLookDirection += ((1 - CosineAngle) * xSpeed * ySpeed - zSpeed * SineAngle)* yLookDirection;
	xNewLookDirection += ((1 - CosineAngle) * xSpeed * zSpeed + ySpeed * SineAngle) * zLookDirection;

	// Calculate the new Y position.
	yNewLookDirection = ((1 - CosineAngle) * xSpeed * ySpeed + zSpeed * SineAngle) * xLookDirection;
	yNewLookDirection += (CosineAngle + (1 - CosineAngle) * ySpeed) * yLookDirection;
	yNewLookDirection += ((1 - CosineAngle) * ySpeed * zSpeed - xSpeed * SineAngle) * zLookDirection;

	// Calculate the new Z position.
	zNewLookDirection = ((1 - CosineAngle) * xSpeed * zSpeed - ySpeed * SineAngle) * xLookDirection;
	zNewLookDirection += ((1 - CosineAngle) * ySpeed * zSpeed + xSpeed * SineAngle) * yLookDirection;
	zNewLookDirection += (CosineAngle + (1 - CosineAngle) * zSpeed) * zLookDirection;


	// Last we add the new rotations to the old view to correctly rotate the camera.
	_up.x = _pos.x + xNewLookDirection;
	_up.y = _pos.y + yNewLookDirection;
	_up.z = _pos.z + zNewLookDirection;
    
}
[/Source]
Heres the code that trells the prog to rotate by mouse

void Camera::RotateByMouse(int mousePosX, int mousePosY, int midX, int midY)
{
	float yDirection = 0.0f;         // Direction angle.
	float xDirection = 0.0f;         // Direction angle.
	float yRotation = 0.0f;          // Rotation angle.

	// If the mouseX and mouseY are at the middle of the screen then we can't rotate the view.
	if((mousePosX == midX) && (mousePosY == midY))
      return;

	// Next we get the direction of each axis.  We divide by 1000 to get a smaller value back.
	yDirection = (float)((midX - mousePosX)) / 1000.0f;		
	//yRotation = (float)((midY - mousePosY)) / 500.0f;		
    //xDirection = (float)((midY - mousePosY)) / 1000.0f;		

	// We use curentRotX to help use keep the camera from rotating too far in either direction.
	_look.x -= yDirection; 
	//_look.y -= xDirection;
/*
	// Stop the camera from going to high...
	if(_look.x > 1.0f)
      {
		   _look.x = 1.0f;
         return;
      }

	// Stop the camera from going to low...
	if(_look.x < -1.0f)
		{
         _look.x = -1.0f;
         return;
 */
   // Next we get the axis which is a perpendicular vector of the view direction and up values.
   // We use the cross product of that to get the axis then we normalize it.
   float xAxis = 0, yAxis = 0, zAxis = 0;
   float xDir = 0, yDir = 0, zDir = 0;

   // Get the Direction of the view.
    xDir = _pos.x - _look.x;
	yDir = _pos.y - _look.y;
	zDir = _pos.z - _look.z;

   // Get the cross product of the direction and the up.
   xAxis = (yDir * _up.z) - (zDir * _up.y);
   yAxis = (zDir * _up.x) - (xDir * _up.z);
   zAxis = (xDir * _up.y) - (yDir * _up.x);

   // Normalize it.
   float len = 1 /(float)sqrt(xAxis * xAxis + yAxis * yAxis + zAxis * zAxis);
   xAxis *= len;
   yAxis *= len;
   zAxis *= len;

   // Rotate the camera.
  //RotateCamera(-xDirection, xAxis, yAxis, zAxis);
  RotateCamera(-yDirection, 0, 0, 0);

}
[/Source]
i think the problems in here???? [Edited by - chaoticseedx on October 7, 2005 3:43:35 PM]
Advertisement
A couple of things that will make it easier to look through your code are a) use [ source ][ /source ] tags, and b) put each function in its own source block.
hey chaoticseedx,

the rolling is caused when you are rotating around the camera's y axis, i tried to explain this to someone earlier but lost him so i wont try that again. the gist of it was when rotating around local x and y axis, then revert those rotations in the same order, some rolling will occur.

to stop the roll you will want to rotate the camera around the world y axis.

to give you some idea on how to eliminate the roll, this is how i rotate my camera
// Rotates the camera on the X-axisvoid CCamera::Pitch( float p_fAngle ) {	D3DXMATRIX T;      // Rotate around camera's right axis	D3DXMatrixRotationAxis(&T, &m_vRight,	p_fAngle);	// rotate _up and _look around _right vector	D3DXVec3TransformCoord(&m_vUp,&m_vUp, &T);	D3DXVec3TransformCoord(&m_vForward,&m_vForward, &T);}// Rotates the camera on the Y-axisvoid CCamera::Yaw( float p_fAngle ) {	D3DXMATRIX T;            // Rotate around world y axis	D3DXMatrixRotationY( &T, p_fAngle );         // This line will rotate around camera's y axis	//D3DXMatrixRotationAxis(&T, &m_vUp, p_fAngle);	// rotate _right and _look around _up or y-axis	D3DXVec3TransformCoord(&m_vRight,&m_vRight, &T);	D3DXVec3TransformCoord(&m_vForward,&m_vForward, &T);}


as for the not having full rotation... i can't remember right now but i think it may have something to do with the sine/cosine but dont quote me. :P

Feel free to use this code if you want, and if you need any help just ask.
Ok i do have those in my code Pitch Yaw Roll and so forth, i also have those linked to some keys like w-moves forward and s-backwards now q and e control the yaw left and right and t and g control the pitch up and down. When you use the kybrd to do this it works rotates around in a full 360 deg circle i have no problem with that but when i use the mouse to move you cant turn completely around and then the camera is not horizontally correct its like the roll is changing it.

Here is my camera.cpp i bet some of the coding is wrong...

[Source]#include "camera.h"Camera::Camera(){	_cameraType = AIRCRAFT;	_pos   = D3DXVECTOR3(0.0f, 0.0f, 0.0f);	_right = D3DXVECTOR3(1.0f, 0.0f, 0.0f);	_up    = D3DXVECTOR3(0.0f, 1.0f, 0.0f);	_look  = D3DXVECTOR3(0.0f, 0.0f, 1.0f);}Camera::Camera(CameraType cameraType){	_cameraType = cameraType;	_pos   = D3DXVECTOR3(0.0f, 0.0f, 0.0f);	_right = D3DXVECTOR3(1.0f, 0.0f, 0.0f);	_up    = D3DXVECTOR3(0.0f, 1.0f, 0.0f);	_look  = D3DXVECTOR3(0.0f, 0.0f, 1.0f);}Camera::~Camera(){}void Camera::getPosition(D3DXVECTOR3* pos){	*pos = _pos;}void Camera::setPosition(D3DXVECTOR3* pos){	_pos = *pos;}void Camera::getRight(D3DXVECTOR3* right){	*right = _right;}void Camera::getUp(D3DXVECTOR3* up){	*up = _up;}void Camera::getLook(D3DXVECTOR3* look){	*look = _look;}void Camera::walk(float units){	// move only on xz plane for land object	if( _cameraType == LANDOBJECT )		_pos += D3DXVECTOR3(_look.x, 0.0f, _look.z) * units;	if( _cameraType == AIRCRAFT )		_pos += _look * units;}void Camera::strafe(float units){	// move only on xz plane for land object	if( _cameraType == LANDOBJECT )		_pos += D3DXVECTOR3(_right.x, 0.0f, _right.z) * units;	if( _cameraType == AIRCRAFT )		_pos += _right * units;}void Camera::fly(float units){	// move only on y-axis for land object	if( _cameraType == LANDOBJECT )		_pos.y += units;	if( _cameraType == AIRCRAFT )		_pos += _up * units;}void Camera::pitch(float angle){	D3DXMATRIX T;	D3DXMatrixRotationAxis(&T, &_right,	angle);	// rotate _up and _look around _right vector	D3DXVec3TransformCoord(&_up,&_up, &T);	D3DXVec3TransformCoord(&_look,&_look, &T);}void Camera::yaw(float angle){	D3DXMATRIX T;	// rotate around world y (0, 1, 0) always for land object	if( _cameraType == LANDOBJECT )		D3DXMatrixRotationY(&T, angle);	// rotate around own up vector for aircraft	if( _cameraType == AIRCRAFT )		D3DXMatrixRotationAxis(&T, &_up, angle);	// rotate _right and _look around _up or y-axis	D3DXVec3TransformCoord(&_right,&_right, &T);	D3DXVec3TransformCoord(&_look,&_look, &T);}void Camera::roll(float angle){	// only roll for aircraft type	if( _cameraType == AIRCRAFT )	{		D3DXMATRIX T;		D3DXMatrixRotationAxis(&T, &_look,	angle);		// rotate _up and _right around _look vector		D3DXVec3TransformCoord(&_right,&_right, &T);		D3DXVec3TransformCoord(&_up,&_up, &T);	}}void Camera::getViewMatrix(D3DXMATRIX* V){	// Keep camera's axes orthogonal to eachother	D3DXVec3Normalize(&_look, &_look);	D3DXVec3Cross(&_up, &_look, &_right);	D3DXVec3Normalize(&_up, &_up);	D3DXVec3Cross(&_right, &_up, &_look);	D3DXVec3Normalize(&_right, &_right);	// Build the view matrix:	float x = -D3DXVec3Dot(&_right, &_pos);	float y = -D3DXVec3Dot(&_up, &_pos);	float z = -D3DXVec3Dot(&_look, &_pos);	(*V)(0,0) = _right.x;(*V)(0, 1) = _up.x; (*V)(0, 2) = _look.x;	           (*V)(0, 3) = 0.0f;	(*V)(1,0) = _right.y;(*V)(1, 1) = _up.y;(*V)(1, 2) = _look.y;	           (*V)(1, 3) = 0.0f;	(*V)(2,0) = _right.z;(*V)(2, 1) = _up.z;(*V)(2, 2) = _look.z;	           (*V)(2, 3) = 0.0f;	(*V)(3,0) = x;(*V)(3, 1) = y;	(*V)(3, 2) = z;			           (*V)(3, 3) = 1.0f;  }void Camera::setCameraType(CameraType cameraType){	_cameraType = cameraType;}[/Source]
[/source]

[Source]void Camera::RotateCamera(float AngleDir, float xSpeed, float ySpeed, float zSpeed){    float xNewLookDirection = 0, yNewLookDirection = 0, zNewLookDirection = 0;    float xLookDirection = 0, yLookDirection = 0, zLookDirection = 0;    float CosineAngle = 0, SineAngle = 0;   // First we will need to calculate the cos and sine of our angle.  I creaetd two macros to   // do this in the CCamera.h header file called GET_COS and GET_SINE.  To use the macros   // we just send in the variable we ant to store the results and the angle we need to   // calculate.	GET_COS(CosineAngle, AngleDir);    GET_SINE(SineAngle, AngleDir);	// Next get the look direction (where we are looking) just like in the move camera function.    xLookDirection = _look.x - _pos.x;	yLookDirection = _look.y - _pos.y;	zLookDirection = _look.z - _pos.z;   // Normalize the direction.   float dp = 1 /(float)sqrt(xLookDirection * xLookDirection + yLookDirection * yLookDirection +                             zLookDirection * zLookDirection);   xLookDirection *= dp;   yLookDirection *= dp;   zLookDirection *= dp;	// Calculate the new X position.	xNewLookDirection = (CosineAngle + (1 - CosineAngle) * xSpeed) * xLookDirection;	xNewLookDirection += ((1 - CosineAngle) * xSpeed * ySpeed - zSpeed * SineAngle)* yLookDirection;	xNewLookDirection += ((1 - CosineAngle) * xSpeed * zSpeed + ySpeed * SineAngle) * zLookDirection;	// Calculate the new Y position.	yNewLookDirection = ((1 - CosineAngle) * xSpeed * ySpeed + zSpeed * SineAngle) * xLookDirection;	yNewLookDirection += (CosineAngle + (1 - CosineAngle) * ySpeed) * yLookDirection;	yNewLookDirection += ((1 - CosineAngle) * ySpeed * zSpeed - xSpeed * SineAngle) * zLookDirection;	// Calculate the new Z position.	zNewLookDirection = ((1 - CosineAngle) * xSpeed * zSpeed - ySpeed * SineAngle) * xLookDirection;	zNewLookDirection += ((1 - CosineAngle) * ySpeed * zSpeed + xSpeed * SineAngle) * yLookDirection;	zNewLookDirection += (CosineAngle + (1 - CosineAngle) * zSpeed) * zLookDirection;	// Last we add the new rotations to the old view to correctly rotate the camera.	_up.x = _pos.x + xNewLookDirection;	_up.y = _pos.y + yNewLookDirection;	_up.z = _pos.z + zNewLookDirection;    [/Source]
[/source]

[Source]void Camera::RotateByMouse(int mousePosX, int mousePosY, int midX, int midY){	float yDirection = 0.0f;         // Direction angle.	float xDirection = 0.0f;         // Direction angle.	float yRotation = 0.0f;          // Rotation angle.	// If the mouseX and mouseY are at the middle of the screen then we can't rotate the view.	if((mousePosX == midX) && (mousePosY == midY))      return;	// Next we get the direction of each axis.  We divide by 1000 to get a smaller value back.	yDirection = (float)((midX - mousePosX)) / 1000.0f;			//yRotation = (float)((midY - mousePosY)) / 500.0f;		    //xDirection = (float)((midY - mousePosY)) / 1000.0f;			// We use curentRotX to help use keep the camera from rotating too far in either direction.	_look.x -= yDirection; 	//_look.y -= xDirection;/*	// Stop the camera from going to high...	if(_look.x > 1.0f)      {		   _look.x = 1.0f;         return;      }	// Stop the camera from going to low...	if(_look.x < -1.0f)		{         _look.x = -1.0f;         return; */   // Next we get the axis which is a perpendicular vector of the view direction and up values.   // We use the cross product of that to get the axis then we normalize it.   float xAxis = 0, yAxis = 0, zAxis = 0;   float xDir = 0, yDir = 0, zDir = 0;   // Get the Direction of the view.    xDir = _pos.x - _look.x;	yDir = _pos.y - _look.y;	zDir = _pos.z - _look.z;   // Get the cross product of the direction and the up.   xAxis = (yDir * _up.z) - (zDir * _up.y);   yAxis = (zDir * _up.x) - (xDir * _up.z);   zAxis = (xDir * _up.y) - (yDir * _up.x);   // Normalize it.   float len = 1 /(float)sqrt(xAxis * xAxis + yAxis * yAxis + zAxis * zAxis);   xAxis *= len;   yAxis *= len;   zAxis *= len;   // Rotate the camera.  //RotateCamera(-xDirection, xAxis, yAxis, zAxis);  RotateCamera(-yDirection, 0, 0, 0);}[/Source]
[/source]
Sorry bout the long wait, but it looks as if your using the same base code as i have with my camera. but one question. Whay do you have a separate function to rotate the camera when you have functions to rotate it on each axis? (the yaw, pitch, roll functions).

the way i handle camera rotations by mouse is by sending the delta of the mouse movement on each axis (I'm currently using DirectInput).

// This is in my HandleEvents function in my input class, which is where i handle all my mouse clicks and keyboard presses	CGame::GetInstance()->GetCamera()->Yaw( ((float)DeltaMouseX() ) * p_fTimeElapsed );	CGame::GetInstance()->GetCamera()->Pitch( ((float)DeltaMouseY() ) * p_fTimeElapsed );


Also, do you change your camera type to LANDOBJECT? this may cuase the camera to roll.
Here are my pitch and yaw functions:

The early part of the code:
#define WIN32_LEAN_AND_MEAN  //??#define VC_LEANMEAN     //??#include "camera.h"Camera::Camera(){	_cameraType = AIRCRAFT;	_pos   = D3DXVECTOR3(0.0f, 0.0f, 0.0f);	_right = D3DXVECTOR3(1.0f, 0.0f, 0.0f);	_up    = D3DXVECTOR3(0.0f, 1.0f, 0.0f);	_look  = D3DXVECTOR3(0.0f, 0.0f, 1.0f);}Camera::Camera(CameraType cameraType){	_cameraType = cameraType;	_pos   = D3DXVECTOR3(0.0f, 0.0f, 0.0f);	_right = D3DXVECTOR3(1.0f, 0.0f, 0.0f);	_up    = D3DXVECTOR3(0.0f, 1.0f, 0.0f);	_look  = D3DXVECTOR3(0.0f, 0.0f, 1.0f);}Camera::~Camera(){}void Camera::getPosition(D3DXVECTOR3* pos){	*pos = _pos;}void Camera::setPosition(D3DXVECTOR3* pos){	_pos = *pos;}void Camera::getRight(D3DXVECTOR3* right){	*right = _right;}void Camera::getUp(D3DXVECTOR3* up){	*up = _up;


PITCH:
void Camera::pitch(float angle){	D3DXMATRIX T;	D3DXMatrixRotationAxis(&T, &_right,	angle);	// rotate _up and _look around _right vector	D3DXVec3TransformCoord(&_up,&_up, &T);	D3DXVec3TransformCoord(&_look,&_look, &T);}


YAW:
void Camera::yaw(float angle){	D3DXMATRIX T;	// rotate around world y (0, 1, 0) always for land object	if( _cameraType == LANDOBJECT )		D3DXMatrixRotationY(&T, angle);        //SUPPOSEDLY THIS STOPS IT FROM ROLLING	// rotate around own up vector for aircraft	if( _cameraType == AIRCRAFT )		D3DXMatrixRotationAxis(&T, &_up, angle);	// rotate _right and _look around _up or y-axis	D3DXVec3TransformCoord(&_right,&_right, &T);	D3DXVec3TransformCoord(&_look,&_look, &T);}



This is my rotatebyMouse Function, where the arrow stars are(<-------********)
are the parts that i think are effecting the roll, Now if i insert the
_look.y = yDirection (So i can look up and down) The camera rolls, Not if i only have the _look.x = xdirection... see what i mean...
And with only the _look.x = xDirection code in their it will rotate about
(min 0deg to max180deg) I cant rotate all the way around!!!


void Camera::RotateByMouse(int mousePosX, int mousePosY, int midX, int midY){	float yDirection = 0.0f;         // Direction angle.	float xDirection = 0.0f;         // Direction angle.	float yRotation = 0.0f;          // Rotation angle.	// If the mouseX and mouseY are at the middle of the screen then we can't rotate the view.	if((mousePosX == midX) && (mousePosY == midY))      return;	// Next we get the direction of each axis.  We divide by 1000 to get a smaller value back.	xDirection = (float)((midX - mousePosX)) / 1000.0f;	yDirection = (float)((midY - mousePosY)) / 1000.0f;					// We use curentRotX to help use keep the camera from rotating too far in either direction.    _look.x -= Direction;     <-------------------------*******    	// Stop the camera from going to high...	if(_look.x > 1.0f)      {		   _look.x = 1.0f;         return;      }	// Stop the camera from going to low...	if(_look.x < -1.0f)		{         _look.x = -1.0f;         return;	}   // Next we get the axis which is a perpendicular vector of the view direction and up values.   // We use the cross product of that to get the axis then we normalize it.   float xAxis = 0, yAxis = 0, zAxis = 0;   float xDir = 0, yDir = 0, zDir = 0;   // Get the Direction of the view.    xDir = _pos.x - _look.x;	yDir = _pos.y - _look.y;	zDir = _pos.z - _look.z;   // Get the cross product of the direction and the up.   xAxis = (yDir * _up.z) - (zDir * _up.x);   yAxis = (zDir * _up.x) - (xDir * _up.y);   zAxis = (xDir * _up.y) - (yDir * _up.z);   // Normalize it.   float len = 1 /(float)sqrt(xAxis * xAxis + yAxis * yAxis + zAxis * zAxis);   xAxis *= len;   yAxis *= len;   zAxis *= len;   // Rotate the camera.  RotateCamera(xDirection, 0, 1, 0); <------------------------*****}


For the most part i think i plugged evrything in right from another .cpp but its just not working right!!!! But thats cool i barely started c++ 2 weeks ago and i got a 3d world running... thx to previous experience in vb and directx.

appreciate the help man!!!!
Typically, you'll keep "heading" and "elevation" as state for the camera (if you're a first-person perspective), and movement in X affects heading, and movement in Y affects elevation (pitch).

Each frame, when you generate the camera matrix, you re-generate it based on the heading and pitch. The specifics depend on the API; in GL it's something like:

glMatrixMode( GL_MODELVIEW );glLoadIdentity();glRotatef( 0, 1, 0, heading );glRotatef( 1, 0, 0, pitch );


Make sure you wrap the heading part when you go beyond 180 (to -180) and below -180 (to 180). Also make sure you clamp the pitch to +/- 89 degrees.

If you do it this way, your camera will always be "straight" (Y up). More ideas about simple cameras found at my site.

In DirectX, use the D3DX functions to generate rotation matrices, multiply them together, and put them into the VIEW matrix instead.
enum Bool { True, False, FileNotFound };
ummm sorry i understand that a little bit, i think i am doing that though, but if the y axis is always up how are you gonna pitch up and down, y == up.

~Chaos
Sorry if i confused you, but you wnat your camera to be LANDOBJECT.

as for your RotateCamera function, my point was why are you writing another function when you already have a set of functions that rotate the camera for you( the Yaw, Pitch and Roll functions, but you wont be using the Roll one :P )

that way all you need to do is somehow convert your mouse movements into an angle in radians( i cheat a little here by just feeding in the amount the mouse has moved since last frame ) into the function to rotate the camera (i.e. movement on the mouse x axis makes the camera rotate around the y axis or YAW rotation, movement on the mouse y axis rotates around the x axis or PITCH rotation )

I'm guessing your not using DirectInput to get your mouse positions, so what you could do is save the last known position of the mouse and calculate the mouse DELTA each frame by subtracting the current position from the last position
fCurrentMouseX = GetMouseX(); // This isnt really a function, should replace it with however you get your mouse positionfCurrentMouseY = GetMouseY();// Calculate DeltafMouseDeltaX = fCurrentMouseX - fLastMouseX;fMouseDeltaY = fCurrentMouseY - fLastMouseY;// Save off mouse position so we can do it all over again next framefLastMouseX = fCurrentMouseX;fLastMouseY = fCurrentMouseY;


Hope this helps, if you want i could write you a small apps to try and demostrate what i mean

P.S: the words in capitals are just my way of referring to what it meant in previous posts, not trying to tell you stuff you already might know :D
Alright ive been out for awhile and during that time i finally got something to work for me on this camera issue!!!
So i finally got the camera to rotate 360 deg by using my original pitch and yaw functions, the right way. Now heres the code that i came up with, it works... but the movement is very choppy its not smooth like i would like it to be, but this is the only way i could get it to work!! Any ideas on how to make the camera movement smoother??

HandleInput:
  POINT mousePos;   GetCursorPos(&mousePos);    int minMousePosx = g_Width / 2 - 1 ;   int maxMousePosx = g_Width / 2 + 1;   int minMousePosy = g_Height / 2 - 2;   int maxMousePosy = g_Height / 2 + 2;   if (mousePos.x < minMousePosx) {	TheCamera.yaw(-mousePos.x * timeDelta / 150  );SetCursorPos(w,h);   }    if (mousePos.x > maxMousePosx) {	TheCamera.yaw(mousePos.x * timeDelta / 150 );SetCursorPos(w,h);   }       if (mousePos.y < minMousePosy) {	TheCamera.pitch(-mousePos.y * timeDelta / 150 );SetCursorPos(w,h);   } 	 if (mousePos.y > maxMousePosy) {	TheCamera.pitch(mousePos.y * timeDelta / 150  );SetCursorPos(w,h);   } 



It looks a little primitive to me but its working!! i would like a better way of doing it though...

~Chaos

This topic is closed to new replies.

Advertisement