public void DebugDraw(IDebugDrawer drawer) { for (int i = 0; i < this.hullPoints.Count; i += 3) { TSVector pos = this.hullPoints[i]; TSVector pos2 = this.hullPoints[i + 1]; TSVector pos3 = this.hullPoints[i + 2]; TSVector.Transform(ref pos, ref this.orientation, out pos); TSVector.Add(ref pos, ref this.position, out pos); TSVector.Transform(ref pos2, ref this.orientation, out pos2); TSVector.Add(ref pos2, ref this.position, out pos2); TSVector.Transform(ref pos3, ref this.orientation, out pos3); TSVector.Add(ref pos3, ref this.position, out pos3); drawer.DrawTriangle(pos, pos2, pos3); } }
public void DebugDraw(IDebugDrawer drawer) { JVector pos1, pos2, pos3; for (int i = 0; i < hullPoints.Count; i += 3) { pos1 = hullPoints[i + 0]; pos2 = hullPoints[i + 1]; pos3 = hullPoints[i + 2]; JVector.Transform(ref pos1, ref orientation, out pos1); JVector.Add(ref pos1, ref position, out pos1); JVector.Transform(ref pos2, ref orientation, out pos2); JVector.Add(ref pos2, ref position, out pos2); JVector.Transform(ref pos3, ref orientation, out pos3); JVector.Add(ref pos3, ref position, out pos3); drawer.DrawTriangle(pos1, pos2, pos3); } }
// this method is extremely brute force, only use for debugging! public void DebugDraw(IDebugDrawer drawer) { if (this.shape.type == ShapeType.Box) { BoxShape box = this.shape as BoxShape; // get corners JVector a = box.GetCorner(0); JVector b = box.GetCorner(1); JVector c = box.GetCorner(2); JVector d = box.GetCorner(3); // transform points JMatrix xform = JMatrix.CreateRotationZ(this.orientation); JVector.Transform(ref a, ref xform, out a); JVector.Transform(ref b, ref xform, out b); JVector.Transform(ref c, ref xform, out c); JVector.Transform(ref d, ref xform, out d); a += this.position; b += this.position; c += this.position; d += this.position; if (isStatic) { drawer.SetColor(0.25f, 0.85f, 0.25f, 1); } else if (isActive) { drawer.SetColor(0.95f, 0.95f, 0.95f, 1); } else { drawer.SetColor(0.65f, 0.65f, 0.65f, 1); } drawer.DrawTriangle(a, c, b); drawer.DrawTriangle(c, a, d); // draw outline drawer.SetColor(0, 0, 0, 1); drawer.DrawLine(a, b); drawer.DrawLine(b, c); drawer.DrawLine(c, d); drawer.DrawLine(d, a); } else if (this.shape.type == ShapeType.Circle) { JMatrix o1 = JMatrix.CreateRotationZ(orientation); JVector dir = JVector.Up; JVector u = JVector.Zero; JVector a; for (int i = -1; i <= 36; i++) { JVector.TransposedTransform(ref dir, ref o1, out a); // get the support in the given direction JVector s; this.shape.SupportMapping(ref a, out s); // transform the support into world space a = JVector.Transform(s, o1) + position; dir = JVector.Transform(dir, JMatrix.CreateRotationZ(0.0174532925f * 10f)); if (i >= 0) { if (isStatic) { drawer.SetColor(0.25f, 0.85f, 0.25f, 1); } else if (isActive) { drawer.SetColor(0.95f, 0.95f, 0.95f, 1); } else { drawer.SetColor(0.65f, 0.65f, 0.65f, 1); } drawer.DrawTriangle(a, u, this.position); drawer.SetColor(0, 0, 0, 1); drawer.DrawLine(a, u); } u = a; } } //JMatrix o1 = JMatrix.CreateRotationZ(orientation); //JVector dir = JVector.Up; //JVector u = JVector.Zero; //JVector a; //for (int i = -1; i <= 36; i++) //{ // JVector.TransposedTransform(ref dir, ref o1, out a); // // get the support in the given direction // JVector s; this.shape.SupportMapping(ref a, out s); // // transform the support into world space // a = JVector.Transform(s, o1) + position; // dir = JVector.Transform(dir, JMatrix.CreateRotationZ(0.0174532925f * 10f)); // if (i >= 0) // { // if (isStatic) // drawer.SetColor(0.25f, 0.85f, 0.25f, 1); // else if (isActive) // drawer.SetColor(0.95f, 0.95f, 0.95f, 1); // else // drawer.SetColor(0.65f, 0.65f, 0.65f, 1); // drawer.DrawTriangle(a, u, this.position); // drawer.SetColor(0,0,0, 1); // drawer.DrawLine(a, u); // } // u = a; //} //JMatrix xForm = JMatrix.CreateRotationZ(orientation); //drawer.SetColor(1, 0, 0, 1); //drawer.DrawLine(position + JVector.Transform(JVector.Left * 0.25f, xForm), position + JVector.Transform(JVector.Zero, xForm)); //drawer.SetColor(0, 1, 0, 1); //drawer.DrawLine(position + JVector.Transform(JVector.Up * 0.25f, xForm), position + JVector.Transform(JVector.Zero, xForm)); }