public override bool isActive(SSSkeletalJointRuntime joint)
 {
     if (_topLevelActiveJoints == null)
     {
         return(true);
     }
     else
     {
         bool jointIsControlled;
         int  jointIdx = joint.baseInfo.jointIndex;
         if (_jointIsControlledCache.ContainsKey(jointIdx))
         {
             jointIsControlled = _jointIsControlledCache [jointIdx];
         }
         else
         {
             if (_topLevelActiveJoints.Contains(jointIdx))
             {
                 jointIsControlled = true;
             }
             else if (joint.baseInfo.parentIndex == -1)
             {
                 jointIsControlled = false;
             }
             else
             {
                 jointIsControlled = isActive(joint.parent);
             }
             _jointIsControlledCache [jointIdx] = jointIsControlled;
         }
         return(jointIsControlled);
     }
 }
Пример #2
0
        private void _traverseWithControllers(SSSkeletalJointRuntime joint, List <SSSkeletalChannelController> controllers)
        {
            joint.currentLocation = _computeJointLocWithControllers(joint, controllers, controllers.Count - 1);

            foreach (var child in joint.children)
            {
                _traverseWithControllers(child, controllers);
            }
        }
        public override SSSkeletalJointLocation computeJointLocation(SSSkeletalJointRuntime joint)
        {
            if (_neutralViewDirty)
            {
                Quaternion precedingBindPoseOrient = Quaternion.Identity;
                for (var j = joint.parent; j != null; j = j.parent)
                {
                    precedingBindPoseOrient = Quaternion.Multiply(
                        joint.baseInfo.bindPoseLocation.orientation, precedingBindPoseOrient);
                }
                Quaternion precedingInverted = precedingBindPoseOrient.Inverted();
                _neutralViewDirectionLocal = Vector3.Transform(_neutralViewDirectionBindPose, precedingInverted)
                                             .Normalized();
                _neutralViewUpLocal = Vector3.Transform(_neutralViewUpBindPose, precedingInverted)
                                      .Normalized();
                _neutralViewYLocal = Vector3.Transform(
                    Vector3.Cross(_neutralViewDirectionBindPose, _neutralViewUpBindPose), precedingInverted)
                                     .Normalized();
                _neutralViewDirty = false;
            }

            SSSkeletalJointLocation ret = new SSSkeletalJointLocation();

            ret.position = jointPositionLocal;

            if (targetObject != null)
            {
                Vector3 targetPosInMesh
                    = Vector3.Transform(targetObject.Pos, _hostObject.worldMat.Inverted());
                Vector3 targetPosInLocal = targetPosInMesh;
                if (joint.parent != null)
                {
                    targetPosInLocal = joint.parent.currentLocation.undoTransformTo(targetPosInLocal);
                }
                Vector3 targetDirLocal = targetPosInLocal - jointPositionLocal;
                Vector3 nvDir          = new Vector3();
                nvDir.X = Vector3.Dot(targetDirLocal, _neutralViewDirectionLocal);
                nvDir.Y = Vector3.Dot(targetDirLocal, _neutralViewYLocal);
                nvDir.Z = Vector3.Dot(targetDirLocal, _neutralViewUpLocal);

                float theta = -(float)Math.Atan2(nvDir.Y, nvDir.X);
                float phi   = (float)Math.Atan2(nvDir.Z, nvDir.Xy.LengthFast);

                Quaternion neededRotation = Quaternion.FromAxisAngle(_neutralViewUpLocal, theta)
                                            * Quaternion.FromAxisAngle(_neutralViewYLocal, phi);
                ret.orientation = neutralViewOrientationLocal * neededRotation;
            }
            else
            {
                ret.orientation = neutralViewOrientationLocal;
            }
            return(ret);
        }
