Subdivide and MSG_POINTS_CHANGED?



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

    On 06/01/2009 at 12:21, xxxxxxxx wrote:

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

    ---------
    Howdy,

    The Subdivide modeling function sends the messages MSG_POINTS_CHANGED and MSG_POLYGONS_CHANGED along with a VariableChanged data structure. But I'm having a difficult time understanding the logic behind the information received.

    Here's my test tag code:

    > switch (type) \> { \>      case MSG_POLYGONS_CHANGED: \>           GePrint("Message = MSG_POLYGONS_CHANGED"); \>            \>           VariableChanged \*vchg = (VariableChanged\* )data; \>           if(vchg) \>           { \>                GePrint("VariableChanged data sent"); \>                 \>                LONG oCnt = vchg->old_cnt, nCnt = vchg->new_cnt; \>                GePrint("oCnt = "+LongToString(oCnt)+"; nCnt = "+LongToString(nCnt)); \>                 \>                if(vchg->map) \>                { \>                     GePrint("VariableChanged map included"); \>                } \>           } \>           break; \>      case MSG_POINTS_CHANGED: \>           GePrint("Message = MSG_POINTS_CHANGED"); \>            \>           VariableChanged \*vchg = (VariableChanged\* )data; \>           if(vchg) \>           { \>                GePrint("VariableChanged data sent"); \>                 \>                LONG oCnt = vchg->old_cnt, nCnt = vchg->new_cnt; \>                GePrint("oCnt = "+LongToString(oCnt)+"; nCnt = "+LongToString(nCnt)); \>                 \>                Vector \*padr = ToPoint(op)->GetPoint(); \>                LONG ind, pCnt = ToPoint(op)->GetPointCount(); \>                 \>                if(nCnt > oCnt && nCnt == pCnt) \>                { \>                     for(ind=oCnt; ind<nCnt; ind++) \>                     { \>                          GePrint("padr["+LongToString(ind)+"] = "+VectorToString(padr[ind])); \>                     } \>                } \>                 \>                if(vchg->map) \>                { \>                     GePrint("VariableChanged map included"); \>                } \>           } \>           break; \> }

    With a simple polygon cube, when the Subdivide function is called the console prints this:

    Message = MSG_POINTS_CHANGED
    VariableChanged data sent
    oCnt = 8; nCnt = 26
    padr[8] = [0,0,0]
    padr[9] = [0,0,0]
    padr[10] = [0,0,0]
    padr[11] = [0,0,0]
    padr[12] = [0,0,0]
    padr[13] = [0,0,0]
    padr[14] = [0,0,0]
    padr[15] = [0,0,0]
    padr[16] = [0,0,0]
    padr[17] = [0,0,0]
    padr[18] = [0,0,0]
    padr[19] = [0,0,0]
    padr[20] = [0,0,0]
    padr[21] = [0,0,0]
    padr[22] = [0,0,0]
    padr[23] = [0,0,0]
    padr[24] = [0,0,0]
    padr[25] = [0,0,0]
    Message = MSG_POLYGONS_CHANGED
    VariableChanged data sent
    oCnt = 6; nCnt = 24
    Message = MSG_POINTS_CHANGED
    VariableChanged data sent
    oCnt = 26; nCnt = 26
    Message = MSG_POLYGONS_CHANGED
    VariableChanged data sent
    oCnt = 24; nCnt = 24

    You can see that the messages are sent several times. When the message MSG_POINTS_CHANGED is received and the VariableChanged data has differing old point count and new point count (oCnt = 8; nCnt = 26), all of the added points' values in the points array are 0,0,0.

    So, I'm assuming this means that when the MSG_POINTS_CHANGED is received at that particular moment, the points array has only been resized and initialized, but the point positions have not been set, yet. But, I need to do a calculation based on the added points' positions and update the storage array in the tag. :o(

    In the SDK documentation for VariableChanged data, there are only examples of how to build the data structure and send the MSG_POINTS_CHANGED message from a tool, but no examples of how to proceed when a tag receives the message and data structure.

    From searching older posts, it seems the older modeling tools don't support the newer TranslationMaps data and messages, but the question is which modeling tools are which, and how do you code to support all of the older tools?

    Just when you think you have all the bases covered, one of your beta testers will use a tool that's not covered, and then it's back to the drawing board. :o(

    Adios,
    Cactus Dan



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

    On 08/01/2009 at 00:43, xxxxxxxx wrote:

    I am currently a bit busy with some other stuff but maybe check out the chapter about the TranslationMaps class. it seems like this could help you here.

    cheers,
    Matthias



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

    On 09/01/2009 at 07:42, xxxxxxxx wrote:

    Howdy,

    Yes, I'm already using translation maps when receiving the message MSG_TRANSLATE_POINTS, and I've also figured out how to build a translation map when receiving the message MSG_POINTS_CHANGED along with the VariableChanged data when it includes a map.

    Well, after reading over the VariableChanged structure section in the documentation again, I think I've got it fairly well covered now:

    > case MSG_POINTS_CHANGED:
    >      VariableChanged *vchg = (VariableChanged* )data;
    >      if(vchg)
    >      {
    >           LONG oCnt = vchg->old_cnt, nCnt = vchg->new_cnt;
    >           
    >           Vector *padr = ToPoint(op)->GetPoint();
    >           LONG pCnt = ToPoint(op)->GetPointCount();
    >           
    >           if(vchg->map)
    >           {
    >                if(nCnt < oCnt)
    >                {
    >                     // build a translation map and call tag's remapping function
    >                     
    >                     tData->SetLong(POINT_COUNT,nCnt);// update stored point count
    >                }
    >                else if(nCnt > oCnt)
    >                {
    >                     // build a translation map and call tag's remapping function
    >                     
    >                     tData->SetBool(POINTS_ADDED,TRUE);// set POINTS_ADDED flag
    >                }
    >           }
    >           else
    >           {
    >                if(nCnt < oCnt)
    >                {
    >                     // resize storage array
    >                     
    >                     tData->SetLong(POINT_COUNT,nCnt);// update stored point count
    >                }
    >                else if(nCnt > oCnt)
    >                {
    >                     // resize storage array
    >                     
    >                     tData->SetBool(POINTS_ADDED,TRUE);// set POINTS_ADDED flag
    >                }
    >                else if(nCnt == oCnt)
    >                {
    >                     if(tData->GetBool(POINTS_ADDED))
    >                     {
    >                          // do added points' positions calculations and store in storage array
    >                          
    >                          tData->SetLong(POINT_COUNT,pCnt);// update stored point count
    >                          tData->SetBool(POINTS_ADDED,FALSE);// unset POINTS_ADDED flag
    >                     }
    >                }
    >           }
    >      }
    >      break;

    Does that look like it covers everything to you?

    Adios,
    Cactus Dan


Log in to reply