Wrong forward direction Compound body as Vehicle body

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Upkto
Posts: 2
Joined: Sun Apr 10, 2016 12:10 pm

Wrong forward direction Compound body as Vehicle body

Post by Upkto »

Hi all, I have a problem. Wrong exhibiting a forward direction of the machine body. I do not know how to solve this problem.

Code: Select all

List<CompoundShapeEntry> bodies = new List<CompoundShapeEntry>();
            bodies.Add(new CompoundShapeEntry(new BoxShape(2.5f,0.75f,4.5f), new Vector3(0,0.5f,0),60));
            bodies.Add(new CompoundShapeEntry(new BoxShape(2f, 0.75f, 2f), new Vector3(0, 1f, 0), 1));
            bodies.Add(new CompoundShapeEntry(new SphereShape(0.75f), new Vector3(0, 1f, 2), 1));

            
            CompoundBody body = new CompoundBody(bodies,61);
            
            body.CollisionInformation.LocalPosition = new Vector3(0,0.5f,0);
            body.CollisionInformation.Tag = this;

            _vehicle = new Vehicle(body);

Code: Select all

Vector3(0, 1f, 2)
- SphereShape is at the front of the body ( isn't it? )
When i use
Target = Game.Players[0].Car.Vehicle.Body;

Code: Select all

                
Target = Game.Players[0].Car.Vehicle.Body;
...
Camera.Position = Target.WorldTransform.Translation - Target.WorldTransform.Forward*10+ Vector3.Up*2;
                Camera.LookAt(Target.WorldTransform.Translation);
Vehicle.Body.WorldTransform.Forward It does not coincide with the direction of spheres
And the camera is looking towards the front.
The car goes in the opposite direction from the sphere
Attachments
CameraLook at forward direction of Vehicle.Body
CameraLook at forward direction of Vehicle.Body
bepu_screen.jpg (39.06 KiB) Viewed 4090 times
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Wrong forward direction Compound body as Vehicle body

Post by Norbo »

BEPUphysics uses the same right handed convention as XNA, so Right is (1,0,0), Up is (0,1,0), and Forward is (0,0,-1). Since the offset on the sphere is along the positive z axis, it's actually being placed on the 'back' in terms of the coordinate system convention.
Upkto
Posts: 2
Joined: Sun Apr 10, 2016 12:10 pm

Re: Wrong forward direction Compound body as Vehicle body

Post by Upkto »

Thank you very much! I find it very helpful.
Post Reply