Messages



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

    On 16/08/2009 at 12:53, xxxxxxxx wrote:

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

    ---------
    I can receive the message MSG_TRANSLATE_POINTS in a TagPlugin, but so far I have not been able to receive this message in an ObjectPlugin.

    Is this possible?

    Also I have not been able to receive a MSG_POINTS_CHANGED in either a TagPlugin or an ObjectPlugin.

    Is there any way to receive these messages?

    Thanks hopefully,

    Nebu



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

    On 17/08/2009 at 03:22, xxxxxxxx wrote:

    MSG_POINTS_CHANGED works just fine in a TagData plugin. Remember that it is only called if the number of points changed, for instance if a point was deleted.

    As for ObjectData plugins, what are you trying to achieve, check for a change of the points of input objects?

    cheers,
    Matthias



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

    On 17/08/2009 at 10:32, xxxxxxxx wrote:

    Thank you for responding, I really appreciate that.

    Yes I did think the MSG_POINTS_CHANGED message would be sent when the position of a point changed.
    I have misinterpreted 'The points have changed' entry in the SDK.

    What I want to be able to do in an object or tag plugin is make changes to a polygon object as fast as possible.

    For example: A tag the user adds to a polygon object and after making a selection of points the user clicks on a button in the tag that effectively lock these points.
    The problem is what 'event/message' I should use to implement the freezing.
    I have the following code that works, but I am doing something we are not supposed to do: make changes in the structure of an object in the execute member of a TagPlugin (TagData).
    Still this example might be the most easiest to explain what I am after, so here is the relevant code:

    > \> LONG LockPoints::Execute(PluginTag \*tag, BaseDocument \*doc, BaseObject \*op, BaseThread \*bt, LONG priority, LONG flags) \> {      \>      PolygonObject\* objPoly =(PolygonObject\* )op; \>      ResetPoints(doc,objPoly); \>       \>      return EXECUTION_RESULT_OK; \> } \> \> Bool LockPoints::Message(GeListNode \*node, LONG type, void \*data) \> {     // Receives messages. \>      if (type == MSG_DESCRIPTION_COMMAND) \>      {     DescriptionCommand \*dc = (DescriptionCommand\* ) data; \>           PolygonObject\* objPoly; \>            \>           BaseTag\* tag = (BaseTag\* )node; \>           BaseObject\* obj = tag->GetObject(); \>           objPoly=(PolygonObject\* )obj; \>            \>           if (dc->id[0].id==LOCKPOINT_LOCKSELECTED) \>           {     LockSelected(node->GetDocument(),objPoly); \>           } \>           if (dc->id[0].id==LOCKPOINT_UNLOCKSELECTED) \>           { \>           } \>      } \>       \>      if (type == MSG_TRANSLATE_POINTS) \>      {     // Update the indexes as needed \>      } \>      return TRUE; \> } \> \> Bool LockPoints::LockSelected(BaseDocument \*doc, PolygonObject\* objPoly) \> {     BaseSelect \* objSelPoints; \>      LONG lngI; \>      LONG \* lngIndex; \>      Vector \* posIndex; \>      const Vector \* arrPoints; \> \>      if (!objPoly->IsInstanceOf(Opolygon)) \>           return FALSE; \>      objSelPoints=objPoly->GetPointS(); \>      LONG lngPointCount=objPoly->GetPointCount(); \>      LONG size = sizeof(LONG) \* objSelPoints->GetCount(); \>      pointArray = (LONG\* )GeAlloc(size); \>      if (!pointArray) \>           return FALSE; \>      size = sizeof(Vector) \* objSelPoints->GetCount(); \>      posArray = (Vector\* )GeAlloc(size); \>      arrPoints=objPoly->GetPointR(); \> \>      lngIndex = pointArray; \>      posIndex = posArray; \>      for (lngI=0;lngI<lngPointCount;lngI++) \>      {     if (objSelPoints->IsSelected(lngI)) \>           {     \*lngIndex=lngI; \>                \*posIndex=arrPoints[lngI]; \>                lngIndex++; \>                posIndex++; \>           } \>      } \>      lngLockedPoints=objSelPoints->GetCount(); \>       \>      return TRUE; \> } \> \> Bool LockPoints::ResetPoints(BaseDocument \*doc, PolygonObject\* objPoly) \> {     LONG \* lngIndex; \>      Vector \* posIndex; \>      LONG lngI; \>      LONG lngPointCount=objPoly->GetPointCount(); \>      Vector \* arrPoints; \>      lngIndex = pointArray; \>      posIndex = posArray; \>      arrPoints=objPoly->GetPointW(); \> \>      for (lngI=0;lngI<lngLockedPoints;lngI++) \>      {     if (arrPoints[\*lngIndex]!=\*posIndex) \>           {     arrPoints[\*lngIndex]=\*posIndex; \>           } \> \>           lngIndex++; \>           posIndex++; \>      } \> \>      return TRUE; \> } \>

    The ResetPoints function is called from the Execute, and in the important threading information in the SDK it states that this is not allowed.
    At least that is how I interpret it, it would be nice if I am wrong.

    If a user now selects a 'locked' point and wants to move it he can't because the position is immediately overwritten with the stored position.

    Now I have read that you could use the MessageData to capture the EVMSG_CHANGE.
    And in this topic I found how you could then call your own plugin again:

    Atom array compatibility

    But the EVMSG_CHANGE is only fired after the user completes dragging.
    So you can move the point and on releasing the mouse, the point jumps back to its locked position.
    What I want is a method that makes it look like you cannot move the points, like in my code, but then not violating the rules.

    Thanks,

    Nebu



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

    On 17/08/2009 at 11:50, xxxxxxxx wrote:

    MSG_UPDATE is the correct message sent when the bounding box needs to be recalculated - which is a sure sign that points changed position. It is also sent for other changes unfortunately.

    Still, user editing doesn't send messages until after the fact (except for MSG_PRETRANSLATE_XXX). You'll just have to be resigned to resetting the 'locked' points whenever you think there was possible manipulation of them. Actually keeping the user from moving them at all may be a tricky business.



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

    On 17/08/2009 at 12:38, xxxxxxxx wrote:

    Thank you Robert, I just checked to see if I receive MSG_UPDATE and MSG_POINTS_CHANGED messages and I do receive the MSG_POINTS_CHANGED when I delete a point but no MSG_UPDATE when I move a point.

    Only tried it with a TagPlugin yet. Still it sounds like it would give me the same situation as catching the EVMSG_CHANGE from the MessageData, so I could just use that.

    If it can't be done it can't be done, but I must say I did not expect that there would be no way to do it.

    Right now,as a last resort, I am looking at the RegisterSceneHookPlugin to see if that might be used. The following is from the SDK:

    SceneHookData
    This is a data class to register a function that will be called on every scene prepare, for example before redraw

    So I will just have a look and see.

    Cheers,

    Wim



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

    On 17/08/2009 at 13:16, xxxxxxxx wrote:

    Once again from the SDK:

    InitSceneHook()

    Called before all scene hooks and expressions in a scene are calculated. Here you can allocate temporary data in the node.

    FreeSceneHook()

    Called after all scene hooks and expressions in a scene are calculated, before the drawing starts. Here you can free temporary data allocated in InitSceneHook().

    So once again my interpretation is that these are called outside the drawing pipeline?

    I did a quick test with a GePrint in the InitSceneHook() and this does get fired multiple times when the user drags a point.
    So I might be able to use this to update points on a polygonobject??

    Cheers



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

    On 21/08/2009 at 03:17, xxxxxxxx wrote:

    So I went ahead and implemented it.
    Now I modify the positions of points in the InitSceneHook, and it does not crash, but then again doing it in the TagData::Execute() did not crash either.
    So what I really would like to know is what I am doing safe?
    Thanks,
    Nebu



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

    On 21/08/2009 at 03:28, xxxxxxxx wrote:

    It is safe to change points positions in TagData::Execute. Just don't change the scene (inserting/deleting objects etc.).

    cheers,
    Matthias


Log in to reply