public AxisOrientationConstraint(ConstraintAxis axis, float angleMin, float angleMax) { // Set the axis that we will rotate around this.axis = (int)axis; switch (axis) { case ConstraintAxis.X: this.rotateAround = Vector3.right; break; case ConstraintAxis.Y: this.rotateAround = Vector3.up; break; case ConstraintAxis.Z: this.rotateAround = Vector3.forward; break; default: this.rotateAround = Vector3.zero; break; } // Set the min and max rotations in degrees this.angleMin = angleMin; this.angleMax = angleMax; // Set the min and max rotations in quaternion space this.minQuaternion = Quaternion.AngleAxis(angleMin, this.rotateAround); this.maxQuaternion = Quaternion.AngleAxis(angleMax, this.rotateAround); this.angleRange = angleMax - angleMin; }
public override void OnEnter() { var go = Fsm.GetOwnerDefaultTarget(gameObject); if (go == null) { return; } thisTransform = go.transform; axis = (ConstraintAxis)constraintAxis.Value; axisIndex = (int)axis; // Set the axis that we will rotate around switch (axis) { case ConstraintAxis.x: rotateAround = Vector3.right; break; case ConstraintAxis.y: rotateAround = Vector3.up; break; case ConstraintAxis.z: rotateAround = Vector3.forward; break; } _defaultRotation = !defaultRotation.IsNone ? defaultRotation.Value : thisTransform.localRotation.eulerAngles; ComputeRange(); }
// AddJointConstraint - Adds a joint constraint to the system. public void AddBoneOrientationConstraint(int thisJoint, ConstraintAxis axis, float angleMin, float angleMax) { int index = FindBoneOrientationConstraint(thisJoint); BoneOrientationConstraint jc = index >= 0 ? jointConstraints[index] : new BoneOrientationConstraint(thisJoint); if(index < 0) { index = jointConstraints.Count; jointConstraints.Add(jc); } AxisOrientationConstraint constraint = new AxisOrientationConstraint(axis, angleMin, angleMax); jc.axisConstrainrs.Add(constraint); jointConstraints[index] = jc; }
// AddJointConstraint - Adds a joint constraint to the system. public void AddBoneOrientationConstraint(int joint, ConstraintAxis axis, float angleMin, float angleMax) { int index = FindBoneOrientationConstraint(joint); BoneOrientationConstraint jc = index >= 0 ? jointConstraints[index] : new BoneOrientationConstraint(joint); if (index < 0) { index = jointConstraints.Count; jointConstraints.Add(jc); } AxisOrientationConstraint constraint = new AxisOrientationConstraint(axis, angleMin, angleMax); jc.axisConstrainrs.Add(constraint); jointConstraints[index] = jc; }
public override void OnEnter() { var go = Fsm.GetOwnerDefaultTarget(gameObject); if (go == null) { return; } _withinRange = true; axis = (ConstraintAxis)constraintAxis.Value; axisIndex = (int)axis; if (!defaultRotation.IsNone) { _defaultRotation = defaultRotation.Value; } else { _defaultRotation = go.transform.localRotation.eulerAngles; } }
public AxisOrientationConstraint(ConstraintAxis axis, float angleMin, float angleMax) { // Set the axis that we will rotate around this.axis = (int)axis; switch(axis) { case ConstraintAxis.X: this.rotateAround = Vector3.right; break; case ConstraintAxis.Y: this.rotateAround = Vector3.up; break; case ConstraintAxis.Z: this.rotateAround = Vector3.forward; break; default: this.rotateAround = Vector3.zero; break; } // Set the min and max rotations in degrees this.angleMin = angleMin; this.angleMax = angleMax; // Set the min and max rotations in quaternion space this.minQuaternion = Quaternion.AngleAxis(angleMin, this.rotateAround); this.maxQuaternion = Quaternion.AngleAxis(angleMax, this.rotateAround); this.angleRange = angleMax - angleMin; }
void ConstrainSelection(ConstraintAxis axis) { switch (axis) { case ConstraintAxis.X: Vector3Int startPos = startSelection, endPos = endSelection; ClearSelection(); //We don't want the size to be negative, so we flip it around if so if (startPos.y > endPos.y) { startPos.y = endSelection.y; endPos.y = startSelection.y; } for (int y = startPos.y; y <= endPos.y; y++) { AddToSelection(new Vector3Int(startPos.x, y, 0)); } break; case ConstraintAxis.Y: startPos = startSelection; endPos = endSelection; ClearSelection(); //We don't want the size to be negative, so we flip it around if so if (startPos.x > endPos.x) { startPos.x = endSelection.x; endPos.x = startSelection.x; } for (int x = startPos.x; x <= endPos.x; x++) { AddToSelection(new Vector3Int(x, startPos.y, 0)); } break; case ConstraintAxis.Rectangle: startPos = startSelection; endPos = endSelection; ClearSelection(); //We don't want the size to be negative, so we flip it around if so if (startPos.x > endPos.x) { startPos.x = endSelection.x; endPos.x = startSelection.x; } if (startPos.y > endPos.y) { startPos.y = endSelection.y; endPos.y = startSelection.y; } for (int x = startPos.x; x <= endPos.x; x++) { for (int y = startPos.y; y <= endPos.y; y++) { AddToSelection(new Vector3Int(x, y, 0)); } } break; case ConstraintAxis.Single: ClearSelection(); AddToSelection(endSelection); break; } }