Пример #4
0
        public override SSSkeletalJointLocation computeJointLocation(SSSkeletalJointRuntime joint)
        {
            SSSkeletalJointLocation ret;

            ret.position = positionOffset;

            var thetaRot = Quaternion.FromAxisAngle(thetaAxis, theta.value);
            var phiRot   = Quaternion.FromAxisAngle(phiAxis, phi.value);

            ret.orientation = Quaternion.Multiply(thetaRot, phiRot);
            return(ret);
        }
 public SSSkeletalHierarchyRuntime(SSSkeletalJoint[] joints)
 {
     _joints = new SSSkeletalJointRuntime[joints.Length];
     for (int j = 0; j < joints.Length; ++j) {
         var jointInput = joints [j];
         _joints [j] = new SSSkeletalJointRuntime(jointInput);
         int parentIdx = jointInput.parentIndex;
         if (parentIdx < 0) {
             _topLevelJoints.Add (j);
         } else {
             _joints [j].parent = _joints [parentIdx];
             _joints [parentIdx].children.Add (_joints[j]);
         }
     }
 }
        public override SSSkeletalJointLocation computeJointLocation(SSSkeletalJointRuntime joint)
        {
            if (_neutralViewDirty) {
                Quaternion precedingBindPoseOrient = Quaternion.Identity;
                for (var j = joint.parent; j != null; j = j.parent) {
                    precedingBindPoseOrient = Quaternion.Multiply (
                        joint.baseInfo.bindPoseLocation.orientation, precedingBindPoseOrient);
                }
                Quaternion precedingInverted = precedingBindPoseOrient.Inverted ();
                _neutralViewDirectionLocal = Vector3.Transform (_neutralViewDirectionBindPose, precedingInverted)
                    .Normalized();
                _neutralViewUpLocal = Vector3.Transform (_neutralViewUpBindPose, precedingInverted)
                    .Normalized();
                _neutralViewYLocal = Vector3.Transform (
                    Vector3.Cross (_neutralViewDirectionBindPose, _neutralViewUpBindPose), precedingInverted)
                    .Normalized();
                _neutralViewDirty = false;
            }

            SSSkeletalJointLocation ret = new SSSkeletalJointLocation ();
            ret.position = jointPositionLocal;

            if (targetObject != null) {
                Vector3 targetPosInMesh
                    = Vector3.Transform (targetObject.Pos, _hostObject.worldMat.Inverted());
                Vector3 targetPosInLocal = targetPosInMesh;
                if (joint.parent != null) {
                    targetPosInLocal = joint.parent.currentLocation.undoTransformTo (targetPosInLocal);
                }
                Vector3 targetDirLocal = targetPosInLocal - jointPositionLocal;
                Vector3 nvDir = new Vector3();
                nvDir.X = Vector3.Dot (targetDirLocal, _neutralViewDirectionLocal);
                nvDir.Y = Vector3.Dot (targetDirLocal, _neutralViewYLocal);
                nvDir.Z = Vector3.Dot (targetDirLocal, _neutralViewUpLocal);

                float theta = -(float)Math.Atan2 (nvDir.Y, nvDir.X);
                float phi = (float)Math.Atan2 (nvDir.Z, nvDir.Xy.LengthFast);

                Quaternion neededRotation = Quaternion.FromAxisAngle (_neutralViewUpLocal, theta)
                                          * Quaternion.FromAxisAngle (_neutralViewYLocal, phi);
                ret.orientation = neutralViewOrientationLocal * neededRotation;
            } else {
                ret.orientation = neutralViewOrientationLocal;
            }
            return ret;
        }
Пример #7
0
 public SSSkeletalHierarchyRuntime(SSSkeletalJoint[] joints)
 {
     _joints = new SSSkeletalJointRuntime[joints.Length];
     for (int j = 0; j < joints.Length; ++j)
     {
         var jointInput = joints [j];
         _joints [j] = new SSSkeletalJointRuntime(jointInput);
         int parentIdx = jointInput.parentIndex;
         if (parentIdx < 0)
         {
             _topLevelJoints.Add(j);
         }
         else
         {
             _joints [j].parent = _joints [parentIdx];
             _joints [parentIdx].children.Add(_joints[j]);
         }
     }
 }
 public override bool isActive(SSSkeletalJointRuntime joint)
 {
     if (_topLevelActiveJoints == null) {
         return true;
     } else {
         bool jointIsControlled;
         int jointIdx = joint.baseInfo.jointIndex;
         if (_jointIsControlledCache.ContainsKey (jointIdx)) {
             jointIsControlled = _jointIsControlledCache [jointIdx] ;
         } else {
             if (_topLevelActiveJoints.Contains (jointIdx)) {
                 jointIsControlled = true;
             } else if (joint.baseInfo.parentIndex == -1) {
                 jointIsControlled = false;
             } else {
                 jointIsControlled = isActive(joint.parent);
             }
             _jointIsControlledCache [jointIdx] = jointIsControlled;
         }
         return jointIsControlled;
     }
 }
