PDA

View Full Version : Key object one time


JokerMartini
03-22-2012, 08:47 PM
I'm trying to think of a way that would work best with a large number of objects.

I want to key an objects turbo-smooth iteration from 0 to 1 the first moment there is a change in the transform.

Would i want to collect all the object and put them into a bit array.

#{(object1,false),(object2,false)}
The first variable in the array being the object and the boolean containing the information for me to know whether or not it has been keyed or not already.

Then for t in start to end by 1 do
(
for obj in bitarray do
(
If objects transform != objects transform at (t-1) do
(
key iteration to 1
#(object,true)
)
)
)

MrPingouin
03-23-2012, 02:38 PM
What kind of transformations are you looking at ?

One solution would be to use the controller.keys value, as it returns an array of all the keyframes set (empty array if there's no animation).

Maybe something like :

for o in selection do
(
for c in #(o.position.controller, o.rotation.controller, o.scale.controller) do
(
if c.keys.count > 1 then
(
addNewKey o.modifiers["TurboSmooth"].iterations.controller o.pos.controller.keys[1].value
)
)
)

Something like that.

Note that this piece of code would work only if the iterations parameter has a controller, which is not the case by default (if not animated).

You can either set its controller to a Bezier_Float, or activate the animation mode and set the value.

MrPingouin
03-23-2012, 02:47 PM
Well, my code won't work this way.

You first have to use the controller.keys arrays to know what is the lowest keyframe.

And then apply your keyframe.

And as what you want do is set the iterations from 0 to 1, you can try using


with animate on
(
at time 0 o.modifiers["turbosmooth"].iterations = 0
-- if you don't specify the 0f value, then you'll have two keyframes at 0 and t, but both will have the iterations set to 1
at time t o.modifiers["turbosmooth"].iterations = 1
)

CGTalk Moderation
03-23-2012, 02:47 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.