Camrera blur

Is there any scrpit or plug-in that will give me the kind of turbulence effect that you get in an airplane when there is bad weather or basicly some thing that will shake the camera violently and/or blur what the camera is looking at?

This is an old one that might not work on 2.34:

# Aug 1999 by [email protected]
  
import Blender
import whrandom
import math
  
l=Blender.link
turb=Blender.Object.Get(l.name+".turb")
  
t=Blender.Get(Blender.Const.BP_CURTIME) - 1.0
if t==0.0:
  try:                 #try to set ta[name]
          ta[l.name]=0.0
  except :             # if it fails we have to init ta
          ta={}
          ta[l.name]=0.0
  
dt = t-ta[l.name] # change in time
ta[l.name]=t               # store old time
  
if (Blender.bylink):
  if dt<>0:       # execute only if time has changed
          dx=l.LocX-turb.LocX     # difference Obj/Turb
          dy=l.LocY-turb.LocY
          dz=l.LocZ-turb.LocZ
          r=math.sqrt(dx**2 + dy**2 + dz**2)
          l.dLocX=whrandom.random()*turb.SizeX/r # add random
          l.dLocY=whrandom.random()*turb.SizeY/r
          l.dLocZ=whrandom.random()*turb.SizeZ/r

and here:

http://www-users.cs.umn.edu/~mein/blender/plugins/sequence.html

you’ll find a sequence plugin called “Jitter”

%<

Anybody know how to use the above script?

I tried making a script link on both the camera and the objec, neither seemed to do anything.

Also tried executing the script, but got an error.

This really old simple script now in the Noise python module docs (http://www.blender.org/modules/documentation/234PythonDoc/Noise-module.html) might be useful:


from Blender import Get, Scene, Noise
####################################################
# This controls jitter speed
sl = 0.025
# This controls the amount of position jitter
sp = 0.1
# This controls the amount of rotation jitter
sr = 0.25
####################################################
 
time = Get('curtime')
ob = Scene.GetCurrent().getCurrentCamera()
ps = (sl*time, sl*time, sl*time)
# To add jitter only when the camera moves, use this next line instead
#ps = (sl*ob.LocX, sl*ob.LocY, sl*ob.LocZ)
rv = Noise.vTurbulence(ps, 3, 0, Noise.NoiseTypes.NEWPERLIN)
ob.dloc = (sp*rv[0], sp*rv[1], sp*rv[2])
ob.drot = (sr*rv[0], sr*rv[1], sr*rv[2])

Scriptlink it to a framechanged event, You probably want to play with the values a bit, the values used here will create more something of a ship on a stormy sea effect. For more chaotic effect use higher values for the sl variable which controls jitter speed.

You can also use randomly inserted IPOs to make camera jitter. (This has nothing to do with the plugin above)

/d_m

Thanks a lot eeshlo, this script rocks !! :smiley:

I’ve been waiting for this one for months not being able to use the first camjitter script. This script is simple tu use and efficient.

Serialsiner

how do i use this because i cant get it to work

You just have to type in the values for speed, position and rotation in the text window, link your camera to the script with the Framechange option and hit Alt+A in the 3d view.

A rather essential piece I forgot to add here (is in the noise module doc though), is that the camera must actually have an object ipo, otherwise it indeed won’t do anything…
A single locrot key is enough though, so just use the i-key in 3d view and select ‘LocRot’.
Sorry, for the confusion…

It would be cool to be able to choose the duration of the effect too, and the frames where to add the shaking … would it be difficult to add this ?

Sorry for bringing up this old thread…but I want to possibly expand this script
according to what the last poster suggested for a project i’m working on.

I would like to control the three variables that govern the jitter using the distance of an empty or another Blender object.

For example…as a aircraft approches the camera, the amount of jitter increases…until it passes, and the levels drop again.

Basically all I need to know is how to measure distance from the camera to whatever other object I want the script to work with.

Thanks!

That’s easy. If you stay in python coding. Just do a little function to colect position of the empty at each frame. link it to the scene on a framechange event. Then when a framechange ocure it will start by looking for position and then compute the distance. then see if the rest of the script need to be called.

To calculate distance, just do
x = empty(x)-object(x)
y = empty(y)-object(y)
z = empty(z)-object(z)

math.sqrt(math.pow(math.sqrt(math.sqrt(math.pow(x,2)+math.pow(y,2)),2)+math.pow(z,2))

which mean do the pytagore on the x,y the when you get the diagonal of it get the final distance using the hypo of (x,y) as side and z as the other. The final give you a distance in 3D.

diagonale = abs(x2.0+y2.0+z**2.0)**0.5

hehe. yea that’s better. :stuck_out_tongue: