Community
Navisworks API
Welcome to Autodesk’s Navisworks API Forums. Share your knowledge, ask questions, and explore popular Navisworks API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

obtain texture coordinates

3 REPLIES 3
Reply
Message 1 of 4
965xxx
766 Views, 3 Replies

obtain texture coordinates

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)));

           

        }

 }

 

3 REPLIES 3
Message 2 of 4
rangsk
in reply to: 965xxx

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?

Message 3 of 4
t0316kcw
in reply to: 965xxx

It's been 3 years now. Any answer/suggestion regarding to this post?

 

Thanks.

Message 4 of 4
nicolas.augustin
in reply to: t0316kcw

Any answer/suggestion regarding to this post?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report