 Timestamp:
 20140723 12:43:58 (5 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

2014/30/MikkoI/WindowsGame1/WindowsGame1/WindowsGame1/Camera/Camera.cs
r5558 r5581 12 12 public Vector2 offset = Vector2.Zero; 13 13 public float zoomFactor = 1; 14 public float yaw = 45; 15 public Camera() { 16 14 public float pitch = 45; 15 public float yaw = 0; 16 public Camera() 17 { 18 17 19 } 18 public Matrix getMatrix(Vector2 gridSize,Vector2 mapSize) { 19 return Matrix.CreateTranslation(new Vector3((gridSize.X * mapSize.X / 2), (gridSize.Y * mapSize.Y / 2), 0)) * 20 Matrix.CreateRotationZ(MathHelper.ToRadians(45)) * 21 Matrix.CreateRotationX(MathHelper.ToRadians(yaw)) * 20 public Matrix getMatrix(Vector2 gridSize, Vector2 mapSize, Vector2 screenSize) 21 { 22 viewPortBounds(); 23 24 Vector3 pixelMapSize = new Vector3((gridSize.X * mapSize.X / 2), (gridSize.Y * mapSize.Y / 2), 0); 25 return Matrix.CreateTranslation(new Vector3(pixelMapSize.X + offset.X, pixelMapSize.Y + offset.Y, 0)) * 26 Matrix.CreateRotationZ(MathHelper.ToRadians(45 + yaw)) * 27 Matrix.CreateRotationX(MathHelper.ToRadians(pitch)) * 22 28 Matrix.CreateScale(zoomFactor, zoomFactor, 0) * 23 Matrix.CreateTranslation(new Vector3(offset.X, offset.Y, 0)); 29 Matrix.CreateTranslation(new Vector3(screenSize.X / 2, screenSize.Y / 2, 0)); 30 } 31 void viewPortBounds() 32 { 33 //rajoittaa viewporttia 34 35 //if (yaw < 70) { yaw = 70; } else if (yaw > 70) { yaw = 70; }//rajoita pyörittämistä (70  70) 36 if (pitch < 88) { pitch = 88; } else if (pitch > 45) { pitch = 45; }//rajoittaa ylösalasliikettä 37 if (zoomFactor < 0.4f) { zoomFactor = 0.4f; } else if (zoomFactor > 3f) { zoomFactor = 3f; }//rajoittaa zoomia 24 38 } 25 39 }
Note: See TracChangeset
for help on using the changeset viewer.