5class UndergroundDiagData
15 ref ScriptInvoker m_OnRotationChanged =
new ScriptInvoker();
17 void BoxDrawGizmo(vector pPosition)
20 Math3D.MatrixIdentity3(m_Rotation);
42 for (
int i = 0; i < 3; ++i)
43 m_Rotation[i] = transform[i];
48 void GetTransform(inout vector transform[4])
59 bool Gizmo_IsSupported()
64 void Gizmo_SetWorldTransform(vector transform[4],
bool finalize)
89 void Gizmo_GetWorldTransform(vector transform[4])
115 private ref BoxDrawGizmo m_AA, m_BB, m_Global;
119 vector TransformPointByMatrix(vector transform[4], vector localPoint)
121 return transform[0] * localPoint[0] + transform[1] * localPoint[1] + transform[2] * localPoint[2] + transform[3];
124 vector InverseTransformPointByMatrix(vector transform[4], vector pointWorld)
127 vector relative = pointWorld - transform[3];
130 float localX = vector.
Dot(relative, transform[0].Normalized());
131 float localY = vector.Dot(relative, transform[1].Normalized());
132 float localZ = vector.Dot(relative, transform[2].Normalized());
134 return Vector(localX, localY, localZ);
146 vector position =
m_Player.GetPosition();
148 m_AA =
new BoxDrawGizmo(position);
149 m_BB =
new BoxDrawGizmo(position +
"1 1 1");
150 m_Global =
new BoxDrawGizmo(Math3D.BoxCenter(m_AA.GetPosition(), m_BB.GetPosition()));
156 m_Global.m_OnRotationChanged.Insert(OnGlobalRotationChanged);
161 m_Global.m_OnRotationChanged.Remove(OnGlobalRotationChanged);
181 vector boxSize = Math3D.BoxSize(m_AA.GetPosition(), m_BB.GetPosition());
183 vector globalTransform[4];
184 Math3D.MatrixIdentity4(globalTransform);
185 m_Global.GetTransform(globalTransform);
187 DrawRotatedBox(globalTransform, boxSize, 0xFFFF0000);
195 private void OnGlobalRotationChanged(vector transform[4])
205 private void DrawRotatedBox(vector transform[4], vector size,
int color)
207 vector localCorners[8] = {
218 vector worldCorners[8];
219 for (
int i = 0; i < 8; ++i)
222 localCorners[i][0] * size[0],
223 localCorners[i][1] * size[1],
224 localCorners[i][2] * size[2],
226 worldCorners[i] = TransformPointByMatrix(transform, scaled);
235 for (
int j = 0; j < 24; j += 2)
237 Debug.DrawLine(worldCorners[edgePairs[j]], worldCorners[edgePairs[j + 1]], color,
ShapeFlags.ONCE);
247 private ref UndergroundDiagData
m_Data =
new UndergroundDiagData();
248 private ref BoxDraw m_BoxDraw;
250 private const int COLOR_START = 0xFF2ECC71;
251 private const int COLOR_END = 0xFF4B77BE;
252 private const int COLOR_END_NOATTACH = 0xFFF7CA18;
253 private const int COLOR_OBSTRUCTION = 0xFFFF00FF;
254 private const int COLOR_HIT = 0xFFFF0000;
255 private const int COLOR_GUIDE = 0xC03A3A3A;
256 private const int COLOR_WEAPON = 0x1FFFFFFF;
257 private const int COLOR_LAST_POS = 0x3AF7CA18;
259 private bool m_EditModeEnabled =
true;
262 UndergroundDiagData
Data()
268 void DrawDiag(
float deltaTime)
270 UndergroundDiagData data =
m_Data;
274 DbgUI.Begin(
"UndergroundDiag Diag");
277 int gray = 0x80FFFFFF;
278 int darkObst = gray&COLOR_OBSTRUCTION;
279 int endNoAttachCol = gray & COLOR_END_NOATTACH;
282 DbgUI.Check(
" Edit Mode", m_EditModeEnabled);
290 private void HandleGizmos()
292 if (m_EditModeEnabled)
295 m_BoxDraw =
new BoxDraw();
vector m_Position
Cached world position.
proto GizmoApi GetGizmoApi()
vector m_Transform[4]
If 'OnDebug' is to be called.
proto void SelectUser(Managed instance)
proto void DeselectTracker(Managed tracker)
static float Dot(vector v1, vector v2)
Returns Dot product of vector v1 and vector v2.
proto native void SetPosition(vector position)
Set the world position of the Effect.
proto native vector Vector(float x, float y, float z)
Vector constructor from components.