private void DrawBoundingPrimitive(GameTime gameTime, ICollisionPrimitive collisionPrimitive, Color color) { if (collisionPrimitive is SphereCollisionPrimitive) { int primitiveCount = 0; vertexData = new VertexData <VertexPositionColor>(VertexFactory.GetSphereVertices(1, 10, out primitiveCount), PrimitiveType.LineStrip, primitiveCount); coll = collisionPrimitive as SphereCollisionPrimitive; world = Matrix.Identity * Matrix.CreateScale(coll.BoundingSphere.Radius) * Matrix.CreateTranslation(coll.BoundingSphere.Center); this.wireframeEffect.World = world; this.wireframeEffect.View = this.managerParameters.CameraManager.ActiveCamera.View; this.wireframeEffect.Projection = this.managerParameters.CameraManager.ActiveCamera.ProjectionParameters.Projection; this.wireframeEffect.DiffuseColor = Color.White.ToVector3(); this.wireframeEffect.CurrentTechnique.Passes[0].Apply(); vertexData.Draw(gameTime, this.wireframeEffect); } else { BoxCollisionPrimitive coll = collisionPrimitive as BoxCollisionPrimitive; BoundingBoxBuffers buffers = BoundingBoxDrawer.CreateBoundingBoxBuffers(coll.BoundingBox, this.GraphicsDevice); BoundingBoxDrawer.DrawBoundingBox(buffers, this.wireframeEffect, this.GraphicsDevice, this.managerParameters.CameraManager.ActiveCamera); } }
private void DrawCollisionPrimitive(GameTime gameTime, ICollisionPrimitive collisionPrimitive) { if (collisionPrimitive is SphereCollisionPrimitive) { SphereCollisionPrimitive coll = collisionPrimitive as SphereCollisionPrimitive; this.wireframeEffect.World = Matrix.Identity * Matrix.CreateScale(coll.BoundingSphere.Radius) * Matrix.CreateTranslation(coll.BoundingSphere.Center); this.wireframeEffect.View = this.managerParameters.CameraManager.ActiveCamera.View; this.wireframeEffect.Projection = this.managerParameters.CameraManager.ActiveCamera.ProjectionParameters.Projection; this.wireframeEffect.DiffuseColor = sphereColor.ToVector3(); this.wireframeEffect.CurrentTechnique.Passes[0].Apply(); sphereVertexData.Draw(gameTime, this.wireframeEffect); } else { BoxCollisionPrimitive coll = collisionPrimitive as BoxCollisionPrimitive; BoundingBoxBuffers buffers = BoundingBoxDrawer.CreateBoundingBoxBuffers(coll.BoundingBox, this.GraphicsDevice, boxColor); BoundingBoxDrawer.DrawBoundingBox(buffers, this.wireframeEffect, this.GraphicsDevice, this.managerParameters.CameraManager.ActiveCamera); } }