Beispiel #1
0
 private void SetView()
 {
     view = new View2D { Height = this.ClientRectangle.Height, Width = this.ClientRectangle.Width, Perspective = 1024 };
 }
Beispiel #2
0
        public void Project(View2D view)
        {
            if (Points == null || Points.Length != TransformedVertices.Length)
            {
                Points = new Point[TransformedVertices.Length];
            }

            int screenX = view.Width / 2;
            int screenY = view.Height / 2;

            for (int i = 0; i < TransformedVertices.Length; i++)
            {
                Vertex vertex = TransformedVertices[i];

                if (Math.Abs(vertex.Z) > 0.0001)
                {
                    Points[i] = new Point
                    (
                        Convert.ToInt32(vertex.X * view.Perspective / vertex.Z) + screenX,
                        Convert.ToInt32(vertex.Y * view.Perspective / vertex.Z) + screenY
                    );
                }
                else
                {
                    Points[i] = Point.Empty;
                }
            }
        }
Beispiel #3
0
 public void Project(View2D view)
 {
     foreach (var obj in worldObjects)
     {
         if (obj.Visible)
         {
             obj.Project(view);
         }
     }
 }