All pastes #2050113 Raw Edit

Something

public text v1 · immutable
#2050113 ·published 2011-04-24 15:29 UTC
rendered paste body
void CameraNode::RotateCameraInterface()
{
	float verTurn;
	float horTurn;
	float turnSpeed;

	D3DXVECTOR3 targetDirection, vRotAxis;
	D3DXMATRIX matRotAxis, matRotZ;

	D3DXVec3Normalize(&targetDirection, &(_lookAt - _camPosition)); //create direction vector

	D3DXVec3Cross(&vRotAxis, &targetDirection, &_upVec); //strafe vector
	D3DXVec3Normalize(&vRotAxis, &vRotAxis);

	//create rotation matrices
	//D3DXMatrixRotationAxis(&matRotAxis,	&vRotAxis, g_pInput->GetRelativeY() / -360);
	//D3DXMatrixRotationZ(&matRotZ,g_pInput->GetRelativeX() / -360);


	turnSpeed = cameraControllerInterface->getCameraSpeed();
	horTurn = cameraControllerInterface->getTurnHorizontal() * turnSpeed;
	verTurn = cameraControllerInterface->getTurnVertical()* turnSpeed;

	D3DXMatrixRotationAxis(&matRotAxis,	&vRotAxis, verTurn);
	D3DXMatrixRotationY(&matRotZ, horTurn);

	//rotate direction
	D3DXVec3TransformCoord(&targetDirection,&targetDirection,&(matRotAxis * matRotZ));
	//rotate up vector
	D3DXVec3TransformCoord(&_upVec,&_upVec,&(matRotAxis * matRotZ));
	//translate up vector
	_lookAt = targetDirection + _camPosition;

}




void CameraNode::MoveCameraInterface() 
{
	float VELOCITY = 1.0f;
	float verVelocity;
	float horVelocity;
	D3DXVECTOR3 targetDirectionVer, targetDirectionHor, strafeAxis;

	//forwardBack
	D3DXVec3Normalize(&targetDirectionVer,	&(_lookAt - _camPosition));

	//LR
	D3DXVec3Cross(&strafeAxis, &targetDirectionVer, &D3DXVECTOR3( 0.0f, -1.0f, 0.0f ));

	//get inputs from our controller(s) interface
	verVelocity = cameraControllerInterface->getStrafeVertical();
	horVelocity = cameraControllerInterface->getStrafeHorizontal();
	
	_camPosition += targetDirectionVer * verVelocity;
	_lookAt += targetDirectionVer * verVelocity;

	_camPosition -= strafeAxis * horVelocity;
	_lookAt -= strafeAxis * horVelocity;



}