Search code examples
pythonfbxautodesk

Creating a Point or Vertex in FBX SDK


I'm trying to create a single vertex point at a given coordinate of a parent node.

# create a manager, scene and node
manager = fbx.FbxManager.Create()
scene = fbx.FbxScene.Create(manager, "")
node = fbx.FbxNode.Create(manager, "")

# create a mesh
mesh = fbx.FbxMesh.Create(scene, "")

# How to add a single vertex to the mesh?

# add the mesh attribute to the node
node.AddNodeAttribute(mesh)

# add node to the node tree
root_node = scene.GetRootNode()
root_node.AddChild(node)

# Translate the node to (0, 0, 10)
node.LclTranslation.Set(fbx.FbxDouble3(0, 0, 10))

This doesn't have to be a specific python answer. I appreciate your help.


Solution

  • A vertex or point is a coordinate specified by the following:

    v = fbx.FbxVector4(x, y, z)
    

    A vertex itself isn't visible unless it is made a control point to a mesh.

    my_mesh = fbx.FbxMesh.Create(my_scene, '')
    my_mesh.SetControlPointAt(v, 0)
    

    Where 0 is the "order" or "index" of the vertex in a group of vertices (if there is one). Then a polygon which may represents a side of the mesh may be drawn:

    my_mesh.BeginPolygon()
    my_mesh.AddPolygon(0)
    my_mesh.AddPolygon(n)
    ...
    my_mesh.EndPolygon()