3rd Person Camera and scaled model

Started by
3 comments, last by discodowney 14 years, 1 month ago
Im having a problem i hope someone can help me with. Im implementing a 3rd person camera. have it setup so it translates to a point behind the model when the model moves. But the problem is that i have scaled the model to 0.15 its size. So when i move the model right the camera is moving as if behind the unscaled model. So it looks like the camera is shooting off further than the model. Anyone know how i get it to stay behind the scaled down model? cheers.
Advertisement
You say nothing about how you've done camera's set-up. So I guess something and suggest you to use forward kinematics. If you scale the model by its model matrix you may also consider to split the model's transformation into a combined rotation/translation part and a scaling part, so that the camera can be parented w/o scaling.

You need to advice more details for a more sophisticated answer, IMHO.
Okay. I create the model from a .x file. Then in the Display loop i have a show method t odrarw the mesh. In here i translate it, scale it and rotate it. there are seperate matrices for each transformation, then they are all multiplied to give a world matrix for an overall transformation. Then when the model is moved the following happens

D3DXVECTOR3 shipPos = theSpaceShip.getPos();
TheCamera.setPosition(&shipPos);
TheCamera.setLook(&(cameraLookAt));
TheCamera.getViewMatrix(&View);
Device->SetTransform(D3DTS_VIEW, &View);

i get the models position, setPosition sets the camera to a fixed distance from the model, setLook sets the LookAt, then i make up the View Matrix and set it.

I dont understand what you mean when you say the camera can be parented w/o scaling.
The usual way of declaring spatial dependency is done by "parenting" the child object to the parent object. Done so means that any translation/rotation applied to the parent object is also applied to the child object in a way that the relative position/orientation of the child to the parent is not changed.

To yield this is relatively simple. If the parent object has a world matrix P, and the child object has a translation T denoting its local position w.r.t. the parent, and similarly a rotation R denoting its local orientation w.r.t. the parent, then the world matrix of the child object is
R * T * P
(when using row vectors like you do probably, because of D3D). So, if some translation or rotation is changing P, then the child object is also influenced.

Now, if you think of the complete combination of a transformation, then scaling is there, too. So the object matrix may look like
SP * RP * TP =: P
Attaching the camera as a child means then that it is also influenced by the scaling:
R * T * P = R * T * SP * RP * TP
If you don't want that, then you need to split the object transformation as said in the previous post.
Cheers man. Have it working for just movement along axis'. Now on to rotations. Thanks for the help

This topic is closed to new replies.

Advertisement