private ConstraintTestData SetupConstraintRig() { var data = new ConstraintTestData(); data.rigData = RuntimeRiggingTestFixture.SetupRigHierarchy(); var chainIKGO = new GameObject("chainIK"); var chainIK = chainIKGO.AddComponent <ChainIKConstraint>(); chainIK.Reset(); chainIKGO.transform.parent = data.rigData.rigGO.transform; chainIK.data.root = data.rigData.hipsGO.transform.Find("Chest"); Assert.IsNotNull(chainIK.data.root.transform, "Could not find root transform"); chainIK.data.tip = chainIK.data.root.transform.Find("LeftArm/LeftForeArm/LeftHand"); Assert.IsNotNull(chainIK.data.tip.transform, "Could not find tip transform"); var targetGO = new GameObject("target"); targetGO.transform.parent = chainIKGO.transform; chainIK.data.target = new JobTransform(targetGO.transform, true); data.rigData.rootGO.GetComponent <RigBuilder>().Build(); targetGO.transform.position = chainIK.data.tip.transform.position; data.constraint = chainIK; return(data); }
private ConstraintTestData SetupConstraintRig() { var data = new ConstraintTestData(); data.rigData = RuntimeRiggingTestFixture.SetupRigHierarchy(); var multiRotationGO = new GameObject("multiPosition"); var multiRotation = multiRotationGO.AddComponent <MultiRotationConstraint>(); multiRotation.Reset(); multiRotationGO.transform.parent = data.rigData.rigGO.transform; multiRotation.data.constrainedObject = data.rigData.hipsGO.transform; data.constrainedObjectRestRotation = multiRotation.data.constrainedObject.rotation; var sources = new WeightedTransformArray(); var src0GO = new GameObject("source0"); var src1GO = new GameObject("source1"); src0GO.transform.parent = multiRotationGO.transform; src1GO.transform.parent = multiRotationGO.transform; sources.Add(new WeightedTransform(src0GO.transform, 0f)); sources.Add(new WeightedTransform(src1GO.transform, 0f)); multiRotation.data.sourceObjects = sources; src0GO.transform.rotation = data.rigData.hipsGO.transform.rotation; src1GO.transform.rotation = data.rigData.hipsGO.transform.rotation; data.rigData.rootGO.GetComponent <RigBuilder>().Build(); data.constraint = multiRotation; return(data); }
public static ConstraintTestData SetupConstraintRig() { var data = new ConstraintTestData(); data.rigData = RuntimeRiggingTestFixture.SetupRigHierarchy(); var overrideTransformGO = new GameObject("overrideTransform"); var overrideTransform = overrideTransformGO.AddComponent <OverrideTransform>(); overrideTransform.Reset(); overrideTransformGO.transform.parent = data.rigData.rigGO.transform; overrideTransform.data.constrainedObject = data.rigData.hipsGO.transform.Find("Chest"); var overrideSourceGO = new GameObject("source"); overrideSourceGO.transform.parent = overrideTransformGO.transform; overrideTransform.data.sourceObject = overrideSourceGO.transform; data.rigData.rootGO.GetComponent <RigBuilder>().Build(); data.constraint = overrideTransform; return(data); }
private ConstraintTestData SetupConstraintRig() { var data = new ConstraintTestData(); data.rigData = RuntimeRiggingTestFixture.SetupRigHierarchy(); var dampedTransformGO = new GameObject("dampedTransform"); var dampedTransform = dampedTransformGO.AddComponent <DampedTransform>(); dampedTransform.Reset(); dampedTransformGO.transform.parent = data.rigData.rigGO.transform; dampedTransform.data.constrainedObject = data.rigData.hipsGO.transform.Find("Chest/LeftArm/LeftForeArm/LeftHand"); var dampedSourceGO = new GameObject("source"); dampedSourceGO.transform.parent = dampedTransformGO.transform; dampedTransform.data.sourceObject = new JobTransform(dampedSourceGO.transform, true); data.rigData.rootGO.GetComponent <RigBuilder>().Build(); data.constraint = dampedTransform; return(data); }
public static ConstraintTestData SetupConstraintRig() { var data = new ConstraintTestData(); data.rigData = RuntimeRiggingTestFixture.SetupRigHierarchy(); var blendConstraintGO = new GameObject("blendConstraint"); var blendConstraint = blendConstraintGO.AddComponent <BlendConstraint>(); blendConstraint.Reset(); blendConstraintGO.transform.parent = data.rigData.rigGO.transform; var leftForeArm = data.rigData.hipsGO.transform.Find("Chest/LeftArm/LeftForeArm"); var leftHand = leftForeArm.Find("LeftHand"); blendConstraint.data.sourceObjectA = leftForeArm; blendConstraint.data.sourceObjectB = leftHand; var constrainedObject = new GameObject("constrainedBlendObj"); constrainedObject.transform.parent = blendConstraintGO.transform; blendConstraint.data.constrainedObject = constrainedObject.transform; data.restPose = new AffineTransform(constrainedObject.transform.position, constrainedObject.transform.rotation); blendConstraint.data.positionWeight = blendConstraint.data.rotationWeight = 0.5f; blendConstraint.data.blendPosition = blendConstraint.data.blendRotation = true; data.rigData.rootGO.GetComponent <RigBuilder>().Build(); data.constraint = blendConstraint; return(data); }
private ConstraintTestData SetupConstraintRig() { var data = new ConstraintTestData(); data.rigData = RuntimeRiggingTestFixture.SetupRigHierarchy(); var twistCorrectionGO = new GameObject("twistCorrection"); var twistCorrection = twistCorrectionGO.AddComponent <TwistCorrection>(); twistCorrection.Reset(); twistCorrectionGO.transform.parent = data.rigData.rigGO.transform; var leftArm = data.rigData.hipsGO.transform.Find("Chest/LeftArm"); var leftForeArm = leftArm.Find("LeftForeArm"); var leftHand = leftForeArm.Find("LeftHand"); // Force zero rotation to simplify testing leftHand.rotation = Quaternion.identity; leftForeArm.rotation = Quaternion.identity; leftArm.rotation = Quaternion.identity; twistCorrection.data.sourceObject = leftHand; twistCorrection.data.twistAxis = TwistCorrectionData.Axis.X; data.restLocalRotation = leftHand.localRotation; var twistNodes = new WeightedTransformArray(); var twistNode0GO = new GameObject("twistNode0"); var twistNode1GO = new GameObject("twistNode1"); twistNode0GO.transform.parent = leftForeArm; twistNode1GO.transform.parent = leftForeArm; twistNode0GO.transform.SetPositionAndRotation(Vector3.Lerp(leftForeArm.position, leftHand.position, 0.25f), leftHand.rotation); twistNode1GO.transform.SetPositionAndRotation(Vector3.Lerp(leftForeArm.position, leftHand.position, 0.75f), leftHand.rotation); twistNodes.Add(new WeightedTransform(twistNode0GO.transform, 0f)); twistNodes.Add(new WeightedTransform(twistNode1GO.transform, 0f)); twistCorrection.data.twistNodes = twistNodes; data.rigData.rootGO.GetComponent <RigBuilder>().Build(); data.constraint = twistCorrection; return(data); }
public static ConstraintTestData SetupConstraintRig() { var data = new ConstraintTestData(); data.rigData = RuntimeRiggingTestFixture.SetupRigHierarchy(); var twistChainGO = new GameObject("twistChain"); var twistChain = twistChainGO.AddComponent <TwistChainConstraint>(); twistChain.Reset(); twistChainGO.transform.parent = data.rigData.rigGO.transform; twistChain.data.root = data.rigData.hipsGO.transform.Find("Chest/LeftArm"); Assert.IsNotNull(twistChain.data.root, "Could not find root transform"); twistChain.data.tip = twistChain.data.root.transform.Find("LeftForeArm/LeftHand"); Assert.IsNotNull(twistChain.data.tip, "Could not find tip transform"); var rootTargetGO = new GameObject("rootTarget"); rootTargetGO.transform.parent = twistChainGO.transform; var tipTargetGO = new GameObject("tipTarget"); tipTargetGO.transform.parent = twistChainGO.transform; twistChain.data.rootTarget = rootTargetGO.transform; twistChain.data.tipTarget = tipTargetGO.transform; data.rigData.rootGO.GetComponent <RigBuilder>().Build(); rootTargetGO.transform.position = twistChain.data.root.position; rootTargetGO.transform.rotation = twistChain.data.root.rotation; tipTargetGO.transform.position = twistChain.data.tip.position; tipTargetGO.transform.rotation = twistChain.data.tip.rotation; data.constraint = twistChain; return(data); }
public static ConstraintTestData SetupConstraintRig() { var data = new ConstraintTestData(); data.rigData = RuntimeRiggingTestFixture.SetupRigHierarchy(); var multiParentGO = new GameObject("multiParent"); var multiParent = multiParentGO.AddComponent <MultiParentConstraint>(); multiParent.Reset(); multiParentGO.transform.parent = data.rigData.rigGO.transform; multiParent.data.constrainedObject = data.rigData.hipsGO.transform; data.constrainedObjectRestTx = new AffineTransform( multiParent.data.constrainedObject.position, multiParent.data.constrainedObject.rotation ); var sources = new WeightedTransformArray(); var src0GO = new GameObject("source0"); var src1GO = new GameObject("source1"); src0GO.transform.parent = multiParentGO.transform; src1GO.transform.parent = multiParentGO.transform; sources.Add(new WeightedTransform(src0GO.transform, 0f)); sources.Add(new WeightedTransform(src1GO.transform, 0f)); multiParent.data.sourceObjects = sources; var pos = data.rigData.hipsGO.transform.position; var rot = data.rigData.hipsGO.transform.rotation; src0GO.transform.SetPositionAndRotation(pos, rot); src1GO.transform.SetPositionAndRotation(pos, rot); data.rigData.rootGO.GetComponent <RigBuilder>().Build(); data.constraint = multiParent; return(data); }
private ConstraintTestData SetupConstraintRig() { var data = new ConstraintTestData(); data.rigData = RuntimeRiggingTestFixture.SetupRigHierarchy(); var twoBoneIKGO = new GameObject("twoBoneIK"); var twoBoneIK = twoBoneIKGO.AddComponent <TwoBoneIKConstraint>(); twoBoneIK.Reset(); twoBoneIKGO.transform.parent = data.rigData.rigGO.transform; twoBoneIK.data.root = data.rigData.hipsGO.transform.Find("Chest/LeftArm"); Assert.IsNotNull(twoBoneIK.data.root, "Could not find root transform"); twoBoneIK.data.mid = twoBoneIK.data.root.transform.Find("LeftForeArm"); Assert.IsNotNull(twoBoneIK.data.mid, "Could not find mid transform"); twoBoneIK.data.tip = twoBoneIK.data.mid.transform.Find("LeftHand"); Assert.IsNotNull(twoBoneIK.data.tip, "Could not find tip transform"); var targetGO = new GameObject("target"); targetGO.transform.parent = twoBoneIKGO.transform; var hintGO = new GameObject("hint"); hintGO.transform.parent = twoBoneIKGO.transform; twoBoneIK.data.target = targetGO.transform; twoBoneIK.data.hint = hintGO.transform; data.rigData.rootGO.GetComponent <RigBuilder>().Build(); targetGO.transform.position = twoBoneIK.data.tip.position; data.constraint = twoBoneIK; return(data); }
public static ConstraintTestData SetupConstraintRig() { var data = new ConstraintTestData(); data.rigData = RuntimeRiggingTestFixture.SetupRigHierarchy(); var multiRefGO = new GameObject("multiReferential"); var multiRef = multiRefGO.AddComponent <MultiReferentialConstraint>(); multiRef.Reset(); multiRefGO.transform.parent = data.rigData.rigGO.transform; List <Transform> sources = new List <Transform>(3); var src0GO = new GameObject("source0"); var src1GO = new GameObject("source1"); src0GO.transform.parent = multiRefGO.transform; src1GO.transform.parent = multiRefGO.transform; sources.Add(data.rigData.hipsGO.transform); sources.Add(src0GO.transform); sources.Add(src1GO.transform); multiRef.data.sourceObjects = sources; multiRef.data.driver = 0; var pos = data.rigData.hipsGO.transform.position; var rot = data.rigData.hipsGO.transform.rotation; src0GO.transform.SetPositionAndRotation(pos, rot); src1GO.transform.SetPositionAndRotation(pos, rot); data.restPose = new AffineTransform(pos, rot); data.rigData.rootGO.GetComponent <RigBuilder>().Build(); data.constraint = multiRef; return(data); }
public static ConstraintTestData SetupConstraintRig() { var data = new ConstraintTestData(); data.rigData = RuntimeRiggingTestFixture.SetupRigHierarchy(); var multiAimGO = new GameObject("multiAim"); var multiAim = multiAimGO.AddComponent <MultiAimConstraint>(); multiAim.Reset(); multiAimGO.transform.parent = data.rigData.rigGO.transform; var head = data.rigData.hipsGO.transform.Find("Chest/Head"); multiAim.data.constrainedObject = head; var sources = new WeightedTransformArray(); var src0GO = new GameObject("source0"); var src1GO = new GameObject("source1"); src0GO.transform.parent = multiAimGO.transform; src1GO.transform.parent = multiAimGO.transform; sources.Add(new WeightedTransform(src0GO.transform, 0f)); sources.Add(new WeightedTransform(src1GO.transform, 0f)); multiAim.data.sourceObjects = sources; multiAim.data.aimAxis = MultiAimConstraintData.Axis.Z; data.constrainedObjectRestTx = new AffineTransform(head.position, head.rotation); src0GO.transform.SetPositionAndRotation(data.constrainedObjectRestTx.translation + Vector3.forward, data.constrainedObjectRestTx.rotation); src1GO.transform.SetPositionAndRotation(data.constrainedObjectRestTx.translation + Vector3.forward, data.constrainedObjectRestTx.rotation); data.rigData.rootGO.GetComponent <RigBuilder>().Build(); data.constraint = multiAim; return(data); }