Rotation and Position question

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
hunx
Posts: 4
Joined: Thu Aug 21, 2014 9:49 pm

Rotation and Position question

Post by hunx »

i have a question with the position of one object when you rotate it

for example when you use the

Code: Select all

space.Entities[1].Position.X
thing, the object moves in the X axis, this is ok

but if i rotate for example my object with the .AngularVelocity the object rotate in the axis, but i dont know how indicates him when he is in another rotation for move again in the correct angle

sorry my bad english, is not my first languaje i hope you understand with this draw
this is i want to do
Image

thanks
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Rotation and Position question

Post by Norbo »

If you want to get the entity's local up direction, you can use the entity.OrientationMatrix.Up property. It is equivalent to transforming (0, 1, 0) by the OrientationMatrix, but due to the properties of orthonormal transforms the axis can be cheaply pulled directly out of the matrix's components.

There are equivalent properties for Right, Forward, and so on.
hunx
Posts: 4
Joined: Thu Aug 21, 2014 9:49 pm

Re: Rotation and Position question

Post by hunx »

i recently download the demo in the main page on codeplex and this is exactly what i want to do, a first person camera museum for my final project in the university,

then i have another question how do you do the collision between the camera and the objects in the space?
there are something like "camera.radious" or something what collides with the entities in the space?

or do the camera work as an object
thanks for all norbo
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Rotation and Position question

Post by Norbo »

The camera itself is just a nonphysical helper class that creates a view matrix to render things with.

In the demos, when you're walking around as a character, the camera is positioned to follow the character's body around. All the collision and movement is handled by the CharacterController. Similarly, when you use a vehicle in the demos, the camera follows the vehicle around.

If you wanted to have a free flying camera that collided with things, you could create a sphere for the camera to follow around and then change the sphere's velocity to match user input. It would look something like this:

Code: Select all

            var sphere = new Sphere(new Vector3(), 1, 10);
            //Don't let gravity pull down the sphere.
            sphere.IsAffectedByGravity = false; 
             //There's no reason for the sphere to rotate due to collisions. Set its inertia tensor to infinity.
            sphere.LocalInertiaTensorInverse = new Matrix3x3();
            //Make it easy to slide.
            sphere.Material.KineticFriction = 0; 
            sphere.Material.StaticFriction = 0;

...

            //During updates, change the velocity of the sphere to make it move around.
            if (MoveForwardKeyPressed)
                sphere.LinearVelocity = Camera.WorldMatrix.Forward * speed;
Post Reply