Example #1
0
 public Joint(string name, int id, int parentId, Vector3 translation, Vector3 rotation, Vector3 scale, List<int> indices, List<float> weights)
 {
     _name = name;
     _id = id;
     _parentId = parentId;
     _parent = null;
     _children = new List<Joint>();
     _translation = Matrix.CreateTranslation(translation);
     _rotation = Matrix.CreateRotationX(MathHelper.ToRadians(rotation.X));
     _rotation *= Matrix.CreateRotationY(MathHelper.ToRadians(rotation.Y));
     _rotation *= Matrix.CreateRotationZ(MathHelper.ToRadians(rotation.Z));
     _scale = Matrix.CreateScale(scale);
     _transformation = _scale * _rotation * _translation;
     _indices = indices;
     _weights = weights;
 }
Example #2
0
 public void AddJoint(Joint joint)
 {
     if (joint.IsRootJoint)
     {
         _rootJoint = joint;
         UpdateChildren();
     }
     else if (_rootJoint == null)
     {
         _unTreedJoints.Add(joint);
         return;
     }
     else
     {
         _unTreedJoints.Add(joint);
         UpdateChildren();
     }
 }
Example #3
0
        public bool AddChildNode(Joint child)
        {
            // If the child Joint is the parent of the child we need to add.
            if (_id == child.ParentId)
            {
                child._parent = this;
                _children.Add(child);
                return true;
            }

            // If the child Joint is not this Joint's child, check through the current children
            // of this Joint.
            for (int i = 0; i < _children.Count; i++)
            {
                bool done = _children[i].AddChildNode(child);

                if (done)
                    return true;
            }

            // If this Joint and it's children are not the parent or we hit the end Joint,
            // just go back up the tree.
            return false;
        }
Example #4
0
        private void Init(Joint parent)
        {
            _parent = parent;

            foreach (Joint j in _children)
                j.Init(this);
        }
Example #5
0
        public void Init()
        {
            _parent = this;

            foreach (Joint j in _children)
                j.Init(this);
        }
Example #6
0
 public Skeleton()
 {
     _rootJoint = null;
     _unTreedJoints = new List<Joint>();
 }