Re: Physics Accuracy Issues...
Posted: Tue Nov 16, 2010 2:47 am
This is the code that i now use for the wheel attaching
If I have the wheel going in the direction of the x axis then it does this...
http://www.youtube.com/watch?v=ABWgSkOUcXM
If i rotate it in another direction it does the same bug as before where the rotation wraps over...
I am using the wheels matrix for calculating all the joints but still no luck
Heres the code i use.
//The entity the raycast has hit
Entity body = HitEntity;
Entity wheel = Bodys[0];
//My wheels are already rotated by the time we get to attaching them here so we must set the rotation of all the joint stuff
Matrix o = wheel.OrientationMatrix;
//Connect the wheel to the body.
var pointOnLineJoint = new PointOnLineJoint(body, wheel, wheel.CenterPosition, o.Down, wheel.CenterPosition);
var suspensionLimit = new LinearAxisLimit(body, wheel, wheel.CenterPosition, wheel.CenterPosition, o.Down, -1, 0);
//This linear axis motor will give the suspension its springiness by pushing the wheels outward.
var suspensionSpring = new LinearAxisMotor(body, wheel, wheel.CenterPosition, wheel.CenterPosition, o.Down);
suspensionSpring.Settings.Mode = MotorMode.Servomechanism;
suspensionSpring.Settings.Servo.Goal = 0;
suspensionSpring.Settings.Servo.SpringSettings.StiffnessConstant = 200;
suspensionSpring.Settings.Servo.SpringSettings.DampingConstant = 50;
var swivelHingeAngularJoint = new SwivelHingeAngularJoint(body, wheel, o.Up, o.Right);
//Motorize the wheel.
MyMotor = new RevoluteMotor(body, wheel, o.Left);
MyMotor.Settings.VelocityMotor.Softness = .2f;
MyMotor.IsActive = false;
MyServo = new RevoluteMotor(body, wheel, o.Up);
MyServo.Settings.Mode = MotorMode.Servomechanism;
MyServo.Basis.SetWorldAxes(o.Up, o.Right, o.Forward);
MyServo.TestAxis = body.OrientationMatrix.Right;
//Add the wheel and connection to the space.
space.Add(pointOnLineJoint);
space.Add(suspensionLimit);
space.Add(suspensionSpring);
space.Add(swivelHingeAngularJoint);
space.Add(MyMotor);
space.Add(MyServo);
If I have the wheel going in the direction of the x axis then it does this...
http://www.youtube.com/watch?v=ABWgSkOUcXM
If i rotate it in another direction it does the same bug as before where the rotation wraps over...
I am using the wheels matrix for calculating all the joints but still no luck
Heres the code i use.
//The entity the raycast has hit
Entity body = HitEntity;
Entity wheel = Bodys[0];
//My wheels are already rotated by the time we get to attaching them here so we must set the rotation of all the joint stuff
Matrix o = wheel.OrientationMatrix;
//Connect the wheel to the body.
var pointOnLineJoint = new PointOnLineJoint(body, wheel, wheel.CenterPosition, o.Down, wheel.CenterPosition);
var suspensionLimit = new LinearAxisLimit(body, wheel, wheel.CenterPosition, wheel.CenterPosition, o.Down, -1, 0);
//This linear axis motor will give the suspension its springiness by pushing the wheels outward.
var suspensionSpring = new LinearAxisMotor(body, wheel, wheel.CenterPosition, wheel.CenterPosition, o.Down);
suspensionSpring.Settings.Mode = MotorMode.Servomechanism;
suspensionSpring.Settings.Servo.Goal = 0;
suspensionSpring.Settings.Servo.SpringSettings.StiffnessConstant = 200;
suspensionSpring.Settings.Servo.SpringSettings.DampingConstant = 50;
var swivelHingeAngularJoint = new SwivelHingeAngularJoint(body, wheel, o.Up, o.Right);
//Motorize the wheel.
MyMotor = new RevoluteMotor(body, wheel, o.Left);
MyMotor.Settings.VelocityMotor.Softness = .2f;
MyMotor.IsActive = false;
MyServo = new RevoluteMotor(body, wheel, o.Up);
MyServo.Settings.Mode = MotorMode.Servomechanism;
MyServo.Basis.SetWorldAxes(o.Up, o.Right, o.Forward);
MyServo.TestAxis = body.OrientationMatrix.Right;
//Add the wheel and connection to the space.
space.Add(pointOnLineJoint);
space.Add(suspensionLimit);
space.Add(suspensionSpring);
space.Add(swivelHingeAngularJoint);
space.Add(MyMotor);
space.Add(MyServo);