PDA

View Full Version : camera shake with mel?


ragdoll
05-25-2007, 11:55 AM
Has anyone done this? I tried just placing something simple to the translates

$randTY = noise(time);
camera1.translateY = $randTY;

same for tx and tz... im no heavy scripter so i was wondering if anyone knows how to build up a noise movement, like what you get from a hand held camera with the shaky movements?

Is it possible to first keyframe the camera movements then plug the noise script to add to the shaky-ness?

-rj

ragdoll
05-25-2007, 01:13 PM
ok so i was playing around with some tests and found another possibility(?) to add camera shake...

i created a camera, and any poly object in my sample a pShpere, then i added an aim constraint so that the camera would stay focused on the sphere while I added the noise script to the translateY of the sphere... this way i can freely animate the cameras translates all the while having a random up and down motion... it's getting there but not quite exactly the shaky stuff im after...

just thought i'd add in some other options just to widen things...

azshall
05-25-2007, 02:18 PM
Group your camera and make sure the pivot is centered on the group ... then add some custom attributes to the camera:

shaker
frequency
amplitude
seed
Then write a new expression that looks like this...


float $mult = camShaker.shaker;
float $amp = camShaker.amplitude;
float $freq = camShaker.frequency;
float $seed = 2;

vector $noise = <<(frame * ($freq * .1) + $seed), (frame * ($freq * .1) + $seed), (frame * ($freq * .1) + $seed)>>;
vector $cameraShake = (dnoise($noise) * $amp * .05) * $mult;

camShaker.rotateX = $cameraShake.x;
camShaker.rotateY = $cameraShake.y;
camShaker.rotateZ = $cameraShake.z;


We're using a $noise variable to increment the noise so it will change over playback (hence .. frame .. in the expression). Then we're running $noise through some dnoise to randomize it, scale the amplitude and the amount of shake ($mult) ...

After that we throw it on our camera's rotation...

This will allow you to animate the parameters if need be so you can totally kill the shake if you don't need it, amplify it or make it less turbulent with the frequency ...

Enjoy!

Seth

ragdoll
05-25-2007, 04:38 PM
you sir are a awesome! thank you a million times over! :love:


i was messing around with using dynamics in creating its random motion but the one you made is da bomb! :scream: thanks again!

-rj

Siggef
12-02-2007, 11:45 PM
Hi!

This looks like a awsome script.. i can't manage to get it to work though.. Im not used to mel so maybe there is something i miss when executing the script..

Ive created a camera, named it camShaker, added the attributes and grouped it..

When i executes the script i get this messages


// Error: float $mult = camShaker.shaker;
//
// Error: Invalid use of Maya object "camShaker.shaker". //
// Error: float $amp = camShaker.amplitude;
//
// Error: Invalid use of Maya object "camShaker.amplitude". //
// Error: float $freq = camShaker.frequency;
//
// Error: Invalid use of Maya object "camShaker.frequency". //
// Error: vector $noise = <<(frame * ($freq * .1) + $seed), (frame * ($freq * .1) + $seed), (frame * ($freq * .1) + $seed)>>;
//
// Error: Invalid use of Maya object "frame". //
// Error: vector $noise = <<(frame * ($freq * .1) + $seed), (frame * ($freq * .1) + $seed), (frame * ($freq * .1) + $seed)>>;
//
// Error: Invalid use of Maya object "frame". //
// Error: vector $noise = <<(frame * ($freq * .1) + $seed), (frame * ($freq * .1) + $seed), (frame * ($freq * .1) + $seed)>>;
//
// Error: Invalid use of Maya object "frame". //
// Error: camShaker.rotateX = $cameraShake.x;
//
// Error: Invalid use of Maya object "camShaker.rotateX". //
// Error: camShaker.rotateY = $cameraShake.y;
//
// Error: Invalid use of Maya object "camShaker.rotateY". //
// Error: camShaker.rotateZ = $cameraShake.z; //
// Error: Invalid use of Maya object "camShaker.rotateZ". /



What am i doing wrong?
Am I missing some workflow?
When am I supposed to execute the script?

Im using maya 8.5...

Tnx
Sigge

harmless
12-06-2007, 03:58 PM
it's not a script, it's an expression meant to be added to a camera called camShaker

Inlakechh
12-07-2007, 02:31 PM
This is a great Expression. Thanks alot :).

CGTalk Moderation
12-07-2007, 02:31 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.