public static void draw_text(Vector2D p, string text, Color c)
 {
     if(text.Length < 1 || _text_writer == null)
         return;
     _text_writer.Clear();
     _text_writer.AddLine(text, new PointF((float)p.x, (float)p.y), new SolidBrush(c));
     _text_writer.Draw();
 }
Exemple #2
0
 private static void internal_check_nearest(Vector2D from, Vector2D to, int ragdoll_index)
 {
     if(_nearest_point == null || from.length_to_vector(to) < _nearest_point.length_to_vector(to))
     {
         _nearest_point = from;
         _index = ragdoll_index;
     }
 }
        public static void draw_line(Vector2D vec_1, Vector2D vec_2, Color c, float width)
        {
            // Configure line
            GL.LineWidth(width);
            GL.Color3(c);

            // Draw line
            GL.Begin(PrimitiveType.Lines);
                GL.Vertex2(vec_1.x, vec_1.y);	// line start
                GL.Vertex2(vec_2.x, vec_2.y);	// line end
            GL.End();
        }
        public static void draw_point(Vector2D vec, Color c, float size)
        {
            // Configure point
            GL.Enable(EnableCap.PointSmooth);
            GL.PointSize(size);

            // Draw point
            GL.Begin(PrimitiveType.Points);
                GL.Color3(c);
                GL.Vertex2(vec.x, vec.y);
            GL.End();
        }
        public static void draw_triangle(Vector2D[] vertices, Color c)
        {
            if(vertices.Length <3)
                return;

            GL.Begin(PrimitiveType.Triangles);
                GL.Color3(c);
                GL.Vertex2(vertices[0].x, vertices[0].y);
                GL.Vertex2(vertices[1].x, vertices[1].y);
                GL.Vertex2(vertices[2].x, vertices[2].y);
            GL.End();
        }
        private void accum_forces()
        {
            Random rand = new Random();
            int NUM_POINTS = _snow_curr.Length;
            for(int i = 0; i < NUM_POINTS; ++i)
            {
                _forces[i] = _gravity;

                double x = rand.Next(-100, 100) * 0.01;
                double y = rand.Next(-100, 100) * 0.01;

                _forces[i] += new Vector2D(x, y);
            }
        }
Exemple #7
0
 public static void check_nearest(List<Skeleton> skeletons, Vector2D to)
 {
     if(!_busy)
     {
         foreach(Skeleton skeleton in skeletons)
         {
             Vector2D[] points = skeleton.points;
             for(int i = 0; i < points.Length; ++i)
             {
                 internal_check_nearest(points[i], to, skeleton.index);
             }
         }
     }
     _busy = true;
 }
 private void handle_outside()
 {
     Random rand = new Random();
     int NUM_POINTS = _snow_curr.Length;
     for(int i = 0; i < NUM_POINTS; ++i)
     {
         if(_snow_curr[i].y > 720 + 2 * _radius[i])
         {
             _snow_old[i] = _snow_curr[i] = new Vector2D(rand.Next(20, 1270), -rand.Next(20, 100));
         }
     }
 }
Exemple #9
0
 public Vector2D(Vector2D vector)
 {
     _x = vector.x;
     _y = vector.y;
 }
Exemple #10
0
        public static Vector2D min(Vector2D left, Vector2D right)
        {
            Vector2D final = new Vector2D();

            final.x	= (left.x < right.x) ? left.x : right.x;
            final.y	= (left.y < right.y) ? left.y : right.y;

            return final;
        }
Exemple #11
0
 // Calculate force when draging around skeleton with mouse
 public void mouse_force(Vector2D mouse_position)
 {
     internal_mouse_force(mouse_position);
 }
Exemple #12
0
 public double length_to_vector(Vector2D vector)
 {
     Vector2D final = this - vector;
     return final.length();
 }
Exemple #13
0
 private void internal_draw(Vector2D mouse)
 {
     if(_climbing_mode)
     {
         internal_draw_grips();
     }
     if(_graphics)
     {
         internal_draw_body(mouse);
     }
     if(_debug_bones)
     {
         internal_draw_joints();
         internal_draw_points();
     }
     if(_debug_forces)
     {
         internal_draw_forces();
     }
 }
Exemple #14
0
 private void internal_add_force(Vector2D force, int index)
 {
     Force my_force = new Force();
     my_force._force = force;
     my_force._index = index;
     _add_forces.Enqueue(my_force);
 }
