Building additional rotation controls
  • skyvat
    activ8 member
    Posts: 54
    Joined: Thu Jul 08, 2004 10:19 pm

    Building additional rotation controls

    by skyvat » Tue Sep 06, 2005 3:58 am

    Hello all,

    I want to learn more about modules and scripting. To start, it'd be handy to have a module that could give more options for rotation.

    I'd like it to:

    Limit rotations to less than 360 continuous (sort of like the OPT control for limiting move clip playback)

    Allow me to apply the usual oscilator controls to rotation (CUT, SMOOTH, LINE, RANDOM, etc)

    If someone can help me out with this via a sample module and an explaination of the workings I hope that will get me started.

    Thanks in advance.

    Dan
  • User avatar
    yves@garagecube
    master
    Posts: 695
    Joined: Mon Jun 28, 2004 5:50 pm
    Location: Geneva
    Contact:

    Re: Building additional rotation controls

    by yves@garagecube » Wed Sep 07, 2005 12:39 pm

    Please try to elaborate. What do you know and don't know about module/scripting ?

    The best thing is try to create a module and use the interface builder to connect it to specific keywords (you don't need scripting at this stage). It is a good start to build simple module. Then you may want to begin with a simple module, like an auto-rotate of the focus layer.

    To do that, create a module and go to the script type PeriodicalEvent.

    Write this:

    Code: Select all

    v = modul8.getValue('direct_layer_rotation_z', 0)
    if v==None:
       v = 0
    v+= elapsed*10
    modul8.setValue('direct_layer_rotation_z', v,0)


    This very simple example implement a time based auto-rotate. Feel free to ask questions.
  • skyvat
    activ8 member
    Posts: 54
    Joined: Thu Jul 08, 2004 10:19 pm

    by skyvat » Thu Sep 08, 2005 3:29 am

    Yves,

    I understand how to build a module and create a control relationship between the 2 using keywords. I can control the rotation but only MANUALLY using the CTRL keywords. i need to create automated controls - like those that have oscilators.

    I've tried playing with DIRECT commands. I'm not sure what they do, but my hope is they direct the change in a property over time - as with an oscilator. I tried this, but I'm missing an important step, all I can get is a very small (1 pixel?) change in any property.

    I then tried entering your script into the Periodical event field. Again, it seems like I just don't understand how you connect that script to the module interface.

    Really trying to understand this stuff and have scoured the forum, there's not much there that's helping. Hope you can clarify. I've stared at downloaded modules for hours and it's only serving to confuse me more.

    awaiting guidance,

    Dan
  • skyvat
    activ8 member
    Posts: 54
    Joined: Thu Jul 08, 2004 10:19 pm

    Re: Building additional rotation controls

    by skyvat » Thu Sep 08, 2005 5:25 am

    yves@garagecube wrote:
    The best thing is try to create a module and use the interface builder to connect it to specific keywords (you don't need scripting at this stage). It is a good start to build simple module. Then you may want to begin with a simple module, like an auto-rotate of the focus layer.



    I'm confused by this. You seem to say i don't need scripting knowledge to do automated animations, but then your response includes code. I've been going over the manual and again, auto animations seem to require scripts for periodical events. Can you show me any examples of automated animations that can be done using keyword connect?
  • User avatar
    yves@garagecube
    master
    Posts: 695
    Joined: Mon Jun 28, 2004 5:50 pm
    Location: Geneva
    Contact:

    Re: Building additional rotation controls

    by yves@garagecube » Thu Sep 08, 2005 9:37 am

    skyvat wrote:
    yves@garagecube wrote:
    The best thing is try to create a module and use the interface builder to connect it to specific keywords (you don't need scripting at this stage). It is a good start to build simple module. Then you may want to begin with a simple module, like an auto-rotate of the focus layer.



    I'm confused by this. You seem to say i don't need scripting knowledge to do automated animations, but then your response includes code. I've been going over the manual and again, auto animations seem to require scripts for periodical events. Can you show me any examples of automated animations that can be done using keyword connect?


    No, you are right animation requires scripting.

    Sorry if I was not very clear. I just wanted to say that using direct keyword mapping is a good start for exploring module creation. Now, in your case, it is true that you need to do at least some minimal scripting.
    Last edited by yves@garagecube on Thu Sep 08, 2005 9:57 am, edited 1 time in total.
  • User avatar
    yves@garagecube
    master
    Posts: 695
    Joined: Mon Jun 28, 2004 5:50 pm
    Location: Geneva
    Contact:

    by yves@garagecube » Thu Sep 08, 2005 9:56 am

    skyvat wrote:I then tried entering your script into the Periodical event field. Again, it seems like I just don't understand how you connect that script to the module interface.


    Basically you can communicate with your interface using the "module" global object and the "setValue" / "getValue" functions :

    module.setValue(controlName, key, value)
    module.getValue(controlName, key)

    - controlName is the name of the control that you specified in the interface builder.
    - key is for controls which have several possible values (like two axis, etc.). For a knob or a slider you can always pass 0.
    - value is the value of the control. Typically it goes from 0.0 to 1.0 (50% = 0.5). However you can also change the range in the interface builder.

    Try to add a knob to your module and give it the name "speed".

    And use this new version of the precedent periodical script:

    Code: Select all

    v = modul8.getValue('direct_layer_rotation_z', 0)
    if v==None:
       v = 0
    v+= elapsed*10.0 *module.getValue('speed',0)
    modul8.setValue('direct_layer_rotation_z', v,0)


    Now you can change the speed of the rotation using the knob.

    The interesting line is :

    v+= elapsed*10.0 *module.getValue('speed',0)

    The getValue returns the current value of the knob from 0.0 to 1.0.
    "elapsed" is the amount of time in seconds since the last frame.
  • skyvat
    activ8 member
    Posts: 54
    Joined: Thu Jul 08, 2004 10:19 pm

    getting an error

    by skyvat » Fri Sep 09, 2005 9:51 pm

    Cut and pasted, then reformated slightly (v=0 indent was causing errors)

    line 4
    TypeError: unsupported operand type(s) for *: 'float' and 'NoneType'

    this is mine

    Code: Select all

    v = modul8.getValue('direct_layer_rotation_z', 0)
    if v==None:
       v = 0
    v+= elapsed*10.0 *module.getValue('speed',0)
    modul8.setValue('direct_layer_rotation_z', v,0)


    can you recognize the error?

    Dan
  • User avatar
    yves@garagecube
    master
    Posts: 695
    Joined: Mon Jun 28, 2004 5:50 pm
    Location: Geneva
    Contact:

    Re: getting an error

    by yves@garagecube » Mon Sep 12, 2005 6:10 pm

    Just tried your code and it was working...

    Did you create a knob named 'speed' ?

    I uploaded the sample to the module "public" library. You can download it from here. It is called "tutorialAutoRotate".
  • skyvat
    activ8 member
    Posts: 54
    Joined: Thu Jul 08, 2004 10:19 pm

    by skyvat » Tue Sep 13, 2005 5:13 am

    will do...

Who is online

Users browsing this forum: No registered users and 6 guests