How to keep Texture mapping result


#1

Hi~
There are cpp, 3dm and jpg in my attached file.
TestSample.zip (140.3 KB)

I want to change texture coordinates and keep the texture result.
Even if it change render mesh density in the Document properties > Mesh > Render mesh quality, I also want to keep my texture mapping result.

So I get the render mesh from Brep

const ON_Mesh* mesh = F->Mesh(ON::render_mesh); 

And I change the texture coordinats from m_T in the mesh.

ON_2fPointArray Texs = mesh->m_T;
for (int i = 0; i<mesh->m_T.Count(); i++)
{
     ON_2fPoint* fpnt = Texs.At(i);
     double x = fpnt->x / ScaleX;
     double y = fpnt->y / ScaleY;
     fpnt->x = float(x);
     fpnt->y = float(y);
 }
 const_cast<ON_Mesh*>(mesh)->m_T = Texs;

After computing, I can’t see the result immediately until I click the object again or change viewport.

When I modify Document properties > Mesh > Render mesh quality and click the object, the texture mapping are changed and the result is Rhino texture mapping way.

And I run my code again to change the texture mapping, but texture mapping failure.
The mapping result always keep the Rhino texture mapping way.

Can somebody help me to solve the problem?


(Andrew le Bihan) #4

You must set m_S if you want to give surface texture coords.