Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions examples/code-only/Example19_Jitter2Physics/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,24 @@ void Start(Scene rootScene)

PhysicsWorld.Init();

const float groundBoxDim = 15.0f;

// ground Entity setup
groundEntity = game.Create3DPrimitive(PrimitiveModelType.Plane);
groundEntity.Transform.Position = new Vector3(-10, -10, -10);
groundEntity.Transform.Scale = new Vector3(15, 0.5f, 15);
groundEntity.Transform.Scale = new Vector3(groundBoxDim, 1, groundBoxDim);
var groundPosition = groundEntity.Transform.Position;
groundEntity.Scene = rootScene;

// ground body setup
groundBody = PhysicsWorld.world.CreateRigidBody();
groundBody.MotionType = MotionType.Static;
groundBody.AddShape(new BoxShape(new JVector(15, .5f, 15)));
groundBody.Position = new JVector(groundPosition.X, groundPosition.Y, groundPosition.Z);
groundBody.AddShape(new BoxShape(groundBoxDim));

// Physics box is centered; shift down so its top matches the plane.
groundBody.Position = new JVector(groundPosition.X,
groundPosition.Y - 0.5f * groundBoxDim,
groundPosition.Z);

// spawning cubes
for (int i = 0; i <= 150; i++)
Expand All @@ -56,14 +62,14 @@ void Start(Scene rootScene)
});
var cubePosition = new Vector3(-10, 10 + i * 2, -10);

ent.Transform.Position = cubePosition;
ent.Transform.Scale = new Vector3(.5f);
ent.Transform.Position = cubePosition;
ent.Transform.Scale = new Vector3(0.5f);
ent.Scene = rootScene;

//cube body setup
var body = PhysicsWorld.world.CreateRigidBody();
body.AddShape(new BoxShape(0.25f));
body.SetMassInertia(1f);
body.AddShape(new BoxShape(0.5f));
body.SetMassInertia(1f);
body.Position = new JVector(cubePosition.X, cubePosition.Y, cubePosition.Z);

cubeEntities.Add(ent);
Expand Down