emilianavt / BVHTools

BVH Tools for Unity
Other
205 stars 27 forks source link

error while executing the code from ReadMe #13

Open cssddnnc9527 opened 2 years ago

cssddnnc9527 commented 2 years ago

I try to run the last paragraph code of the read me file, but it fails as follows: I want to use my own bvh file to drive 3d Model.

无标题

Any idea will be appreciated !

emilianavt commented 2 years ago

It sounds like UnityEngine is not imported.

cssddnnc9527 commented 2 years ago

How to import UnityEngine ?
Do I need to install UE in my OS?

emilianavt commented 2 years ago

BVHTools is a library written for use with Unity as part of a Unity project or game. It won't work stand-alone. The UnityEngine namespace provides functions to interact with the game engine and is usually imported by default when you create a new C# script in Unity.

cssddnnc9527 commented 2 years ago

Very appreciated!

With your help, the compile errors gone. But met the error as follows:

无标题

I have my own *.fbx file, but I don't know where to put it, and where to set the file path.

Thanks again!

emilianavt commented 2 years ago

You have to put it in the scene. If you then attach the BVHAnimationLoader to the model's root in the scene, it should work.

cssddnnc9527 commented 2 years ago

As following graph:

无标题

my scene name is "self", my 3d model is "X Bot", I also put "X bot" in the Assets category. But in the right part of the graph, I can't select Target Avatar. The error in the down left corner still exists.

What did I miss ? Looking forward your response. Best regards.

In addition, the content of "New Behaviour Script" is as follows: _using System.Collections; using System.Collections.Generic; using UnityEngine;

public class NewBehaviourScript : MonoBehaviour { // Start is called before the first frame update void Start() { BVHAnimationLoader loader = gameObject.AddComponent(); loader.targetAvatar = GetComponent(); loader.clipName = "anim1"; loader.filename = "sampled_0_temp100_0k_0.bvh"; loader.parseFile(); loader.loadAnimation(); }

// Update is called once per frame
void Update()
{

}

}_

emilianavt commented 2 years ago

Your X Bot needs to be set to have a humanoid rig. I would recommend getting familiar with the basics of Unity's animation system.

cssddnnc9527 commented 2 years ago

Ultimately the model can be driven by the BVH file, but it kept T pose and move very slightly which is obviously not correct.So I have three questions:

  1. What may the root cause be?
  2. I use the model and motion capture file(.fbx) from mixamo.com, then transform .fbx to *.bvh, but the effect is not ideal. Anything wrong with this process?
  3. Could you tell me where to get .fbx and .bvh which have same struture?

Thank you very much! Looking forward to your response.

Best wishes!

emilianavt commented 2 years ago

Perhaps the bone names and structure of the model and of the BVH file do not match. In that case you can use the translation map on the animation loader component an manually translate them.

For getting matching fbx and bvh file, the easiest method would be to record them with the recorder component.