// starts recording public bool StartRecording() { if (avatarObject == null) { return(false); } if (isRecording) { return(false); } isRecording = true; // load the fbx file if (!LoadFile()) { isRecording = false; Debug.LogError("File could not be loaded: " + loadFilePath); if (infoText != null) { infoText.GetComponent <GUIText>().text = "File could not be loaded: " + loadFilePath; } } // check for save file name if (saveFilePath == string.Empty) { isRecording = false; Debug.LogError("No file to save."); if (infoText != null) { infoText.GetComponent <GUIText>().text = "No file to save."; } } // create the animation stack, if animation name is specified if (animationName != string.Empty && !MocapFbxWrapper.CreateAnimStack(animationName)) { isRecording = false; //throw new Exception("Could not create animation: " + animationName); Debug.LogError("Could not create animation: " + animationName); if (infoText != null) { infoText.GetComponent <GUIText>().text = "Could not create animation: " + animationName; } } if (isRecording && animationName != string.Empty) { MocapFbxWrapper.SetCurrentAnimStack(animationName); } if (isRecording) { Debug.Log("Recording started."); if (infoText != null) { infoText.GetComponent <GUIText>().text = "Recording... Say 'Stop' to stop the recorder."; } // get initial avatar position if (avatarCtrl != null) { int hipsIndex = avatarCtrl.GetBoneIndexByJoint(KinectInterop.JointType.SpineBase, false); Transform hipsTransform = avatarCtrl.GetBoneTransform(hipsIndex); initialPos = hipsTransform != null ? hipsTransform.position : Vector3.zero; } // initialize times fStartTime = fCurrentTime = Time.time; fMinFrameTime = maxFramesPerSecond > 0f ? 1f / maxFramesPerSecond : 0f; iSavedFrame = 0; // get global time mode as fps fGlobalFps = MocapFbxWrapper.GetGlobalFps(); // get global scale factor fFbxScale = 100f / MocapFbxWrapper.GetGlobalScaleFactor(); // Unity scale factor fUnityScale = importScaleFactor != 0f ? 1f / importScaleFactor : 1f; } return(isRecording); }