modifying MaterialData using GetDDescription()



  • On 13/02/2015 at 04:32, xxxxxxxx wrote:

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

    ---------
    I'm talking about SimpleMaterial.cpp example, I want to add descriptions using GetDDescription()

    what I need to understand "about both res and GetDDescription methods" :
    1- how is the Main.... is added?? "I didn't find it any where in the .res file, found only the "Color"
    2- let's consider I want to add on the left "under the Main..." another group like Diffuse or Reflection, how to do this? and how to add to this group "when you select Diffuse or Reflection, the properties of the group"

    3- how to hide Illumination group from the left.



  • On 13/02/2015 at 06:59, xxxxxxxx wrote:

    Hello,

    the changes you describe are typically not associated with GetDDescription. These settings are defined in the material's resource file.

    The "Main" group is simply the ID_MATERIALPROPERTIES group. Additional groups are added the same way like the "Main" group: You have to define the element in the left column in the Obaselist group and than the actual parameter group. Examples are the different materials within Cinema like the Cheen material (it's resource files can be found in your Cinema distribution) or this example material.

    If you want to hide the default Illumination group you simply do not include it in your material with INCLUDE Millum.

    best wishes,
    Sebastian



  • On 13/02/2015 at 18:58, xxxxxxxx wrote:

    Hi Sebastian,

    this is a quite good and neat example!!, thanks
    but I'm still aware of an unsolved part which is:
    adding description dynamically using GetDDescription()

    I just copied and pasted the GetDDescription() part from the lookatcamera tag example

      
    Bool SDKExampleMaterial::GetDDescription(GeListNode* node, Description* description, DESCFLAGS_DESC& flags)
    {
    	if (!description->LoadDescription(ID_SDK_EXAMPLE_MATERIAL))
    		return false;
    	const DescID* singleid = description->GetSingleDescID();
      
    	DescID cid = DescLevel(16001, DTYPE_GROUP, 0);
    	if (!singleid || cid.IsPartOf(*singleid, nullptr))	// important to check for speedup c4d!
    	{
    		BaseContainer maingroup = GetCustomDataTypeDefault(DTYPE_GROUP);
    		maingroup.SetString(DESC_NAME, "Main Group");
    		if (!description->SetParameter(cid, maingroup, DescLevel(0)))
    			return true;
    	}
      
    	cid = DescLevel(16002, DTYPE_GROUP, 0);
    	if (!singleid || cid.IsPartOf(*singleid, nullptr))	// important to check for speedup c4d!
    	{
    		BaseContainer subgroup = GetCustomDataTypeDefault(DTYPE_GROUP);
    		subgroup.SetString(DESC_NAME, "Sub Group");
    		if (!description->SetParameter(cid, subgroup, DescLevel(16001)))
    			return true;
    	}
      
    	cid = DescLevel(16003, DTYPE_BOOL, 0);
    	if (!singleid || cid.IsPartOf(*singleid, nullptr))	// important to check for speedup c4d!
    	{
    		BaseContainer locked = GetCustomDataTypeDefault(DTYPE_BOOL);
    		locked.SetString(DESC_NAME, "SPECIAL Locked");
    		locked.SetBool(DESC_DEFAULT, true);
    		if (!description->SetParameter(cid, locked, DescLevel(16002)))
    			return true;
    	}
      
    	cid = DescLevel(16004, DTYPE_BOOL, 0);
    	if (!singleid || cid.IsPartOf(*singleid, nullptr))	// important to check for speedup c4d!
    	{
    		BaseContainer locked = GetCustomDataTypeDefault(DTYPE_BOOL);
    		locked = GetCustomDataTypeDefault(DTYPE_LONG);
    		locked.SetString(DESC_NAME, "SPECIAL Long");
    		locked.SetBool(DESC_DEFAULT, true);
    		if (!description->SetParameter(cid, locked, DescLevel(16002)))
    			return true;
    	}
      
    	flags |= DESCFLAGS_DESC_LOADED;
      
    	return true;
    }  
    


  • On 13/02/2015 at 19:29, xxxxxxxx wrote:

    update: I think I'm missing something!! , the above code somehow works, but I see the description ONLY in the attribute manager "not in the material manager"

    I'm near 99% sure it is related to this part of the .res file "need to translate it somewhere!!"

    GROUP Obaselist
    {
    	BOOL MATERIAL_PAGE_PROPERTIES { HIDDEN; PAGE; PARENTMSG ID_MATERIALPROPERTIES; }
    	BOOL SDK_EXAMPLE_MATERIAL_ILLUMINANTION_GROUP_ENABLE { PARENTMSG SDK_EXAMPLE_MATERIAL_ILLUMINANTION_GROUP; }
    }
    


  • On 14/02/2015 at 11:04, xxxxxxxx wrote:

    for some reason, the 1% ^ wins , the above comment is not the correct part, I don't know why the description is only added to AM and not to MM ...
    also what about adding other stuff like MaterialPreview and Obaselist from GetDDescription() , I don't see this done anywhere



  • On 16/02/2015 at 02:00, xxxxxxxx wrote:

    Hello,

    as I said, a material is typically configured using the res file, not using GetDDescription. Why do you want to do this using GetDDescription?

    When you look at the resource files you see that a "channel" is made of two things: The actual parameter group and a Boolean parameter in the Obaselist group. This parameter is used to represent the group in the left side column of the Material Editor. So when you want to create a group dynamically you have to do exactly that:

    • create a DTYPE_GROUP (as you already done)
    • create a DTYPE_BOOL parameter that is a child of the Tbaselist2d group. You must define the DESC_PARENTMSG setting of that parameter as this defines the associated group.

    Best wishes,
    Sebastian



  • On 16/02/2015 at 07:04, xxxxxxxx wrote:

    Hi Sebastian,

    I want to do this because I may be doing some special stuff "for example a tree" on the left.

    thanks a lot for clarification, now I have 2 problems;
    1- when I did what you said, the group appeared in MM , but for some reason the bool didn't appear on the left column "left column is empty, right part is filled with the group and its children"

    2- how to add other stuff like Mbase and Mpreview.



  • On 17/02/2015 at 01:40, xxxxxxxx wrote:

    Hello,

    please make sure your Obaselist group is defined in the resource file. This is what Tbaselist2d is referencing to.

    The simplest way to add Mbase and Mpreview is to use the resource file. You could create a temporary Description, load the desired sub-Descriptions using LoadDescription(), iterate through all the containing parameters using BrowseInit() and GetNext() and add these paramters to your description.

    Best wishes,
    Sebastian



  • On 17/02/2015 at 11:03, xxxxxxxx wrote:

    thanks a lot Sebastian , I think I understand how it works now.


Log in to reply