public void Set(utlMatrix34 mtx) { m_A = mtx.A; m_B = mtx.B; m_C = mtx.C; m_D = mtx.D; }
public static void DrawGridBackground(utlMatrix34 mtx, Vector2 gridStart, Vector2 gridEnd, Vector2 gridSize, int lineWidth, Color lineColor) { Vector2 startPos = new Vector2(gridStart.x, gridStart.y); Vector2 endPos = new Vector2(gridEnd.x, gridStart.y); float distance = utlMath.FloatDistance(gridStart.x, gridEnd.x); float gridCount = distance / gridSize.x; for (int indexX = 0; indexX < gridCount; indexX++) { startPos.y += gridSize.y; endPos.y += gridSize.y; endPos.x = gridEnd.x; DrawLine(mtx.Transform(startPos), mtx.Transform(endPos), lineWidth, lineColor); } startPos.Set(gridStart.x, gridStart.y); endPos.Set(gridStart.x, gridEnd.x); for (int indexY = 0; indexY < gridCount; indexY++) { startPos.x += gridSize.x; endPos.x += gridSize.x; endPos.y = gridEnd.y; DrawLine(mtx.Transform(startPos), mtx.Transform(endPos), lineWidth, lineColor); } }
public void RotateZ(float r) { utlMatrix34 m = new utlMatrix34(); m.RotateZXform(r); this.Dot(m); }
public void Update(baseState state, utlMatrix34 mtx, artConfigurationData configData) { m_State = state; MoveBool = false; // input Event ev = Event.current; //stateEditorUtils.MousePos = ev.mousePosition; //if the mouse button is down. if (ev.type == EventType.MouseDown && ev.button == 0) { LeftMouseButton = true; if (m_MainBodyHover) { MoveBool = true; Selected = true; } if (m_ResizeBodyHover) { this.Resize = true; } if (this.m_TitleHover) { RenameBool = true; } } if (ev.type == EventType.MouseUp) { LeftMouseButton = false; Selected = false; Resize = false; //RenameBool = false; } //GUI.Window(m_Id, mtx.Transform(WinRect), DrawNodeWindow, m_WindowStateAlias); Vector3 startPos = GetStartPosForConditional(); for (int i = 0; i < this.ConditionLineList.Count; i++) { Vector3 endPos = GetEndPosForConditional(ConditionLineList[i]); Color shadowCol = new Color(0, 0, 1, 0.06f); //artGUIUtils.DrawArrowTranformed(mtx, startPos, endPos, WinRect, ConditionLineList[i].WinRect, 1, Color.black, 1, shadowCol, Color.white); artGUIUtils.DrawArrowTranformed(mtx, startPos, endPos, WinRect, ConditionLineList[i].WinRect, configData.ArrowLineWidth, configData.ArrowLineColor, configData.ArrowFillColor); } DrawCurrentRunningState(configData); DrawNodeWindow(this.m_Id, configData); //DrawCurrentRunningState(); }
public static void DrawGridBackground(utlMatrix34 mtx) { Color shadowCol = new Color(0, 0, 0, 0.2f); artGUIUtils.DrawGridBackground(mtx, new Vector2(-5000, -5000), new Vector2(5000, 5000), new Vector2(25, 25), 1, shadowCol); Color blueCol = new Color(0, 0, 1, 0.4f); artGUIUtils.DrawGridBackground(mtx, new Vector2(-5000, -5000), new Vector2(5000, 5000), new Vector2(250, 250), 3, blueCol); //stateEditorDrawUtils.DrawGridBackground(new Vector2(-5000, -5000), new Vector2(5000, 5000), new Vector2(250, 250), 1, blueCol); }
/// <summary> /// Is within the window using the scroll transform. /// </summary> /// <param name="tranVect"></param> /// <returns></returns> public bool IsWithinUsingPanZoomTransform(Vector2 vect, utlMatrix34 mtx) { Vector3 transVect = new Vector3(); transVect = mtx.UnTransform(vect); if (transVect.x >= m_WinRect.x && transVect.x < m_WinRect.x + m_WinRect.width) { if (transVect.y >= m_WinRect.y && transVect.y < m_WinRect.y + m_WinRect.height) { return(true); } } return(false); }
public static void DrawArrowTranformed(utlMatrix34 mtx, Vector2 startPos, Vector2 endPos, Rect winRectStart, Rect winRectEnd, float lineWidth, Color lineColor, Color bodyColor) { Vector3 startPosTrans = new Vector3(); startPosTrans = mtx.Transform(startPos); Vector3 endPosTrans = new Vector3(); endPosTrans = mtx.Transform(endPos); Rect transStartRect = new Rect(winRectStart); Rect transEndRect = new Rect(winRectEnd); transStartRect.position = mtx.Transform(transStartRect.position); transEndRect.position = mtx.Transform(transEndRect.position); DrawArrow(startPosTrans, endPosTrans, transStartRect, transEndRect, lineWidth, lineColor, bodyColor); }
void Dot(utlMatrix34 m) { float x, y, z; x = A.x * m.A.x + A.y * m.B.x + A.z * m.C.x; y = A.x * m.A.y + A.y * m.B.y + A.z * m.C.y; z = A.x * m.A.z + A.y * m.B.z + A.z * m.C.z; A.Set(x, y, z); x = B.x * m.A.x + B.y * m.B.x + B.z * m.C.x; y = B.x * m.A.y + B.y * m.B.y + B.z * m.C.y; z = B.x * m.A.z + B.y * m.B.z + B.z * m.C.z; B.Set(x, y, z); x = C.x * m.A.x + C.y * m.B.x + C.z * m.C.x; y = C.x * m.A.y + C.y * m.B.y + C.z * m.C.y; z = C.x * m.A.z + C.y * m.B.z + C.z * m.C.z; C.Set(x, y, z); x = D.x * m.A.x + D.y * m.B.x + D.z * m.C.x + m.D.x; y = D.x * m.A.y + D.y * m.B.y + D.z * m.C.y + m.D.y; z = D.x * m.A.z + D.y * m.B.z + D.z * m.C.z + m.D.z; D.Set(x, y, z); }
public static void DrawArrow(Vector3 startPos, Vector3 endPos, Rect winRectspawnPointStart, Rect winRectEnd, int lineWidth, Color lineColor, int shadowWidth, Color shadowColor, Color bodyColor) { //clip the line through the window rects Vector2 colPos = new Vector2(); if (LineRectIntersection(startPos, endPos, winRectspawnPointStart, ref colPos)) { startPos = colPos; } if (LineRectIntersection(startPos, endPos, winRectEnd, ref colPos)) { endPos = colPos; } Handles.color = shadowColor; for (int i = 0; i < 3; i++) { Handles.DrawBezier(startPos, endPos, endPos, startPos, shadowColor, null, (i + shadowWidth) * 4); } // Handles.DrawLine(startPos, endPos); //Handles.color = lineColor; //Handles.DrawLine(startPos, endPos); //Handles.DrawBezier(startPos, endPos, endPos, startPos, shadowColor, null, shadowWidth); Handles.DrawBezier(startPos, endPos, endPos, startPos, lineColor, null, lineWidth); Handles.color = bodyColor; for (float i = 0; i < 10; i += 0.5f) { Handles.DrawWireCube(startPos, new Vector3(i, i, i)); } Handles.color = lineColor; Handles.DrawWireCube(startPos, new Vector3(10, 10, 10)); const int arrowHeadSize = 3; Vector3[] arrowHead = new Vector3[arrowHeadSize]; float arrowSize = 15; arrowHead[0] = new Vector3(0, 0, 0); arrowHead[1] = new Vector3(0, arrowSize * 0.5f, arrowSize); arrowHead[2] = new Vector3(0, -arrowSize * 0.5f, arrowSize); utlMatrix34 mtx = new utlMatrix34(endPos); Vector3 lookAtPos = new Vector3(startPos.x, startPos.y, startPos.z); //new Vector3(winRectEnd.x + (winRectEnd.width * 0.5f), winRectEnd.y + (winRectEnd.height * 0.5f), 0); mtx.LookAt(lookAtPos); Vector3[] arrowHeadWorld = new Vector3[arrowHeadSize]; for (int i = 0; i < arrowHeadWorld.Length; i++) { arrowHeadWorld[i] = new Vector3(); arrowHeadWorld[i] = mtx.Transform(arrowHead[i]); } float slice = 0.05f; for (float i = slice; i < 1.0f - slice; i += slice) { Vector3 lerpVect = Vector3.Lerp(arrowHeadWorld[1], arrowHeadWorld[2], i); Handles.DrawBezier(arrowHeadWorld[0], lerpVect, lerpVect, arrowHeadWorld[0], bodyColor, null, 3); } Handles.DrawBezier(arrowHeadWorld[0], arrowHeadWorld[1], arrowHeadWorld[1], arrowHeadWorld[0], shadowColor, null, 3); Handles.DrawBezier(arrowHeadWorld[0], arrowHeadWorld[2], arrowHeadWorld[2], arrowHeadWorld[0], shadowColor, null, 3); Handles.DrawBezier(arrowHeadWorld[1], arrowHeadWorld[2], arrowHeadWorld[2], arrowHeadWorld[1], shadowColor, null, 3); Handles.color = lineColor; Handles.DrawLine(arrowHeadWorld[0], arrowHeadWorld[1]); Handles.DrawLine(arrowHeadWorld[0], arrowHeadWorld[2]); Handles.DrawLine(arrowHeadWorld[1], arrowHeadWorld[2]); }
/// <summary> /// returns the position of the window with the scroll/pan mtx transform. /// </summary> /// <returns></returns> public Vector3 GetTransformedPos(utlMatrix34 mtx) { return(mtx.Transform(GetPos())); }
/* * public static void DrawArrowTranformed(utlMatrix34 mtx, Vector3 startPos, Vector3 endPos, Rect winRectStart, Rect winRectEnd, int lineWidth, Color lineColor, int shadowWidth, Color shadowColor, Color bodyColor) * { * Vector3 startPosTrans = new Vector3(); * startPosTrans = mtx.Transform(startPos); * * Vector3 endPosTrans = new Vector3(); * endPosTrans = mtx.Transform(endPos); * * Rect transStartRect = new Rect(winRectStart); * Rect transEndRect = new Rect(winRectEnd); * * transStartRect.position = mtx.Transform(transStartRect.position); * transEndRect.position = mtx.Transform(transEndRect.position); * * DrawArrow(startPosTrans, * endPosTrans, * transStartRect, * transEndRect, * lineWidth, * lineColor, shadowWidth, shadowColor, bodyColor); * * }*/ public static void DrawArrow(Vector2 startPos, Vector2 endPos, Rect winRectStart, Rect winRectEnd, float lineWidth, Color lineColor, Color bodyColor) { Vector2 colPos = new Vector2(); if (LineRectIntersection(startPos, endPos, winRectStart, ref colPos)) { startPos = colPos; } if (LineRectIntersection(startPos, endPos, winRectEnd, ref colPos)) { endPos = colPos; } //Handles.DrawBezier(startPos, endPos, endPos, startPos, lineColor, null, lineWidth); DrawLine(startPos, endPos, lineWidth, lineColor); artGUIUtils.DrawRect(new Rect(startPos.x - 5, startPos.y - 5, 10, 10), lineWidth, lineColor, bodyColor); //arrow head draw const int arrowHeadSize = 3; Vector3[] arrowHead = new Vector3[arrowHeadSize]; float arrowSize = 15; arrowHead[0] = new Vector3(0, 0, 0); arrowHead[1] = new Vector3(0, arrowSize * 0.5f, arrowSize); arrowHead[2] = new Vector3(0, -arrowSize * 0.5f, arrowSize); utlMatrix34 mtx = new utlMatrix34(endPos); Vector3 lookAtPos = new Vector3(startPos.x, startPos.y, 0); //new Vector3(winRectEnd.x + (winRectEnd.width * 0.5f), winRectEnd.y + (winRectEnd.height * 0.5f), 0); mtx.LookAt(lookAtPos); Vector3[] arrowHeadWorld = new Vector3[arrowHeadSize]; for (int i = 0; i < arrowHeadWorld.Length; i++) { arrowHeadWorld[i] = new Vector3(); arrowHeadWorld[i] = mtx.Transform(arrowHead[i]); } float slice = 0.05f; for (float i = slice; i < 1.0f - slice; i += slice) { Vector3 lerpVect = Vector3.Lerp(arrowHeadWorld[1], arrowHeadWorld[2], i); //Handles.DrawBezier(arrowHeadWorld[0], lerpVect, lerpVect, arrowHeadWorld[0], bodyColor, null, 3); DrawLine(arrowHeadWorld[0], lerpVect, 3, bodyColor); } Handles.color = lineColor; artGUIUtils.DrawLine(arrowHeadWorld[0], arrowHeadWorld[1], lineWidth, lineColor); artGUIUtils.DrawLine(arrowHeadWorld[0], arrowHeadWorld[2], lineWidth, lineColor); artGUIUtils.DrawLine(arrowHeadWorld[1], arrowHeadWorld[2], lineWidth, lineColor); }