Пример #9
0
        private SSSkeletalJointLocation _computeJointLocWithControllers(
            SSSkeletalJointRuntime joint, List <SSSkeletalChannelController> controllers, int controllerIdx)
        {
            var channel = controllers [controllerIdx];

            if (channel.isActive(joint))
            {
                var channelLoc = channel.computeJointLocation(joint);
                if (joint.parent != null)
                {
                    channelLoc.applyPrecedingTransform(joint.parent.currentLocation);
                }
                if (!channel.interChannelFade ||
                    channel.interChannelFadeIndentisy() >= 1f ||
                    controllerIdx == 0)
                {
                    return(channelLoc);
                }
                else
                {
                    var fallbackLoc
                        = _computeJointLocWithControllers(joint, controllers, controllerIdx - 1);
                    return(SSSkeletalJointLocation.interpolate(
                               fallbackLoc, channelLoc, channel.interChannelFadeIndentisy()));
                }
            }
            else
            {
                if (controllerIdx > 0)
                {
                    return(_computeJointLocWithControllers(joint, controllers, controllerIdx - 1));
                }
                else
                {
                    throw new Exception("fell through without an active skeletal channel controller");
                }
            }
        }
 public virtual bool isActive(SSSkeletalJointRuntime joint)
 {
     return true;
 }
 public override SSSkeletalJointLocation computeJointLocation(SSSkeletalJointRuntime joint)
 {
     return(_channelManager.computeJointFrame(joint.baseInfo.jointIndex));
 }
 /// <summary>
 /// Returns joint location, defined as displacement from the parent location
 /// (see SSJointLocation.ApplyPrecedingTransform())
 /// </summary>
 public abstract SSSkeletalJointLocation computeJointLocation(SSSkeletalJointRuntime joint);
 public override SSSkeletalJointLocation computeJointLocation(SSSkeletalJointRuntime joint)
 {
     // play nice with the rest of the controllers by applying a change in coordinates; not
     // just setting absolute coordinates:
     return(joint.baseInfo.bindPoseLocation);
 }
 public override SSSkeletalJointLocation computeJointLocation(SSSkeletalJointRuntime joint)
 {
     return _channelManager.computeJointFrame (joint.baseInfo.jointIndex);
 }
        private SSSkeletalJointLocation _computeJointLocWithControllers(
			SSSkeletalJointRuntime joint, List<SSSkeletalChannelController> controllers, int controllerIdx)
        {
            var channel = controllers [controllerIdx];
            if (channel.isActive(joint)) {
                var channelLoc = channel.computeJointLocation (joint);
                if (joint.parent != null) {
                    channelLoc.applyPrecedingTransform (joint.parent.currentLocation);
                }
                if (!channel.interChannelFade
                    || channel.interChannelFadeIndentisy() >= 1f
                    || controllerIdx == 0) {
                    return channelLoc;
                } else {
                    var fallbackLoc
                    = _computeJointLocWithControllers (joint, controllers, controllerIdx - 1);
                    return SSSkeletalJointLocation.interpolate (
                        fallbackLoc, channelLoc, channel.interChannelFadeIndentisy());
                }
            } else {
                if (controllerIdx > 0) {
                    return _computeJointLocWithControllers (joint, controllers, controllerIdx - 1);
                } else {
                    throw new Exception ("fell through without an active skeletal channel controller");
                }
            }
        }
        private void _traverseWithControllers(SSSkeletalJointRuntime joint, List<SSSkeletalChannelController> controllers)
        {
            joint.currentLocation = _computeJointLocWithControllers (joint, controllers, controllers.Count - 1);

            foreach (var child in joint.children) {
                _traverseWithControllers (child, controllers);
            }
        }
 public override SSSkeletalJointLocation computeJointLocation(SSSkeletalJointRuntime joint)
 {
     return _joints [joint.baseInfo.jointIndex].computeJointLocation (joint);
 }
 public override SSSkeletalJointLocation computeJointLocation(SSSkeletalJointRuntime joint)
 {
     // play nice with the rest of the controllers by applying a change in coordinates; not
     // just setting absolute coordinates:
     return joint.baseInfo.bindPoseLocation;
 }
Пример #19
0
 public override SSSkeletalJointLocation computeJointLocation(SSSkeletalJointRuntime joint)
 {
     return(_joints [joint.baseInfo.jointIndex].computeJointLocation(joint));
 }
 /// <summary>
 /// Returns joint location, defined as displacement from the parent location
 /// (see SSJointLocation.ApplyPrecedingTransform())
 /// </summary>
 public abstract SSSkeletalJointLocation computeJointLocation(SSSkeletalJointRuntime joint);
 public override bool isActive(SSSkeletalJointRuntime joint)
 {
     int jidx = joint.baseInfo.jointIndex;
     return _joints.ContainsKey (jidx) && _joints [jidx].isActive (joint);
 }
 public virtual bool isActive(SSSkeletalJointRuntime joint)
 {
     return(true);
 }
Пример #23
0
        public override bool isActive(SSSkeletalJointRuntime joint)
        {
            int jidx = joint.baseInfo.jointIndex;

            return(_joints.ContainsKey(jidx) && _joints [jidx].isActive(joint));
        }