public void Add(AxisVectors axisVectors) { x.AddRange(axisVectors.x); y.AddRange(axisVectors.y); z.AddRange(axisVectors.z); all.AddRange(axisVectors.all); }
void HandleNearest(AxisVectors axisVectors, float minSelectedDistanceCheck) { float xClosestDistance = ClosestDistanceFromMouseToLines(axisVectors.x); float yClosestDistance = ClosestDistanceFromMouseToLines(axisVectors.y); float zClosestDistance = ClosestDistanceFromMouseToLines(axisVectors.z); float allClosestDistance = ClosestDistanceFromMouseToLines(axisVectors.all); if (type == TransformType.Scale && allClosestDistance <= minSelectedDistanceCheck) { nearAxis = Axis.Any; } else if (xClosestDistance <= minSelectedDistanceCheck && xClosestDistance <= yClosestDistance && xClosestDistance <= zClosestDistance) { nearAxis = Axis.X; } else if (yClosestDistance <= minSelectedDistanceCheck && yClosestDistance <= xClosestDistance && yClosestDistance <= zClosestDistance) { nearAxis = Axis.Y; } else if (zClosestDistance <= minSelectedDistanceCheck && zClosestDistance <= xClosestDistance && zClosestDistance <= yClosestDistance) { nearAxis = Axis.Z; } else if (type == TransformType.Rotate && mainTargetRoot != null) { Ray mouseRay = myCamera.ScreenPointToRay(Input.mousePosition); Vector3 mousePlaneHit = Geometry.LinePlaneIntersect(mouseRay.origin, mouseRay.direction, pivotPoint, (transform.position - pivotPoint).normalized); if ((pivotPoint - mousePlaneHit).sqrMagnitude <= (handleLength * GetDistanceMultiplier()).Squared()) { nearAxis = Axis.Any; } } }
public void Add(AxisVectors axisVectors) { X.AddRange(axisVectors.X); Y.AddRange(axisVectors.Y); Z.AddRange(axisVectors.Z); All.AddRange(axisVectors.All); }
void HandleNearestPlanes(TransformType type, AxisVectors axisVectors, float minSelectedDistanceCheck) { float xClosestDistance = ClosestDistanceFromMouseToPlanes(axisVectors.x); float yClosestDistance = ClosestDistanceFromMouseToPlanes(axisVectors.y); float zClosestDistance = ClosestDistanceFromMouseToPlanes(axisVectors.z); float allClosestDistance = ClosestDistanceFromMouseToPlanes(axisVectors.all); HandleNearest(type, xClosestDistance, yClosestDistance, zClosestDistance, allClosestDistance, minSelectedDistanceCheck); }
void SetCircles(AxisInfo axisInfo, AxisVectors axisVectors) { axisVectors.Clear(); if (type == TransformType.Rotate) { float circleLength = handleLength * GetDistanceMultiplier(); AddCircle(pivotPoint, axisInfo.xDirection, circleLength, axisVectors.x); AddCircle(pivotPoint, axisInfo.yDirection, circleLength, axisVectors.y); AddCircle(pivotPoint, axisInfo.zDirection, circleLength, axisVectors.z); AddCircle(pivotPoint, (pivotPoint - transform.position).normalized, circleLength, axisVectors.all, false); } }
void SetCircles(AxisInfo axisInfo, AxisVectors axisVectors) { axisVectors.Clear(); if (TranslatingTypeContains(TransformType.Rotate)) { float circleLength = GetHandleLength(TransformType.Rotate); AddCircle(pivotPoint, axisInfo.xDirection, circleLength, axisVectors.x); AddCircle(pivotPoint, axisInfo.yDirection, circleLength, axisVectors.y); AddCircle(pivotPoint, axisInfo.zDirection, circleLength, axisVectors.z); AddCircle(pivotPoint, (pivotPoint - transform.position).normalized, circleLength, axisVectors.all, false); } }
void OnPostRender() { if (target == null) { return; } lineMaterial.SetPass(0); Color xColor = (selectedAxis == Axis.X) ? selectedColor : this.xColor; Color yColor = (selectedAxis == Axis.Y) ? selectedColor : this.yColor; Color zColor = (selectedAxis == Axis.Z) ? selectedColor : this.zColor; Color allColor = (selectedAxis == Axis.Any) ? selectedColor : this.allColor; DrawLines(handleLines.x, xColor); DrawLines(handleLines.z, zColor); if (posType == PosType.vector3) { DrawLines(handleLines.y, yColor); DrawTriangles(handleTriangles.y, yColor); } DrawTriangles(handleTriangles.x, xColor); DrawTriangles(handleTriangles.z, zColor); DrawSquares(handleSquares.x, xColor); DrawSquares(handleSquares.y, yColor); DrawSquares(handleSquares.z, zColor); DrawSquares(handleSquares.all, allColor); AxisVectors rotationAxisVector = circlesLines; if (isTransforming && space == TransformSpace.Global && type == TransformType.Rotate) { rotationAxisVector = drawCurrentCirclesLines; AxisInfo axisInfo = new AxisInfo(); axisInfo.xDirection = totalRotationAmount * Vector3.right; axisInfo.yDirection = totalRotationAmount * Vector3.up; axisInfo.zDirection = totalRotationAmount * Vector3.forward; SetCircles(axisInfo, drawCurrentCirclesLines); } DrawCircles(rotationAxisVector.x, xColor); DrawCircles(rotationAxisVector.y, yColor); DrawCircles(rotationAxisVector.z, zColor); DrawCircles(rotationAxisVector.all, allColor); }
void SetCircles(AxisInfo axisInfo, AxisVectors axisVectors) { axisVectors.Clear(); if (type == TransformType.Rotate) { float circleLength = setting.handleLength * DistanceMultiplier; if (setting.enableState == EnableState.Normal) { AddCircle(target.position, axisInfo.xDirection, circleLength, axisVectors.x); AddCircle(target.position, axisInfo.zDirection, circleLength, axisVectors.z); AddCircle(target.position, (target.position - myCamera.transform.position).normalized, circleLength, axisVectors.all, false); } AddCircle(target.position, axisInfo.yDirection, circleLength, axisVectors.y); } }
void OnPostRender() { if (mainTargetRoot == null) { return; } lineMaterial.SetPass(0); Color xColor = (nearAxis == Axis.X) ? (isTransforming) ? selectedColor : hoverColor : this.xColor; Color yColor = (nearAxis == Axis.Y) ? (isTransforming) ? selectedColor : hoverColor : this.yColor; Color zColor = (nearAxis == Axis.Z) ? (isTransforming) ? selectedColor : hoverColor : this.zColor; Color allColor = (nearAxis == Axis.Any) ? (isTransforming) ? selectedColor : hoverColor : this.allColor; //Note: The order of drawing the axis decides what gets drawn over what. DrawQuads(handleLines.z, zColor); DrawQuads(handleLines.x, xColor); DrawQuads(handleLines.y, yColor); DrawTriangles(handleTriangles.x, xColor); DrawTriangles(handleTriangles.y, yColor); DrawTriangles(handleTriangles.z, zColor); DrawQuads(handleSquares.x, xColor); DrawQuads(handleSquares.y, yColor); DrawQuads(handleSquares.z, zColor); DrawQuads(handleSquares.all, allColor); AxisVectors rotationAxisVector = circlesLines; if (isTransforming && space == TransformSpace.Global && type == TransformType.Rotate) { rotationAxisVector = drawCurrentCirclesLines; AxisInfo axisInfo = new AxisInfo(); axisInfo.xDirection = totalRotationAmount * Vector3.right; axisInfo.yDirection = totalRotationAmount * Vector3.up; axisInfo.zDirection = totalRotationAmount * Vector3.forward; SetCircles(axisInfo, drawCurrentCirclesLines); } DrawQuads(rotationAxisVector.all, allColor); DrawQuads(rotationAxisVector.x, xColor); DrawQuads(rotationAxisVector.y, yColor); DrawQuads(rotationAxisVector.z, zColor); }