Importing a procedurally generated mesh into Isaac Sim

Hi @ananyea1 - In order to create a mesh programmatically in Isaac Sim, you need to define the mesh attributes such as points, faceVertexIndices, and faceVertexCounts. However, you also need to define the normals and texture coordinates for the mesh to be visible in the viewer.

Here is an example of how you can create a mesh programmatically:

from pxr import Usd, UsdGeom, Vt, Gf

stage = Usd.Stage.CreateNew('test.usda')

mesh = UsdGeom.Mesh.Define(stage, '/World/proc_mesh')

# Define points for a simple triangle
points = Vt.Vec3fArray(3)
points[0] = Gf.Vec3f(0, 0, 0)
points[1] = Gf.Vec3f(0, 1, 0)
points[2] = Gf.Vec3f(1, 0, 0)

# Define face indices
faceIndices = Vt.IntArray(3)
faceIndices[0] = 0
faceIndices[1] = 1
faceIndices[2] = 2

# Define face counts
faceCounts = Vt.IntArray(1)
faceCounts[0] = 3


# Define normals
normals = Vt.Vec3fArray(3)
normals[0] = Gf.Vec3f(0, 0, 1)
normals[1] = Gf.Vec3f(0, 0, 1)
normals[2] = Gf.Vec3f(0, 0, 1)


# Define texture coordinates
texCoords = Vt.Vec2fArray(3)
texCoords[0] = Gf.Vec2f(0, 0)
texCoords[1] = Gf.Vec2f(0, 1)
texCoords[2] = Gf.Vec2f(1, 0)

texCoordsAttr = UsdGeom.TexCoordSource.Create(mesh, 'st', texCoords)


This script creates a new USD stage, defines a mesh with a single triangle, and sets the points, face indices, face counts, normals, and texture coordinates for the mesh. The mesh is then saved to a USD file named ‘test.usda’.

Please note that this script does not apply any physics or collision properties to the mesh. You would need to use the UsdPhysics and PhysxSchema APIs to apply these properties as needed for your application.

Also, please ensure that the normals and texture coordinates are correctly defined for your mesh. Incorrect normals or texture coordinates could cause the mesh to be invisible or not render correctly in the viewer.