vehicle.body position

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Domino
Posts: 8
Joined: Fri Aug 01, 2008 3:44 am

vehicle.body position

Post by Domino »

Hi , i would want to set my 3d model's position to the one of my vehicle.body, but there seems to be no 'real' position, i tried with vehicle.body.centerposition but it seems to fuck up when the vehicle is in angle (it seems to take the center position of the bounding box, not the body itself). is there a way i could have this body's worldmatrix or position?

thanks, Domino from csquared-games
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: vehicle.body position

Post by Norbo »

The centerPosition of the body should refer to the geometric center of the object; in testing, I was able to attach a model to the vehicle's body using the DisplayModel class of the demos. The relevant part of the code would be where the world matrix is created for display models which follow entities, which I've modified slightly for clarity:

Code: Select all

            Matrix worldMatrixToUse;
            if (entity != null)//Update the world matrix if the model is following an entity.
                worldMatrixToUse = worldMatrix * entity.rotationMatrix * Matrix.CreateTranslation(entity.centerPosition);
            else
                worldMatrixToUse = worldMatrix;
Where the worldMatrix was the 'local' transformation of the model being used.


If you alter the entity.centerOfMass, you'd probably want to use that in lieu of the entity.centerPosition- a change to the above code which I think I will include in the next version.
Domino
Posts: 8
Joined: Fri Aug 01, 2008 3:44 am

Re: vehicle.body position

Post by Domino »

Thanks, by using your method i found what i did wrong, i translated the model before applying the rotation :oops: thats why the model acted like that.
Post Reply