Created
December 28, 2012 19:38
-
-
Save merpnderp/4401173 to your computer and use it in GitHub Desktop.
Move a point to/from the front face of a cube to/from another face.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Vector3 getTransformedPoint (Vector3 point, bool _inverse) | |
{ | |
float inverse = _inverse ? -1f : 1f; | |
float x; | |
float y; | |
/* | |
-20, 1 -60 // front point | |
20, 1, 60 // back point | |
60, 1, -20 // right point | |
-60, 1, 20 // left point | |
-20, -60, 1 // bottom point | |
-20, 60, 1 // top point | |
*/ | |
switch (up) { | |
case TreeFace.back: | |
//back facing point | |
point.x = -point.x * inverse; | |
point.z = -point.z * inverse; | |
break; | |
case TreeFace.left: | |
//left facing point | |
x = point.x; | |
point.x = point.z * inverse; | |
point.z = -x * inverse; | |
break; | |
case TreeFace.right: | |
x = point.x; | |
point.x = -point.z * inverse; | |
point.z = x * inverse; | |
break; | |
case TreeFace.top: | |
//top facing point | |
y = point.y; | |
point.y = -point.z * inverse; | |
point.z = y * inverse; | |
break; | |
case TreeFace.bottom: | |
y = point.y; | |
point.y = point.z * inverse; | |
point.z = -y * inverse; | |
break; | |
} | |
return point; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment