Assigning a material to a material tag



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 30/12/2007 at 15:54, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   10.5 
    Platform:      Mac OSX  ; 
    Language(s) :   C.O.F.F.E.E  ;

    ---------
    Hi,

    I want to create and assign a material in COFFEE, but this line generates an error:

    > tag- >SetMaterial(material);

    In the COFFEE doc, I found that the SetMaterial methods wants a MARKER. What is that and how can I transform a material into a marker?

    This is my code for creating & assigning a material in COFFEE:

    > _
    >      // getting the selected object
    >      if (!(obj = doc->GetActiveObject())) return;
    >      
    >      // creating a new material and a new texture tag
    >      if (!(material = AllocMaterial(Mmaterial))) { println("Error: AllocMaterial"); }
    >      if (!(tag = AllocTag(Ttexture))) { println("Error: AllocTag"); }
    >      
    >      // assigning the texture tag to the object
    >      if( !(obj->InsertTag(tag))) { println("Error: InsertTag"); }
    >      
    >      // insering the new material to the document     
    >      if (!(doc->InsertMaterial(material, NULL))) { println("Error: InsertMaterial"); }
    >      
    >      // assigning the material to the texture tag
    >      tag->SetMaterial(material);
    >      
    >      // enabling the Color channel for the material
    >      material->SetChannelState(CHANNEL_COLOR, TRUE);
    >
    >      // getting the path for the texture
    >      file = GeGetRootFilename();
    >      if (!file) return;
    >      file->RemoveLast();
    >      file->AddLast("tex.jpg");
    >      
    >      // assigning the texture to the Color channel
    >      if (!(channel = material->GetChannel(CHANNEL_COLOR))) { println("Error: GetChannel"); }
    >      if (!(container = channel->GetContainer())) { println("Error: GetContainer"); }
    >      container->SetData(CH_TEXTURE, file->GetFullString());
    >      channel->SetContainer(container);
    > _

    Thanks for your help!!



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 31/12/2007 at 03:37, xxxxxxxx wrote:

    This works for me:

    > var mat = AllocMaterial(Mmaterial);
    > doc- >InsertMaterial(mat, NULL);
    >
    > mat->SetName("Hello Material");
    >
    > var tag = AllocTag(Ttexture);
    > op->InsertTag(tag);
    >
    > var bc = tag->GetContainer();
    > bc->SetData(TEXTURETAG_MATERIAL , mat);
    > tag->SetContainer(bc);



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 31/12/2007 at 05:29, xxxxxxxx wrote:

    Ah, you extract the container from the tag, modify it and write it back. OK, I'll try it out.

    Thanks


Log in to reply