|06 June 2009||#1|
Join Date: Jun 2009
How to access each vertex of a polyCube and move it randomly??
Hi MEL Masters,
I have a query for all MEL experts. I am new to MEL, so I am in a learning phase right now.
The problem is that I have created a polyCube in Maya. Like all cubes, it has 8 vertices. What I'm trying to do is that I want each and every vertex of the polyCube to move at a random X,Y,Z position thereby creating a deformed cube.
The solution in my mind is that first i create three variables as;
float $Xpos = rand(-12,12)
float $Ypos = rand(-12,12)
float $Zpos = rand(-12,12)
and then assign these variables as X,Y,Z position of each vertex like;
move $Xpos $Ypos $Zpos;
I understand that for this I have to use the for() loop so that each time a distorted cube is created it will have a different shape.
Finally i will make a procedure that will accept the number of distorted cubes as input form the user and gives the result. Something like;
global proc CreateDistortedCubes(int $NoOfCubes)
If anyone can write me a MEL for this or at least give me a clue in the form of a chunk of code, i'll be greatful.
I can handle the for() loop on my own. I just want to know how to access each vertex of a polyCube through MEL, and move each vertex dynamically through rand() command.
|06 June 2009||#2|
Join Date: Nov 2007
Here's a crude example.
You might want to mess about with the move command flag, -relative & -absolute.
You could also load the procedure into memory, and place distortObj(-1, 1) in an expression to
get some random animation going.
Should work for any number of objects selected.
Hope that helps.
Last edited by mlefevre : 06 June 2009 at 09:47 AM.
|06 June 2009||#4|
Join Date: Sep 2003
Thread automatically closed
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.
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
|Thread Closed share thread|