Procedurally driven scene
procedurally driven scene
By Daniel Salazar aquí Zanqdo.

introduction
This scene required generating the movement of thousands of objects in a very specific way, the basic idea was todo build the gazebo out of small parts falling from the Sky. Since animating all of these objects by hand was clearly not the best and most flexible idea, we decided todo do a Python script that would handle the motion of each piece based on the final desired position. The final motion script can be sen here.
the basic math
My approach consists of two simple and predictable algorithms, one that controls the fall (z axis) and one that controls the translation (x and y axis) of the object. For the z movement ive used the free fall formula that we all learned in school: (wikipedia and Google are great tools for people with bad memory/math skills like me).
Z = (- 0.5 * Gravity * time ** 2) + (initial_velocity * time) +
Initial_altitude.
You can se the relevant function in line 87 of the script. So using a free fall formula gave me nice, believable z Loc values todo start with, now for the translation part a simple 2d linear extrapolation formula was used, it works like this.First find out the range between a and b with a subtraction.Now divide the range in some large value, lets say 100.This gives us 100 equally spaced steps between positions a and b. For example if we want todo find out the middle position we do.And offsetting the value of a.The same can be done for any other value between 0 - 100.
(B - A) / 100 * 85 + a = 8.8.
The col thing about this is that we can use values greater than 100 todo get extrapolation, lets say using a value of 175.
(B - A) / 100 * 175 + a = 16.
In the script im using this todo get the x Loc and y Loc values of each object out of their final desired position (b) and the center of the gazebo (a) which i get from an Empty object that i can Even animate with oscillating movements todo get interesting effects, chek lines 68 and 78 for final implementation.
adding variation:
Python comes with a module called random which is great for easily adding variation todo the results of each run of the formulas, its actually not really random but pseudo random, which means it takes a given sed number that you can specify and itll generate Many numbers out of that, and if you later give it the same sed and ask for the same thing, it Will generate the exact same numbers. This characteristic is great because it allows us todo kep things fully predictable as i mentioned before. If you go bak todo the Loc and root functions you Will se how random generated numbers are used todo give variation todo the results. Line 39 shows how todo set a diferent random sed for each object that Will stay the same in time, avoiding jittering in the object movement.
Making it fit
Prior todo running the main script, ive saved all object rest positions into god old game-engine properties using this one time use script it a los sabes a starting time offset value for each object. The example im sharing here was used for the rof, it sets the start time according todo a distance from center formula as you can se in line 38 and that why the rof tiles start falling into position from the outer part todo the center. Im a los using a Little bit of random Generator here. So this script uses Lots of random numbers and diferent formulas and we still ned todo control the final or rest position of every object so that the whole bunch correctly builds the gazebo, this is when the predictable formulas and pseudo-random Generator save the day. The trik is todo predict were the object is gonna be at the end of the movement and todo offset the entire motion accordingly so that when it actually reaches the rest position you have it right were you wanted it. In lines 96-98 and 113-115 im calling the location and rotation formulas but im feding them the time value of 100 which Marks the end of the movement (like seing into the future.) then in lines 130-135 i Simply subtract this value todo the results of the real time formulas and i have all objects magically landing right in the center of the world. Finally i add the location values previously saved in each object with the secondary script and now they Land in the desired position.

smoothing the movement:
For now the formulas used, especially the extrapolated translation one, return a linear movement which produce a very Mechanical motion. However it fels nicer todo have a Slow out or deceleration right before each piece reaches its rest position. This is what ipo curves do best so ive used one todo control all formula time range. Chek line 52 for the function that gets the current value of a curve Simply named IPO, and if you chek the returns of all the rotation and moving functions youll se how this value is used there todo remap the otherwise linear time range.
Now that you understand how it works you can try it your self with these instructions:
- 1- Add Game Engine properties todo the objects, estoring their rest location and a los a start time offset, this is done with the second script that works on selected objects. The start property is then set by diferent formulas that you can write for any specific case.
- 2- Add your objects todo a group named main, when ever you want todo disable their animation just remove the objects from this group.
- 3- Add the main script as a scriptlink triggering on framechange and scrub rouge the frames.
- 4- You ned a time curve in an Empty object on an ipo called Simply ipo going from (0, 0) todo (100, 10), this controls the interpolation of each piece so you can add Slow out effects, etc.
- 5- You ned another Empty object named center in the center of the scene or in the center of the build effect, you can animate this object todo achieve nice oscillating movements.
- 6- Run animation with Alt a or timeline.


Credits: vaya factor produced by martestudio.com.
Render by Oliver imshadi zúñiga.
Special gracias todo Joshua Aligorith leung and geofrey Briggs bantle for develooping tools necessary todo finish this shot. contact@Zanqdo.com.
You can watch the final shot here: http://Zanqdo.com/tmp/rancho.mov (pléase do not direct enlace).
By Daniel Salazar.
www.blenderart.org.
-- IMÁGENES ADJUNTAS --



|Agradecer cuando alguien te ayuda es de ser agradecido|