Replies: 1 comment
-
A So if creating a body: Simulation.Bodies.Add(BodyDescription.CreateDynamic(
new RigidPose(new Vector3(0, -15, 0), QuaternionEx.CreateFromAxisAngle(new Vector3(0, 1, 0), MathF.PI / 2)),
mesh.ComputeClosedInertia(1),
new CollidableDescription(Simulation.Shapes.Add(mesh)),
new BodyActivityDescription(0.01f))); Or a static: Simulation.Statics.Add(new StaticDescription(
new Vector3(0, -15, 0), QuaternionEx.CreateFromAxisAngle(new Vector3(0, 1, 0), MathF.PI / 2),
new CollidableDescription(Simulation.Shapes.Add(mesh)))); 2.4 also has some convenience casts that can make the description of bodies shorter. For example, you can directly provide the shape's Simulation.Bodies.Add(BodyDescription.CreateDynamic(
new RigidPose(new Vector3(0, -15, 0), QuaternionEx.CreateFromAxisAngle(new Vector3(0, 1, 0), MathF.PI / 2)),
mesh.ComputeClosedInertia(1), Simulation.Shapes.Add(mesh), 0.01f)); Simulation.Statics.Add(new StaticDescription(
new Vector3(0, -15, 0), QuaternionEx.CreateFromAxisAngle(new Vector3(0, 1, 0), MathF.PI / 2),
Simulation.Shapes.Add(mesh))); You can find more examples in the demos. The idea is that shapes can be shared across many bodies/statics. Also, I generally recommend against using |
Beta Was this translation helpful? Give feedback.
-
Hi,
Could you please show me how to add a mesh to the simulation?
Here my code snippet where i extract vertices from my model to create a mesh... and then i dont' know how to use this mesh to add a new "body" to the simulation...
`
physics.BufferPool.Take(_trianglesCount, out var _triangleBuffer);
for (int i = 0; i < _trianglesCount; i++)
{
ref Triangle t = ref _triangleBuffer[i];
}
var _mesh = new Mesh(_triangleBuffer.Slice(0, _trianglesCount), System.Numerics.Vector3.One, physics.BufferPool);
physics.Bodies.Add(?)
`
Thanks for your help!
Beta Was this translation helpful? Give feedback.
All reactions