/// <summary>
        /// Initialize stereoscopic camera controller
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            this.headTrack = WaveServices.GetService <HeadTrackSensor>();

            this.leftLookAtEntity  = this.Owner.FindChild("leftLookAt");
            this.rightLookAtEntity = this.Owner.FindChild("rightLookAt");
            this.leftEyeEntity     = this.Owner.FindChild("leftEye");
            this.rightEyeEntity    = this.Owner.FindChild("rightEye");

            this.leftEye  = this.leftEyeEntity.FindComponent <Camera3D>();
            this.rightEye = this.rightEyeEntity.FindComponent <Camera3D>();

            this.leftLookAtTransform  = this.leftLookAtEntity.FindComponent <Transform3D>();
            this.rightLookAtTransform = this.rightLookAtEntity.FindComponent <Transform3D>();
            this.leftEyeTransform     = this.leftEyeEntity.FindComponent <Transform3D>();
            this.rightEyeTransform    = this.rightEyeEntity.FindComponent <Transform3D>();

            // Left eye
            this.leftEye.Viewport    = new Viewport(0, 0, 0.5f, 1);
            this.leftEye.FieldOfView = this.FieldOfView;
            this.leftEye.NearPlane   = this.NearPlane;
            this.leftEye.FarPlane    = this.FarPlane;

            // Right eye
            this.rightEye.Viewport    = new Viewport(0.5f, 0, 0.5f, 1);
            this.rightEye.FieldOfView = this.FieldOfView;
            this.rightEye.NearPlane   = this.NearPlane;
            this.rightEye.FarPlane    = this.FarPlane;

            this.isInitialized = true;
            this.RefreshCameraCalibration();
        }
示例#2
0
    void Start()
    {
        if (!sensor)
        {
            var sensorObj = new GameObject("HeadTrackSensor");
            sensor = sensorObj.AddComponent <HeadTrackSensor>();
        }

        vchar = GetComponent <Character>();

        sensor.headTrack = this;
        animator         = GetComponentInParent <Animator>();
        head             = animator.GetBoneTransform(HumanBodyBones.Head);
        var spine1 = animator.GetBoneTransform(HumanBodyBones.Spine);
        var spine2 = animator.GetBoneTransform(HumanBodyBones.Chest);

        spines = new List <Transform>();
        spines.Add(spine1);
        spines.Add(spine2);
        var neck = animator.GetBoneTransform(HumanBodyBones.Neck);

        if (neck.parent != spine2)
        {
            spines.Add(neck.parent);
        }

        if (head)
        {
            headHeight = Vector3.Distance(transform.position, head.position);
            sensor.transform.position = head.transform.position;
        }
        else
        {
            sensor.transform.position = transform.position;
        }

        var layer = LayerMask.NameToLayer("HeadTrack");

        sensor.transform.parent = transform;
        sensor.gameObject.layer = layer;
        sensor.gameObject.tag   = transform.tag;
        tagsHash = new List <int>();

        for (int i = 0; i < animatorTags.Count; i++)
        {
            tagsHash.Add(Animator.StringToHash(animatorTags[i]));
        }
        GetLookPoint();
    }