Page 1 of 1

Wrong forward direction Compound body as Vehicle body

Posted: Sun Apr 10, 2016 12:40 pm
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

Re: Wrong forward direction Compound body as Vehicle body

Posted: Sun Apr 10, 2016 5:17 pm
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.

Re: Wrong forward direction Compound body as Vehicle body

Posted: Wed Apr 13, 2016 9:36 am
by Upkto
Thank you very much! I find it very helpful.