Default values of Vector descriptions



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

    On 23/01/2012 at 07:10, xxxxxxxx wrote:

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

    ---------
    Hello,
    within my effector plugin, there're quite some parameters generated while runtime (rather than in the ressource files). This seems to work fine, at least most of it. Somehow I'm not able to set the default values of newly created Vector parameters. Actually , this is not quite correct. I seem to be able to set the default values, but they aren't represented in the GUI. If I use "Set to defaults" from the context menu, the GUI also shows the correct values. But if I do not use "Set to defaults" and change a component of the vector, the other components will be set to the wrongly displayed GUI values.
    I hope, I was able to describe the behaviour understandably.
    Here's my ModifyDDescription() :

    Bool MyTestPlugin::ModifyDDescription(GeListNode *node, Description *description, AtomArray* ar)  
    {  
      const DescID *singleid = description->GetSingleDescID();  
      BaseContainer * const bcData = ((BaseList2D* )node)->GetDataInstance();  
      DescID cid;  
      
      for (LONG idx = 0; idx < ed.iMax; idx++) {  
        cid = DescLevel(MYTESTPLUGIN_GROUP_BASE + idx, DTYPE_GROUP, 0);  
        if (!singleid || cid.IsPartOf(*singleid, NULL)) { // important to check for speedup c4d!  
          BaseContainer subgroup = GetCustomDataTypeDefault(DTYPE_GROUP);  
      
          subgroup.SetString(DESC_NAME, "Group" + LongToString(idx));  
          if (!description->SetParameter(cid, subgroup, DescLevel(MYTESTPLUGIN_GROUP))) {  
            return TRUE;  
          }  
        }  
        cid = DescLevel(MYTESTPLUGIN_SIZE_BASE + idx, DTYPE_VECTOR, 0);  
        if (!singleid || cid.IsPartOf(*singleid, NULL)) { // important to check for speedup c4d!  
          BaseContainer bc = GetCustomDataTypeDefault(DTYPE_VECTOR);
          bc.SetString(DESC_NAME, "Size");  
          bc.SetVector(DESC_MIN, Vector(RCO 0.001, RCO 0.001, RCO 0.001));  
          bc.SetVector(DESC_MAX, Vector(RCO 2.0, RCO 2.0, RCO 2.0));  
          bc.SetVector(DESC_STEP, Vector(RCO 0.001, RCO 0.001, RCO 0.001));  
          bc.SetVector(DESC_DEFAULT, Vector(RCO 1.0, RCO 1.0, RCO 1.0));  
          bc.SetLong(DESC_UNIT, DESC_UNIT_PERCENT);  
          if (!description->SetParameter(cid, bc, DescLevel(MYTESTPLUGIN_GROUP_BASE + idx))) {  
            return TRUE;  
          }  
        }  
      }  
      return TRUE;  
    }
    

    Thanks in advance,
    regards,
    Andreas



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

    On 23/01/2012 at 18:32, xxxxxxxx wrote:

    It is easier simply to set the Vector description using:

    bcData->SetVector(MYTESTPLUGIN_SIZE_BASE + idx, Vector(RCO 1.0, RCO 1.0, RCO 1.0));

    or using the more recent expected method:

    node->SetParameter(DescLevel(MYTESTPLUGIN_SIZE_BASE + idx), GeData(Vector(RCO 1.0, RCO 1.0, RCO 1.0)), DESCFLAGS_SET_PARAM_SET);

    By the way, what is 'RCO'?  I've never seen that used in C++.



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

    On 24/01/2012 at 00:23, xxxxxxxx wrote:

    Thanks, for the hint. I'll try it. 
    I'm not sure, where in the SDK I stumbled over RCO. I think it was in some example plugin. Basically it seems to be a macro, hinting the compiler what to do with this Real constant (I think it decides (at least) which type is quicker on the given architecture, SReal and LReal). It was said to speed up some code on 64-Bit systems.
    And although the above code snippet is not at all speed critical, I'm trying to use it all over the place, in order to get a hang of it.



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

    On 24/01/2012 at 00:45, xxxxxxxx wrote:

    This is what the SDK docs say:
    "RCO  -  Defines float constants to Real. Use this define to define float consts, e.g. instead of 10.0f write SCO(10.0). This will speed up the 64 bit version some percent."



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

    On 24/01/2012 at 01:17, xxxxxxxx wrote:

    I tried to add

    bcData->SetVector(MYTESTPLUGIN_SIZE_BASE + idx, Vector(RCO 1.0));
    

    after

      
    if (!description->SetParameter(cid, bc, DescLevel(MYTESTPLUGIN_GROUP_BASE + idx))) {  
      return TRUE;  
    }  
    

    This kind of works for the default value, but as ModifyDDescription() is called several times, it will pin the values. That's why I had rather used the default value.
    Now, I ended up with this:

      
    Vector vTemp;  
    vTemp = bcData->GetVector(MYTESTPLUGIN_SIZE_BASE + idx, Vector(RCO 1.0));  
    bcData->SetVector(MYTESTPLUGIN_SIZE_BASE + idx, vTemp);  
    

    Feels a bit cheesy... and I thought, that's what the default value was for...



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

    On 24/01/2012 at 05:50, xxxxxxxx wrote:

    Don't call the bcData->SetVector() in GetDDescription() but in Init().  Then it will be called only when the object needs to be initialized as GetDDescription() is called whenever the description needs to be updated or displayed (in the A.M.).



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

    On 24/01/2012 at 09:43, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    node->SetParameter(DescLevel(MYTESTPLUGIN_SIZE_BASE + idx), GeData(Vector(RCO 1.0, RCO 1.0, RCO 1.0)), DESCFLAGS_SET_PARAM_SET);

    With DESCFLAGS_SET_PARAM_SET it doesn't set the parameter value. Replacing flags with DESCFLAGS_SET_0 it works as expected.


Log in to reply