func Draw() { gl.Clear(gl.COLOR_BUFFER_BIT) gl.PushMatrix() defer gl.PopMatrix() gl.Color4f(0, 1, 0, .5) DrawCircle(vect.Vect{ScreenSize.X / 2, ScreenSize.Y / 2}, ScreenSize.Y/2.0-5.0, false) if Settings.Paused { gl.Color3f(1, 1, 1) RenderFontAt("Paused", 20, 30) } //draw collision objects gl.PushMatrix() gl.Translated(ScreenSize.X/2, ScreenSize.Y/2, 0) gl.Scaled(Settings.Scale, Settings.Scale, 1) DrawDebugData(space) gl.PopMatrix() }
func DrawDebugData(space *collision.Space) { //Draw shapes for _, b := range space.Bodies { if b.Enabled == false { //Inactive gl.Color3f(.5, .8, .5) } else if b.IsStatic() { //Static gl.Color3f(1, 1, 1) } else { //Normal gl.Color3f(1, 0, 0) } for _, s := range b.Shapes { DrawShape(s) } } gl.Color3f(0, 1, 0.5) for _, b := range space.Bodies { DrawTransform(&b.Transform, 0.2) } if Settings.DrawAABBs { for _, b := range space.Bodies { gl.Color3f(.3, .7, .7) for _, s := range b.Shapes { DrawQuad(s.AABB.Lower, s.AABB.Upper, false) } } } const contactRadius = 0.2 const contactNormalScale = 0.5 for arb := space.ContactManager.ArbiterList.Arbiter; arb != nil; arb = arb.Next { for i := 0; i < arb.NumContacts; i++ { con := arb.Contacts[i] gl.Color3f(0, 0, 1) p1 := con.Position p2 := vect.Add(p1, vect.Mult(con.Normal, contactNormalScale)) //p2 := vect.Add(p1, vect.Mult(con.Normal, con.Separation)) DrawLine(p1, p2) gl.Color3f(0, 1, 0) DrawCircle(con.Position, contactRadius, false) } } if Settings.DrawTreeNodes { for _, node := range space.GetDynamicTreeNodes() { gl.Color3f(0.0, .7, .7) DrawQuad(node.AABB().Lower, node.AABB().Upper, false) } } }