- #******************************************************
- # Add a random walk animation to selected objects
- # - random_walk.py
- # - Give Selected Objects a simple random
- # animation
- # - By Mark Caldwell
- # - Version 0.1
- # - 30th April 2006
- # - Tested with Vue 5 Infinite 5.10 and Vue 6 Infinite Pre Release
- #
- # How to use in 4 easy steps
- #
- # 1. Download this file onto your computer
- #
- # 2. Edit the configuration variables below
- #
- # 3. Select Objects to be Replace in Vue Infinite
- #
- # 4. Then run script and wait for it to work
- # To run it go to Python -> Run Python Script
- # Then locate the file on your computer
- #
- #******************************************************
-
- def RandomWalk (objprop,i,accxmin,accxmax,accymin,accymax,acczmin,acczmax):
- vx=random.uniform(accxmin,accxmax)
- vy=random.uniform(accymin,accymax)
- vz=random.uniform(acczmin,acczmax)
- vel=[vx,vy,vz]
- objprop=UpdateObj (objprop,i,vel)
- return objprop
-
- def UpdateObj (objprop,i,vel):
- objprop[i][0]=objprop[i][0]+vel[0]
- objprop[i][1]=objprop[i][1]+vel[1]
- objprop[i][2]=objprop[i][2]+vel[2]
- return objprop
-
- import random
-
- #----------------------------------------------
- # Configuration: Set these to alter end result
- #----------------------------------------------
-
- # Frames to generate
- start=0 # First frame of animation
- stop=101 # Last frame of animation if step divides into stop add 1 to get a frame on last step
- step=10 # Number of frames between key frames
-
- # Starting Velocity of objects
- velsxmin=-1 # Starting Minimum Velocity in the x direction
- velsxmax=1 # Starting Maximum Velocity in the x direction
- velsymin=-1 # Starting Maximum Velocity in the y direction
- velsymax=1 # Starting Maximum Velocity in the y direction
- velszmin=-1 # Starting Maximum Velocity in the z direction
- velszmax=1 # Starting Maximum Velocity in the z direction
-
- # Random Walk accelerations applied at a key frame
- accxmin=-20 # Minimum Acceleration the x direction
- accxmax=20 # Maximum Acceleration the x direction
- accymin=-20 # Minimum Acceleration the y direction
- accymax=20 # Maximum Acceleration the y direction
- acczmin=-20 # Minimum Acceleration the z direction
- acczmax=20 # Maximum Acceleration the z direction
-
- #----------------------------------------------
- # Internal Variables Set Up: Don't alter these
- #----------------------------------------------
-
- obj=[]
- objprop=[]
- ran = random.Random()
- countobj=CountSelectedObjects()
-
- #----------------------------------------------
- # Find Selected Objects
- #----------------------------------------------
-
- for i in range(0,countobj):
- object=GetSelectedObjectByIndex(i)
- obj.append(object)
- vx=random.uniform(velsxmin,velsxmax)
- vy=random.uniform(velsymin,velsymax)
- vz=random.uniform(velszmin,velszmax)
- v=[vx,vy,vz]
- objprop.append(v)
-
- #----------------------------------------------
- # Add Plants
- #----------------------------------------------
-
- for j in range(start+step,stop,step):
- SetCurrentFrame (j)
- for i in range(0,countobj):
- object=obj[i]
- objprop=RandomWalk (objprop,i,accxmin,accxmax,accymin,accymax,acczmin,acczmax)
- object.Move(objprop[i][0],objprop[i][1],objprop[i][2])
Random Walk
- Random Walk
- Version: 0.1
- April 30, 2006
- 1.9 KB
Select some objects, run this script and they wander around randomly in your scene.