Changing Orientation At Will

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Syntax
Posts: 19
Joined: Wed Jan 05, 2011 6:40 pm

Changing Orientation At Will

Post by Syntax »

Hello, I am currently working with a complex object that resembles a vehicle. I would like to able to instantly tell the main body of the vehicle to rotate to a specific orientation value and for all of the wheels and other attachments to follow. However, the wheels seem to be causing friction and if i try to rotate the vehicle 180 degrees, the vehicle only rotates 55 degrees or so. There is also a lot of odd movements from the other items on the vehicle as they try to catch up with the frame of the vehicle. All of my spring settings for joints are setup with the damping constant and stiffness constant set to max values and advanced.softness set to a min value. This is to keep the wheels and other items in their exact position relative to the frame of the vehicle. I am trying to rotate the frame by doing this:

frame.Orientation = Quaternion.CreateFromAxisAngle(Vector3.Up, 180);

Oddly enough, if I do this:
frame.Position = newPosition;
Everything moves together and there is no problem at all.

What do I need to do to make a complicated object and all of it's children rotate to a specific angle?

Thanks in advance,
Syntax
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Changing Orientation At Will

Post by Norbo »

Changing the orientation or position directly is a discontinuous motion, so it's not advisable to try to tune the constraints to keep up to a teleporting body. The process of position correction will introduce significant forces to the system which will push the system off your goal state.

Instead, apply a consistent transform to all elements of the articulated structure. Changing position alone is easy- you can offset every object by the same amount. Orientation is trickier. You do need to apply a consistent rotation to all objects, but there's more too.

The offsets from the main object to its children are rotating, too. Compute the offsets, rotate the offset by the same rotation, and reposition the child accordingly.

It doesn't matter which object in the structure you consider the 'main' object or where you consider the center of rotation to be; just maintain consistency across all objects. Choosing a single object as the 'main' body and using its position as a pivot just allows you to avoid rotating the offset of that one object.
frame.Orientation = Quaternion.CreateFromAxisAngle(Vector3.Up, 180);
The angle should be in radians, so 180 should be MathHelper.Pi.
All of my spring settings for joints are setup with the damping constant and stiffness constant set to max values and advanced.softness set to a min value.
Careful with this; excessive values can cause significant instability. Also, the advanced Softness property is only used if advanced settings have been set to active. When using the non-advanced settings, the Stiffness and Damping values are internally converted into the position correction factor and softness values.
Post Reply