Camera Jitter Script - Update

here is a camera jitter python script which worked with python 2.2, but appears to be completely broken in 2.5 (OSX). hopefully it’s okay to post it…
what would i need to change to get it running with python 2.5 ?

#!BPY
“”"
Name: ‘Camera Jitter’
Blender: 241
Group: ‘Animation’
Tooltip: ‘Adds Random movement to the current camera.’
“”"

--------------------------------------------------------------------------

***** BEGIN GPL LICENSE BLOCK *****

Copyright © 2006 Mariano Hidalgo

This program is free software; you can redistribute it and/or

modify it under the terms of the GNU General Public License

as published by the Free Software Foundation; either version 2

of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,

but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

GNU General Public License for more details.

You should have received a copy of the GNU General Public License

along with this program; if not, write to the Free Software Foundation,

Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

***** END GPL LICENCE BLOCK *****

--------------------------------------------------------------------------

import Blender
from Blender import Scene, Noise
try:
import nt
os = nt
os.sep=’\’
except:
import posix
os = posix
os.sep=’/’
def init():

This controls jitter speed

Blender.sl = 0.025

This controls the amount of position jitter

Blender.sp = 0.1

This controls the amount of rotation jitter

Blender.sr = 0.25

This Boolean controls wheter the jitter is always on or just when moving

Blender.moving = 0
def slink_mode():
time = Blender.Get(‘curtime’)
ob = Scene.GetCurrent().getCurrentCamera()
if Blender.moving:
Blender.ps = (Blender.slob.LocX, Blender.slob.LocY, Blender.slob.LocZ)
else:
Blender.ps = (Blender.sl
time, Blender.sltime, Blender.sltime)
rv = Noise.vTurbulence(Blender.ps, 3, 0, Noise.NoiseTypes.NEWPERLIN)
ob.dloc = (Blender.sprv[0], Blender.sprv[1], Blender.sprv[2])
ob.drot = (Blender.sr
rv[0], Blender.srrv[1], Blender.srrv[2])
def script_mode():
try:
Blender.Text.Load(Blender.Get(“scriptsdir”) + os.sep +“camera_jitter.py”)
except:
Blender.Text.Load(Blender.Get(“uscriptsdir”) + os.sep + “camera_jitter.py”)
scn = Scene.GetCurrent()
scn.clearScriptLinks([‘camera_jitter.py’])
scn.addScriptLink(‘camera_jitter.py’, ‘Redraw’)
def show_prefs():
text = Blender.Draw.Create("")
jitterSpeed = Blender.Draw.Create(Blender.sl)
positionJitter = Blender.Draw.Create(Blender.sp)
rotationJitter = Blender.Draw.Create(Blender.sr)
mov = Blender.Draw.Create(Blender.moving)

block = []
block.append(“The Jitter Speed”)
block.append((“Jitter Speed”, jitterSpeed, 0.005, 0.500))
block.append(“Amount of POS Jitter”)
block.append((“Position Jitter”, positionJitter, 0.1, 2.0))
block.append(“Amount of ROT Jitter”)
block.append((“Rotation Jitter”, rotationJitter, 0.05, 1.00))
block.append((“Only When Moving”, mov, “Add random movement only when camera moves?”))

retval = Blender.Draw.PupBlock(“Camera Noise Preferences” , block)

if retval:
Blender.sl = jitterSpeed.val
Blender.sp = positionJitter.val
Blender.sr = rotationJitter.val
Blender.moving = mov.val

if Blender.link:
slink_mode()
else:
script_mode()
try:
print Blender.sl
except:
init()
show_prefs()

You could keyframe your own jitter it’s not that hard randomizing ipo’s for camera movement.
Try finding the version of Blender that the script worked with, append your scene, then run the script & render your animation.
Post the errors that the script is producing so people can help you fix it.
m.a.

thanks.
tried a few tricks and got it !
:cool:

I can post the python 2.5 updated version if anyone is interested.

okay…
so I got it moving-- the camera moves properly in the 3d views (including camera view), but does not render out the camera jitter.
i get an error in the console;
scene.getCurrentCamera() depreciated!
use scene.objects.camera instead

here is the (so far) revised version;

#!BPY
“”"
Name: ‘Camera Jitter’
Blender: 244
Group: ‘Animation’
Tooltip: ‘Adds Random movement to the current camera.’
“”"

--------------------------------------------------------------------------

***** BEGIN GPL LICENSE BLOCK *****

Copyright © 2007 Mariano Hidalgo

This program is free software; you can redistribute it and/or

modify it under the terms of the GNU General Public License

as published by the Free Software Foundation; either version 2

of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,

but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

GNU General Public License for more details.

You should have received a copy of the GNU General Public License

along with this program; if not, write to the Free Software Foundation,

Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

***** END GPL LICENCE BLOCK *****

--------------------------------------------------------------------------

import Blender
from Blender import Scene, Noise
import os
def init():

This controls jitter speed

Blender.sl = 0.025

This controls the amount of position jitter

Blender.sp = 0.1

This controls the amount of rotation jitter

Blender.sr = 0.25

This Boolean controls wheter the jitter is always on or just when moving

