• Advertisement
Sign in to follow this  

ArcBall Camera

This topic is 4044 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement