UpdatePose() public method

public UpdatePose ( float voiceAmplitude ) : void
voiceAmplitude float
return void
コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        if (Driver != null)
        {
            // Get the current pose from the driver
            OvrAvatarDriver.PoseFrame pose;
            if (Driver.GetCurrentPose(out pose))
            {
                // If we're recording, record the pose
                if (RecordPackets)
                {
                    RecordFrame(Time.deltaTime, pose);
                }

                // Update the various avatar components with this pose
                if (ControllerLeft != null)
                {
                    ControllerLeft.UpdatePose(pose.controllerLeftPose);
                }
                if (ControllerRight != null)
                {
                    ControllerRight.UpdatePose(pose.controllerRightPose);
                }
                if (HandLeft != null)
                {
                    HandLeft.UpdatePose(pose.controllerLeftPose);
                }
                if (HandRight != null)
                {
                    HandRight.UpdatePose(pose.controllerRightPose);
                }
                if (Body != null)
                {
                    Body.UpdatePose(pose.voiceAmplitude);
                }

                if (sdkAvatar != IntPtr.Zero)
                {
                    ovrAvatarTransform      bodyTransform   = CreateOvrAvatarTransform(pose.headPosition, pose.headRotation);
                    ovrAvatarHandInputState inputStateLeft  = CreateInputState(CreateOvrAvatarTransform(pose.handLeftPosition, pose.handLeftRotation), pose.controllerLeftPose);
                    ovrAvatarHandInputState inputStateRight = CreateInputState(CreateOvrAvatarTransform(pose.handRightPosition, pose.handRightRotation), pose.controllerRightPose);

                    foreach (float[] voiceUpdate in voiceUpdates)
                    {
                        Oculus.Avatar.CAPI.ovrAvatarPose_UpdateVoiceVisualization(sdkAvatar, voiceUpdate);
                    }
                    voiceUpdates.Clear();

                    Oculus.Avatar.CAPI.ovrAvatarPose_UpdateBody(sdkAvatar, bodyTransform);
                    Oculus.Avatar.CAPI.ovrAvatarPose_UpdateHands(sdkAvatar, inputStateLeft, inputStateRight);
                    Oculus.Avatar.CAPI.ovrAvatarPose_Finalize(sdkAvatar, Time.deltaTime);
                }
            }
        }
        if (sdkAvatar != IntPtr.Zero && assetLoadingIds.Count == 0)
        {
            //If all of the assets for this avatar have been loaded, update the avatar
            UpdateSDKAvatarUnityState();

            UpdateCustomPoses();

            if (!assetsFinishedLoading)
            {
                AssetsDoneLoading.Invoke();
                assetsFinishedLoading = true;
            }
        }
    }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        if (Driver != null)
        {
            // Get the current pose from the driver
            OvrAvatarDriver.PoseFrame pose;
            if (Driver.GetCurrentPose(out pose))
            {
                // If we're recording, record the pose
                if (RecordPackets)
                {
                    RecordFrame(Time.deltaTime, pose);
                }

                // Update the various avatar components with this pose
                if (ControllerLeft != null)
                {
                    ControllerLeft.UpdatePose(pose.controllerLeftPose);
                }
                if (ControllerRight != null)
                {
                    ControllerRight.UpdatePose(pose.controllerRightPose);
                }
                if (HandLeft != null)
                {
                    HandLeft.UpdatePose(pose.controllerLeftPose);
                }
                if (HandRight != null)
                {
                    HandRight.UpdatePose(pose.controllerRightPose);
                }
                if (Body != null)
                {
                    Body.UpdatePose(pose.voiceAmplitude);
                }

                if (sdkAvatar != IntPtr.Zero)
                {
                    ovrAvatarTransform      bodyTransform   = CreateOvrAvatarTransform(pose.headPosition, pose.headRotation);
                    ovrAvatarHandInputState inputStateLeft  = CreateInputState(CreateOvrAvatarTransform(pose.handLeftPosition, pose.handLeftRotation), pose.controllerLeftPose);
                    ovrAvatarHandInputState inputStateRight = CreateInputState(CreateOvrAvatarTransform(pose.handRightPosition, pose.handRightRotation), pose.controllerRightPose);

                    foreach (float[] voiceUpdate in voiceUpdates)
                    {
                        CAPI.ovrAvatarPose_UpdateVoiceVisualization(sdkAvatar, voiceUpdate);
                    }
                    voiceUpdates.Clear();

                    CAPI.ovrAvatarPose_UpdateBody(sdkAvatar, bodyTransform);
                    CAPI.ovrAvatarPose_UpdateHands(sdkAvatar, inputStateLeft, inputStateRight);
                    CAPI.ovrAvatarPose_Finalize(sdkAvatar, Time.deltaTime);
                }
            }
        }
        if (sdkAvatar != IntPtr.Zero && assetLoadingIds.Count == 0)
        {
            //If all of the assets for this avatar have been loaded, update the avatar
            UpdateSDKAvatarUnityState();

            UpdateCustomPoses();

            if (!assetsFinishedLoading)
            {
                AssetsDoneLoading.Invoke();
                assetsFinishedLoading = true;
            }
        }

        /*
         * if(leftHandCollider)
         * {
         *  if ((OVRInput.Get(OVRInput.RawAxis1D.LIndexTrigger) > triggerGrabDeadzone || OVRInput.Get(OVRInput.RawAxis1D.LHandTrigger) > triggerGrabDeadzone) && !leftGrabbingObject)
         *  {
         *      //leftHandCollider.enabled = true;
         *      leftHandCollider.isTrigger = false;
         *  }
         *  else
         *  {
         *      leftHandCollider.isTrigger = true;
         *      //leftHandCollider.enabled = false;
         *  }
         * }
         * if (rightHandCollider)
         * {
         *  if ((OVRInput.Get(OVRInput.RawAxis1D.RIndexTrigger) > triggerGrabDeadzone || OVRInput.Get(OVRInput.RawAxis1D.RHandTrigger) > triggerGrabDeadzone) && !rightGrabbingObject)
         *  {
         *      rightHandCollider.isTrigger = false;
         *      //rightHandCollider.enabled = true;
         *
         *  }
         *  else
         *  {
         *      rightHandCollider.isTrigger = true;
         *      //rightHandCollider.enabled = false;
         *  }
         * }
         */
    }