public override void DrawSolidCircle(Vec2 center, float radius, Vec2 axis, Color color) { float k_segments = 16.0f; float k_increment = 2.0f * Box2DX.Common.Settings.Pi / k_segments; float theta = 0.0f; Gl.glEnable(Gl.GL_BLEND); Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA); Gl.glColor4f(0.5f * color.R, 0.5f * color.G, 0.5f * color.B, 0.5f); Gl.glBegin(Gl.GL_TRIANGLE_FAN); for (int i = 0; i < k_segments; ++i) { Vec2 v = center + radius * new Vec2((float)SysMath.Cos(theta), (float)SysMath.Sin(theta)); Gl.glVertex2f(v.X, v.Y); theta += k_increment; } Gl.glEnd(); Gl.glDisable(Gl.GL_BLEND); theta = 0.0f; Gl.glColor4f(color.R, color.G, color.B, 1.0f); Gl.glBegin(Gl.GL_LINE_LOOP); for (int i = 0; i < k_segments; ++i) { Vec2 v = center + radius * new Vec2((float)SysMath.Cos(theta), (float)SysMath.Sin(theta)); Gl.glVertex2f(v.X, v.Y); theta += k_increment; } Gl.glEnd(); Vec2 p = center + radius * axis; Gl.glBegin(Gl.GL_LINES); Gl.glVertex2f(center.X, center.Y); Gl.glVertex2f(p.X, p.Y); Gl.glEnd(); }
public override void DrawPolygon(Vec2[] vertices, int vertexCount, Color color) { var firstVertex = vertices[0].ToVector2(); var vectors = vertices.Take(vertexCount).Select(vertex => vertex.ToVector2() - firstVertex).ToArray(); _spriteBatch.DrawPolygon(firstVertex, vectors, color.ToXnaColor()); }
public override void DrawPolygon(Vec2[] vertices, int vertexCount, Color color) { Gl.glColor3f(color.R, color.G, color.B); Gl.glBegin(Gl.GL_LINE_LOOP); for (int i = 0; i < vertexCount; ++i) { Gl.glVertex2f(vertices[i].X, vertices[i].Y); } Gl.glEnd(); }
public override void DrawCircle(Vec2 center, float radius, Color color) { float k_segments = 16.0f; float k_increment = 2.0f * Box2DX.Common.Settings.Pi / k_segments; float theta = 0.0f; Gl.glColor3f(color.R, color.G, color.B); Gl.glBegin(Gl.GL_LINE_LOOP); for (int i = 0; i < k_segments; ++i) { Vec2 v = center + radius * new Vec2((float)SysMath.Cos(theta), (float)SysMath.Sin(theta)); Gl.glVertex2f(v.X, v.Y); theta += k_increment; } Gl.glEnd(); }
public override void Step(Settings settings) { base.Step(settings); DistanceInput input = new DistanceInput(); input.TransformA = _transformA; input.TransformB = _transformB; input.UseRadii = true; SimplexCache cache = new SimplexCache(); cache.Count = 0; DistanceOutput output; Collision.Distance(out output, ref cache, ref input, _polygonA, _polygonB); StringBuilder strBld = new StringBuilder(); strBld.AppendFormat("distance = {0}", new object[] { output.Distance }); OpenGLDebugDraw.DrawString(5, _textLine, strBld.ToString()); _textLine += 15; strBld = new StringBuilder(); strBld.AppendFormat("iterations = {0}", new object[] { output.Iterations }); OpenGLDebugDraw.DrawString(5, _textLine, strBld.ToString()); _textLine += 15; { Color color = new Color(0.9f, 0.9f, 0.9f); int i; for (i = 0; i < _polygonA.VertexCount; ++i) { _dv[i] = Math.Mul(_transformA, _polygonA.Vertices[i]); } _debugDraw.DrawPolygon(_dv, _polygonA.VertexCount, color); for (i = 0; i < _polygonB.VertexCount; ++i) { _dv[i] = Math.Mul(_transformB, _polygonB.Vertices[i]); } _debugDraw.DrawPolygon(_dv, _polygonB.VertexCount, color); } Vec2 x1 = output.PointA; Vec2 x2 = output.PointB; OpenGLDebugDraw.DrawPoint(x1, 4.0f, new Color(1, 0, 0)); OpenGLDebugDraw.DrawSegment(x1, x2, new Color(1, 1, 0)); OpenGLDebugDraw.DrawPoint(x2, 4.0f, new Color(1, 0, 0)); }
public override void DrawSolidPolygon(Vec2[] vertices, int vertexCount, Color color) { Gl.glEnable(Gl.GL_BLEND); Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA); Gl.glColor4f(0.5f * color.R, 0.5f * color.G, 0.5f * color.B, 0.5f); Gl.glBegin(Gl.GL_TRIANGLE_FAN); for (int i = 0; i < vertexCount; ++i) { Gl.glVertex2f(vertices[i].X, vertices[i].Y); } Gl.glEnd(); Gl.glDisable(Gl.GL_BLEND); Gl.glColor4f(color.R, color.G, color.B, 1.0f); Gl.glBegin(Gl.GL_LINE_LOOP); for (int i = 0; i < vertexCount; ++i) { Gl.glVertex2f(vertices[i].X, vertices[i].Y); } Gl.glEnd(); }
public override void DrawSegment(Vec2 p1, Vec2 p2, Color color) { _spriteBatch.DrawLine(p1.ToVector2(), p2.ToVector2(), color.ToXnaColor()); }
public override void DrawSolidPolygon(Vec2[] vertices, int vertexCount, Color color) { physicsSimulationWindow.DrawSolidPolygon(vertices, vertexCount, color); }
public override void DrawCircle(Vec2 center, float radius, Color color) { _spriteBatch.DrawCircle(center.ToVector2(), radius, 32, color.ToXnaColor()); }
public override void DrawSolidCircle(Vec2 center, float radius, Vec2 axis, Color color) { DrawCircle(center, radius, color); }
public override void Step(Settings settings) { //B2_NOT_USED(settings); Manifold manifold; Collision.CollidePolygons(out manifold, _polygonA, _transformA, _polygonB, _transformB); WorldManifold worldManifold = new WorldManifold(); worldManifold.Initialize(manifold, _transformA, _polygonA._radius, _transformB, _polygonB._radius); OpenGLDebugDraw.DrawString(5, _textLine, string.Format("point count = {0}", manifold.PointCount)); _textLine += 15; { Color color = new Color(0.9f, 0.9f, 0.9f); Vec2[] v = new Vec2[Box2DX.Common.Settings.MaxPolygonVertices]; for (int i = 0; i < _polygonA.VertexCount; ++i) { v[i] = Math.Mul(_transformA, _polygonA.Vertices[i]); } _debugDraw.DrawPolygon(v, _polygonA.VertexCount, color); for (int i = 0; i < _polygonB.VertexCount; ++i) { v[i] = Math.Mul(_transformB, _polygonB.Vertices[i]); } _debugDraw.DrawPolygon(v, _polygonB.VertexCount, color); } for (int i = 0; i < manifold.PointCount; ++i) { OpenGLDebugDraw.DrawPoint(worldManifold.Points[i], 4.0f, new Color(0.9f, 0.3f, 0.3f)); } base.Step(settings); }
public override void DrawSolidPolygon(Vec2[] vertices, int vertexCount, Color color) { DrawPolygon(vertices, vertexCount, color); }
public override void DrawSegment(Vec2 p1, Vec2 p2, Color color) { Gl.glColor3f(color.R, color.G, color.B); Gl.glBegin(Gl.GL_LINES); Gl.glVertex2f(p1.X, p1.Y); Gl.glVertex2f(p2.X, p2.Y); Gl.glEnd(); }
public static void DrawSegment(Vec2 p1, Vec2 p2, Color color, params object[] p) { Gl.glColor3f(color.R, color.G, color.B); Gl.glBegin(Gl.GL_LINES); Gl.glVertex2f(p1.X, p1.Y); Gl.glVertex2f(p2.X, p2.Y); Gl.glEnd(); }
public override void DrawSolidCircle(Vec2 center, float radius, Vec2 axis, Color color) { physicsSimulationWindow.DrawSolidCircle(center, radius, axis, color); }
public static void DrawPoint(Vec2 p, float size, Color color) { Gl.glPointSize(size); Gl.glBegin(Gl.GL_POINTS); Gl.glColor3f(color.R, color.G, color.B); Gl.glVertex2f(p.X, p.Y); Gl.glEnd(); Gl.glPointSize(1.0f); }
public static void DrawAABB(AABB aabb, Color c) { Gl.glColor3f(c.R, c.G, c.B); Gl.glBegin(Gl.GL_LINE_LOOP); Gl.glVertex2f(aabb.LowerBound.X, aabb.LowerBound.Y); Gl.glVertex2f(aabb.UpperBound.X, aabb.LowerBound.Y); Gl.glVertex2f(aabb.UpperBound.X, aabb.UpperBound.Y); Gl.glVertex2f(aabb.LowerBound.X, aabb.UpperBound.Y); Gl.glEnd(); }
public override void DrawSegment(Vec2 p1, Vec2 p2, Color color) { physicsSimulationWindow.DrawSegment(p1, p2, color); }
public override void Step(Settings settings) { base.Step(settings); Collision.DistanceInput input = new Collision.DistanceInput(); input.proxyA.Set(_polygonA); input.proxyB.Set(_polygonB); input.TransformA = _transformA; input.TransformB = _transformB; input.UseRadii = true; Collision.SimplexCache cache = new Collision.SimplexCache(); cache.Count = 0; Collision.DistanceOutput output; Collision.Distance(out output, cache, input); OpenGLDebugDraw.DrawString(5, _textLine, string.Format("distance = {0}", output.Distance)); _textLine += 15; OpenGLDebugDraw.DrawString(5, _textLine, string.Format("iterations = {0}", output.Iterations)); _textLine += 15; { Color color = new Color(0.9f, 0.9f, 0.9f); Vec2[] v = new Vec2[Box2DX.Common.Settings.MaxPolygonVertices]; for (int i = 0; i < _polygonA.VertexCount; ++i) { v[i] = Math.Mul(_transformA, _polygonA.Vertices[i]); } _debugDraw.DrawPolygon(v, _polygonA.VertexCount, color); for (int i = 0; i < _polygonB.VertexCount; ++i) { v[i] = Math.Mul(_transformB, _polygonB.Vertices[i]); } _debugDraw.DrawPolygon(v, _polygonB.VertexCount, color); } Vec2 x1 = output.PointA; Vec2 x2 = output.PointB; Gl.glPointSize(4.0f); Gl.glColor4f(1.0f, 0.0f, 0.0f, 1); Gl.glBegin(Gl.GL_POINTS); Gl.glVertex2f(x1.X, x1.Y); Gl.glVertex2f(x2.X, x2.Y); Gl.glEnd(); Gl.glPointSize(1.0f); Gl.glColor4f(1.0f, 1.0f, 0.0f, 1); Gl.glBegin(Gl.GL_LINES); Gl.glVertex2f(x1.X, x1.Y); Gl.glVertex2f(x2.X, x2.Y); Gl.glEnd(); }