Example #1
0
        void StartBody(BodyModel body)
        {
            body.parts.Clear();

            StartPart(body.root);

            body.registry.ForEach((c) => { if (c.gameObject.activeSelf)
                                           {
                                               c.ControllerStart();
                                           }
                                  });
        }
Example #2
0
        void UpdateBody(BodyModel body)
        {
            if (body.followCamera && !body.moveThisAsHead && body.head)
            {
                body.moveThisAsHead = body.head.transformRef;
            }

            if (body.replicatedTsf && !body.referenceTsf)
            {
                body.referenceTsf = HPTK.core.trackingSpace;
            }

            if (body.followCamera && body.moveThisAsHead && HPTK.core.trackedCamera)
            {
                if (body.referenceTsf && body.replicatedTsf)
                {
                    Vector3    relPos = body.referenceTsf.InverseTransformPoint(HPTK.core.trackedCamera.position);
                    Quaternion relRot = Quaternion.Inverse(body.referenceTsf.rotation) * HPTK.core.trackedCamera.rotation;

                    body.moveThisAsHead.position = body.replicatedTsf.TransformPoint(relPos);
                    body.moveThisAsHead.rotation = body.replicatedTsf.rotation * relRot;
                }
                else
                {
                    body.moveThisAsHead.position = HPTK.core.trackedCamera.position;
                    body.moveThisAsHead.rotation = HPTK.core.trackedCamera.rotation;
                }
            }

            body.parts.ForEach(p => { if (p.gameObject.activeSelf)
                                      {
                                          UpdatePart(p);
                                      }
                               });

            // Update registered controllers

            if (HPTK.core.controlsUpdateCalls)
            {
                body.registry.ForEach((c) => { if (c.gameObject.activeSelf)
                                               {
                                                   c.ControllerUpdate();
                                               }
                                      });
            }
        }
Example #3
0
        public override sealed void Awake()
        {
            base.Awake();

            GetView();

            if (!parent)
            {
                parent = transform.parent.GetComponent <PartModel>();
            }
            if (!body)
            {
                body = transform.parent.GetComponent <BodyModel>();
            }

            parts.RemoveAll(p => p == null);
            bones.RemoveAll(b => b == null);

            if (parent)
            {
                if (!parent.parts.Contains(this))
                {
                    parent.parts.Add(this);
                }
            }
            else
            {
                if (!body)
                {
                    Debug.LogError("Part without parent is interpreted as root part and it requires a body. Move " + transform.name + " as child of a BodyModel in hierarchy");
                }
                else if (body.root != null && body.root != this)
                {
                    Debug.LogWarning("Multiple body roots were found. Preserving original root");
                }
                else
                {
                    body.root = this;
                }
            }

            _registry = registry;

            PartAwake();
        }
Example #4
0
 public override sealed void Awake()
 {
     base.Awake();
     model = GetComponent <BodyModel>();
 }