简体   繁体   English

如何从 fbx 文件中获取所有节点或多边形的名称?

[英]How can I get the names of all nodes or polygons from an fbx file?

I have a 3D character model saved in an FBX format.我有一个以 FBX 格式保存的 3D 角色模型。 I want to know the list of names for each model or joint so I can decide if that part of the character is relevant to me or not.我想知道每个模型或关节的名称列表,以便我可以决定角色的那部分是否与我相关。 I am not using Maya software.我没有使用 Maya 软件。 I got the 3D model from a third party and I am going to use that model for animation in unity3D but before importing the model in unity3d, I want to know the model label like hair, head etc so is there any way to get the label programmatically from FBX file?我从第三方获得了 3D 模型,我将使用该模型在 unity3D 中制作动画,但在将模型导入 unity3d 之前,我想知道模型标签,如头发、头部等,所以有什么方法可以获取标签以编程方式从 FBX 文件? Thanks谢谢

About FBX format关于 FBX 格式

"FBX" is a compiled format, created by Autodesk, that can be utilized by a number of 3D Softwares even though FBX is a proprietary file format. “FBX”是一种由 Autodesk 创建的编译格式,即使 FBX 是一种专有文件格式,它也可以被许多 3D 软件使用。 Because it is compiled, you will end up with a wide-range of "NULL" format symbols;因为它是编译的,所以你最终会得到范围广泛的“NULL”格式符号; IE - IE -

€«±µÈ7L—C«‚›ìŸn»yàn´ZÌ'>ï¯Óp>¸z±ú‘uá#OFªƒû·Pð>U>j}jp[7)

Because of this, it is better to either export as a DAE / Collada format or OBJ format if you are not utilizing bone structures.因此,如果您不使用骨骼结构,最好导出为DAE / Collada格式或OBJ格式。

About Collada / DAE_FBX / DAE format关于 Collada / DAE_FBX / DAE 格式

This format is open source and was typically used for video games in the past.这种格式是开源的,过去通常用于视频游戏。 The file is an XML based file and should be easy to manipulate in Java / JavaScript.该文件是一个基于XML的文件,应该很容易在 Java/JavaScript 中操作。 Because of this, the file offers full support for opening the file up in your favorite notepad program / app... or even your favorite programming language.因此,该文件完全支持在您最喜欢的记事本程序/应用程序...甚至您最喜欢的编程语言中打开文件。

Utilizing this format, your geometry will be listed under the child "geometry".使用此格式,您的几何图形将列在子“几何图形”下。

Potential Solution (Python in Maya)潜在解决方案(Maya 中的 Python)

If you are using Maya and can inject a bit of code in before exporting the FBX file... Try running this before export (Python):如果您使用的是 Maya 并且可以在导出 FBX 文件之前注入一些代码......在导出之前尝试运行它(Python):

import maya.cmds as cmds

# Create the location and fileName
yourDesktopVar = "C:\\Users\\[Your user]\\Desktop\\"
saveFileName   = "Joints_Models_Groups.txt"
documentToSave = open((yourDesktopVar + saveFileName), "w")

# Setup arrays full of relative information

jointNames     = [jn for jn in cmds.ls(type = "joint")]
meshNames      = [cmds.listRelatives(mn, parent=1)[0] for mn in cmds.ls(type = "mesh")]

# ================================
# Writing Joints
# ================================

documentToSave.write("Joints\n\r")
documentToSave.write("--------------")

for eachJointName in jointNames:
    documentToSave.write(eachJointName + "\n\r")

# Create a blank space
documentToSave.write("\n\r\n\r)

# ================================
# Writing Meshes
# ================================
documentToSave.write("Meshes\n\r")
documentToSave.write("--------------")

for eachMeshName in meshNames:
    documentToSave.write(eachMeshName + "\n\r")

Obviously, you'll have to edit this to fit your format, but this will crank out a basic text document that should give you enough information to start with.显然,您必须编辑它以适合您的格式,但这将生成一个基本的文本文档,该文档应该为您提供足够的信息来开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM