2 parallel planes, apply same ang. vel. = intersect

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
JusTiCe8
Posts: 52
Joined: Mon Jun 01, 2015 9:02 am

2 parallel planes, apply same ang. vel. = intersect

Post by JusTiCe8 »

Hi,

willing to make kind of "ball in a maze" game, instead of using constraint (as explained in another thread) to force the ball to stay on the plane (with here plane = a wide and flat BEPU box), I cheat a little by adding a second plane on top of the first, a bit higher than the ball diameter, so the ball can bounce but not very much and is not allowed to jump but is not blocked.

My issue is planes didn't stay parallel after applied to them the exact same angular velocity:

Code: Select all

//creation  (sphere radius is  2.0)
ground = new Box(new BEPUutilities.Vector3(0, 0, 0), 100, 1, 100);
top_wall = new Box(new BEPUutilities.Vector3(0, 6f, 0), 100, 1, 100);

// in update:
//rotate them, x and z angles are two float inc/decremented by 0.5f increment
// angle are set only when key are pressed, otherwise angles = 0
ground.AngularVelocity = new BEPUutilities.Vector3(xangle, 0, zangle);
top_wall.AngularVelocity = new BEPUutilities.Vector3(xangle, 0, zangle);
 
with this code, I got this:

Image
Image

What am I doing wrong ? What I've missed ?
I guess it could be some kind of center of rotation issue, where it is applied on both planes or something close.

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

Re: 2 parallel planes, apply same ang. vel. = intersect

Post by Norbo »

The planes are still parallel, it's just that they are each rotating around their own center of mass. In order to maintain the space between the planes, they'll need to translate. One option is compute offsets from each plane to some desired shared origin of rotation, and then rotate those offsets to match the current orientation. Then, by adding the target origin of rotation and rotated offsets, compute the world space locations of the planes.

Note that it's best to control objects with velocities instead of directly setting positions to avoid collision response issues, so to get the kinematic plane-boxes into position, set their LinearVelocity to a value needed to exactly reach the target in one frame- e.g. planeBox.LinearVelocity = (targetPosition - planeBox.Position) / dt.

There's also the option of just using a CompoundShape with two BoxShapes in it and not worrying about the above :)
JusTiCe8
Posts: 52
Joined: Mon Jun 01, 2015 9:02 am

Re: 2 parallel planes, apply same ang. vel. = intersect

Post by JusTiCe8 »

Doh !! I know it was something obvious :) thanks for the reply and tips, CompoundShape looks a lot more easy as playing with offsets.
Post Reply