I am trying to get a better understanding of the Model
s and their Node
hierarchy in Libgdx
.
As much as i understood, a Model
is made of many ChildNode
s, which can contain other Node
s as well. Each node has a Vector3 translation
describing its position, Vector3 scale
, describing its scale and Quaternion rotation
describing its rotation, all relative to the parent Node
or Model
. The Matrix4 gloabalTransform
describes the same, but relative to the world they are in.
Now if i think about games like Garrys Mod
, where the Model
s of the Player
s can move parts of the model dynamically (for example if they lie on an edge after they died their upper body can hang down the wall), i can only think about, that they modify the single Node
s at runtime, in their source code.
Now my questions:
- Is my assumption correct?
- Do i have the possibility to create the
Node
s inBlender
(lets say 1Node
is the left lower leg, 1Node
is the left upper leg...) and get and change them at runtime by using (for example)modelInstance.getNode("leftLowerLeg").translation.set(Vector3 position)
, or are they created and named automatically, depending on the shape, facecount...?
Thanks a lot!
Looking at that it appears that the concept of node is that of scene graph. Your model can be made of parts (MeshPart) and each separate part is a child of a node. Having a separate node means you can apply transforms to it thus moving it independently from any other model part. So it appears that you do want to construct your model as separate parts and load those parts in a hierarchy of nodes to suit your needs. Keep a reference to the node you want to move independently and apply transforms.
Node can "contain" a MeshPart (i.e. MeshPart is child of Node) Nodes can contain other nodes. take a look wikipedia for scene graph terminology. Hang on the docs for Model say "A model represents a 3D assets. It stores a hierarchy of nodes. A node has a transform and optionally a graphical part in form of a MeshPart and Material. Mesh parts reference subsets of vertices in one of the meshes of the model. Animations can be applied to nodes, to modify their transform (translation, rotation, scale) over time." Note it says sub set of vertices which implies that the model is one model but you separate them for your needs assigning different sub sets into Nodes.
From Xoppa:
This tutorial shows how to use the node hierarchy from the modeling application. Here are two tutorials explaining the node structure and how to use it:
I am currently working on this exact problem. Nodes can have nodes which can have nodes! You can find a specific node using ModelInstance.getNode(String NameOfNode);
which returns an object of type Node. These nodes are named what you named the objects in blender. EG, to get the Right shoulder bone in a model with the bone named Shoulder_R
, you could do:
Node node = myModelInstance.getNode("Shoulder_R");
node that contains all the information pertaining to that bone, including translation, rotation, scale, and the appropriate transform matrices. I am currently stuck at the point of trying to manipulate these bones while an animation is playing, post the animation controller update.
My desired end result is to manually modify for example where an arm is pointing so its pointing at another object while the animation and model continue to play/move. I hope this helps you in your quest, and if you discover the answer to the remaining part of the mystery, please post back!
来源:https://stackoverflow.com/questions/22452572/understanding-3d-models-and-nodes-in-libgdx