How to dynamically change the scale of my entity object ?

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
rc183
Posts: 7
Joined: Fri Apr 08, 2011 2:34 pm

How to dynamically change the scale of my entity object ?

Post by rc183 »

Hi,

I have one question about BEPU Physic.

I have a ball model associated to a Sphere entity (BEPU Sphere Object) and i try to modify the scale of this ball dinamicaly depending of the time.

I tried to modify the WorldTransform attribute of my Sphere entity but it doesn't seem work. I think that my scale is ignored.

There is a better way to create this effect ?

Thank you in advance for your answers.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: How to dynamically change the scale of my entity object

Post by Norbo »

WorldTransform is a rigid transform, meaning it should contain only orientation and translation. Including scale or shear components in a Matrix will confuse the property setter and end up with wrong orientation/translation.

There is no universal 'scale' property across all entities. However, many shapes have properties that can be changed. For example, a SphereShape (used by the Sphere prefab entity) has a Radius property. It is settable.

There's also a TransformableShape that can take any other convex shape and an affine transform. You can nonuniformly scale and shear shapes by doing this, but be aware that using this eliminates the engine's ability to use the inner shapes' special case collision detection systems. It might not be as efficient.

Note that changing an entity's shape such that it encounters a new collision due to expansion will have a 'squishy' collision response. Collision response primarily relies on correcting velocity, with penetration being corrected over multiple frames. Since the shape change is instantaneous and nonphysical, it has to rely entirely on the penetration correction, which, again, takes multiple frames.
rc183
Posts: 7
Joined: Fri Apr 08, 2011 2:34 pm

Re: How to dynamically change the scale of my entity object

Post by rc183 »

Thank you very much for your answer.

I have tried to modify the radius attribute of my sphere. The radius correctly change but my model and the bouding box are always too big (no change is applied).

I have tried to call the UpdateBoudingBox method after the change of the radius but nothing seems to work.

This is normal ?

Thank you in advance.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: How to dynamically change the scale of my entity object

Post by Norbo »

The bounding box is computed with every call to UpdateBoundingBox based on the current dimensions of the shape. The UpdateBoundingBox calls will occur automatically if the object is active (and changing dimensions should wake the object up, if I remember correctly).

So if it is truly not changing, then no, that is not expected.

Could it just a lack of graphical change? Examining it before and after the dimension change and bounding box update using the debugger would make it obvious.

If you're using the ModelDrawer, note that it does not bother updating its graphics when an entity changes shape. To update the appearance, you need to remove the entity from the ModelDrawer and add it again.
Post Reply