Blender.moving = 0
def slink_mode():
time = Blender.Get(‘curtime’)
ob = Scene.getCurrent().getCurrentCamera()
if Blender.moving:
Blender.ps = (Blender.slob.LocX, Blender.slob.LocY, Blender.slob.LocZ)
else:
Blender.ps = (Blender.sl
time, Blender.sltime, Blender.sltime)
rv = Noise.vTurbulence(Blender.ps, 3, 0, Noise.NoiseTypes.NEWPERLIN)
ob.dloc = (Blender.sprv[0], Blender.sprv[1], Blender.sprv[2])
ob.drot = (Blender.sr
rv[0], Blender.srrv[1], Blender.srrv[2])
def script_mode():
try:
Blender.Text.Load(Blender.Get(“scriptsdir”) + os.sep +“camera_jitter25.py”)
except:
Blender.Text.Load(Blender.Get(“uscriptsdir”) + os.sep + “camera_jitter25.py”)
scn = Scene.GetCurrent()
scn.clearScriptLinks([‘camera_jitter25.py’])
scn.addScriptLink(‘camera_jitter25.py’, ‘Redraw’)
def show_prefs():
text = Blender.Draw.Create("")
jitterSpeed = Blender.Draw.Create(Blender.sl)
positionJitter = Blender.Draw.Create(Blender.sp)
rotationJitter = Blender.Draw.Create(Blender.sr)
mov = Blender.Draw.Create(Blender.moving)

block = []
block.append(“The Jitter Speed”)
block.append((“Jitter Speed”, jitterSpeed, 0.005, 0.500))
block.append(“Amount of POS Jitter”)
block.append((“Position Jitter”, positionJitter, 0.1, 2.0))
block.append(“Amount of ROT Jitter”)
block.append((“Rotation Jitter”, rotationJitter, 0.05, 1.00))
block.append((“Only When Moving”, mov, “Add random movement only when camera moves?”))

retval = Blender.Draw.PupBlock(“Camera Noise Preferences” , block)

if retval:
Blender.sl = jitterSpeed.val
Blender.sp = positionJitter.val
Blender.sr = rotationJitter.val
Blender.moving = mov.val

if Blender.link:
slink_mode()
else:
script_mode()
try:
print Blender.sl
except:
init()
show_prefs()

Could anyone take upon themselves to update this script ? I have absolutely no python exp. so I can’t do it for myself. I would really appreciate it :slight_smile:

Try the website of the original creator ?

------> http://useless-scripts.blogspot.com

the errors it is producing should not stop it from working.
go through & change the text:
scene.getCurrentCamera()
to
scene.objects.camera
in all instances.
if this does not work, check the python api for other changes that affect cameras.
i know there is a problem with many old camera scripts,
i believe this is related to changes in the api.
personally, i wont get to fixing this script for some time, (it’s in a long line of to do’s)
so if it gets done by someone, please post results here.
m.a.

hi buddamint,
I’ve just written an update for 2.45. Tested on 2.42 - 2.45 winXP.
Meta-Androcto has updated the Manual on blenderWiki.
So look for this in “camera_jitter” Manual page.

have fun!
blenderWiki-team

many thanx migius!
Btw. the website links to the old script (not the zip at bottom) - almost tricked me :slight_smile:

again thanx for responding so quickly to my request :slight_smile:

edit: where is the shaking saved, I thought it modified the camera IPO - goes to show how little i know about python/blender :stuck_out_tongue:

hi Claws, to your question: the script makes shaking on-the-fly - does no recording to ipo.
I don’t understand the original manual about the camera needs an ipo with key. ???
migius

Apeal to all users: please report about usage on osx and linux !
Although first tests were positive, i suppose many users may have problems to make it working, because of (hidden) “Script Links”-option in Scene-Scripts Panel which must be enabled for proper work. So I’ve made an update with modified UI with note for new users. :slight_smile:

to get on blenderWiki

okay then! could it be made to actually affect the camera IPO? I don’t know how it works, but the ability to save it to an IPO would be great :slight_smile:

thx

edit: i’ll test it on linux as soon as i can, but im affraid saturday will be the earliest I can do that.

no problem, i can do it. :slight_smile:

However i see no benefits to have it baked in camera IPO. For what is it good?

What about generating extra IPO only for jitter and mixing it in NLA-editor with camera IPO?

I am happy with on-the-fly jitter because:

  • edit-friendly - non-destructive for camera animation.
  • works perfect for renderings.
    migius

cool, I have wanted this script to be updated for a while now but don’t know python. thanks

Well if you would do it - I would be grateful, maybe as a choice: save IPO? yes/no

Theres really no other reason than I’d like to poke around the IPO and then keep it for the next time i open the file - but it’s up to you :slight_smile: really; many thx for your work :slight_smile:

if you can bake the camera shake to ipo then you can tweek the keys… do slow mo… reverse the action or pause etc. All very usefull for animations.

If it is really useful, hmm…
ok, the modified version 1.02-2008.02.17 is waiting for you on blenderWiki. :slight_smile: for one week already

I guess you need an universal IPO baker script too, don’t you? …to mix many IPOs together (well, actually it should be a standard functionality in Action-Editor)

and what about IPO driver for camera_jitter-script, ie jitter parameters controlled by IPO curves?
three channels for speed/location/rotation separatelly

I guess you need an universal IPO baker script too, don’t you? ….to mix many IPOs together (well, actually it should be a standard functionality in Action-Editor)

In fact i thought of that before… For example to merge dLocX and LocX so that you end up with only LocX and the dLoc is free to be re-used and still the object behaves the same…

Does such a script exist ? It seems awfully complicated from a mathematical point of view to add bezier IPO curves…

Such a script seems not to exists yet.
I would not do it mathematically, but through interpolation at each frame and after there optimizing/smooth of resulting IPO curve if needed. :slight_smile: see camera_jitter code for inspiration.

Interesting part will be to implement switching between local coordinate systems for parented objects on different hierarchy-levels.
^^ is it understandable?

Yeah, i thought of this possibility. In fact i use more or less this technique on a portion of the script i am writing. But a true nice mathematical solution would be so much nicer :D.
Keep up the good work with your jitter script !

Thanks Migius !
I haven’t had a chance to check the updated version yet-- will test it soon.