Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Optimal Mapping [SOLVED]

    SDK Help
    0
    3
    290
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post