Skip to main content
gamedev.net
🔒 Locked

ArcBall Camera

Started by VanillaSnake21 Jan 29, 2007 at 5:53 PM 2 replies 1.2k views
Original Post
VanillaSnake21
VanillaSnake21
I've googled the topic, but I couldn't find any good resources on it. Does anyone know any good examples of using the arcball camera. And also can someone explain what this camera type is. I found some examples in the DXUTCamera file, what is the difference between the arcball camera and a model viewer camera (thats the one DxViewer is using). Thanks for replies in advance. Tim.
You didn't come into this world. You came out of it, like a wave from the ocean. You are not a stranger here. -Alan Watts
jpetrie
jpetrie
Arcball isn't a camera, it's just a method of mapping 2D mouse movement to 3D rotations (expressed as a rotation matrix or quaternion).

Of course, you can use this to represent a camera, although usually the resulting matrix is applied to the object viewed by the camera and not the camera itself (though this too is mainly a point of view thing).

In any case, here's what GraphicsDev has to say about arcball: clicky
VanillaSnake21
VanillaSnake21
My camera is using something similar to an arcball at least I think it is. Could you tell me if at least heading the right way, this is the source:

[source lang "cpp"]D3DXVECTOR3 Camera::PlotMouseToBall(){	GetCursorPos(&cursor_current_pos);	D3DXVECTOR3 rp;        // ViewPort is just the client area of the window	rp.x = ((cursor_current_pos.x - 108) / (float)(ViewPort.x>>1)) - 1.0f;	rp.y = ((cursor_current_pos.y - 154) / (float)(ViewPort.y>>1)) - 1.0f;	float z = 1.0f - (MXMATH::sqr(rp.x) + MXMATH::sqr(rp.y));	if(z >= 0)		rp.z = sqrt(z);	else		rp.z = 0.0f;	return rp;}void Camera::CalculateBallRotation(){	D3DXVECTOR3 nowPoint = PlotMouseToBall();	if(spherePoint == nowPoint)	{		BALL_angle += 0;		is_changed = true;	}	else	{	D3DXVec3Normalize(&nowPoint, &nowPoint);	D3DXVec3Normalize(&spherePoint, &spherePoint);	if(TODEG(BALL_angle) >= 360)		BALL_angle -= TORAD(360);	BALL_angle += MXMATH::AngleBetweenVectors(spherePoint, nowPoint);	D3DXVec3Cross(&BALL_axis, &nowPoint, &spherePoint);	D3DXVec3Normalize(&BALL_axis, &BALL_axis);	spherePoint = nowPoint;	is_changed = true;	}	}// and then I call D3DXMatrixRotationAxis() and set that matrix as the world transformation matrix.CameraPerspective.BuildWorldTrackBallMatrix(&g_mx_view, g_device);g_device->SetTransform(D3DTS_WORLD, &g_mx_transform);


The problem I seem to be facing is that when I apply the matrix as the world transform, and I try to rotate something the obect appears at two places at once. Thanks for the link by the way im gonna check out the examples.

You didn't come into this world. You came out of it, like a wave from the ocean. You are not a stranger here. -Alan Watts
VanillaSnake21
VanillaSnake21
any suggestions? The paper by Shoemaker explains a lot about the prototype and implementation, but its a little technical and quite short on the code. And thats basically the only Info I got up to now.
You didn't come into this world. You came out of it, like a wave from the ocean. You are not a stranger here. -Alan Watts

Topic Locked

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

Sign in to reply to this topic.