Tutorial by Lee Griggs Thanks to Pedro Fernando Gómez for his assistance with XGen. In this short tutorial you will learn how to randomly scale the size of Sphere Primitives uniformly using Expressions. Start off by creating a polygon plane with which we can assign the XGen description. Scale the plane to 10 in X,Y and Z. Increase the subdivisions of the plane to 10 in Width and Height.
• With the polygon plane selected, go to XGen>Create Description... • The Create XGen Description will appear asking What kind of Primitives are made by this Description? Choose Spheres and Generate the Primitives - Randomly across the surface.
• Increase the Density to around 100. You should see the plane fill with spheres as in the image below.
If you was to add a typical random expression like the following to each of the Length, Width and Depth attributes you would see that it randomly scales the spheres in non-uniform directions:
$a=rand(0.1,1); $aSpheres are randomly scaled individually in length, width and depth
A way to scale the spheres uniformly in all directions is to create an attribute under the Expressions tab that we can call from the Primitive Attributes. • Go to the Expressions tab and enter sphere_size in the Name attribute. Make sure it is set to float and click on the icon (below) in order to create the attribute.
You should see the new float attribute sphere_size has been created underneath. • Enter the following expression in the text field:
These values will determine the global range of the size of the spheres.
• Now replace the previous expression with the following in the Length, Width and Depth attributes:
You should see that the spheres are now randomly scaled uniformly in all directions:
That concludes this short tutorial on how to uniformly scale spheres using expressions.
Got questions? Visit the Autodesk forums.