Esempio n. 1
0
        void IOpenGLDrawable.Draw()
        {
            // Draw the tool location as a cone
            Vector3 position = GetPosition();

            GL.Color3(Color.Silver);
            Polyhedra.DrawCone(position + new Vector3(0, 0, router.ToolDiameter), position, router.ToolDiameter / 2.0f);



            // Draw the past positions & velocity graph
            float   lastTime   = 0;
            Vector3 lastPos    = new Vector3(0, 0, 0);
            float   lastVel    = 0;
            bool    lastIsGood = false;

            GL.Disable(EnableCap.Lighting);
            lock (previousPoints)
            {
                Vector3 lastpoint = new Vector3(0, 0, 0);
                for (int i = 0; i < previousPoints.Count(); i++)
                {
                    PreviousPoint point     = previousPoints[i];
                    float         age_delta = point.createTime - lastTime;
                    float         time      = age_delta / 1000.0f; // Age is microseconds, time is seconds
                    float         pos_delta = (point.location - lastPos).Length;
                    float         vel       = pos_delta / time;    // Inches per second
                    Vector3       atpoint   = new Vector3(point.location.X * 1000, point.location.Y * 1000, point.location.Z * 1000);
                    if (lastIsGood)
                    {
                        GL.LineWidth(1);
                        GL.Begin(PrimitiveType.Lines);
                        GL.Color3(Color.LightGray);
                        for (int j = 0; j < 5; j++)
                        {
                            GL.Vertex3(lastpoint + new Vector3(0, 0, j * 10));
                            GL.Vertex3(lastpoint + new Vector3(0, 0, j * 10 + 10));

                            GL.Vertex3(lastpoint + new Vector3(0, 0, j * 10));
                            GL.Vertex3(atpoint + new Vector3(0, 0, j * 10));
                        }
                        GL.End();
                        GL.LineWidth(2);
                        GL.Begin(PrimitiveType.Lines);
                        GL.Color3(Color.Orange);
                        GL.Vertex3(lastpoint + new Vector3(0, 0, lastVel * lastVel * 200));
                        GL.Vertex3(atpoint + new Vector3(0, 0, vel * vel * 200));
                        GL.End();
                    }
                    lastVel   = vel;
                    lastpoint = atpoint;

                    lastPos    = point.location;
                    lastTime   = point.createTime;
                    lastIsGood = true;
                }
            }
            GL.Enable(EnableCap.Lighting);
            GL.LineWidth(1);
        }
Esempio n. 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="logger">An instance of our main Logger class, used for trace logs of which location/tile was saved.</param>
 /// <param name="point">The main instance of PreviousPoint the rest of the mod will warp the player to. Contains a GameLocation and Vector2 tile location.</param>
 public WandPatches(Logger newLogger, PreviousPoint point, RodCooldown cooldown)
 {
     logger        = newLogger;
     previousPoint = point;
     rodCooldown   = cooldown;
 }