Beispiel #1
0
 public void OnWorldObjectInitialized(VJoint worldObject)
 {
     if (worldObjects.ContainsKey(worldObject.id))
     {
         Debug.LogWarning("WorldObject with id " + worldObject.id + " already known. Ignored.");
     }
     else
     {
         worldObjects.Add(worldObject.id, worldObject);
     }
 }
Beispiel #2
0
 public VJoint(string name, string hAnimName, VJoint parent, Vector3 position, Quaternion rotation)
 {
     this.parent = parent;
     this.id     = name;
     if (hAnimName == "")
     {
         this.hAnimName = "_no_HAnim_" + name;
     }
     else
     {
         this.hAnimName = hAnimName;
     }
     this.position = position;
     this.rotation = rotation;
 }
        protected VJoint[] GenerateVJoints()
        {
            VJoint[] res = new VJoint[bones.Length];
            Dictionary <string, VJoint> lut = new Dictionary <string, VJoint>();

            for (int b = 0; b < bones.Length; b++)
            {
                VJoint parent = null;
                if (b > 0)
                {
                    parent = lut[bones[b].parent.name];
                    if (GetHAnimName(parent.id) == "")
                    {
                        Debug.Log(bones[b].name + " is not child of HAnim bone (" + parent.id + ").");
                    }
                }

                // Default HAnim skeleton has rotation that aligns with global Zero COS
                Quaternion rot = Quaternion.identity;


                Vector3 position = bones[b].position;
                if (b > 0)
                {
                    // For ASAP IK to work, we need to make sure that the local Position we pass is
                    //  relative to a parent bone with a COS that is also aligned with global Zero COS
                    //  ...so ".localPosition" is not enough.
                    position = Quaternion.Inverse(Quaternion.identity) * (bones[b].position - bones[b].parent.position);
                    // Note: Of course the inverse of the identity is the identity, however, just in case
                    //  we ever use a different global Zero COS, we might have a non-identity rotation to
                    //  throw in here
                }
                res[b] = new VJoint(bones[b].name, GetHAnimName(bones[b].name), position, rot, parent);
                lut.Add(bones[b].name, res[b]);
            }
            return(res);
        }
Beispiel #4
0
 public VJoint(string name, string hAnimName, Vector3 position, Quaternion rotation, VJoint parent) : this(name, hAnimName, parent, position, rotation)
 {
 }
 // Use this for initialization
 void Start()
 {
     vjoint = new VJoint(transform.name, transform.position, transform.rotation);
     FindObjectOfType <ASAPManager>().OnWorldObjectInitialized(vjoint);
 }