Skip to main content
gamedev.net
🔒 Locked 🎮 Unity

Camera look_at

Started by Enjoy 0 replies 450+ views
Original Post
Enjoy
Enjoy
Hi, I am using quaternions to represent rotations. How can I get a rotation quaternion, if I set a new camera target? Here is what am I doing:

void CCamera::LookAt( vec3 pTarget )
{	
	vTarget = pTarget;
	vView = vTarget - vPos; //New view vector
	vView.normalize();
	
	vec3 vViewInit(0.0f, 0.0f, 1.0f); //Previous view vector
	vViewInit.normalize();
	
	float angle = acos( dot_product(vViewInit, vView) );
	qCurrent = CreateFromAxisAngle( ( vViewInit * vView ), angle );
}


But it is not working as I want it to work. What is the way to make it right? Thank you in advance.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.