mirror of
https://github.com/lighttransport/tinyusdz.git
synced 2026-01-18 01:11:17 +01:00
The mapbox earcut library returns triangles in clockwise winding order, but USD expects counter-clockwise order. This was causing reversed face orientation for polygons with 5 or more vertices when using the earcut triangulation method. Changes: - src/tydra/render-data.cc: Reverse triangle winding order by swapping indices 1 and 2 when processing earcut results to convert from CW to CCW - examples/tydra_to_renderscene/to-renderscene-main.cc: Add --trifan option to enable triangle fan triangulation method for testing The triangle fan method was already producing correct CCW triangles and did not require changes. Tested with models/ngon.usdc containing pentagon, hexagon, and octagon. Both triangulation methods now correctly produce CCW triangles. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
90 lines
3.5 KiB
Plaintext
Executable File
90 lines
3.5 KiB
Plaintext
Executable File
#usda 1.0
|
|
(
|
|
defaultPrim = "root"
|
|
doc = "Blender v5.0.0"
|
|
metersPerUnit = 1
|
|
upAxis = "Z"
|
|
)
|
|
|
|
def Xform "root" (
|
|
customData = {
|
|
dictionary Blender = {
|
|
bool generated = 1
|
|
}
|
|
}
|
|
)
|
|
{
|
|
def Xform "Pentagon"
|
|
{
|
|
custom string userProperties:blender:object_name = "Pentagon"
|
|
float3 xformOp:rotateXYZ = (0, -0, 0)
|
|
float3 xformOp:scale = (1, 1, 1)
|
|
double3 xformOp:translate = (-2.9930577278137207, 0, 0)
|
|
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"]
|
|
|
|
def Mesh "Pentagon" (
|
|
active = true
|
|
)
|
|
{
|
|
float3[] extent = [(-0.809017, -0.95105654, 0), (1, 0.95105654, 0)]
|
|
int[] faceVertexCounts = [5]
|
|
int[] faceVertexIndices = [0, 1, 2, 3, 4]
|
|
normal3f[] normals = [(0, 0, 1), (0, 0, 1), (0, 0, 1), (0, 0, 1), (0, 0, 1)] (
|
|
interpolation = "faceVarying"
|
|
)
|
|
point3f[] points = [(1, 0, 0), (0.309017, 0.95105654, 0), (-0.809017, 0.58778524, 0), (-0.809017, -0.58778524, 0), (0.309017, -0.95105654, 0)]
|
|
uniform token subdivisionScheme = "none"
|
|
custom string userProperties:blender:data_name = "Pentagon"
|
|
}
|
|
}
|
|
|
|
def Xform "Hexagon"
|
|
{
|
|
custom string userProperties:blender:object_name = "Hexagon"
|
|
float3 xformOp:rotateXYZ = (0, -0, 0)
|
|
float3 xformOp:scale = (1, 1, 1)
|
|
double3 xformOp:translate = (0.006942272186279297, 0, 0)
|
|
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"]
|
|
|
|
def Mesh "Hexagon" (
|
|
active = true
|
|
)
|
|
{
|
|
float3[] extent = [(-1, -0.8660254, 0), (1, 0.8660254, 0)]
|
|
int[] faceVertexCounts = [6]
|
|
int[] faceVertexIndices = [0, 1, 2, 3, 4, 5]
|
|
normal3f[] normals = [(0, 0, 0.99999994), (0, 0, 0.99999994), (0, 0, 0.99999994), (0, 0, 0.99999994), (0, 0, 0.99999994), (0, 0, 0.99999994)] (
|
|
interpolation = "faceVarying"
|
|
)
|
|
point3f[] points = [(1, 0, 0), (0.5, 0.8660254, 0), (-0.5, 0.8660254, 0), (-1, 1.2246469e-16, 0), (-0.5, -0.8660254, 0), (0.5, -0.8660254, 0)]
|
|
uniform token subdivisionScheme = "none"
|
|
custom string userProperties:blender:data_name = "Hexagon"
|
|
}
|
|
}
|
|
|
|
def Xform "Octagon"
|
|
{
|
|
custom string userProperties:blender:object_name = "Octagon"
|
|
float3 xformOp:rotateXYZ = (0, -0, 0)
|
|
float3 xformOp:scale = (1, 1, 1)
|
|
double3 xformOp:translate = (3.0069422721862793, 0, 0)
|
|
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"]
|
|
|
|
def Mesh "Octagon" (
|
|
active = true
|
|
)
|
|
{
|
|
float3[] extent = [(-1, -1, 0), (1, 1, 0)]
|
|
int[] faceVertexCounts = [8]
|
|
int[] faceVertexIndices = [0, 1, 2, 3, 4, 5, 6, 7]
|
|
normal3f[] normals = [(0, 0, 0.99999994), (0, 0, 0.99999994), (0, 0, 0.99999994), (0, 0, 0.99999994), (0, 0, 0.99999994), (0, 0, 0.99999994), (0, 0, 0.99999994), (0, 0, 0.99999994)] (
|
|
interpolation = "faceVarying"
|
|
)
|
|
point3f[] points = [(1, 0, 0), (0.70710677, 0.70710677, 0), (6.123234e-17, 1, 0), (-0.70710677, 0.70710677, 0), (-1, 1.2246469e-16, 0), (-0.70710677, -0.70710677, 0), (-1.8369701e-16, -1, 0), (0.70710677, -0.70710677, 0)]
|
|
uniform token subdivisionScheme = "none"
|
|
custom string userProperties:blender:data_name = "Octagon"
|
|
}
|
|
}
|
|
}
|
|
|