Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Vector3 GetCorrectedCubePosition(float Face, float X, float Y)
- {
- Vector3 positionOnCube = new Vector3(X, Y, 0);
- positionOnCube -= new Vector3(planet.BlockMap.FaceWidth / 2, planet.BlockMap.FaceWidth / 2, planet.BlockMap.FaceWidth / 2);
- //adjust for positive and negative values
- if (Face == PlanetBlockMap.SOUTH | Face == PlanetBlockMap.BACK | Face == PlanetBlockMap.WEST) //negative Y
- {
- positionOnCube.Z *= -1;
- }
- //rotate the whole vector to suit the direction this face is facing
- Vector3 rotatedPosition = Vector3.Zero;
- if (Face == PlanetBlockMap.NORTH)
- {
- rotatedPosition.X = positionOnCube.X;
- rotatedPosition.Y = positionOnCube.Z;
- rotatedPosition.Z = positionOnCube.Y;
- }
- else if (Face == PlanetBlockMap.SOUTH)
- {
- rotatedPosition.X = positionOnCube.Y;
- rotatedPosition.Y = positionOnCube.Z;
- rotatedPosition.Z = positionOnCube.X;
- }
- else if (Face == PlanetBlockMap.FRONT)
- {
- rotatedPosition.X = positionOnCube.Y;
- rotatedPosition.Y = positionOnCube.X;
- rotatedPosition.Z = positionOnCube.Z;
- }
- else if (Face == PlanetBlockMap.BACK)
- {
- rotatedPosition = positionOnCube;
- }
- else if (Face == PlanetBlockMap.EAST)
- {
- rotatedPosition.X = positionOnCube.Z;
- rotatedPosition.Y = positionOnCube.Y;
- rotatedPosition.Z = positionOnCube.X;
- }
- else if (Face == PlanetBlockMap.WEST)
- {
- rotatedPosition.X = positionOnCube.Z;
- rotatedPosition.Y = positionOnCube.X;
- rotatedPosition.Z = positionOnCube.Y;
- }
- rotatedPosition *= (1f / planet.BlockMap.FaceWidth);
- return rotatedPosition;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement