CompoundShapeEntry problem

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
phinwone
Posts: 8
Joined: Sun Sep 08, 2013 2:18 pm

CompoundShapeEntry problem

Post by phinwone »

I'm trying to get a group


-------------------------------------------------------
sph1 = new DynamicObject(this, space, Sphere, Sphere, new Vector3(-11, 24, 20), new Vector3(0, 0, 0), new Vector3(0.05f, 0.05f, 0.05f), 1);
Components.Add(sph1);
sph2...
sph3..

space.Add(...)

var bodies = new List<CompoundShapeEntry>()
{
new CompoundShapeEntry(sph1.Hull.CollisionInformation.Shape, sph1.Position, 100),
new CompoundShapeEntry(sph2.Hull.CollisionInformation.Shape, sph2.Position, 100),
new CompoundShapeEntry(sph3.Hull.CollisionInformation.Shape, sph3.Position, 100)
};
group = new CompoundBody(bodies, 450000);
space.Add(group);

--------------------------

What is wrong?
Last edited by phinwone on Mon Sep 16, 2013 4:46 am, edited 1 time in total.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: CompoundShapeEntry problem

Post by Norbo »

What is wrong?
You tell me :P

Are you getting errors? Weird behavior? Crashes?

At a glance, the mass of the compound body is a bit extreme. That could cause instability if it ever comes to rest on a much lighter object.
phinwone
Posts: 8
Joined: Sun Sep 08, 2013 2:18 pm

Re: CompoundShapeEntry problem

Post by phinwone »

group is unstable, at first seconds the three balls behave like they in the group and then they drop out and go in different directions, very strange, and I had changed the mass a lot of times but no effect
phinwone
Posts: 8
Joined: Sun Sep 08, 2013 2:18 pm

Re: CompoundShapeEntry problem

Post by phinwone »

For the first 5 seconds the spheres falling down to the surface, like a group and nothing bad happens, but after contact they start to slowly creep up looks like the group displaces them from itself after all they drop out
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: CompoundShapeEntry problem

Post by Norbo »

If you're seeing objects move relative to each other within what is supposed to be a CompoundBody, then the renderer may be drawing stuff in the wrong places. Also note that creating a CompoundBody using another entity's shape does not bind that other entity in any way; shapes can be shared between multiple entities. Separate entities will move separately.

If the above isn't it, could you reproduce the behavior in the BEPUphysicsDemos for me to look at?
phinwone
Posts: 8
Joined: Sun Sep 08, 2013 2:18 pm

Re: CompoundShapeEntry problem

Post by phinwone »

I added group in the modeldrawer and i saw new 3 balls of real group, actually I thought CompoundBody must bind existing physical objects in the list of CompoundShapeEntry but it creates new physical objects which physically collides with existing, maybe exist a different way to bind existing objects?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: CompoundShapeEntry problem

Post by Norbo »

If you want to create a physical link between separate entities, use constraints.

WeldJoint controls all degrees of freedom. It would produce the closest behavior to a CompoundBody.

Note that constraints are like springs. A heavier object can pull a spring further than a light object. If the constraints seem really loose, try reducing the entity masses or increasing the Stiffness and Damping of the joint.

Check out the BEPUphysicsDemos for examples of using constraints.
phinwone
Posts: 8
Joined: Sun Sep 08, 2013 2:18 pm

Re: CompoundShapeEntry problem

Post by phinwone »

Thanks for the help, Norbo
phinwone
Posts: 8
Joined: Sun Sep 08, 2013 2:18 pm

Re: CompoundShapeEntry problem

Post by phinwone »

How can I make a strong connection through the joints? i have two boxes joined via WeldJoint and i need disable any local rotation and movement, i have tryed various mass, stiffness, dumping, but did not get ideal state of boxes, just want two object behavior as one object
Thanks!
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: CompoundShapeEntry problem

Post by Norbo »

Here's a couple of configurations which are highly rigid and seem to keep things together. The first one is just the default:

Code: Select all

            Box a = new Box(new Vector3(0, 20, 0), 1, 1, 1, 1);
            Box b = new Box(new Vector3(1, 20, 0), 1, 1, 1, 1);
            WeldJoint weld = new WeldJoint(a, b);
Now if the masses are increased, the settings are increased proportionally:

Code: Select all

            Box a = new Box(new Vector3(0, 20, 0), 1, 1, 1, 1000);
            Box b = new Box(new Vector3(1, 20, 0), 1, 1, 1, 1000);
            WeldJoint weld = new WeldJoint(a, b);
            weld.NoRotationJoint.SpringSettings.DampingConstant *= 1000;
            weld.NoRotationJoint.SpringSettings.StiffnessConstant *= 1000;
            weld.BallSocketJoint.SpringSettings.DampingConstant *= 1000;
            weld.BallSocketJoint.SpringSettings.StiffnessConstant *= 1000;

This keeps it roughly as rigid as it was with lower mass. If that's what you've already tried and it still feels too soft, it may be that some element of the configuration is weaker relative to its required job. For example, long lever arms connecting objects together will tend to show more error.

If no error whatsoever is allowed, then a compound body should be used as before. Compounds can't be created directly from existing entities, but you can get the compound's constituent CollisionShapes however you'd like. If the goal is to 'merge' two entities, then the original entities could be removed and their shapes could be used to create a new compound in their place.

Only use constraints if a physical link (that is, a connection which is simulated and capable of weakness) is desired.
Post Reply