理解Libgdx 3D模型和节点 [英] Understanding 3D Models and Nodes in Libgdx

查看:609
本文介绍了理解Libgdx 3D模型和节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得一个更好的理解型号和它们的节点层次结构<$ C $的C> Libgdx 。 由于我的理解,一个型号是由许多儿童节点 s,它可以包含其他很多节点取值为好。每个节点都有一个 Vector3类型转换描述它的位置, Vector3类型比例,描述其规模和四元旋转描述它的自转,所有相对于父节点型号。该 Matrix4 gloabalTransform 描述相同,但相对于世界他们是在

I am trying to get a better understanding of the Models and their Nodehierarchy in Libgdx. As much as i understood, a Model is made of many ChildNodes, which can contain other Nodes 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.

现在,如果我想就像 Garrysmod,游戏中的型号 S的播放 S能够动态地将模型的一部分​​(例如,如果他们趴在一条边后,他们死于自己的上身可以垂壁),我只能想想,自己修改单节点在运行期,在其来源$ C ​​$ C。 现在我的问题:

Now if i think about games like Garrys Mod, where the Models of the Players 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 Nodes at runtime, in their source code. Now my questions:

  1. 是我的假设是正确的?
  2. 请我一定要创建节点 S在搅拌机的可能性(可以说1 节点是左小腿,1 节点是左大腿......),并获取和使用改变他们在运行时(对于例如) modelInstance.getNode(leftLowerLeg)。translation.set(Vector3类型位置),或者是他们创建的自动命名,根据不同的形状,facecount ...?
  1. Is my assumption correct?
  2. Do i have the possibility to create the Nodes in Blender (lets say 1 Node is the left lower leg, 1 Node 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...?

非常感谢!

推荐答案

看着<一href="http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/model/Node.html"相对=nofollow>这的看来,节点的概念是场景图。模型可制成份(MeshPart)和每个单独的部件是一个节点的子节点。有一个单独的节点意味着你可以应用转换到它因此移动它独立于任何其他模式的一部分。所以看来你想构建你的模​​型作为独立的部分,并加载在节点的层次结构的部分,以满足您的需求。请参考您要独立地移动和应用转换的节点。

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.

节点可以包含一个MeshPart(即MeshPart是节点的子)节点可以包含其他节点。一起来看看维基百科的场景图的术语。挂在文档的模式说模型再度presents三维资产。它存储节点的层次结构,一个节点一个变换,并在MeshPart和材料形成任选一个图形化的一部分。网眼部分引用的顶点的子集在模型的网眼中的一个。动画可以应用于节点,修改其变换(平移,旋转,缩放)随时间。请注意它说子组顶点,这意味着,该模型是一个模型,但你将它们分开为您的需要分配不同的子集为节点。

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.

从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:

  1. 理论
  2. 实用
  1. Theory
  2. Practical

这篇关于理解Libgdx 3D模型和节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