Graphics Reference
In-Depth Information
Getting ready
For our physics engine, we will use BulletSharp, a .NET wrapper of the popular Bullet
Physics library used in many AAA game and movie titles. Consider the following steps:
1.
Download the BulletSharp library from https://code.google.com/p/
bulletsharp/ . It is also included in the \External folder within the downloadable
content for this topic.
2.
Add a reference to the \External\bulletsharp-2.82\Release SharpDX\
BulletSharp.dll assembly.
Referencing the SharpDX version of the BulletSharp assembly
uses the existing SharpDX vector and matrix structures.
3.
We use an example scene to demonstrate the physics engine. This is available
within the downloadable content.
4.
A debug renderer class, PhysicsDebugDraw , is included in the completed project
for debugging the rigid body shapes and constraints. This depends on .\Shaders\
PhysicsDebug.hlsl and the BufferedDebugDraw class.
5.
Finally, we will need a project that has the MeshRenderer class available.
How to do it…
We will begin by loading our 3D scene and generate their corresponding rigid bodies in
the Bullet Physics Library.
1.
Add the PhysicsScene1.fbx 3D scene to the project and set Build Action
to MeshContentTask.
2.
At the start of D3DApp.Run where we initialize our renderers, load
PhysicsScene1.cmo (the compiled mesh object file) and create the
MeshRenderer instances, as follows:
// Create and initialize the mesh renderer
var loadedMesh =
Common.Mesh.LoadFromFile("PhysicsScene1.cmo");
List<MeshRenderer> meshes = new List<MeshRenderer>();
meshes.AddRange(from mesh in loadedMesh
select ToDispose(new MeshRenderer(mesh)));
foreach (var m in meshes) {
m.Initialize(this);
m.World = Matrix.Identity;
}
var meshWorld = Matrix.Identity;
 
Search WWH ::




Custom Search