I’m attempting to carry out some coordinate transformations for meshes, i’ve successfully done this for FBX files, but I have an OBJ file which I am testing and every vertex has the position (0,0,0).
The obj does have several thousand polygons and control points, when viewing the OBJ in MeshLab, the count of each matches that which I log from Aspose.
Here are the first three coordinates copied directly from the .obj file, maybe Aspose can’t handle E notation?:
v -3.12842593e-01 2.17075611e+01 3.50575465e+01
v -3.12842593e-01 2.16943491e+01 3.69071182e+01
v -3.12842593e-01 2.14158294e+01 3.69164094e+01
Using the below, all the control points are located at 0,0,0:
node.Accept(delegate (Node node)
{
for (int i = 0; i < node.Entities.Count; i++)
{
if (node.Entities[i] is Mesh mesh)
{
var points = mesh.ControlPoints;
for (int j = 0; j < points.Count; j++)
{
var v = points[j];
Console.Writeline(v.ToString())
}
}
}
return true;
});
When getting the vertices from a TriMesh the issue persists:
rootNode.Accept(delegate (Node node)
{
for (int i = 0; i < node.Entities.Count; i++)
{
if (node.Entities[i] is Mesh mesh)
{
var vertexDeclaration = new VertexDeclaration();
var vertexFieldForVertex = vertexDeclaration.AddField(VertexFieldDataType.FVector3, VertexFieldSemantic.Position);
if (mesh.GetElement(VertexElementType.Normal) == null)
{
var normalData = PolygonModifier.GenerateNormal(mesh);
mesh.VertexElements.Add(normalData);
}
var triMesh = TriMesh.FromMesh(vertexDeclaration, mesh);
foreach (var vertex in triMesh)
{
var v = vertex.ReadFVector3(vertexFieldForVertex);
Console.WriteLine(v.ToString());
}
}
}
return true;
});
What could be causing this issue? The model can be viewed fine. Can I send it over to you?
Also, what would be the most efficient way to loop through all of the XYZ verticies of a Mesh?
Thanks
OBJ image in MeshLab:
image.jpg (411.7 KB)
EDIT: Exporting the mesh using Aspose (only importing/exporting), the resulting file within MeshLab has the same number of vertices / faces, yet nothing is visible:
image.png (101.5 KB)
EDIT:
Removing the E notation from the points allowed me to load the OBJ. Obviously not a fix and I can’t achieve what I set out to do, but at least we’ve found the issue.