Hi everyone,
There is a model with textured surface. I try getting of texture coordinate for vertices. Nevertheless VertexProps has only nwEVertexProperty.eNORMAL and InwSimpleVertex instead texture coordinates return something like a mess.
Is there way to obtain real data of texture coordinates?
…
COMApi.InwOaPath path = ComBridge.ToInwOaPath(child);
foreach (COMApi.InwOaFragment3 frag in path.Fragments())
{
frag.GenerateSimplePrimitives((COMApi.nwEVertexProperty.eTEX_COORD | COMApi.nwEVertexProperty.eNORMAL), callbkListener);
Scene.m_current_mesh.AddSurface(frag, props);
}
….
class CallbackGeomListener : COMApi.InwSimplePrimitivesCB
{
....
public void Triangle(COMApi.InwSimpleVertex v1, COMApi.InwSimpleVertex v2, COMApi.InwSimpleVertex v3)
{
Scene.m_current_mesh.Indexes.Add((uint)Scene.m_current_mesh.Indexes.Count);
Scene.m_current_mesh.Indexes.Add((uint)Scene.m_current_mesh.Indexes.Count);
Scene.m_current_mesh.Indexes.Add((uint)Scene.m_current_mesh.Indexes.Count);
Array array_v = (Array)(object)v1.coord;
Scene.m_current_mesh.Positions.Add((float)(array_v.GetValue(1)));
Scene.m_current_mesh.Positions.Add((float)(array_v.GetValue(3)));
Scene.m_current_mesh.Positions.Add(-(float)(array_v.GetValue(2)));
array_v = (Array)(object)v2.coord;
Scene.m_current_mesh.Positions.Add((float)(array_v.GetValue(1)));
Scene.m_current_mesh.Positions.Add((float)(array_v.GetValue(3)));
Scene.m_current_mesh.Positions.Add(-(float)(array_v.GetValue(2)));
array_v = (Array)(object)v3.coord;
Scene.m_current_mesh.Positions.Add((float)(array_v.GetValue(1)));
Scene.m_current_mesh.Positions.Add((float)(array_v.GetValue(3)));
Scene.m_current_mesh.Positions.Add(-(float)(array_v.GetValue(2)));
array_v = (Array)(object)v1.normal;
Scene.m_current_mesh.Normals.Add((float)(array_v.GetValue(1)));
Scene.m_current_mesh.Normals.Add((float)(array_v.GetValue(3)));
Scene.m_current_mesh.Normals.Add(-(float)(array_v.GetValue(2)));
array_v = (Array)(object)v2.normal;
Scene.m_current_mesh.Normals.Add((float)(array_v.GetValue(1)));
Scene.m_current_mesh.Normals.Add((float)(array_v.GetValue(3)));
Scene.m_current_mesh.Normals.Add(-(float)(array_v.GetValue(2)));
array_v = (Array)(object)v3.normal;
Scene.m_current_mesh.Normals.Add((float)(array_v.GetValue(1)));
Scene.m_current_mesh.Normals.Add((float)(array_v.GetValue(3)));
Scene.m_current_mesh.Normals.Add(-(float)(array_v.GetValue(2)));
array_v = (Array)(object)v1.tex_coord;
Scene.m_current_mesh.UV0.Add((float)(array_v.GetValue(1)));
Scene.m_current_mesh.UV0.Add((float)(array_v.GetValue(2)));
array_v = (Array)(object)v2.tex_coord;
Scene.m_current_mesh.UV0.Add((float)(array_v.GetValue(1)));
Scene.m_current_mesh.UV0.Add((float)(array_v.GetValue(2)));
array_v = (Array)(object)v3.tex_coord;
Scene.m_current_mesh.UV0.Add((float)(array_v.GetValue(1)));
Scene.m_current_mesh.UV0.Add((float)(array_v.GetValue(2)));
}
}
I'm having the same issue. I'm able to get position and normal data correctly from the geometry, but the texture coordinate information I'm receiving is completely junk (some 0s, some very small values which may as well be 0, and NaNs). Like the original poster, I am calling:
frag.GenerateSimplePrimitives(ComApi.nwEVertexProperty.eNORMAL | ComApi.nwEVertexProperty.eTEX_COORD, callbkListener);
How can I get the correct texture coords?