Can't recieve data from my shader plugin



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

    On 20/04/2007 at 01:56, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   R9-R10 
    Platform:   Windows  ;   
    Language(s) :   C.O.F.F.E.E  ;  C++  ;

    ---------
    COFFEE RELATED

    Hi there!

    I've created a volumeplugin and applied it to an object, but when i'm trying to access it via

    <CODE>var doc = GetActiveDocument();
    var textag = op->GetFirstTag();

    while(textag!NULL)
    {
    if(textag->GetType() == Ttexture)
    {
          var mat = textag#TEXTURETAG_MATERIAL;
          println("FOUND IT: ", mat);
    }
    textag = textag->GetNext();
    }</CODE>

    the console always prints "nil" for my shader, but if i'm doing the same with a standard C4d material anything is going fine.

    Did i missing something?

    Ciao

    Sascha



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

    On 20/04/2007 at 03:24, xxxxxxxx wrote:

    Without knowing the sourcecode of your volumeshader it is a bit hard to say what is going on. In what language is the shader written, COFFEE or C++? The C++ SDK Volume shaders work fine for your little example. You can contact me under sdk_support(at)maxon.net if you want to keep your source code confidential.

    cheers,
    Matthias



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

    On 20/04/2007 at 04:06, xxxxxxxx wrote:

    Hi Matthias,

    it is nothing special, just a simple dummy shader, mainly for getting access to some data of the shader to export it.
    It is written in Coffee.

      
    // global variables  
    var DiffuseResource;  
    var DiffuseDialogVar;               // dialog variable  
    var DiffuseVariables;               // temporary saved settings  
      
    // create variable stuct  
    struct diffuse_variables  
    {       
         var sfdiffcolor;  
                
         var sfdifftex;  
    }  
      
    ///////////////  
    // procedures  
      
    InitDiffuseVariables()  
    {  
         DiffuseVariables = new(diffuse_variables);  
                
         DiffuseVariables->sfdifftex = new(Filename);  
         DiffuseVariables->sfdifftex->SetFullString("Please select a texture");  
           
         DiffuseVariables->sfdiffcolor = vector(1.0, 1.0, 1.0);  
    }  
      
    // dialog class  
    class DiffuseDialog : GeModalDialog  
    {  
         public:  
              DiffuseDialog();       
                
              CreateLayout();  
              Init();  
              Command(id,msg);       
    }  
      
    DiffuseDialog::DiffuseDialog()  
    {  
         super();  
    }  
      
    DiffuseDialog::CreateLayout()  
    {  
         LoadDialogResource(IDD_SUNFLOW_DIFFUSE,DiffuseResource,0);  
         AddDlgGroup(DR_DLGGROUP_OK);  
         return TRUE;  
    }  
      
    DiffuseDialog::Init()  
    {  
         SetColorField(IDC_SUNFLOW_DIFFUSE_COLOR , DiffuseVariables->sfdiffcolor);  
         SetString(IDC_SUNFLOW_DIFFUSE_TEXTURE, tostring(DiffuseVariables->sfdifftex->GetFullString()));  
           
         return TRUE;  
    }  
      
    DiffuseDialog::Command(id,msg)  
    {  
         var doc = GetActiveDocument();  
           
         switch (id)  
         {  
              case IDC_SUNFLOW_DIFFUSE_COLOR:  
                   DiffuseVariables->sfdiffcolor = GetColor(IDC_SUNFLOW_DIFFUSE_COLOR);  
              break;  
                
              case IDC_SUNFLOW_DIFFUSE_TEXTURE_BUTTON:  
                   if (DiffuseVariables->sfdifftex->FileSelect("Please select a texture", FALSE))  
                   {  
                        SetString(IDC_SUNFLOW_DIFFUSE_TEXTURE, tostring(DiffuseVariables->sfdifftex->GetFullString()));  
                   }  
              break;  
                
              case IDC_SUNFLOW_DIFFUSE_TEXTURE:  
                   DiffuseVariables->sfdifftex->SetFullString(GetString(IDC_SUNFLOW_DIFFUSE_TEXTURE));  
              break;  
         }  
    }  
      
    //plugin  
      
    class Diffuse:VolumePlugin//ChannelPlugin   
    {  
    public:  
         Diffuse();  
         GetName();  
         GetID();  
         // Output(settings, render, p, n, d, t, texflag, vd);  
         CalcSurface(settings,render,vd);  
         EditData(settings);  
    }  
      
    Diffuse::GetName()   
    {  
         return "SFDiffuse";  
    }   
      
    Diffuse::GetID()   
    {  
         return SunflowDiffuseID;  
    }   
      
    /* Diffuse::Output(settings, rd, p, n, d, t, texflag, vd)   
    {  
         return DiffuseVariables->sfdiffcolor;  
    } */  
      
    Diffuse::CalcSurface(settings,render,vd)  
    {  
         var col;  
           
         vd->col = DiffuseVariables->sfdiffcolor;  
    }  
      
    Diffuse::EditData(settings)   
    {  
         DiffuseDialogVar->Open(-1,-1);       
         return TRUE;  
    }   
      
    ///////////////  
    // main  
      
    SunflowDiffuse()  
    {       
         InitDiffuseVariables();  
         var file = GeGetRootFilename(); if (!file) return;  
         file->RemoveLast();  
         DiffuseResource = new(GeResource,file);  
         if (!DiffuseResource)  
         {  
              println("    Error: Can't load resource files for SunflowDiffuse");  
              return FALSE;  
         }  
           
         DiffuseDialogVar = new(DiffuseDialog);  
         Register(Diffuse);  
    }
    

    Ciao and thanks.

    Sascha



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

    On 20/04/2007 at 04:39, xxxxxxxx wrote:

    Found it, just included the .coh file in the wrong spot.
    I worked to much on this plug, it was so obvious but i didn't saw it.

    Anyway thanks Matthias.

    Ciao



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

    On 20/04/2007 at 11:01, xxxxxxxx wrote:

    I think my joy was overhasty!
    A new problem arised.

    Ok, i've got a menu plugin with the search routine in the first post and the shader plugin. Now I wanted to access the shader data with the resource descriptions like this

      
    if(mat)  
    {  
         var mattype = mat->GetType();  
         println("MATTYPE: ", mattype);  
         var matname = mat->GetName();  
         println("MATNAME: ", matname);  
         var matbc = mat->GetContainer();  
         println("MATCONTAINER: ", matbc);  
         var matdata = matbc->GetData(IDC_SUNFLOW_DIFFUSE_COLOR);  
         println("MATDATA: ", matdata);  
    }  
    

    but to my surprise I couldn't access them, in fact I always received a nil for GetData. After searching the forum and the SDK, I found that there are two ways of accomplishing my task. 1.Pluginmessaging or 2.Storing the shader data to an object container.

    So, what would be the best method and how and where is the best place to implement it?

    Ciao
    Sascha


Log in to reply