Runtime priority



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

    On 05/10/2009 at 00:41, xxxxxxxx wrote:

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

    ---------
    I develop a plugin based on LookAtCamera.exp and i came across the problem: MyCameraTag::Execute is called about 10 times a sec, that's not enough for my plugin.
    Is there a way to make this routine be called faster by engine?

    Now i run a separate thread which made such call:
    while( !stop ){
        GeSleep( 100 );
        EventAdd( EVENT_CAMERAEXPRESSION );
    }
    If i try to change value to 50 for example, then Cinema starts to work very very slow :)
    I noticed, that when moving an object in scene, Execute method is called much more often. Maybe there are some settings or priority must be changed to achieve such behaviour by default?



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

    On 05/10/2009 at 03:11, xxxxxxxx wrote:

    Expressions are only called when something changes in the scene, for instance the animation is played or you move around objects or camera or change parameters.

    If you have to react a certain time per second I think you better use a MessageData plugin with a set timer.

    Something like this:

    > \> #include "c4d.h" \> #include "c4d_symbols.h" \> \> \> class TimerMessage : public MessageData \> { \>      virtual LONG GetTimer(void); \>      virtual Bool CoreMessage(LONG id, const BaseContainer &bc;); \> }; \> \> LONG TimerMessage::GetTimer() \> { \>      return 100; \> } \> \> Bool TimerMessage::CoreMessage(LONG id, const BaseContainer &bc;) \> { \>      if (id = MSG_TIMER) \>      { \>           //do something \>      } \> \>      return TRUE; \> } \> \> \> Bool RegisterTimerMessage(void) \> { \>      return RegisterMessagePlugin(1024558, String(), 0, gNew TimerMessage); \> } \>

    cheers,
    Matthias



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

    On 05/10/2009 at 05:20, xxxxxxxx wrote:

    Main idea is, that i place following code instead of
    // do something
    line and changes are applied only when i click/move some object in scene. Are there any way to force cinema apply this changes immediately?

    BaseObject* camera=myTag->m_camera;
    if( camera!=NULL )
    {
        Vector cPos=camera->GetPos();
        camera->SetPos( cPos+Vector( 1.0f,0,0 ) );
    }



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

    On 06/10/2009 at 03:26, xxxxxxxx wrote:

    Sorry, I can not really follow you. What do you want to achieve?

    cheers,
    Matthias



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

    On 06/10/2009 at 08:00, xxxxxxxx wrote:

    I want to write plugin which polls joystick and move/rotate object in scene accordingly to joystick deviation. If i use timer, as you suggested, all changes of object position,orientation are applied only when i click by mouse somewhere in Cinema. That won't fit :)

    The only way i found is to start a separate thread which
    do the following code:

    while( !m_stop )
    {
        GeSleep( 100 );
        EventAdd( EVENT_CAMERAEXPRESSION);
    }

    than MyTag::Execute is called from main thread and all changes are applied immediately. I mean, all object manipulations are done in MyTag::Execute, and this works:)
    On my previous computer values below 100 lead to hang up of application, on my new machine GeSleep( 50 ) works ok.

    From my point of view, this approach is not good, because i don't clearly understand all "behind-the-curtain" mechanics of Cinema and this can lead to performance hit.

    Is there a way to do this in another manner?
    Code in MyTag::Execute gets position/orientation of camera and changes it, rather fast code.


Log in to reply