scaling Entity at runtime

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
matim
Posts: 2
Joined: Thu Nov 09, 2017 11:42 pm

scaling Entity at runtime

Post 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
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: scaling Entity at runtime

Post 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.
matim
Posts: 2
Joined: Thu Nov 09, 2017 11:42 pm

Re: scaling Entity at runtime

Post 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
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: scaling Entity at runtime

Post 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.
Post Reply