UV Mapping Projection

  • On 07/10/2015 at 14:40, xxxxxxxx wrote:

    I've been looking through the sdk for information on setting the UV mapping projection to Box.  I can't find any info.  I've also tried performing the task in C4D and checking the console for a clue but it doesn't register the action.

    Is it possible to switch the projection via Python?  Any help or clues are greatly appreciated.

  • On 08/10/2015 at 01:50, xxxxxxxx wrote:


    I guess that you talk about changing the projection mode of a Texture Tag? And with "box" you mean "Cubic"?

    You can change the mode by simply editing the corresponding parameter:


    You find the parameter IDs of the texture tag in the C++ documentation.

    Best wishes,

  • On 08/10/2015 at 06:12, xxxxxxxx wrote:

    Thanks for the response but I'm looking for something else.

    I already have the texture tag set to UVW mapping.  What I want to do is unwrap the texture.  In Body Paint there are projection tools that can be used to help unwrap the UVs.  One of the buttons is called "Box" and it unwraps a cube into 6 sides.

  • On 08/10/2015 at 08:13, xxxxxxxx wrote:

    Several years ago I asked how to execute the "Frontal" UV button in BP. And Matthias told me that we cannot execute those buttons.
    I was upset about that. So he (and some other members) posted some code on how to create the UV's like the Frontal button does for me.

    If Maxon can't give us access to these buttons. Then it would be nice if they posted the source code for them.
    AFAIK. The code they use contains nothing secret that they need to keep secret from their competitors. It's all the same maths used by every single software company.
    But math is painful.😂

    It would handy to have the code behind those buttons.


  • On 08/10/2015 at 08:31, xxxxxxxx wrote:

    Well that sucks.

    Thanks for taking the time to respond.

  • On 08/10/2015 at 09:07, xxxxxxxx wrote:


    as Scott mentions, it is unfortunately not possible to access this functionality.

    Best wishes,

  • On 08/10/2015 at 09:14, xxxxxxxx wrote:

    Thanks for checking into it.  Maybe in the future it will be available via CallCommand.

    I'm writing a productivity script and it would have saved a step.  I can just click the Box button when I'm in BP adjusting the UV to fit the texture.

    I'm pretty happy that python will get me to that point.  Have to leave something for humans to do or I would be out of a job. 😂

  • On 09/10/2015 at 08:30, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    So he (and some other members) posted some code on how to create the UV's like the Frontal button does for me.


    Could you point us to the posted code?


  • On 09/10/2015 at 12:06, xxxxxxxx wrote:

    The code was posted in C++ so I don't know if it will help you or not:

    This is what I have in my C++ notes:

    //This code creates the equivalent to the flat mapping button in the BP UV options  
    #define SIGDIG    5.0                   //Define a value macro to be used several times later on  
    static Real sign(Real n)  
      if( n > 0.0 )    return 1.0;        //Returns zero by default   
      if( n < 0.0 )    return -1.0;       //Otherwise Returns 1.0 or -1.0  
      return 0.0;  
    static Real TrimDecimal(Real num, Real digits)  
      Real n;   
      n = num * Pow((Real)10.0, digits);   
      n = sign(n) * Abs(Floor(n + 0.5));   
      return n / Pow((Real)10.0, digits);   
    Bool FrontalMapUVs(PolygonObject *op, Matrix mg)  
      if( !op ) return false;  
      LONG numFaces = op->GetPolygonCount();  
      LONG numVerts = op->GetPointCount();  
      Vector *pVerts = op->GetPointW();  
      CPolygon *pPolys = op->GetPolygonW();  
      UVWTag *pUVTag = (UVWTag * )op->MakeVariableTag(Tuvw, numFaces);  
      if( !pUVTag ) return false;  
      UVWHandle pUVHndl = pUVTag->GetDataAddressW();  
      if( !pUVHndl ) return false;  
      LONG ndx;  
      Real lenxinv, lenyinv, lenzinv;  
      Vector mapCenter, mapSize, vMin, vMax;  
      vMin.x = 100000.0;  
      vMin.y = 100000.0;  
      vMin.z = 100000.0;  
      vMax.x = -100000.0;  
      vMax.y = -100000.0;  
      vMax.z = -100000.0;  
      for(ndx=0; ndx<numVerts; ndx++)  
          Vector pt = pVerts[ndx] * mg;  
          if( pt.x < vMin.x ) vMin.x = pt.x;  
          if( pt.x > vMax.x ) vMax.x = pt.x;  
          if( pt.y < vMin.y ) vMin.y = pt.y;  
          if( pt.y > vMax.y ) vMax.y = pt.y;  
          if( pt.z < vMin.z ) vMin.z = pt.z;  
          if( pt.z > vMax.z ) vMax.z = pt.z;  
      mapSize.x = Abs(vMax.x - vMin.x);  
      mapSize.y = Abs(vMax.y - vMin.y);  
      mapSize.z = Abs(vMax.z - vMin.z);  
      mapCenter.x = vMin.x+(mapSize.x*0.5);  
      mapCenter.y = vMin.y+(mapSize.y*0.5);  
      mapCenter.z = vMin.z+(mapSize.z*0.5);  
      if (mapSize.x!=0.0) lenxinv = 1.0/mapSize.x;    else lenxinv = 0.0;  
      if (mapSize.y!=0.0) lenyinv = 1.0/mapSize.y;    else lenyinv = 0.0;  
      if (mapSize.z!=0.0) lenzinv = 1.0/mapSize.z;    else lenzinv = 0.0;  
      // Walk the list of polygons and map the UVs  
      for(ndx=0; ndx<numFaces; ndx++)  
          UVWStruct uvw;  
          pUVTag->Get(pUVHndl, ndx, uvw);  
          Vector pt_a = (pVerts[pPolys[ndx].a] - mapCenter) + mg.off;  
          Vector pt_b = (pVerts[pPolys[ndx].b] - mapCenter) + mg.off;  
          Vector pt_c = (pVerts[pPolys[ndx].c] - mapCenter) + mg.off;  
          Vector pt_d = (pVerts[pPolys[ndx].d] - mapCenter) + mg.off;  
          uvw.a.x = TrimDecimal((pt_a.x*lenxinv)+0.5, SIGDIG);  
          uvw.a.y = TrimDecimal((-pt_a.y*lenyinv)+0.5, SIGDIG);  
          uvw.b.x = TrimDecimal((pt_b.x*lenxinv)+0.5, SIGDIG);  
          uvw.b.y = TrimDecimal((-pt_b.y*lenyinv)+0.5, SIGDIG);  
          uvw.c.x = TrimDecimal((pt_c.x*lenxinv)+0.5, SIGDIG);  
          uvw.c.y = TrimDecimal((-pt_c.y*lenyinv)+0.5, SIGDIG);  
          uvw.d.x = TrimDecimal((pt_d.x*lenxinv)+0.5, SIGDIG);  
          uvw.d.y = TrimDecimal((-pt_d.y*lenyinv)+0.5, SIGDIG);  
          pUVTag->Set(pUVHndl, ndx, uvw);  
      return true;  


  • On 12/10/2015 at 00:24, xxxxxxxx wrote:

    Thanks again.

  • On 07/12/2015 at 02:03, xxxxxxxx wrote:

    Originally posted by xxxxxxxx


    as Scott mentions, it is unfortunately not possible to access this functionality.

    Best wishes,

    Any ideas IF this will be accessible in future SDK updates, and if this future is near or far away?

  • On 08/12/2015 at 01:28, xxxxxxxx wrote:


    currently we cannot make any statements on future releases or API functions.

    Best wishes,

  • On 23/12/2015 at 01:33, xxxxxxxx wrote:

    As the original request to access the projection buttons was from 2012, and seeing that these currently still cannot be called from Python (or even C++, if I read correctly) I thought that with the change in communication we finally would get to know if or when more access to the bodypaint module would be provided.

    Thanks for reading.

Log in to reply