Showing posts with label particles. Show all posts
Showing posts with label particles. Show all posts

Thursday, May 27, 2010

3d Max & Krakatoa

I hate 3dmax with malice. Nonetheless, it produces pretty stuff and I should keep it here and find a way to translate this to maya.


Combining 2 Particle Groups

//this procedure adds particles from one particle object to another.
//first select the object to add from, then add-select the object to add to.


global proc addParticles(){

string $particleObjs[] = `ls -sl`;
float $addPositions[] = `getAttr ($particleObjs[0]+".position")`;
int $countToAdd = size($addPositions)/3;;

string $emitCmd = ("emit -object " + $particleObjs[1] + "\n");
for ($i = 0; $i < $countToAdd; $i++){ int $xComp = $i*3; int $yComp = ($i*3)+1; int $zComp = ($i*3)+2; vector $addPos = <<($addPositions[$xComp]),($addPositions[$yComp]),($addPositions[$zComp])>>;
$emitCmd += " -pos "+$addPos+"\n";
}

eval($emitCmd);
}
________________________________

So, open a text editor and paste the code in there and save the file as "addParticles.mel".
Place the file in your maya scripts directory.
On Windows the default place would be:
C:\Documents and Settings\\My Documents\maya\scripts\

Then start or restart maya. In the outliner select the particle object you want to add from, and then add-select the particle object you want to add to. Then type addParticles in your MEL command line and hit enter. Done.

The particles from the first object are added at the same positions they had in their own object. And the original object is not deleted, but you can do that or hide it to verify that the first object now includes all particles.

Cgtalk

Wednesday, February 10, 2010

Geometry Random Rotation on Particles

How to create particle instancing with random rotation -

1. create object to be instanced
2. create particles using particle tool
3. in particleShape1 node create two PerParticle (Array) Attributes using the "Add Dynamic Attributes" button under general. They are rotChoose (which is a float) & rot (which is a vector).
4. Be sure to create these attributes under PerParticle(Array) under creation in the expression editor. Use "All Data Types".

particleShape1.rotChoose = rand(360); (float)
particleShape1.rot = <<0,particleshape1.rotchoose,0>>; (vector)


particleShape1.rotChoose = rand(360);
particleShape1.rot = <<0,particleshape1.rotchoose,0>>;

5. Then plug the rotChoose into rot under the rotation options -> rotation

CGTalk Discussion
Rotation Random

Maya 2010 and Maya 2009