Advertisement
maxkhl

3D Draw

Aug 11th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 KB | None | 0 0
  1.         private Rectangle GetSystemScreenRect(Data.System system, Rectangle ScreenRectangle, int DrawSize)
  2.         {
  3.             var WorldPosition = (system.Coordinates - WorldOffset).RotateY(WorldRotationY);
  4.             var ScreenPos = Translate(WorldPosition) +new Vector((ScreenRectangle.Width), (ScreenRectangle.Height)); //new Vector(system.Coordinates.Z, system.Coordinates.X) - Position;
  5.  
  6.             return new Rectangle((int)((ScreenPos.X - ScreenRectangle.Width / 2)), (int)((ScreenPos.Y - ScreenRectangle.Height / 2)), DrawSize, DrawSize);
  7.         }
  8.  
  9.         private Vector Translate(Data.Vector3 Point)
  10.         {
  11.             Vector returnVec = new Vector();
  12.             if (Point.Z - CameraPosition.Z >= 0)
  13.             {
  14.                 returnVec.X = (int)((double)-(Point.X - CameraPosition.X) / (-0.1f) * CameraZoom);
  15.                 returnVec.Y = (int)((double)(Point.Y - CameraPosition.Y) / (-0.1f) * CameraZoom);
  16.             }
  17.             else
  18.             {
  19.                 returnVec.X = (float)((Point.X - CameraPosition.X) / (Point.Z - CameraPosition.Z) * CameraZoom);
  20.                 returnVec.Y = (float)(-(Point.Y - CameraPosition.Y) / (Point.Z - CameraPosition.Z) * CameraZoom);
  21.             }
  22.             return returnVec;
  23.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement