Add Texture /C++

@johnc

I have new problem
In the DlgSampleTexutre.cpp
I add code to modify the scale of the bitmap texture.

   //Modify Scale
    const ON_Brep* Brep = ON_Brep::Cast(myObj->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;
      uCrv->GetLength(&len0);
      vCrv->GetLength(&len1);
      delete uCrv;	delete vCrv;
    }

    ON_Mesh* mappingMesh = F->Mesh(ON::render_mesh)->Duplicate();
    ON_2fPointArray Texs = mappingMesh->m_T;
    for (int i = 0; i < mappingMesh->m_T.Count(); i++)
    {
      const ON_2dPoint* p2d = mappingMesh->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[0]) / u_dom.Length();
      double ty = (y - v_dom[0]) / v_dom.Length();

      tx /= m_ScaleX;
      ty /= m_ScaleY;
      ON_2fPoint* p2f = Texs.At(i);
      p2f->x = float(tx);
      p2f->y = float(ty);
    }
    mappingMesh->m_T = Texs;
    CDES_TextureMapping DES_TextureMap;
    DES_TextureMap.SetCustomMeshMapping(*myObj, *pDoc, mappingMesh);
 

But I found, the scale of the bitmap texture be changed on the firs time value setting, if I change the value of the scale again, the scale of the bitmap texture doesn’t change.

Could you help me to check the program?

PS:
We need to use above code to change the scale of the bitmap texture.

The project, I compile on Rhino6.
DESNewSample.zip (110.3 KB)
In DESNewSample.zip there are
checkmat small.jpg and my project