Sign in to follow this  

3rd Person Camera and scaled model

This topic is 2846 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

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.

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

This topic is 2846 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this