PDA

View Full Version : Particle Instancing: Varying the start point of animation


Stryker3D
09-12-2007, 06:26 AM
I'm hoping someone can help me out.

I have a coin (simple poly cylinder). I created an emitter and animated it. I instanced the coin to the particles generated from that emitter. Now I have coins spawning from that emitter. Everything is good so far.

The original coin geometry is being affected by a Gravity and Vortex field. Therefore the spawned coins mirror the movement of the original coin. Again so far so good.

Naturally all the spawned coins have the same orientation as the original at that same frame. How do I go about varying the movement (or orientation of the spawned coins). In other words what attribute would I need to write an expression for in order to vary the animation of the spawned coins.

I run into a roadblock because the original coin is not keyframed, it's simply reacting to the forces on it. Unlike sprites, that have a determined animation length, and can be edited using an expression in the spriteNumPP attribute. I've written simple random creation expressions for the velocity, the position, worldBirthPosition, and acceleration, but again all the coins still face the same way, albeit they shoot off in different directions or have a different position, but they still have the same animation/orientation.

Thanks for any help.

DrYo
09-12-2007, 07:01 PM
Create a new custom per-particle attribute in the particle shape node. Make it a vector data type. Call it custom_rotation or something like that.

Then add a creation expression to randomize the values of custom_rotation.

Now, in the section labeled Instancer (Geometry Replacement), find the Rotation pulldown. Choose custom_rotation from the list.

Stryker3D
09-13-2007, 08:37 PM
DrYo,

Thank you so much, that was exactly what I needed to know.

To sum up what I learned:

I can create a vector or float custom Rotation Attribute and call it anything like "randRotation."

Write a creation expression for the random rotation such as:
randRotation = rand(180);

In the Attribute editor of the particles, look for a section called "Instancer (Geometry Replacement)" Click on the arrow icon to reveal more options. Look for the Rotation Options, and under Rotation select randRotation from the drop down menu. If randRotation is not listed, go to the top where it says "Instancer (Geometry Replacement)" and you'll find a check box called "Allow All Data Types." Make sure this is check marked.

Since the expression is a creation expression, it will only vary the rotation when the coins are created. To continue to vary the rotation throughout your animation you will need to write a runtime expression for randRotation, such as:

randRotation = randRotation + 1;
//Instead of 1, you can put any number to dramatically increase the rotation from one frame to the next.

Similar steps can be done to vary the scale of the particles. Create a randScale custom attribute and follow simiar steps above, but instead of the Rotation Options, you would select the Scale Options located under General Options in the "Instancer (Geometry Replacement)" section.

Thank you again DrYo

DrYo
09-14-2007, 05:05 AM
I've only done it with vectors, not floats. But whatever floats your boat.

Cheers

wima
09-14-2007, 02:51 PM
I can create a vector or float custom Rotation Attribute and call it anything like "randRotation."


If using a float for a vector attribute you will have to click the "allow all data types" in the instancer to be able to pick it from the list.

DrYo
09-15-2007, 06:19 AM
Yes, but how do you tell the Instancer which rotation axes you want to change? If you make a float attribute, and assign it to the Instancer rotation, won't you get X, Y, and Z rotations all assigned to the same number?

wima
09-15-2007, 12:23 PM
Yes, but how do you tell the Instancer which rotation axes you want to change? If you make a float attribute, and assign it to the Instancer rotation, won't you get X, Y, and Z rotations all assigned to the same number?

Yes, you will get the same number assigned to X,Y,Z
Im not succesful in finding a reason to use it though. :)

DrYo
09-15-2007, 08:05 PM
Right, as I thought, for rotations you should always use vectors.

CGTalk Moderation
09-15-2007, 08:05 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.