Implement this abstract class to allow JBox2d to automatically draw your physics for debugging purposes. Not intended to replace your own custom rendering routines!
Esempio n. 1
0
 public void DrawTree(DebugDraw argDraw)
 {
     m_tree.DrawTree(argDraw);
 }
Esempio n. 2
0
        /// <summary>
        /// Construct a world object.
        /// </summary>
        /// <param name="gravity">the world gravity vector.</param>
        /// <param name="doSleep">improve performance by not simulating inactive bodies.</param>
        public World(Vec2 gravity, IWorldPool argPool)
        {
            contactStacks = new ContactRegister[ShapeTypesCount][];
            for (int i = 0; i < ShapeTypesCount; i++)
            {
                contactStacks[i] = new ContactRegister[ShapeTypesCount];
            }

            pool = argPool;
            m_destructionListener = null;
            m_debugDraw = null;

            m_bodyList = null;
            m_jointList = null;

            m_bodyCount = 0;
            m_jointCount = 0;

            m_warmStarting = true;
            m_continuousPhysics = true;
            m_subStepping = false;
            m_stepComplete = true;

            m_allowSleep = true;
            m_gravity.set_Renamed(gravity);

            m_flags = CLEAR_FORCES;

            m_inv_dt0 = 0f;

            m_contactManager = new ContactManager(this);
            m_profile = new Profile();

            initializeRegisters();
        }
Esempio n. 3
0
        public virtual void drawTree(DebugDraw argDraw, int nodeId, int spot, int height)
        {
            TreeNode node = m_nodes[nodeId];
            node.aabb.getVertices(drawVecs);

            color.set_Renamed(1, (height - spot) * 1f / height, (height - spot) * 1f / height);
            argDraw.drawPolygon(drawVecs, 4, color);

            argDraw.ViewportTranform.getWorldToScreen(node.aabb.upperBound, textVec);
            argDraw.drawString(textVec.x, textVec.y, nodeId + "-" + (spot + 1) + "/" + height, color);

            if (node.child1 != TreeNode.NULL_NODE)
            {
                drawTree(argDraw, node.child1, spot + 1, height);
            }
            if (node.child2 != TreeNode.NULL_NODE)
            {
                drawTree(argDraw, node.child2, spot + 1, height);
            }
        }
Esempio n. 4
0
 public virtual void drawTree(DebugDraw argDraw)
 {
     if (m_root == TreeNode.NULL_NODE)
     {
         return;
     }
     int height = computeHeight();
     drawTree(argDraw, m_root, 0, height);
 }
Esempio n. 5
0
        public void DrawTree(DebugDraw argDraw, int nodeId, int spot, int height)
        {
            TreeNode node = m_nodes[nodeId];
            node.AABB.GetVertices(drawVecs);

            color.Set(1, (height - spot) * 1f / height, (height - spot) * 1f / height);
            argDraw.DrawPolygon(drawVecs, 4, color);

            argDraw.ViewportTranform.GetWorldToScreen(node.AABB.UpperBound, textVec);
            argDraw.DrawString(textVec.X, textVec.Y, nodeId + "-" + (spot + 1) + "/" + height, color);

            if (node.Child1 != TreeNode.NULL_NODE)
            {
                DrawTree(argDraw, node.Child1, spot + 1, height);
            }
            if (node.Child2 != TreeNode.NULL_NODE)
            {
                DrawTree(argDraw, node.Child2, spot + 1, height);
            }
        }
Esempio n. 6
0
 public virtual void drawTree(DebugDraw argDraw)
 {
     m_tree.drawTree(argDraw);
 }