Comments (8)
This isn't a core feature of glTF itself. But for what it's worth, it's possible to implement this on top of glTF, with custom code.
For example, here's the glTF sample fox, playing the "Run" animation and watching the International Space Station fly by at the same time:
In our case this is done with a vendor extension, AGI_articulations
. An "articulation" is a joint that is permitted to move or rotate about particular axis/axes by amounts defined in the extension, but without a pre-scripted animation. Such transformations are applied separately and subsequently to the transformations applied by the glTF itself and its own built-in animations.
So what you're seeing here is that a bone in the Fox skeleton's head has been given an AGI_articulations
extension and allowed to swivel by some number of degrees, along with a defined "pointing vector". The host software STK aligns this pointing vector with the user's target of choice, in this case the space station passing overhead. The Fox's "Run" animation is playing, causing the head to bob up and down, and the pointing articulation is applied subsequently to that, causing the head to track the station during the pass.
But again, this is vendor-specific, not part of the glTF standard itself. If you're not using STK, it's a feature that would need some development effort for your platform of choice.
from gltf-tutorials.
Yes, this wonderful video inspired me to find new solutions, thank you. I was thinking about a method to change the position of the bone programmatically and recalculate all matrices in real time.
And my idea was that the rotation of the fox's head was recorded in a separate animation and, specifying the number of the current frame of the head, merge it with the current animation of the body.
from gltf-tutorials.
Are you writing a glTF exporter yourself, or using an existing software package to author glTF?
from gltf-tutorials.
I wrote my little GLB file parser for my program (thanks for the document "gltf-What the daсk"). I can get animation keys and create mesh transformation matrices. I pass them to the shader and the animation displays fine if I only use one animation at a time.
And I wanted to try using two or more animations and layering them but didn't seem to get it. This is needed to overlay the animation of the arms and the whole body, this will reduce unnecessary duplication of animations. How to do it correctly?
from gltf-tutorials.
If you have several animations that affect the local transform matrices of nodes, then it should be possible to combine them, but I think that this has some caveats: Imagine one animation that rotates object X clockwise and the other one rotating object X counterclockwise - you cannot say what the result should be. More broadly speaking: It might be possible to combine multiple animations if they are "independent" of each other. But I'm pretty sure that this is not covered by the specification.
But more importantly:
create mesh transformation matrices
That sounds like you're doing vertex skinning. If this is the case: Combining "multiple skinnings" (with animation) is really difficult (it might even be impossible to do this sensibly, but I couldn't give any advice here...)
from gltf-tutorials.
well. Maybe I chose a dead end path and there is another way to do it.
For example, I need to turn my head depending on the direction of the gaze during the playback of the walking animation.
How to do it?
from gltf-tutorials.
It's a bit too early to talk about a "dead end" - at lest for me, it's not entirely clear what the goal is. The last statement sounded like you wanted to make the decision about the actual animations that are played at runtime. That might be difficult, but here is a short pointer to some related discussion: KhronosGroup/glTF#1052:
This eventually led to the implementation note in the spec:
Implementation Note: glTF 2.0 does not specifically define how an animation will be used when imported but, as a best practice, it is recommended that each animation is self contained as an action. For example, "Walk" and "Run" animations might each contain multiple channels targeting a model's various bones. The client implementation may choose when to play any of the available animations.
This sounds pretty similar to your application case. I think that it should be possble do do play several animations simultaneously, with some "caveats":
- Other glTF viewers may not be able to play multiple animations at the same time
- Your viewer/client would need dedicated controls and an infrastructure so that it is possible to tell it something like "Play the 'walk' animation, for 2.3 seconds, and after 1.8 seconds, play a certain part of the 'turn head' animation".
- You'd have to be really careful to not play animations that affect the same bones - otherwise, the results would be unpredictable
It could be a challenge to support this sensibly, but should be certainly be worth a try.
from gltf-tutorials.
thank you
from gltf-tutorials.
Related Issues (20)
- how to calculate the global inverse transform HOT 4
- implementing an algorithm for the simpleSkin model from this github HOT 7
- Update and simplify the skinning section HOT 6
- glTF/GLB model size - is there any tool for checking it? HOT 2
- Update links to point to the Khronos glTF registry
- Question about keyframe compression HOT 2
- Clarify component order for quaternions in scene/node page HOT 5
- Cannot replicate Skin glTF-Tutorial data contents HOT 2
- gltfTutorial_020_Skins.md typo HOT 3
- Minor readability issue - image 18b HOT 3
- Please rename default branch from 'master' to 'main' per Khronos policy HOT 10
- Hi, what is the right thing to do if JOINT_0 comes in a model in the format short 5123? HOT 2
- can Mesh be used in several different Skins? should I provide for this when loading glb? HOT 2
- Where should joint matrices be stored? HOT 2
- Some phones don't draw models if indicesComponentType=5125-GL_UNSIGNED_INT. But they draw fine if indicesComponentType=5123-GL_UNSIGNED_SHORT. I think it may be related to the support on the phone OpenGLES3+. Or are there other reasons? HOT 3
- Animation in model without skeleton and bones HOT 2
- does gltf support metadata, KV string map for example HOT 2
- Hi, is there an example for OpenGL ES 3 using a normal map in glsl shaders to render gltf models? Could you point out a good link to explore? HOT 2
- is it possible to somehow determine in which units of measurement the model is located? Millimeters, centimeters, meters or inches? HOT 1
- how to use schema.json in gltf2.0 HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gltf-tutorials.