Example #1
0
 public static void CopyData(this ISkeleton src, ISkeleton dst)
 {
     if (src == null || dst == null)
     {
         return;
     }
     if (src.JointTable.Count != dst.JointTable.Count || src.Uid != dst.Uid)
     {
         dst.ClearAll();
         dst.Root = src.Root?.DeepCopy() ?? dst.Root;
         dst.BuildJointTable();
         dst.Uid = src.Uid;
     }
     if (src.JointTable != null)
     {
         foreach (var joint in src.JointTable.Keys)
         {
             if (!dst.JointTable.ContainsKey(joint))
             {
                 continue;
             }
             dst.JointTable[joint].BaseTransform      = src.JointTable[joint].BaseTransform;
             dst.JointTable[joint].AnimationTransform = src.JointTable[joint].AnimationTransform;
         }
     }
 }
Example #2
0
 public NewJoint()
 {
     //the nodes constructor
     //nothing to declare for this node
     FRootJoint    = new JointInfo();
     FRootJoint.Id = 0;
     FSkeleton     = new Skeleton(FRootJoint);
     FSkeleton.BuildJointTable();
     FChildPins = new List <INodeIn>();
 }
Example #3
0
        public NewJoint()
        {
            //the nodes constructor
            //nothing to declare for this node
            rootJoint      = new JointInfo();
            rootJoint.Id   = 0;
            outputSkeleton = new Skeleton(rootJoint);
            outputSkeleton.BuildJointTable();
            childPins = new List <INodeIn>();

            guids    = new System.Guid[1];
            guids[0] = new Guid("AB312E34-8025-40F2-8241-1958793F3D39");
        }
Example #4
0
        //here we go, thats the method called by vvvv each frame
        //all data handling should be in here
        public void Evaluate(int SpreadMax)
        {
            //if any of the inputs has changed
            //recompute the outputs
            if (FJointNameInput.PinIsChanged)
            {
                string name;
                FJointNameInput.GetString(0, out name);
                if (!string.IsNullOrEmpty(name))
                {
                    FRootJoint.Name = name;
                    FSkeleton.BuildJointTable();
                    FSkeletonOutput.MarkPinAsChanged();
                }
            }

            if (FChildPins.Any(c => c.PinIsChanged))
            {
                FSkeleton.ClearAll();
                FSkeleton.Root = FRootJoint;
                FSkeleton.BuildJointTable();

                for (int i = 0; i < FChildPins.Count; i++)
                {
                    if (true)             //childPinsList[i].PinIsChanged)
                    {
                        FSkeletonOutput.MarkPinAsChanged();
                        if (FChildPins[i].IsConnected)
                        {
                            object currInterface;
                            FChildPins[i].GetUpstreamInterface(out currInterface);
                            ISkeleton subSkeleton = (ISkeleton)currInterface;
                            IJoint    child       = subSkeleton.Root.DeepCopy();
                            FSkeleton.InsertJoint(FSkeleton.Root.Name, child);
                            FSkeleton.BuildJointTable();
                        }
                    }
                }

                // re-calculate the IDs ...
                int currId = 0;
                foreach (KeyValuePair <string, IJoint> pair in FSkeleton.JointTable)
                {
                    pair.Value.Id = currId;
                    currId++;
                }
            }

            if (FBaseTransformInput.PinIsChanged)
            {
                Matrix4x4 baseTransform;
                FBaseTransformInput.GetMatrix(0, out baseTransform);
                FRootJoint.BaseTransform = baseTransform;
                FSkeletonOutput.MarkPinAsChanged();
            }

            if (FRotationConstraintsInput.PinIsChanged)
            {
                FRootJoint.Constraints.Clear();
                for (int i = 0; i < 3; i++)
                {
                    double from, to;
                    FRotationConstraintsInput.GetValue2D(i, out from, out to);
                    FRootJoint.Constraints.Add(new Vector2D(from, to));
                }
                FSkeletonOutput.MarkPinAsChanged();
            }

            FSkeletonOutput.SetInterface(FSkeleton);
        }