|
In this Tutorial I want to show you how to add Instances to Particles. Includes ways to delete unwanted particles easily and instance different objects to the same particle.

Today I want to show you a nice way how you can put stuff on a landscape as seen above. I wrote these scripts for our short "Noah". I hope to spread my wisdom and help you in creating such scenarios in the particle way. Let's start. Open Maya :-) Create a polygon plane, deform it as you wish. I used the Sculpt Surfaces Tool which can be found under the tab Edit Polygons.  Now imagine you would want to place boulders, trees, stones, whatever, on this surface. Sounds like fun eh? Here is the trick. Push F4 to open the dynamics menues. Change to top view. Select Particles -> Particle Tool -> Options (the square)  Now adjust the settings as you wish. You have to experiment a little to find the desired values. You can't undo while painting, so if the values are not good for you, push enter, to finish the particle painting, AFTER that, undo your actions and open the particle tool options again. Here are the settings I used for my painting.  Particle Name -> you can enter a name here, but please don't Number of Particles -> determines how many particles are painted per click or per sketch interval. Maximum Radius -> the radius in which the particles are positioned (a sphere) Sketch Particles -> activate this button if you want the particles to be created while moving your mouse (very recommended) Sketch Interval -> how often are particles created when sketching, the lower the more particles (depending on Number of Particles) are created. Here is what I painted.  Now push enter to finish particle creation. We now have a new particle object in our outliner called "particle1".  Time for some fun. Move all of the particles slightly above the plane.  While the particle object is selected push shift and add the plane to your selection. Then select Particles -> Make Collide The standard settings are fine. If you are not sure if they were ok, or want to change them check the GeoConnector in the Attribute Tab (strg + a) of your particle object.  Now we need a gravity field to let the particles rain on the surface. Select the particles. Then Fields -> Gravity, standard settings are fine here. Reset them if needed. It would be a good thing to change the timeline play length to 500 or so.  Hit the play button. Gulp, oh my gosh, that's not exactly what we wanted :-) Maybe some standard settings were wrong. Let's select the particle object and open the attribute sheet (strg + a). Select the geoConnector1 tab. Hihi, better invert the resilience and friction values. Set resilience to 0, and friction to 1. The resilience factor determines how much bounce energy is conserved when they hit the ground, to make them not bounce at all, set the value to 0. Fricition makes them sticky and stay at their places, so set it to 1 as we don't want the particles to move once they hit the ground. Ok, play it again. That's better. They still move on my computer a little bit which definetely they should not do. I'd say we have a bug here, anyway, play to the nearest frame where all particles hit the ground and hit stop, or adjust the timeline. The accuracy is still precise. Now select the particle object. Copy the code in the script editor.  The code is very well documented, for further questions push F1 and check the mel help. CODE HERE Hit the small enter button, located at the lowest right of your keyboard. A lot of locators should be generated. Select all the locators you want to be deleted and delete them. For example the ones that didn't hit the ground and are floating somewhere beneath or locators you don't want. You can also delete the particle object and the gravity object, we don't need them anylonger.  Congratulations, you finished the first part of this neat tutorial. You just learned how to paint particles and how to use simple scripts. Let's generate a sphere and a cube. Scale and deform them as you wish, they are just dummies for this tutorial, in your final project it could be two different trees or stones, whatever. Move them whereever you want and position their pivots as desired. If you have a tree you would want the pivot to be where the roots start. The script will move the pivots of the objects to the locators, so position the pivots wisely. Select the object (sphere or cube) and push insert on your keyboard. You can now move the pivot, hit insert again to leave the mode. Now comes the final part. Select the cube shift select the sphere and shift select all of the locators. It's important that the first two selected objects are the sphere and the cube. Use the outliner to make it the easiest way. Copy the script to the script editor and hit the small enter button. CODE HERE You should get something like this:  If you are happy with the result delete all the locator objects, the created position constraints will automatically be deleted, too. Then you can group all the objects to keep your outliner clean. If you are not satisfied with the result manipulate the code. If you want to select more than two objects change this line: int $sela = rand (0,2); (for 3 objects enter 0,3 etc.) Change these values for different rotation and scaling values: float $rotaX = rand (0,5); float $rotaY = rand (0,360); float $rotaZ = rand (0, 5); float $scalX = rand (0.8,1.2); float $scalY = rand (0.8,1.2); float $scalZ = rand (0.8,1.2); Have fun with experimenting. I hope you learned a lot in this tutorial. Great day to all of you. Garry Runke |