AndresTraks / BulletSharpPInvoke

.NET wrapper for the Bullet physics library using Platform Invoke
http://andrestraks.github.io/BulletSharp/
150 stars 97 forks source link

Rigidy body with changing vertex positions #48

Closed petrasvestartas closed 6 years ago

petrasvestartas commented 6 years ago

I would like to animate one of rigid bodies.

I basically would like to create a wavy mesh and change its z coordinate overtime perlin-noise-terrain-mesh1

The on that landscape add some ordinary rigid bodies like cubes.

What would be a way to change a rigid body? Would I need to remove each iteration a rigid body and add new one? Or it is possible to manipulate vertex coordinates?

AndresTraks commented 6 years ago

The ConcaveConvexCastDemo does exactly this. https://github.com/AndresTraks/BulletSharpPInvoke/blob/master/BulletSharp/demos/ConcaveConvexCastDemo/ConcaveConvexCastDemo.cs

The main point is to use a BvhTriangleMeshShape with a TriangleIndexVertexArray and when you update the shape, you overwrite the vertex array, recalculate the bounding box for the shape and clear collision pairs between the ground object and other objects.

The animation should be slow enough and the ground triangles small enough so that the other objects (boxes) don't fall through and the simulation remains stable.

petrasvestartas commented 6 years ago

What in this example ConvexcastBatch class does?

It is not the landscape animation it is those cubes connected with rays?

AndresTraks commented 6 years ago

The landscape is animated in that demo.