public List <Vector3> GetExtentsPoints() { // First egenrate the points in model space in the following order: top, right, bottom, left. List <Vector3> points = new List <Vector3> { Vector3.forward *_radiusZ, Vector3.right *_radiusX, Vector3.forward * -_radiusZ, Vector3.right * -_radiusX }; // Transform the points and return them return(Vector3Extensions.GetTransformedPoints(points, TransformMatrix.ToMatrix4x4x)); }
public void RenderGizmos(XZGrid grid, CameraViewVolume cameraViewVolume) { if (!grid.RenderSettings.IsVisible) { return; } // Note: Can not figure out how to render a finite grid inside a shader yet... :D if (grid.DimensionSettings.DimensionType == XZGridDimensionType.Finite) { RenderGizmos_Obsolete(grid, cameraViewVolume); return; } Plane gridPlane = grid.Plane; Vector3 gridPlaneCenter = gridPlane.ProjectPoint(SceneViewCamera.Camera.transform.position); Box camVolumeAABB = cameraViewVolume.WorldSpaceAABB; List <Vector3> projectedVolumeAABBPts = gridPlane.ProjectAllPoints(camVolumeAABB.GetCornerPoints()); List <Vector3> modelSpacePrjPts = Vector3Extensions.GetTransformedPoints(projectedVolumeAABBPts, grid.TransformMatrix.ToMatrix4x4x.inverse); Box modelSpacePtsBox = Box.FromPoints(modelSpacePrjPts); Vector3 gridPlaneSize = modelSpacePtsBox.Size; Matrix4x4 planeTransformMatrix = Matrix4x4.TRS(gridPlaneCenter, grid.Rotation, gridPlaneSize); Material xzGridMaterial = MaterialPool.Get().XZGridMaterial; xzGridMaterial.SetFloat("_CellSizeX", grid.CellSizeSettings.CellSizeX); xzGridMaterial.SetFloat("_CellSizeZ", grid.CellSizeSettings.CellSizeZ); xzGridMaterial.SetVector("_CellOffset", grid.GetOriginPosition()); xzGridMaterial.SetColor("_LineColor", grid.RenderSettings.CellLineColor); xzGridMaterial.SetColor("_PlaneColor", grid.RenderSettings.PlaneColor); xzGridMaterial.SetFloat("_CamFarPlaneDist", SceneViewCamera.Camera.farClipPlane); xzGridMaterial.SetVector("_CamWorldPos", SceneViewCamera.Camera.transform.position); xzGridMaterial.SetMatrix("_InvRotMatrix", Matrix4x4.TRS(Vector3.zero, grid.Rotation, Vector3.one).inverse); xzGridMaterial.SetMatrix("_PlaneTransformMtx", planeTransformMatrix); int numPasses = xzGridMaterial.passCount; for (int passIndex = 0; passIndex < numPasses; ++passIndex) { xzGridMaterial.SetPass(passIndex); Graphics.DrawMeshNow(GizmosEx.XZRectangleMesh, planeTransformMatrix); } GizmosMatrix.Push(grid.TransformMatrix.ToMatrix4x4x); grid.RenderableCoordinateSystem.RenderGizmos(); GizmosMatrix.Pop(); }
public List <Vector3> GetBoxFaceCornerPoints(BoxFace boxFace) { List <Vector3> modelSpacePoints = _modelSpaceBox.GetBoxFaceCornerPoints(boxFace); return(Vector3Extensions.GetTransformedPoints(modelSpacePoints, TransformMatrix.ToMatrix4x4x)); }
public List <Vector3> GetCornerPoints() { List <Vector3> points = _modelSpaceBox.GetCornerPoints(); return(Vector3Extensions.GetTransformedPoints(points, TransformMatrix.ToMatrix4x4x)); }