Page 1 of 1

Building additional rotation controls

Posted: Tue Sep 06, 2005 3:58 am
by skyvat
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

Re: Building additional rotation controls

Posted: Wed Sep 07, 2005 12:39 pm
by yves@garagecube
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.

Posted: Thu Sep 08, 2005 3:29 am
by skyvat
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

Re: Building additional rotation controls

Posted: Thu Sep 08, 2005 5:25 am
by skyvat
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?

Re: Building additional rotation controls

Posted: Thu Sep 08, 2005 9:37 am
by yves@garagecube
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.

Posted: Thu Sep 08, 2005 9:56 am
by yves@garagecube
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.

getting an error

Posted: Fri Sep 09, 2005 9:51 pm
by skyvat
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

Re: getting an error

Posted: Mon Sep 12, 2005 6:10 pm
by yves@garagecube
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".

Posted: Tue Sep 13, 2005 5:13 am
by skyvat
will do...