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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Scenehook

    SDK Help
    0
    4
    385
    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
      Helper
      last edited by

      On 11/05/2013 at 20:40, xxxxxxxx wrote:

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

      ---------
      Hi Folks,

      I have a SceneHook plugin that's there to work alongside my object plugin. But a few things are unclear to me about the way it works.

      Firstly, is a SceneHook always there in the background, in every document (regardless of whether my object plugin is in the scene or not)? Or can I load/unload a SceneHook on an as needed basis? Is it possible to load a SceneHook when my object is selected, and remove it when it's not (though it won't do any harm sitting in the background if the second next query can be done..)?

      Secondly, is there a flag that indicates that the document is being animated, that I can use stop the SceneHook from showing/working while the document is playing back?

      I only wish the SceneHook to be there when the document is not being played back, and when my object is selected.

      The SceneHook itself seems to be working fine other than the above dilemmas!

      WP.

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

        On 11/05/2013 at 23:38, xxxxxxxx wrote:

        SceneHook plugins are always there in every active document.  You can't load/unload them.  You can use flags/settings/messages to control whether it does something or not.

        if (CheckIsRunning(CHECKISRUNNING_ANIMATIONRUNNING)) // animation is running, do something else  
        
        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 12/05/2013 at 01:13, xxxxxxxx wrote:

          Thanks Robert,

          that CheckIsRunning() seems to have sorted out enough for me to work with. Though it's a pity they can't be loaded/unloaded. I would have thought scene hooks loaded for no reason or with no use is a bit pointless. But anyway.

          Cheers,

          WP.

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

            On 12/05/2013 at 01:53, xxxxxxxx wrote:

            While a SceneHook plugin is always 'running', it is only executed after all expressions and at the Execute Priority (priority pipeline).  InitSceneHook() and FreeSceneHook() are used to allocate and deallocate your resources inbetween executions.  So, use these wisely so that your SceneHook doesn't have allocated memory/classes hanging about indefinitely.  Also, you can use AddToExecution() to specify exactly where in the priority pipeline (and how often) to execute.

            Nonetheless, the best thing to do is to exit the SceneHook on whatever conditions asap.  For instance, my animation check code should be the first line in Execute() and Draw() (if you override the latter).  In that way, your SceneHook will have insignificant impact when animation is running.

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