private void RenderCoordinateSystemAxis(CoordinateSystemAxis axis, CoordinateSystemRenderSettings coordinateSystemRenderSettings) { if (coordinateSystemRenderSettings.IsAxisVisible(axis)) { GizmosColor.Push(coordinateSystemRenderSettings.GetAxisColor(axis)); Vector3 axisVector = CoordinateSystemAxes.GetGlobalVector(axis); Gizmos.DrawLine(Vector3.zero, axisVector * coordinateSystemRenderSettings.GetAxisSize(axis)); GizmosColor.Pop(); } }
public static void RenderLine(Vector3 firstPoint, Vector3 secondPoint, Color color) { GizmosMatrix.Push(Matrix4x4.identity); GizmosColor.Push(color); Gizmos.DrawLine(firstPoint, secondPoint); GizmosColor.Pop(); GizmosMatrix.Pop(); }
public static void RenderMesh(Mesh mesh, Matrix4x4 transformMatrix, Color color) { GizmosMatrix.Push(transformMatrix); GizmosColor.Push(color); Gizmos.DrawMesh(mesh); GizmosColor.Pop(); GizmosMatrix.Pop(); }
public static void RenderOrientedBoxEdges(OrientedBox orientedBox, Color color) { GizmosColor.Push(color); GizmosMatrix.Push(Matrix4x4.TRS(orientedBox.Center, orientedBox.Rotation, orientedBox.ScaledSize)); Gizmos.DrawWireCube(Vector3.zero, Vector3.one); GizmosMatrix.Pop(); GizmosColor.Pop(); }
public static void RenderXZOrientedQuad(XZOrientedQuad3D orientedQuad, Color color) { GizmosMatrix.Push(orientedQuad.TransformMatrix.ToMatrix4x4x); GizmosColor.Push(color); Gizmos.DrawCube(Vector3.zero, new Vector3(orientedQuad.ModelSpaceXZSize.x, 0.0f, orientedQuad.ModelSpaceXZSize.y)); GizmosColor.Pop(); GizmosMatrix.Pop(); }
public static void RenderOrientedBox(OrientedBox orientedBox, Color color) { Matrix4x4 transformMatrix = Matrix4x4.TRS(orientedBox.Center, orientedBox.Rotation, orientedBox.ScaledSize); GizmosMatrix.Push(transformMatrix); GizmosColor.Push(color); Gizmos.DrawCube(Vector3.zero, Vector3.one); GizmosColor.Pop(); GizmosMatrix.Pop(); }
public static void RenderXZOrientedQuad(XZOrientedQuad3D orientedQuad, Color color, float offsetAlongNormal) { Matrix4x4 translationMatrix = Matrix4x4.TRS(orientedQuad.Plane.normal * offsetAlongNormal, Quaternion.identity, Vector3.one); GizmosMatrix.Push(translationMatrix * orientedQuad.TransformMatrix.ToMatrix4x4x); GizmosColor.Push(color); Gizmos.DrawCube(Vector3.zero, new Vector3(orientedQuad.ModelSpaceXZSize.x, 0.0f, orientedQuad.ModelSpaceXZSize.y)); GizmosColor.Pop(); GizmosMatrix.Pop(); }
/// <summary> /// This method renders all nodes in the tree using Unity's 'Gizmos' API. It can be /// used for debugging purposes. /// </summary> public void RenderGizmosDebug(TransformMatrix transformMatrix) { // We will use a transparent green color to render the tree nodes. We will also // activate the identity matrix because the necessary transform information resides // inside the nodes themsleves (the center is all we need actually). GizmosColor.Push(new Color(0.0f, 1.0f, 0.0f, 0.3f)); GizmosMatrix.Push(transformMatrix.ToMatrix4x4x); // Start rendering from the root RenderGizmosDebugRecurse(_rootNode); // Restore the previous color and matrix GizmosMatrix.Pop(); GizmosColor.Pop(); }
public static void RenderLinesBetweenPoints(List <Vector3> points, Color color, Vector3 offset) { GizmosMatrix.Push(Matrix4x4.identity); GizmosColor.Push(color); int numberOfPoints = points.Count; for (int pointIndex = 0; pointIndex < numberOfPoints; ++pointIndex) { Gizmos.DrawLine(points[pointIndex] + offset, points[(pointIndex + 1) % numberOfPoints] + offset); } GizmosColor.Pop(); GizmosMatrix.Pop(); }
public void RenderGizmosDebug(Matrix4x4 transformMatrix, Color aabbLineColor) { if (!_wasBuilt) { return; } GizmosMatrix.Push(transformMatrix); GizmosColor.Push(aabbLineColor); RenderGizmosDebugRecurse(_root); GizmosColor.Pop(); GizmosMatrix.Pop(); }
private void RenderGridCellLines_Obsolete(XZGrid grid, XZVisibleGridCellRange visibleCellRange) { int minCellIndexX = visibleCellRange.XAxisVisibleCellRange.Min; int maxCellIndexX = visibleCellRange.XAxisVisibleCellRange.Max; float numberOfCellsOnX = maxCellIndexX - minCellIndexX + 1.0f; int minCellIndexZ = visibleCellRange.ZAxisVisibleCellRange.Min; int maxCellIndexZ = visibleCellRange.ZAxisVisibleCellRange.Max; float numberOfCellsOnZ = maxCellIndexZ - minCellIndexZ + 1.0f; XZGridCellSizeSettings gridCellSizeSettings = grid.CellSizeSettings; XZGridRenderSettings gridRenderSettings = grid.RenderSettings; Vector3 startPointOnX, startPointOnZ; Vector3 lineCubeSize = Vector3.zero; // Render the grid lines which extend along the grid's X axis GizmosColor.Push(grid.RenderSettings.CellLineColor); startPointOnX = grid.GetCellHrzStart(minCellIndexX); lineCubeSize.z = gridRenderSettings.CellLineThickness; int maxLineIndex = maxCellIndexZ + 1; for (int lineIndex = minCellIndexZ; lineIndex <= maxLineIndex; ++lineIndex) { startPointOnZ = grid.GetCellDepthStart(lineIndex); Vector3 firstPoint = startPointOnX + startPointOnZ; Vector3 secondPoint = firstPoint + XZGrid.ModelSpaceRightAxis * (numberOfCellsOnX * gridCellSizeSettings.CellSizeX); lineCubeSize.x = (firstPoint - secondPoint).magnitude + gridRenderSettings.CellLineThickness; Gizmos.DrawCube((firstPoint + secondPoint) * 0.5f, lineCubeSize); } // Render the grid lines which extend along the grid's Z axis startPointOnZ = grid.GetCellDepthStart(minCellIndexZ); lineCubeSize.x = gridRenderSettings.CellLineThickness; maxLineIndex = maxCellIndexX + 1; for (int lineIndex = minCellIndexX; lineIndex <= maxLineIndex; ++lineIndex) { startPointOnX = grid.GetCellHrzStart(lineIndex); Vector3 firstPoint = startPointOnX + startPointOnZ; Vector3 secondPoint = firstPoint + XZGrid.ModelSpaceLookAxis * (numberOfCellsOnZ * gridCellSizeSettings.CellSizeZ); lineCubeSize.z = (firstPoint - secondPoint).magnitude; Gizmos.DrawCube((firstPoint + secondPoint) * 0.5f, lineCubeSize); } GizmosColor.Pop(); }
private void RenderGridPlane_Obsolete(XZGrid grid, XZVisibleGridCellRange visibleCellRange) { int minCellIndexX = visibleCellRange.XAxisVisibleCellRange.Min; int maxCellIndexX = visibleCellRange.XAxisVisibleCellRange.Max; int minCellIndexZ = visibleCellRange.ZAxisVisibleCellRange.Min; int maxCellIndexZ = visibleCellRange.ZAxisVisibleCellRange.Max; float numberOfCellsOnX = maxCellIndexX - minCellIndexX + 1.0f; float numberOfCellsOnZ = maxCellIndexZ - minCellIndexZ + 1.0f; XZGridCellSizeSettings gridCellSizeSettings = grid.CellSizeSettings; Vector3 planeCenter = (grid.GetCellHrzStart(minCellIndexX) + grid.GetCellDepthStart(minCellIndexZ) + grid.GetCellHrzStart(maxCellIndexX + 1) + grid.GetCellDepthStart(maxCellIndexZ + 1)) * 0.5f; Vector3 planeSize = new Vector3(numberOfCellsOnX * gridCellSizeSettings.CellSizeX, 0.0f, numberOfCellsOnZ * gridCellSizeSettings.CellSizeZ); GizmosColor.Push(grid.RenderSettings.PlaneColor); Gizmos.DrawCube(planeCenter, planeSize); GizmosColor.Pop(); }
public static void RenderOrientedBoxCornerEdges(OrientedBox orientedBox, float cornerEdgeLengthPercentage, Color color) { cornerEdgeLengthPercentage = Mathf.Clamp(cornerEdgeLengthPercentage, 0.0f, 1.0f); List <Vector3> boxCornerPoints = orientedBox.GetCenterAndCornerPoints(); GizmosColor.Push(color); // Render the corner edges along the top edge of the box's front face Segment3D segment = new Segment3D(boxCornerPoints[(int)BoxPoint.FrontTopLeft], boxCornerPoints[(int)BoxPoint.FrontTopRight]); float edgeLength = segment.HalfLength * cornerEdgeLengthPercentage; if (edgeLength > 0.0f) { Gizmos.DrawLine(segment.StartPoint, segment.StartPoint + segment.NormalizedDirection * edgeLength); Gizmos.DrawLine(segment.EndPoint, segment.EndPoint - segment.NormalizedDirection * edgeLength); } // Render the corner edges along the bottom edge of the box's front face segment = new Segment3D(boxCornerPoints[(int)BoxPoint.FrontBottomLeft], boxCornerPoints[(int)BoxPoint.FrontBottomRight]); edgeLength = segment.HalfLength * cornerEdgeLengthPercentage; if (edgeLength > 0.0f) { Gizmos.DrawLine(segment.StartPoint, segment.StartPoint + segment.NormalizedDirection * edgeLength); Gizmos.DrawLine(segment.EndPoint, segment.EndPoint - segment.NormalizedDirection * edgeLength); } // Render the corner edges along the left edge of the box's front face segment = new Segment3D(boxCornerPoints[(int)BoxPoint.FrontTopLeft], boxCornerPoints[(int)BoxPoint.FrontBottomLeft]); edgeLength = segment.HalfLength * cornerEdgeLengthPercentage; if (edgeLength > 0.0f) { Gizmos.DrawLine(segment.StartPoint, segment.StartPoint + segment.NormalizedDirection * edgeLength); Gizmos.DrawLine(segment.EndPoint, segment.EndPoint - segment.NormalizedDirection * edgeLength); } // Render the corner edges along the right edge of the box's front face segment = new Segment3D(boxCornerPoints[(int)BoxPoint.FrontTopRight], boxCornerPoints[(int)BoxPoint.FrontBottomRight]); edgeLength = segment.HalfLength * cornerEdgeLengthPercentage; if (edgeLength > 0.0f) { Gizmos.DrawLine(segment.StartPoint, segment.StartPoint + segment.NormalizedDirection * edgeLength); Gizmos.DrawLine(segment.EndPoint, segment.EndPoint - segment.NormalizedDirection * edgeLength); } // Render the corner edges along the top edge of the box's back face segment = new Segment3D(boxCornerPoints[(int)BoxPoint.BackTopLeft], boxCornerPoints[(int)BoxPoint.BackTopRight]); edgeLength = segment.HalfLength * cornerEdgeLengthPercentage; if (edgeLength > 0.0f) { Gizmos.DrawLine(segment.StartPoint, segment.StartPoint + segment.NormalizedDirection * edgeLength); Gizmos.DrawLine(segment.EndPoint, segment.EndPoint - segment.NormalizedDirection * edgeLength); } // Render the corner edges along the bottom edge of the box's back face segment = new Segment3D(boxCornerPoints[(int)BoxPoint.BackBottomLeft], boxCornerPoints[(int)BoxPoint.BackBottomRight]); edgeLength = segment.HalfLength * cornerEdgeLengthPercentage; if (edgeLength > 0.0f) { Gizmos.DrawLine(segment.StartPoint, segment.StartPoint + segment.NormalizedDirection * edgeLength); Gizmos.DrawLine(segment.EndPoint, segment.EndPoint - segment.NormalizedDirection * edgeLength); } // Render the corner edges along the left edge of the box's back face segment = new Segment3D(boxCornerPoints[(int)BoxPoint.BackTopLeft], boxCornerPoints[(int)BoxPoint.BackBottomLeft]); edgeLength = segment.HalfLength * cornerEdgeLengthPercentage; if (edgeLength > 0.0f) { Gizmos.DrawLine(segment.StartPoint, segment.StartPoint + segment.NormalizedDirection * edgeLength); Gizmos.DrawLine(segment.EndPoint, segment.EndPoint - segment.NormalizedDirection * edgeLength); } // Render the corner edges along the right edge of the box's back face segment = new Segment3D(boxCornerPoints[(int)BoxPoint.BackTopRight], boxCornerPoints[(int)BoxPoint.BackBottomRight]); edgeLength = segment.HalfLength * cornerEdgeLengthPercentage; if (edgeLength > 0.0f) { Gizmos.DrawLine(segment.StartPoint, segment.StartPoint + segment.NormalizedDirection * edgeLength); Gizmos.DrawLine(segment.EndPoint, segment.EndPoint - segment.NormalizedDirection * edgeLength); } // Render the corner edges along the left edge of the box's top face segment = new Segment3D(boxCornerPoints[(int)BoxPoint.FrontTopLeft], boxCornerPoints[(int)BoxPoint.BackTopRight]); edgeLength = segment.HalfLength * cornerEdgeLengthPercentage; if (edgeLength > 0.0f) { Gizmos.DrawLine(segment.StartPoint, segment.StartPoint + segment.NormalizedDirection * edgeLength); Gizmos.DrawLine(segment.EndPoint, segment.EndPoint - segment.NormalizedDirection * edgeLength); } // Render the corner edges along the right edge of the box's top face segment = new Segment3D(boxCornerPoints[(int)BoxPoint.FrontTopRight], boxCornerPoints[(int)BoxPoint.BackTopLeft]); edgeLength = segment.HalfLength * cornerEdgeLengthPercentage; if (edgeLength > 0.0f) { Gizmos.DrawLine(segment.StartPoint, segment.StartPoint + segment.NormalizedDirection * edgeLength); Gizmos.DrawLine(segment.EndPoint, segment.EndPoint - segment.NormalizedDirection * edgeLength); } // Render the corner edges along the left edge of the box's bottom face segment = new Segment3D(boxCornerPoints[(int)BoxPoint.FrontBottomLeft], boxCornerPoints[(int)BoxPoint.BackBottomRight]); edgeLength = segment.HalfLength * cornerEdgeLengthPercentage; if (edgeLength > 0.0f) { Gizmos.DrawLine(segment.StartPoint, segment.StartPoint + segment.NormalizedDirection * edgeLength); Gizmos.DrawLine(segment.EndPoint, segment.EndPoint - segment.NormalizedDirection * edgeLength); } // Render the corner edges along the right edge of the box's bottom face segment = new Segment3D(boxCornerPoints[(int)BoxPoint.FrontBottomRight], boxCornerPoints[(int)BoxPoint.BackBottomLeft]); edgeLength = segment.HalfLength * cornerEdgeLengthPercentage; if (edgeLength > 0.0f) { Gizmos.DrawLine(segment.StartPoint, segment.StartPoint + segment.NormalizedDirection * edgeLength); Gizmos.DrawLine(segment.EndPoint, segment.EndPoint - segment.NormalizedDirection * edgeLength); } GizmosColor.Pop(); }
public static void RenderBoxEdges(Box box, Color color) { GizmosColor.Push(color); Gizmos.DrawWireCube(box.Center, box.Size); GizmosColor.Pop(); }