Exemple #15
0
        private void internal_draw_body(Vector2D mouse)
        {
            // Hands
            GraphicsManager.draw_point(_pos[7]._pos, Color.Khaki, 20);
            GraphicsManager.draw_point(_pos[8]._pos, Color.Khaki, 20);

            // Head
            GraphicsManager.draw_point(_pos[0]._pos, Color.Khaki, 50);

            int neck_width = 10;
            // Neck
            GraphicsManager.draw_line(_pos[0]._pos, _pos[1]._pos, Color.Khaki, neck_width);

            Vector2D moues_dir = mouse - _pos[0]._pos;
            Vector2D dir = _pos[1]._pos - _pos[0]._pos;
            Vector2D perp_vec = new Vector2D(dir.y, dir.x * -1);
            moues_dir.normalize();
            dir.normalize();
            perp_vec.normalize();

            Vector2D left_eye = _pos[0]._pos + perp_vec * 10;
            Vector2D right_eye = _pos[0]._pos + perp_vec * -10;

            // Christmas headpiece
            if(_christmas)
            {
                Vector2D[] hat_points		= new Vector2D[3];
                hat_points[0] = _pos[0]._pos + perp_vec * 20 + dir * -15;
                hat_points[1] = _pos[0]._pos + perp_vec * -20 + dir * -15;
                hat_points[2] = _pos[0]._pos + dir * -60;

                GraphicsManager.draw_triangle(hat_points, Color.Red);
                GraphicsManager.draw_point(hat_points[2], Color.White, 20);
                GraphicsManager.draw_line(hat_points[0], hat_points[1], Color.White, 10);
            }

            // Eyes
            GraphicsManager.draw_point(left_eye, Color.White, 20);
            GraphicsManager.draw_point(right_eye, Color.White, 20);
            GraphicsManager.draw_point(left_eye + moues_dir * 4, Color.Black, 10);
            GraphicsManager.draw_point(right_eye + moues_dir * 4, Color.Black, 10);

            Vector2D mouth_left		= _pos[0]._pos + (perp_vec * -10) + dir * 15;
            Vector2D mouth_right	= _pos[0]._pos + (perp_vec * 10) + dir * 15;

            // Mouth
            GraphicsManager.draw_line(mouth_left, mouth_right, Color.Black, 2);

            int arm_width = 10;
            // Left upper arm
            GraphicsManager.draw_line(_pos[3]._pos, _pos[6]._pos, Color.Black, arm_width);

            // Right upper arm
            GraphicsManager.draw_line(_pos[2]._pos, _pos[5]._pos, Color.Black, arm_width);

            // Left lower arm
            GraphicsManager.draw_line(_pos[6]._pos, _pos[8]._pos, Color.Black, arm_width);

            // Right lower arm
            GraphicsManager.draw_line(_pos[5]._pos, _pos[7]._pos, Color.Black, arm_width);

            // Waist
            GraphicsManager.draw_line(_pos[11]._pos, _pos[12]._pos, Color.Red, arm_width);

            int leg_width = 10;
            // Left upper leg
            GraphicsManager.draw_line(_pos[12]._pos, _pos[14]._pos, Color.Red, leg_width);

            // Right upper leg
            GraphicsManager.draw_line(_pos[11]._pos, _pos[13]._pos, Color.Red, leg_width);

            // Left lower leg
            GraphicsManager.draw_line(_pos[14]._pos, _pos[9]._pos, Color.Red, leg_width);

            // Right lower leg
            GraphicsManager.draw_line(_pos[13]._pos, _pos[15]._pos, Color.Red, leg_width);

            // Feets
            GraphicsManager.draw_point(_pos[9]._pos, Color.Khaki, 20);
            GraphicsManager.draw_point(_pos[15]._pos, Color.Khaki, 20);

            // Torso
            Vector2D[] left		= new Vector2D[3];
            Vector2D[] middle	= new Vector2D[3];
            Vector2D[] right	= new Vector2D[3];

            left[0] = _pos[1]._pos;
            left[1] = _pos[2]._pos;
            left[2] = _pos[11]._pos;

            middle[0] = _pos[11]._pos;
            middle[1] = _pos[12]._pos;
            middle[2] = _pos[1]._pos;

            right[0] = _pos[12]._pos;
            right[1] = _pos[3]._pos;
            right[2] = _pos[1]._pos;

            GraphicsManager.draw_triangle(left, Color.Black);
            GraphicsManager.draw_triangle(middle, Color.Black);
            GraphicsManager.draw_triangle(right, Color.Black);
        }
Exemple #16
0
 // Draw the skeleton
 public void draw(Vector2D mouse)
 {
     internal_draw(mouse);
 }
Exemple #17
0
 public static void release_check()
 {
     _busy			= false;
     _nearest_point	= null;
     _index			= -1;
 }
Exemple #18
0
 private void internal_generate_climbing_points()
 {
     Random rand = new Random();
     for(int i = 0; i < _grips.Length; ++i)
     {
         // Generate grips inside screenspace
         _grips[i] = new Vector2D(rand.Next(0, 1280), rand.Next(0, 720));
         _grip_radius[i] = rand.Next(10, 18);
     }
 }
Exemple #19
0
        private void internal_mouse_force(Vector2D mouse_position)
        {
            if(Nearest.index != _index)
                return;

            Vector2D force = new Vector2D();

            // Skip this if mouse button continues to be
            // down.
            // This works as locking to nearest point
            // at first frame whem mouse button was down
            if(!_lock_point)
            {
                int POINT_COUNT	= _pos.Length;
                double nearest_l	= 99999999;

                // Find closest point to mouse
                for(int i = 0; i < POINT_COUNT; ++i)
                {
                    double length = _pos[i]._pos.length_to_vector(mouse_position);

                    if(length < nearest_l)
                    {
                        nearest_l = length;
                        _mouse_point = i;
                    }
                }
                _lock_point = true;
            }

            // Calculate a vector force between nearest point and mouse
            force = mouse_position - _pos[_mouse_point]._pos;

            // Register this force in the force queue
            internal_add_force(force, _mouse_point);
        }
 private void init()
 {
     Random rand = new Random();
     int NUM_POINTS = _snow_curr.Length;
     for(int i = 0; i < NUM_POINTS; ++i)
     {
         _snow_curr[i] = new Vector2D(rand.Next(20, 1270), -rand.Next(50, 2020));
         _snow_old[i] = _snow_curr[i];
         double r		= rand.Next(20, 60) * 0.1;
         _radius[i]		= r;
     }
 }
Exemple #21
0
 // Add force on a point in skeleton
 public void add_force(Vector2D force, int index)
 {
     internal_add_force(force, index);
 }