Hi @andy and @dale @yoko_kadotani
@andy, you said your test by using ON_Mesh::m_S is no problem. But I use ON_Mesh::m_S, still have problem.
So, I record two avi to show my problem.
Set to ON_Mesh::m_S
It set texture coordiates to ON_Mesh::m_S.
Problem: After computing, the texture coordinates don’t change，because the mapping result doesn’t change even if I set different scale.
Set to ON_Mesh::m_T
It set texture coordiates to ON_Mesh::m_T.
Problem: After computing, I can’t see the result immediately until I click the object again or change viewport. And I run my code again which I use same picture and different scale, but texture mapping failure, because the mapping result doesn’t change.
On Rhino4 and Rhino5, we already had UV mapping in shoe filed, it can make shoe have good texture mapping result.
The following picture is UV mapping result by using our plugin.
On Rhino4 and Rhino5, we use the texture coordinates from m_T in the render mesh to modify picture, and it has good result.
On Rhino4 and Rhino5, the coding is
I get the render mesh from Brep
const ON_Brep* Brep = ON_Brep::Cast(pObject->Geometry());
ON_BrepFace* F = Brep->Face(0);
ON_Interval u_dom, v_dom;
const ON_Surface* Sur = *Brep->m_S.At(0);
u_dom = Sur->Domain(0);
v_dom = Sur->Domain(1);
ON_Curve* uCrv = Sur->IsoCurve(0, v_dom.Mid());
ON_Curve* vCrv = Sur->IsoCurve(1, u_dom.Mid());
double len0, len1;
delete uCrv; delete vCrv;
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;
ON_2dPointArray STexs = Mesh->m_S;
for (int i = 0; i<Mesh->m_T.Count(); i++)
const ON_2dPoint* p2d = Mesh->m_S.At(i);
ON_2dPoint Pnt; Pnt.x = p2d->x; Pnt.y = p2d->y;
double x = Pnt.x;
double y = Pnt.y;
double tx = (x - u_dom) / u_dom.Length();
double ty = (y - v_dom) / v_dom.Length();
tx /= ScaleX;
ty /= ScaleY;
//ON_2dPoint* p2 = STexs.At(i);
//p2->x = tx;
//p2->y = ty;
ON_2fPoint* p2f = Texs.At(i);
p2f->x = float(tx);
p2f->y = float(ty);
const_cast<ON_Mesh*>(Mesh)->m_T = Texs;
Now, on Rhino6 it doesn’t work.
Because this problem we can’t announce our plugin for Rhino6 version.
Could you help me to solve the problem or give us some suggestion?
my Rhino6 SDK is 6.4.18130.19341 and
Rhino6 is 6.4.118130.19341