Sorry for scary title and opening image.
Let's continue to fast track our learning process. I am really itchy to get to the more advanced stuffs, but there are so many things to be explored.
Last time, we know that we can position an object whether it is via:
- Direct Vector assignment
- Node Object Transform Output
- Copying other object transformation
- Node Matrix In and Out
- Mesh Vertex Positions
TRANSFORMING MULTIPLE OBJECTS
Dealing with multiple objects is more fun, so I will get to the loop in this article. But let's keep it basic shall we?Let say we have 5 Cube objects. Our intuition says to use "Create Object List" node. We then plug this list into Object Transform Output node.
We are plugging transparent slot into solid slot. Transparent slot means we have list of multiple objects. AN created Get List Element node automatically. When I first use AN, this makes me a bit confused and sad.
However after a little bit digging, I found that we actually need to use Loop Input node.
Loop Input node is a clever hard working node that does this:
FOR EVERY "ITEM IN THE LIST" DO "SOMETHING".
Let's have a look how we can use this loop thingy node. Create "Loop Input" node.
It's called "My Loop" by default. You can have many of this node within one node-tree. You can rename it to something more unique and useful later on.
For now, we will do something simple. To make this to work, we need to have either of this:
(+) New Iterator
(-) New Parameter
(+) New Generator Output
Let's add "Object List" as New Iterator. "Object" will appear as a new output.
Where do we plug in the Input, you might wonder? We use "Invoke Subprogram" and select "My Loop" (the loop input name). You could also just quickly load "My Loop" under Subprograms.
Now, we have these two.
Don't get intimidated, let's think of this as a special input and output node.
INPUT:
List of Objects
OUTPUT
Iteration of Object
Let's create the setup.
Ok when you plug thing like above, you notice all the Cubes go to position 0,0,0 >>> just like we specify under Object Transform. We are getting somewhere.
What if we want to specify 5 positions in 3D space for those 5 cubes? Well, we need to add New Iterator: Vector List.
This is for 5 Cubes at 5 specific positions. A bit tedious but you need to know this before we go to a little bit more advanced.
X NUMBER OF CUBES AT Y RANDOM POSITIONS
If we were to script this, we would probably make program like this:1. Create X number of cubes.
2. For total of X cubes, place them at random positions.
We will certainly use "Random Vector" node that will give random vector value.
For X total number of Cubes, we will use the new "Object Instancer" node because this node will actually generate objects with specified number quite easily.
The rest of our worry.... "Loop Input" will handle it.
"Random Vector" does NOT actually generate "list" of random vector by default. It will spit only 1 vector value at a time. What I mean is: only if we input an iterative number, Random Vector will then generate list of random vector through the loop.
NOTE: The output of Random Vector is NOT transparent slot. Unlike node that actually generate list of value such as "Float Range".
Plugging in "Index" into "Seed" will actually trigger the node to produce list of Vector values that we can use right away. I am using "Debug Loop" node to be able to see the result.
The rest is pretty easy right? :)
RANDOM SCALING MANY OBJECTS
Continuing from above, if we plug Vector from Value (vector value created from one value input), into the "Scale" of "Object Transform Output".... we will get all objects to be the same scale size.
I wanted to use Float Range that will give random float values within certain range. But as soon as I plug the Float Range into Vector from Value, it creates this "Get List Element" node.
This ALWAYS happens when we are plugging transparent slot value into solid color slot.
We could do the same method: plugging the Index output of "Loop Input" into the "Index" of Get List Element and so as the random cube being generated, the scale will grow from first to the last.
OR, we could actually plug in Float Range node into "Invoke Subprogram" so it will loop without needing to use Index.
To complete this random object placement, I add "Integer Input" node to control both Instances number and the amount of Float Range.
Let see if you can also random rotate these guys? I am sure you can.
POSITION OBJECTS IN LINE
Now, AN node apparently has some quick few nodes dealing with Mesh already. A bit like Sverchok. So it can generate Grid and Line.Since we know we can use the Vertex Positions of "Mesh" to place objects, we can use what we have learned to create something like below.
Spinning Tower of Suzanne. |
Before we are moving to animation, maybe in next articles, I hope you can started to understand the idea of LOOPING / ITERATION.
It's not an easy concept to understand, but you will get it.
Post a Comment