vpenades / SharpGLTF

glTF reader and writer for .NET Standard
MIT License
454 stars 72 forks source link

[Question] How to create "Stop Motion Animation" #184

Closed Jade9706 closed 1 year ago

Jade9706 commented 1 year ago

I'm not good at .gltf format file and I would like to create Animation like "Stop motion animation" in .gltf file.

I have 30 rectangle plane meshes (for 30 frames) that contains dancing woman texture image. (I have 30 frames of the dancing woman image and I created them as a rectangle plane mesh.)

I would like to make only one mesh visible and make other meshes invisible at frame time. Each frame rectangle mesh has different size and position.

Though I had found the examples, I couldn't find the example code. (As I had found, SharpGLTF has Animations such as translation, scale, rotation and morph. I couldn't find any other animation that I want.)

Though I created .glb file with SharpGLTF, I got errors and all frames were shown. T.T Would you let me know how to create .gltf file like "Stop Motion Animation" or how I can find example?

WrongAnimation_GLB

vpenades commented 1 year ago

glTF does not implicitly support animating a visible/invisible feature in the way you would like.

But the visible/invisible feature can be simulated using the SCALE.

Let's say you have 30 meshes, and you only want a single mesh to be visible at a given time.

What you would do is to set the initial scale of all the meshes to ZERO, that makes the meshes effectively invisible.

then you create a STEP animation for every mesh, where you animate the scale of all the 30 meshes, and you set the SCALE of the given mesh to zero, except for the frame you want to show.

Jade9706 commented 1 year ago

glTF does not implicitly support animating a visible/invisible feature in the way you would like.

But the visible/invisible feature can be simulated using the SCALE.

Let's say you have 30 meshes, and you only want a single mesh to be visible at a given time.

What you would do is to set the initial scale of all the meshes to ZERO, that makes the meshes effectively invisible.

then you create a STEP animation for every mesh, where you animate the scale of all the 30 meshes, and you set the SCALE of the given mesh to zero, except for the frame you want to show.

Thank you for your sooner reply.

I also thought that I couldn't help but using SCALE animation. Because I'm not goot at .gltf format as I said in question, I had wanted to ask you, the .gltf expert, if I could change the visibility of mesh in the gltf animation or not.

I will use SCALE animation as you said.