Home > database >  Create an animation from obj/gtlf files, import in Unity
Create an animation from obj/gtlf files, import in Unity

Time:01-10

I have 350 gtlf files. Originally files are in OBJ format (350 files audio) and I have converted them into separate gtlf with obj2gtlf.

How can I create an animated gtlf file with all 350 keyframes? Or how can I create an animation in Unity using these 350 obj/gltf files?

I want to import/create a animation in Unity using these files and run a Hololens Application. By placing this animation I want to see a volumetric video playing inside my Hololens Application.

But I can not make a sequence using a gtlf-transform, it seems to take only one gtlf file (instead of all 350) and detach the texture into separate jpg-file. I can not create animation with Timeline in Unity.

Can anyone help me? I am new to Unity and can not find a solution

PS: Bone animation is not a solution. My files are represent a real man that is captured with a volumetric video method. He stays, speaks, smiles and moves his hand. I need to import a 3d animated model into Unity to use it my master thesis. So I did not animated that model, I have got a captured video as 350 obj files meshes as jpg and audio. I can import a single 3d model as obj file but I can not find a way to import a animated volumetric video.

CodePudding user response:

You seem to have a very specific use case where indeed you need to have these as separate 3D models and textures / materials.

As said the simplest but probably not most performant way would be to simply have all these 3D objects in your scene and only set one of them active at a time.

Something like e.g.

public class ModelFrames : MonoBehaviour
{
    // You drag these all in once via the Inspector
    public GameObject[] models;

    private int currentIndex = -1;

    private void Awake()
    {
        foreach(var model in models)
        {
            model.SetActive(false);
        }
    }

    private void Update()
    {
        if(currentIndex >= 0)
        {
            models[currentIndex].SetActive(false);
        }

        currentIndex = (currentIndex   1) % models.Length;

        models[currentIndex].SetActive(true);
    }
}

If you don't want to switch every frame you could also add some modifier and do

public class ModelFrames : MonoBehaviour
{
    // You drag these all in once via the Inspector
    public GameObject[] models;

    public int targetFramesPerSecond = 60;

    private void Awake()
    {
        foreach(var model in models)
        {
            model.SetActive(false);
        }
    }

    private IEnumerator Start()
    {
        var currentIndex = 0;

        models[currentIndex].SetActive(true);

        while(true)
        {
            yield return new WaitForSeconds(1f / targetFramesPerSecond);

            models[currentIndex].SetActive(false);

            currentIndex = (currentIndex   1) % models.Length;

            models[currentIndex].SetActive(true);
        }
    }
}

enter image description here

  •  Tags:  
  • Related