public override void Draw(GameTime gameTime) { if (Model != null) { if (boneTransforms == null || boneCount != Model.Bones.Count) { boneTransforms = new Matrix[Model.Bones.Count]; boneCount = Model.Bones.Count; } Model.CopyAbsoluteBoneTransformsTo(boneTransforms); var camera = ((JiggleGame)Game).Camera; foreach (var mesh in Model.Meshes) { foreach (BasicEffect effect in mesh.Effects) { if (Body.CollisionSkin != null) { effect.World = boneTransforms[mesh.ParentBone.Index] * Matrix.CreateScale(Scale) * Body.CollisionSkin.GetPrimitiveLocal(0).Transform.Orientation *Body.Orientation *Matrix.CreateTranslation(Body.Position); } else { effect.World = boneTransforms[mesh.ParentBone.Index] * Matrix.CreateScale(Scale) * Body.Orientation * Matrix.CreateTranslation(Body.Position); } effect.View = camera.View; effect.Projection = camera.Projection; ApplyEffects(effect); effect.EnableDefaultLighting(); effect.PreferPerPixelLighting = true; } mesh.Draw(); } } if (((JiggleGame)Game).DebugDrawer.Enabled) { wf = Collision.GetLocalSkinWireframe(); if (Body.CollisionSkin != null) { Body.TransformWireframe(wf); } ((JiggleGame)Game).DebugDrawer.DrawShape(wf); } }
public VertexPositionColor[] GetCollisionWireframe() { VertexPositionColor[] wf = collision.GetLocalSkinWireframe(); // if the collision skin was also added to the body // we have to transform the skin wireframe to the body space if (body.CollisionSkin != null) { body.TransformWireframe(wf); } return(wf); }
public void DrawDebug(Body body, CollisionSkin collision) { if (!body.CollisionSkin.GetType().Equals(typeof(JigLibX.Geometry.Plane))) { wf = collision.GetLocalSkinWireframe(); // if the collision skin was also added to the body // we have to transform the skin wireframe to the body space if (body.CollisionSkin != null) { body.TransformWireframe(wf); } DrawShape(wf); } }
public virtual void DrawWireframe(GraphicsDevice Graphics, Matrix View, Matrix Projection) { try { if (Effect == null) { Effect = new BasicEffect(Graphics); Effect.VertexColorEnabled = true; } foreach (EntityPart ep in parts.Values) { #region part skeleton ep.DrawWireframe(Graphics, View, Projection); VertexPositionColor[] bone = new VertexPositionColor[2]; bone[0] = new VertexPositionColor(Position, Color.Green); bone[1] = new VertexPositionColor(ep.Position, Color.Green); //TransformVectorList(Velocity); foreach (EffectPass pass in Effect.CurrentTechnique.Passes) { pass.Apply(); Graphics.DrawUserPrimitives <VertexPositionColor>( Microsoft.Xna.Framework.Graphics.PrimitiveType.LineStrip, bone, 0, bone.Length - 1); } #endregion } VertexPositionColor[] wireFrame = Skin.GetLocalSkinWireframe(); if (wireFrame.Length == 0) { return; } TransformVectorList(wireFrame); Effect.TextureEnabled = false; Effect.LightingEnabled = false; Effect.View = View; Effect.Projection = Projection; foreach (EffectPass pass in Effect.CurrentTechnique.Passes) { pass.Apply(); Graphics.DrawUserPrimitives <VertexPositionColor>( Microsoft.Xna.Framework.Graphics.PrimitiveType.LineStrip, wireFrame, 0, wireFrame.Length - 1); } VertexPositionColor[] Velocity = new VertexPositionColor[2]; Velocity[0] = new VertexPositionColor(Position, Color.Blue); Velocity[1] = new VertexPositionColor(Position + body.Velocity, Color.Red); //TransformVectorList(Velocity); foreach (EffectPass pass in Effect.CurrentTechnique.Passes) { pass.Apply(); Graphics.DrawUserPrimitives <VertexPositionColor>( Microsoft.Xna.Framework.Graphics.PrimitiveType.LineStrip, Velocity, 0, Velocity.Length - 1); } } catch (Exception e) { System.Console.WriteLine(e.StackTrace); } }
public override void Draw(GameTime gameTime) { if (model != null) { if (boneTransforms == null || boneCount != model.Bones.Count) { boneTransforms = new Matrix[model.Bones.Count]; boneCount = model.Bones.Count; } model.CopyAbsoluteBoneTransformsTo(boneTransforms); Camera camera = ((JiggleGame)this.Game).Camera; foreach (ModelMesh mesh in model.Meshes) { foreach (BasicEffect effect in mesh.Effects) { // the body has an orientation but also the primitives in the collision skin // owned by the body can be rotated! if (body.CollisionSkin != null) { effect.World = boneTransforms[mesh.ParentBone.Index] * Matrix.CreateScale(scale) * body.CollisionSkin.GetPrimitiveLocal(0).Transform.Orientation *body.Orientation *Matrix.CreateTranslation(body.Position); } else { effect.World = boneTransforms[mesh.ParentBone.Index] * Matrix.CreateScale(scale) * body.Orientation * Matrix.CreateTranslation(body.Position); } effect.View = camera.View; effect.Projection = camera.Projection; ApplyEffects(effect); //if (!this.PhysicsBody.IsActive) // effect.Alpha = 0.4f; //else // effect.Alpha = 1.0f; effect.EnableDefaultLighting(); effect.PreferPerPixelLighting = true; } mesh.Draw(); } } if (((JiggleGame)this.Game).DebugDrawer.Enabled) { wf = collision.GetLocalSkinWireframe(); // if the collision skin was also added to the body // we have to transform the skin wireframe to the body space if (body.CollisionSkin != null) { body.TransformWireframe(wf); } ((JiggleGame)this.Game).DebugDrawer.DrawShape(wf); } // base.Draw(gameTime); }