Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    How to detect viewport changes [SOLVED]

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 321 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

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

          Thanks, sounds logical.

          -Pim

          1 Reply Last reply Reply Quote 0
          • First post
            Last post