Direct3d (getting camera to follow)
Hey what''s the correct way to get the camera to follow behind an object?
I''ve tried this but the orientation is wrong:
D3DVECTOR dir;
myglobs.camera->LookAt(theship, NULL, D3DRMCONSTRAIN_Z);
// this is what moves theship
theship->SetPosition(theship,D3DVAL(0), D3DVAL(0), D3DVAL(.9));
theship->GetPosition(myglobs.scene,&dir);
//supposed to keep the camera 5 from back of ship
myglobs.camera->SetPosition(myglobs.scene,dir.x,dir.y,dir.z - 5);
Can you store object movement in a matrix and then just apply the same matrix to the camera? This should work for any transformations, including rotation, assuming your object transformations are done in object space. If not, you''ll have to convert them.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement