Page 1 of 1

scaling Entity at runtime

Posted: Thu Nov 09, 2017 11:48 pm
by matim
Hi,
i'm new in BEPU ;
i'm french so i appology for my bad engligh
is it possible to scale a entity by modify the worldTransform matrix at the runtime ?
worldTransform.M11 is x scale ? right ?
how to set this propriety ? is there a method to do that ?

Thanks

Re: scaling Entity at runtime

Posted: Fri Nov 10, 2017 12:06 am
by Norbo
All entities in the engine are 'rigid' for the purposes of simulation. Entity.WorldTransform is a convenience wrapper around the Position and Orientation properties. When setting a value on the Entity.WorldTransform, the matrix is reinterpreted as just a position and orientation, so all nonrigid transformation is lost (and the resulting rigid transform may be wrong due to the nonrigid input).

To change the size of an entity, you can modify that entity's collision shape. For example, for an entity using a BoxShape, you can modify the underlying BoxShape's width. There is no single universal property for scaling, though; for example, a SphereShape only has a Radius.

There is a TransformableShape which can wrap other convex shapes. That could be useful, but be careful- it is more expensive and has slightly worse behavior than special cases like box-box collision detection.

Note that runtime scaling is a nonphysical process as far as the simulation is concerned. There is no velocity associated with the resize, so collisions only get handled retroactively. Collisions will tend to appear 'squishy' as incremental penetration resolution tries to resolve resize-induced intersection.

Re: scaling Entity at runtime

Posted: Fri Nov 10, 2017 12:22 am
by matim
Thanks for reply,

i understand

my entity named cube1 has a boxshape but i can't get cube1.boxShape.Width ?

Can you help me with a little peace of code ?

please

Re: scaling Entity at runtime

Posted: Fri Nov 10, 2017 12:47 am
by Norbo
Entity.CollisionInformation.Shape would be the property, but it may have to be casted to a BoxShape first if the entity wasn't a prefab Box type. You could keep a reference to the shape used by an entity around to avoid having go through the entity's properties, too.

The EntityConstructionDemo.cs in the BEPUphysicsDemos shows some examples of how entities and shapes are constructed and how they relate to each other.