Ejemplo n.º 1
0
    void Start()
    {
        // check if fbx-wrapper is available
        if (!bFbxAvailable)
        {
            return;
        }

        try
        {
            // instantiate the avatar object from the fbx file
            if (LoadAvatarObject() && avatarObject)
            {
                avatarCtrl = avatarObject.gameObject.GetComponent <AvatarController>();
            }
            else
            {
                if (loadFilePath == string.Empty)
                {
                    throw new Exception("Please specify fbx-file to load.");
                }
                else
                {
                    throw new Exception("Cannot instantiate avatar from file: " + loadFilePath);
                }
            }

            // check the KinectManager availability
            if (!manager)
            {
                manager = KinectManager.Instance;
            }

            if (!manager)
            {
                throw new Exception("KinectManager not found, probably not initialized. See the log for details");
            }

            // initialize fbx wrapper
            if (!bFbxInited)
            {
                bFbxInited = MocapFbxWrapper.InitFbxWrapper();

                if (!bFbxInited)
                {
                    throw new Exception("Fbx wrapper could not be initialized.");
                }
            }

            if (infoText != null)
            {
                infoText.GetComponent <GUIText>().text = "Say: 'Record' to start the recorder.";
            }

            // play the animation
            AnimationPlayer animPlayer = AnimationPlayer.Instance;
            if (animPlayer)
            {
                animPlayer.PlayAnimationClip(saveFilePath, animationName);
            }

            if (recordAtStart)
            {
                StartRecording();
            }
        }
        catch (Exception ex)
        {
            Debug.LogError(ex.Message);
            Debug.LogException(ex);

            if (infoText != null)
            {
                infoText.GetComponent <GUIText>().text = ex.Message;
            }
        }
    }