Guest User

Cinema 4D JMC2OBJ Texture Loader

a guest
Sep 13th, 2013
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fixTextures(doc){
  2.     var mat = doc->GetFirstMaterial();
  3.     if(!mat)
  4.         return;
  5.     doc->StartUndo();
  6.         var i = 1;
  7.     while(mat){
  8.         var oldname = mat->GetName();
  9.        
  10.         var oldnameGEN = tostring(oldname) + ".png";
  11.         var channel, bc;
  12.  
  13.         mat->SetBit(BIT_ACTIVE);
  14.  
  15.         mat->SetChannelState(CHANNEL_COLOR, TRUE);
  16.         //mat->SetChannelState(CHANNEL_BUMP, TRUE);
  17.         mat->SetChannelState(CHANNEL_BUMP, FALSE);
  18.         mat->SetChannelState(CHANNEL_ALPHA, TRUE);
  19.         mat->SetChannelState(CHANNEL_SPECULAR, TRUE);
  20.  
  21.         mat#MATERIAL_COLOR_COLOR = vector(1,1,1);
  22.  
  23.         channel = mat->GetChannel(CHANNEL_COLOR);
  24.         bc = channel->GetContainer();
  25.         bc->SetData(CH_TEXTURE, oldnameGEN);
  26.         bc->SetData(CH_INTERPOLATION, 0);
  27.         channel->SetContainer(bc);
  28.  
  29.         //channel = mat->GetChannel(CHANNEL_BUMP);
  30.         //bc = channel->GetContainer();
  31.         //bc->SetData(CH_TEXTURE, oldnameGEN);
  32.         //bc->SetData(CH_INTERPOLATION, 0);
  33.         //channel->SetContainer(bc);
  34.  
  35.         channel = mat->GetChannel(CHANNEL_ALPHA);
  36.         bc = channel->GetContainer();
  37.         bc->SetData(CH_TEXTURE, oldnameGEN);
  38.         bc->SetData(CH_INTERPOLATION, 0);
  39.         channel->SetContainer(bc);
  40.  
  41.         channel = mat->GetChannel(CHANNEL_SPECULAR);
  42.         bc = channel->GetContainer();
  43.         bc->SetData(CH_TEXTURE, oldnameGEN);
  44.         bc->SetData(CH_INTERPOLATION, 0);
  45.         channel->SetContainer(bc);
  46.  
  47.         mat = mat->GetNext();
  48.         i++;
  49.     }
  50.     doc->EndUndo();
  51.  
  52. }
  53. main(doc,op)
  54. {
  55.     fixTextures(doc);
  56. }
Advertisement
Add Comment
Please, Sign In to add comment