Optimal Mapping [SOLVED]



  • On 16/06/2015 at 08:00, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   16 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    Hello,

    I create two UVW Tags in my code and I want to use optimal mapping on the first one and quader mapping on the second one. How can I achieve this? I know about the CallUVCommand but how can I tell the program to use one of my UVW Tags?

    // Generate Lightmap UV  
    UVWTag* lightmap_uv_tag = (UVWTag* )op->MakeVariableTag(Tuvw,polyobj->GetPolygonCount(),nullptr);  
    lightmap_uv_tag->SetName("lightmap");                      
      
    // Generate Texture UV  
    UVWTag* texture_uv_tag = (UVWTag* )op->MakeVariableTag(Tuvw,polyobj->GetPolygonCount(),nullptr);  
    texture_uv_tag->SetName("texture");
    

    Thanks
    crush4



  • On 17/06/2015 at 11:50, xxxxxxxx wrote:

    Hello,

    it seems that the UV functions should be used in interactive tools. So they expect a properly setup scene. CallUVCommand() works together with GetActiveUVSet() and the created TempUVHandle. So your code could look something like this:

      
    VariableTag* uvwtag = VariableTag::Alloc(Tuvw,poly->GetPolygonCount());  
      
    poly->InsertTag(uvwtag);  
      
    doc->SetActiveObject(poly);  
    doc->SetActiveTag(uvwtag);  
      
    // select all polygons  
      
    BaseSelect* selection = poly->GetPolygonS();  
    selection->SelectAll(0,poly->GetPolygonCount()-1);  
      
    // Cinema must be in UV Poly edit mode  
    doc->SetMode(Muvpolygons);  
      
    TempUVHandle* handle = GetActiveUVSet(doc,GETACTIVEUVSET_ALL);  
      
    if(handle)  
    {  
     // set up settings  
     BaseContainer bcMapSettings;  
      
     bcMapSettings.SetBool(OPTIMALMAPPING_PRESERVEORIENTATION, true);  
     bcMapSettings.SetBool(OPTIMALMAPPING_STRETCHTOFIT,       false);  
     bcMapSettings.SetFloat(OPTIMALMAPPING_DISTORTION,         0.5);  
     bcMapSettings.SetInt32(OPTIMALMAPPING_RELAXCOUNT,          0);  
     bcMapSettings.SetFloat(OPTIMALMAPPING_SPACING,             0.2);  
      
     // call command  
     CallUVCommand(handle->GetPoint(), handle->GetPointCount(), handle->GetPoly(), handle->GetPolyCount(),handle->GetUVW(),handle->GetPolySel(),handle->GetUVPointSel(),handle->GetBaseObject(), Muvpolygons,UVCOMMAND_OPTIMALMAPPING,bcMapSettings);  
      
     // apply  
     handle->SetUVWFromTextureView(handle->GetUVW(),false,false,false);  
      
     FreeActiveUVSet(handle);  
    }  
      
    EventAdd();  
    

    best wishes,
    Sebastian



  • On 18/06/2015 at 12:13, xxxxxxxx wrote:

    Thank you Sebastian,

    this works perfectly for me.

    // Cinema must be in UV Poly edit mode  
    doc->SetMode(Muvpolygons);
    

    is not needed and causes some errors in the uv map if before some uv polygons were selected. I don't know why.


Log in to reply