Exemple #1
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        BVHRecorder bvhRecorder = (BVHRecorder)target;

        if (GUILayout.Button("Detect bones"))
        {
            bvhRecorder.getBones();
            Debug.Log("Bone detection done.");
        }

        if (GUILayout.Button("Remove empty entries from bone list"))
        {
            bvhRecorder.cleanupBones();
            Debug.Log("Cleaned up bones.");
        }

        if (GUILayout.Button("Clear recorded motion data"))
        {
            bvhRecorder.clearCapture();
            Debug.Log("Cleared motion data.");
        }

        if (GUILayout.Button("Save motion to BVH file"))
        {
            try {
                bvhRecorder.saveBVH();
            } catch (Exception ex) {
                Debug.LogError("An error has occurred while saving the BVH file: " + ex);
            }
        }
    }
Exemple #2
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        BVHRecorder bvhRecorder = (BVHRecorder)target;

        if (GUILayout.Button("Detect bones"))
        {
            bvhRecorder.getBones();
            Debug.Log("Bone detection done.");
        }

        if (GUILayout.Button("Remove empty entries from bone list"))
        {
            bvhRecorder.cleanupBones();
            Debug.Log("Cleaned up bones.");
        }

        if (GUILayout.Button("Clear recorded motion data"))
        {
            bvhRecorder.clearCapture();
            Debug.Log("Cleared motion data.");
        }

        if (GUILayout.Button("Save motion to BVH file"))
        {
            try {
                bvhRecorder.saveBVH();
            } catch {
                Debug.LogError("Motion data can only be saved while the scene is running.");
            }
        }
    }
Exemple #3
0
    public void onRecord()
    {
        if (isRecording == false)
        {
            recorder = gameObject.AddComponent <BVHRecorder>();
            var setting = AvatarList[avatars.value];
            recorder.targetAvatar = setting.Avatar.GetComponent <Animator>();
            recorder.scripted     = true;

            recorder.blender = configurationSetting.Blender == 1;
            recorder.enforceHumanoidBones = configurationSetting.EnforceHumanoidBones == 1;
            recorder.getBones();
            recorder.rootBone = setting.Avatar.JointPoints[PositionIndex.hip.Int()].Transform;
            recorder.buildSkeleton();
            recorder.genHierarchy();
            recorder.capturing = configurationSetting.Capturing == 1;
            if (configurationSetting.Capturing == 1)
            {
                recorder.frameRate = configurationSetting.CapturingFPS;
            }
            recorder.catchUp      = configurationSetting.CatchUp == 1;
            isRecording           = true;
            btnRecord.image.color = Color.red;
            btnRecord.GetComponentInChildren <Text>().text  = "Recording";
            btnRecord.GetComponentInChildren <Text>().color = Color.white;
        }
        else
        {
            isRecording        = false;
            recorder.capturing = false;

            var extensions = new[]
            {
                new ExtensionFilter("BVH Files", "bvh"),
            };
            var path = StandaloneFileBrowser.SaveFilePanel("SaveFile", "", "motion.bvh", extensions);

            if (path.Length != 0)
            {
                FileInfo fi = new FileInfo(path);
                recorder.directory = fi.DirectoryName;
                recorder.filename  = fi.Name;
                recorder.saveBVH();
            }
            recorder.clearCapture();
            recorder = null;
            btnRecord.image.color = Color.white;
            btnRecord.GetComponentInChildren <Text>().text  = "Record BVH";
            btnRecord.GetComponentInChildren <Text>().color = Color.black;
        }
    }