Created
March 30, 2021 08:14
-
-
Save IngIeoAndSpare/f209f3d06ef95547f1731fd8d709baf1 to your computer and use it in GitHub Desktop.
DrawLineInUnity
This file contains 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
public void drawTestLine(XDOInfo xdoInfo){ | |
float radiusRatio = 10000 / (float)6378137; | |
// convert : -y , z, -x | |
double min_x = (double)xdoInfo.boundMinY * -1 * radiusRatio; | |
double min_y = (double)xdoInfo.boundMinZ * radiusRatio; | |
double min_z = (double)xdoInfo.boundMinX * -1 * radiusRatio; | |
double max_x = (double)xdoInfo.boundMaxY * -1 * radiusRatio; | |
double max_y = (double)xdoInfo.boundMaxZ * radiusRatio; | |
double max_z = (double)xdoInfo.boundMaxX * -1 * radiusRatio; | |
double a_x = (min_x + max_x) / 2; | |
double a_y = (min_y + max_y) / 2; | |
double a_z = (min_z + max_z) / 2; | |
double a_min_x = min_x - a_x; | |
double a_min_y = min_y - a_y; | |
double a_min_z = min_z - a_z; | |
double a_max_x = max_x - a_x; | |
double a_max_y = max_y - a_y; | |
double a_max_z = max_z - a_z; | |
// case 3 | |
Vector3 a_min_not = new Vector3((float)a_min_x, (float)a_min_y, (float)a_min_z); | |
Vector3 a_max_not = new Vector3((float)a_max_x, (float)a_max_y, (float)a_max_z); | |
Vector3 downPoint1 = new Vector3(a_min_not.x, a_min_not.y, a_max_not.z); | |
Vector3 downPoint2 = new Vector3(a_max_not.x, a_min_not.y, a_max_not.z); | |
Vector3 downPoint3 = new Vector3(a_max_not.x, a_min_not.y, a_min_not.z); | |
Vector3 upPoint1 = new Vector3(a_min_not.x, a_max_not.y, a_min_not.z); | |
Vector3 upPoint2 = new Vector3(a_min_not.x, a_max_not.y, a_max_not.z); | |
Vector3 upPoint3 = new Vector3(a_max_not.x, a_max_not.y, a_min_not.z); | |
Debug.Log(string.Format("convert min {0}, {1}, {2}", a_min_x, a_min_y, a_min_z)); | |
Debug.Log(string.Format("convert max {0}, {1}, {2}", a_max_x, a_max_y, a_max_z)); | |
Debug.Log(string.Format("a_min_not : {0}", a_min_not.ToString())); | |
Debug.Log(string.Format("a_max_not : {0}", a_max_not.ToString())); | |
LineRenderer lr = gameObject.AddComponent<LineRenderer>(); | |
lr.positionCount = 14; | |
lr.startColor = Color.cyan; | |
lr.startWidth = 0.001f; | |
lr.endWidth = 0.001f; | |
lr.SetPosition(0, a_min_not); | |
lr.SetPosition(1, downPoint1); | |
lr.SetPosition(2, downPoint2); | |
lr.SetPosition(3, downPoint3); | |
lr.SetPosition(4, a_min_not); | |
lr.SetPosition(5, upPoint1); | |
lr.SetPosition(6, upPoint2); | |
lr.SetPosition(7, a_max_not); | |
lr.SetPosition(8, upPoint3); | |
lr.SetPosition(9, downPoint3); | |
lr.SetPosition(10, downPoint2); | |
lr.SetPosition(11, a_max_not); | |
lr.SetPosition(12, upPoint2); | |
lr.SetPosition(13, downPoint1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment