Exemplo n.º 1
0
        private void Draw()
        {
            if (m_material)
            {
                Camera camera = Camera.current;
                if (camera)
                {
                    GL.PushMatrix();
                    GL.LoadProjectionMatrix(camera.projectionMatrix);
                    GL.modelview = camera.worldToCameraMatrix;

                    m_material.SetPass(0);

                    for (int i = m_drawers.Count - 1; i >= 0; --i)
                    {
                        IDebugDrawer drawable = m_drawers[i];
                        if (drawable != null)
                        {
                            drawable.Draw();
                        }
                    }

                    GL.PopMatrix();
                }
            }
        }
Exemplo n.º 2
0
        void IBroadphase.DebugDraw(IDebugDrawer debugDrawer)
        {
            Queue <Tuple <Node, int> > q = new Queue <Tuple <Node, int> >();

            if (root != null)
            {
                q.Enqueue(new Tuple <Node, int>(root, 1));
            }

            while (q.Count > 0)
            {
                var  param = q.Dequeue();
                Node node  = param.Item1;
                int  depth = param.Item2;

                Vec2[] verts = new Vec2[] {
                    node.bounds.min,
                    new Vec2(node.bounds.max.x, node.bounds.min.y),
                    node.bounds.max,
                    new Vec2(node.bounds.min.x, node.bounds.max.y)
                };

                debugDrawer.Draw(verts, (object)depth);

                if (!node.IsLeaf)
                {
                    q.Enqueue(new Tuple <Node, int>(node.child0, depth + 1));
                    q.Enqueue(new Tuple <Node, int>(node.child1, depth + 1));
                }
            }
        }
Exemplo n.º 3
0
 public virtual void DebugDraw(IDebugDrawer drawer, Vector2 position, float scale)
 {
     for (int index = 0; index < this.get_LedCount(); ++index)
     {
         Vector2 ledCanvasPosition = this.GetLedCanvasPosition(index);
         drawer.DrawSquare(new Vector4(ledCanvasPosition * scale + position, scale / 100f, scale / 100f), new Color(this.GetUnprocessedLedColor(index)));
     }
 }
Exemplo n.º 4
0
 public override void DebugDraw(IDebugDrawer drawer, Vector2 position, float scale)
 {
     for (int i = 0; i < ((RgbDevice)this).get_LedCount(); i++)
     {
         Vector2 ledCanvasPosition = ((RgbDevice)this).GetLedCanvasPosition(i);
         drawer.DrawSquare(new Vector4(ledCanvasPosition * scale + position, scale / 100f, scale / 100f), new Color(((RgbDevice)this).GetUnprocessedLedColor(i)));
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="drawer">Element to draw</param>
        /// <param name="lifetime">Amount of time (in seconds) to draw the element for</param>
        public TimedDebugDrawModifier(IDebugDrawer drawer, float lifetime)
        {
            m_drawer       = drawer;
            m_lifetime     = lifetime;
            m_initialAlpha = m_drawer.Color.a;

            m_timer = new Timer(TimeScale.Unscaled);
            m_timer.Start();
        }
        /// <summary>
        /// Constructor, automatically uses <see cref="Camera.main"/> for billboarding
        /// </summary>
        /// <param name="drawer">The drawer to modify</param>
        /// <param name="position">The position of the element</param>
        public BillboardDebugDrawModifier(IDebugDrawer drawer, Vector3 position)
        {
            m_drawer   = drawer;
            m_position = position;
            m_camera   = Camera.main;

            if (m_camera == null)
            {
                Debug.LogError("No main camera exists for use with debug draw billboarding, ensure one is tagged with `main camera` in the scene");
            }
        }
Exemplo n.º 7
0
 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);
     }
 }
Exemplo n.º 8
0
        private IEnumerator FlushFinishedDrawersRoutine()
        {
            while (true)
            {
                for (int i = m_drawers.Count - 1; i >= 0; --i)
                {
                    IDebugDrawer drawable = m_drawers[i];
                    if (drawable == null ||
                        drawable.IsFinished)
                    {
                        m_drawers.RemoveAt(i);
                    }
                }

                yield return(m_endOfFrameYield);
            }
        }
Exemplo n.º 9
0
        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);
            }
        }
Exemplo n.º 10
0
 public override void DebugDraw(IDebugDrawer drawer)
 {
     drawer.DrawLine(body1.position + r1,
                     body1.position + r1 + TSVector.Transform(lineNormal, body1.orientation) * 100);
 }
Exemplo n.º 11
0
 public virtual void DebugDraw(IDebugDrawer debugDrawer)
 {
     
 }
Exemplo n.º 12
0
 public override void DebugDraw(IDebugDrawer drawer)
 {
     drawer.DrawPoint(anchor);
 }
Exemplo n.º 13
0
 void IBroadphase.DebugDraw(IDebugDrawer debugDrawer)
 {
 }
Exemplo n.º 14
0
 public override void DebugDraw(IDebugDrawer debugDrawer)
 {
     debugDrawer.DrawLine(Body.LocalToWorld(LocalAnchor), WorldAnchor);
 }
Exemplo n.º 15
0
 public override void DebugDraw(IDebugDrawer drawer)
 {
     drawer.DrawLine(anchor - lineNormal * 50.0f, anchor + lineNormal * 50.0f);
     drawer.DrawLine(body1.position, body1.position + r1);
 }
 public override void DebugDraw(IDebugDrawer drawer)
 {
 }
Exemplo n.º 17
0
 /// <summary>
 /// Extension method to modify the given <see cref="IDebugDrawer"/> by adding a draw lifetime
 /// </summary>
 /// <param name="drawer">The drawer to modify</param>
 /// <param name="lifetime">Amount of time (in seconds) to draw the element for</param>
 /// <returns>The original <see cref="IDebugDrawer"/>, wrapped in a <see cref="TimedDebugDrawModifier"/></returns>
 public static IDebugDrawer Timed(this IDebugDrawer drawer, float lifetime)
 {
     return(new TimedDebugDrawModifier(drawer, lifetime));
 }
Exemplo n.º 18
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="drawer">The drawer to modify</param>
 /// <param name="position">The position of the element</param>
 /// <param name="camera">The camera to face the element toward</param>
 public BillboardDebugDrawModifier(IDebugDrawer drawer, Vector3 position, Camera camera)
 {
     m_drawer   = drawer;
     m_position = position;
     m_camera   = camera;
 }
Exemplo n.º 19
0
 public void DebugDraw(IDebugDrawer debugDrawer)
 {
     broadphase.DebugDraw(debugDrawer);
 }
Exemplo n.º 20
0
 public override void DebugDraw(IDebugDrawer debugDrawer)
 {
     debugDrawer.DrawLine(Body.LocalToWorld(LocalAnchor), WorldAnchor);
 }
Exemplo n.º 21
0
 public override void DebugDraw(IDebugDrawer drawer)
 {
     drawer.DrawPoint(anchor);
 }
Exemplo n.º 22
0
 public void DebugDraw(IDebugDrawer drawer)
 {
     //std::op_code::bad_format_exception
     throw new __std_badOpCode_fromatException();
 }
Exemplo n.º 23
0
 /// <summary>
 /// Extension method to apply a billboarded transformation to the given <see cref="IDebugDrawer"/>
 /// </summary>
 /// <param name="drawer">The drawer to billboard</param>
 /// <param name="position">The position to aply to the element</param>
 /// <param name="camera">The camera to face the element toward</param>
 /// <returns>The billboarded drawer</returns>
 public static IDebugDrawer Billboarded(this IDebugDrawer drawer, Vector3 position, Camera camera)
 {
     return(new BillboardDebugDrawModifier(drawer, position, camera));
 }
Exemplo n.º 24
0
 /// <summary>
 /// Extension method to apply a transformation to a <see cref="IDebugDrawer"/>
 /// </summary>
 /// <param name="drawer">The drawer to transform</param>
 /// <param name="position">The position to apply to the element</param>
 /// <param name="rotation">The rotation to apply to the element</param>
 /// <returns>The transformed drawer</returns>
 public static IDebugDrawer Transformed(this IDebugDrawer drawer, Vector3 position, Quaternion rotation)
 {
     return(new TransformDebugDrawModifier(drawer, position, rotation));
 }
Exemplo n.º 25
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="drawer">The drawer to transform</param>
 /// <param name="position">The world position to place the element at</param>
 /// <param name="rotation">The rotation of the element</param>
 public TransformDebugDrawModifier(IDebugDrawer drawer, Vector3 position, Quaternion rotation)
 {
     m_drawer = drawer;
     m_matrix = Matrix4x4.Translate(position) * Matrix4x4.Rotate(rotation);
 }
Exemplo n.º 26
0
 public virtual void DebugDraw(IDebugDrawer drawer)
 {
 }
Exemplo n.º 27
0
 public override void DebugDraw(IDebugDrawer drawer)
 {
     drawer.DrawLine(body1.position + r1,
         body1.position + r1 + JVector.Transform(lineNormal, body1.orientation) * 100.0f);
 }
Exemplo n.º 28
0
 public override void DebugDraw(IDebugDrawer drawer)
 {
     drawer.DrawLine(this.body1.position, this.body1.position + this.r1);
     drawer.DrawLine(this.body2.position, this.body2.position + this.r2);
 }
Exemplo n.º 29
0
 public override void DebugDraw(IDebugDrawer drawer)
 {
     drawer.DrawLine(body1.position, body1.position + r1);
     drawer.DrawLine(body2.position, body2.position + r2);
 }
Exemplo n.º 30
0
        // 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));
        }
Exemplo n.º 31
0
 public override void DebugDraw(IDebugDrawer drawer)
 {
     drawer.DrawLine(body1.position, body1.position + r1);
     drawer.DrawLine(body2.position, body2.position + r2);
 }
Exemplo n.º 32
0
 public override void DebugDraw(IDebugDrawer drawer)
 {
     drawer.DrawLine(anchor - lineNormal * 50.0f, anchor + lineNormal * 50.0f);
     drawer.DrawLine(body1.position, body1.position + r1);
 }
Exemplo n.º 33
0
 public virtual void DebugDraw(IDebugDrawer drawer)
 {
     //throw new NotImplementedException();
 }
 public override void DebugDraw(IDebugDrawer drawer)
 {
 }