How to detect viewport changes [SOLVED]



  • On 16/03/2015 at 10:53, xxxxxxxx wrote:

    I have a command plugin that positions a light based on its angle and distance towards the camera.
    When the (camera) viewport is rotated or moved, of course the angle and distance between the camera and the light are changed.
    _<_o:_<_o:p_>_o:p>
    The question is now how do I detect that it has c_<_o:_<_o:p_>_
    I can listen in GeDialog.Message() to the message that tells me the viewport is updated (message number 1937337955) and thus I can calculate the new position and rotation of the light.
    Except I cannot use c4d.EventAdd() in GeDialog.Message(), because then Edit Render does not work anymore.
    _ormal">
    _w can I solve:
    -Other ways to detect that the viewport has changed?
     If possible outside GeDialog.Message() where I can upda_<_o:_<_o:p_>_cts without any risks
    - Update objects in GeDialog.Message() usin_<_o:_<_o:p_>_ventAdd() or something else?
    -Pim



  • On 17/03/2015 at 07:55, xxxxxxxx wrote:

    Hello,

    catching the movement of the camera in the viewport can be tricky. The message you catch is the c4d.BFM_SYNC_MESSAGE. I did some experiments and it seems you don't have to update anything when you react to this message.

    A better workflow may be to use a tag. When the camera is moved the scene is solved. That means the Execute() functions of objects and tags are called. So you could create a custom tag and assing that tag to your light using your command. That tag could position the parent light according to the camera position. You find some code that does that in the Look at Camera example.

    best wishes,
    Sebastian



  • On 17/03/2015 at 09:48, xxxxxxxx wrote:

    Thanks, sounds logical.

    -Pim


Log in to reply