PDA

View Full Version : creating many, many boxes...


splash|proof
07-12-2002, 02:02 PM
Is there an easy way to create very many same shapes in Maya. I know that in 3Ds you can "fill" a shape with little shapes like boxes, so that you get sort of a "cloud" of boxes. All random in size and position.

Is there a function or plugin that can do this?

alexx
07-12-2002, 02:21 PM
i dont think there is a direct way doing this in maya.

i guess you will have to do some small mel to achieve the result you want.

alexx

splash|proof
07-12-2002, 02:25 PM
I've never done anything with MEL and haven't got a clue on how to do this, so....

thanx anyway, but I hope there's another way

sigma
07-12-2002, 02:46 PM
I think MEL could be the answer. Heres a little script for creating a box from curves ( by Chris Clay )

curve -d 1 -p 9.26493 1.180816 1.180816 -p 9.26493 1.180816 -1.180816 -p 6.903298 1.180816 -1.180816 -p 6.903298 1.180816 1.180816 -p 9.26493 1.180816 1.180816 -p 9.26493 -1.180816 1.180816 -p 6.903298 -1.180816 1.180816 -p 6.903298 1.180816 1.180816 -p 6.903298 1.180816 -1.180816 -p 6.903298 -1.180816 -1.180816 -p 6.903298 -1.180816 1.180816 -p 9.26493 -1.180816 1.180816 -p 9.26493 -1.180816 -1.180816 -p 6.903298 -1.180816 -1.180816 -p 6.903298 1.180816 -1.180816 -p 9.26493 1.180816 -1.180816 -p 9.26493 -1.180816 -1.180816 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 -k 14 -k 15 -k 16 ; xform -cp;

You can take this script and place it in the Script Editor, then drag & drop it into your Shelf. Now you have a button to create a curve box.

ACFred
07-12-2002, 02:59 PM
Yeah, you can create a bunch of particles and do what's called "instancing". Instancing allows you to apply a piece of geometry to the position of the particle. You can create the particles and instance, say, a box to the particles. A box will appear for each particle in the group. Then, using the instancing attributes, you can randomize scale and rotation to get what I think you want. Then, you apply a little wind and turbulence force to your particles and you have dancing boxes!

Look up "Instancer" in the Maya help file.

sigma
07-12-2002, 03:08 PM
..or what ACFred said. lol
It makes more sense.

:scream:

MDC
07-12-2002, 04:02 PM
Evryone who uses Maya should learn MEL. You're missing out on 90% of what makes Maya so cool. Here's a little script I wrote especially for you as a MEL lesson. It'll generate as many cubes as you want (default 50), randomly sizes them, randomly rotates them, and randomly places them in a predefined area of the world. With a little tweaking, you can make it do exactly what you want.


//stupid random cube script
//Current number of cubes
global int $Cubes;
//Number of cubes you want to create
global int $TotalCubes = 50;
//Translate boundary. This will be used
//to contain the cubes to a specific cubic area of the world
global float $TBounds = 5.0;
//Rotation boundary. This is used to keep the rotations
//360 Degrees or less.
global float $RBounds = 360.0;
//This is used to limit the size of the cube
global float $Size = 2;
//An all puprose variable
global float $f;

//Do this over and over until we've made the total number of cubes
for( $Cubes = 0; $Cubes < $TotalCubes; ++$Cubes)
{
//Initialize the placeholder variable to 0
$f = 0.0;
//Set the size of the cubes somewhere between 0.5 and 2
$f = `rand 0.5 $Size`;

//Create a cube using the random size
polyCube -w $f -h $f -d $f -sx 1 -sy 1 -sz 1 -ax 0 1 0 -tx 1 -ch 1;
//Randomly rotate the cube on each axis
rotate -r -os `rand $RBounds` `rand $RBounds` `rand $RBounds`;
//Randomly place the cube somewhere within the defined boundary
move -r `rand (-$TBounds) $TBounds` `rand (-$TBounds) $TBounds` `rand (-$TBounds) $TBounds`;
};

stunndman
07-12-2002, 08:23 PM
proc scatterObjects() {
vector $newpos;
vector $newrot;
int $numOfDuplicates = 10;
int $i = 0;
string $selectedSurface[] = `ls -sl`;
string $newSurface[];
float $x;
float $y;
float $z;

for($i = 0; $i < $numOfDuplicates;$i++) {
$newpos = `rand <<0,0,0>> <<10,0,10>>`;
$newrot = `rand <<0,0,0>> <<0,360,0>>`;
$newSurface = `duplicate $selectedSurface`;
print($newpos.x + ":" + $newpos.y + ":" + $newpos.z + "\n");
$x = $newpos.x;
$y = $newpos.y;
$z = $newpos.z;
move -a $x $y $z $newSurface;
$x = $newrot.x;
$y = $newrot.y;
$z = $newrot.z;
rotate $x $y $z $newSurface;
}
}
scatterObjects();


here's the one i use for test scenes - will duplicate any selected object

how to parameterize it

1) int $numOfDuplicates = 10;
2) $newpos = `rand <<0,0,0>> <<10,0,10>>`;
3) $newrot = `rand <<0,0,0>> <<0,360,0>>`;

ad 1) no comment
ad 2) the area in within your new objects will be duplicated
<<minimum-x,minimum-y,minimum-z>> <<maximum-x,maximum-y,maximum-z>>
ad 3) a random rotation applied to every duplicate (set all to 0 to not rotate at all)

stunndman
07-12-2002, 08:54 PM
no MEL - no fun - 4000 cubes in a 100 by 100 by 100 cube

sigma
07-12-2002, 11:25 PM
Hey who would like a thread completely dedicated to MEL scripts? I can make it a sticky like the Maya Tutorials at the top. Could be a great resource! Dont know about you but Im always looking for MEL tricks.

TumikSmacker
07-13-2002, 04:40 AM
sounds good sigma :D

InnerVortex
07-13-2002, 08:39 PM
Wow!! myself dont know much MEL, but the potencial of coding in modelling is great, i started reading some stuff.. and could do somethingis, this scripts with explanations really help alot MDC im very greatfull for that, sigma that would be really fine:) go for it

Jhonus
07-14-2002, 01:43 AM
Originally posted by sigma
Hey who would like a thread completely dedicated to MEL scripts? I can make it a sticky like the Maya Tutorials at the top. Could be a great resource! Dont know about you but Im always looking for MEL tricks.

awesome idea. if it goes well and the information flows, then maybe a "rigging tips'n'tricks" one could be added after a few weeks aswell?

MDC
07-14-2002, 02:17 AM
Yeah, a scripting thread would be excellent. So what should we do? Start it rolling with a basic tutorial? Or take a complex script and just rip it apart line by line?

sigma
07-14-2002, 03:20 AM
Ok great lets do this.
For those of you who added MEL scripts above
can you please re-post them in the following thread MEL Scripts (http://www.cgtalk.com/showthread.php?s=&threadid=14082)

:scream:

sunwjjkd
07-14-2002, 04:54 AM
i think snapshot is a good idea .you can try!!

sigma
07-14-2002, 05:40 AM
snapshot? you mean taking a screenshot of the previous posts? but then you cant copy the text. :scream:

iC4
07-15-2002, 02:56 PM
Originally posted by stunndman

proc scatterObjects() {
vector $newpos;
vector $newrot;
int $numOfDuplicates = 10;
int $i = 0;
string $selectedSurface[] = `ls -sl`;
string $newSurface[];
float $x;
float $y;
float $z;

for($i = 0; $i < $numOfDuplicates;$i++) {
$newpos = `rand <<0,0,0>> <<10,0,10>>`;
$newrot = `rand <<0,0,0>> <<0,360,0>>`;
$newSurface = `duplicate $selectedSurface`;
print($newpos.x + ":" + $newpos.y + ":" + $newpos.z + "\n");
$x = $newpos.x;
$y = $newpos.y;
$z = $newpos.z;
move -a $x $y $z $newSurface;
$x = $newrot.x;
$y = $newrot.y;
$z = $newrot.z;
rotate $x $y $z $newSurface;
}
}
scatterObjects();


here's the one i use for test scenes - will duplicate any selected object

how to parameterize it

1) int $numOfDuplicates = 10;
2) $newpos = `rand <<0,0,0>> <<10,0,10>>`;
3) $newrot = `rand <<0,0,0>> <<0,360,0>>`;

ad 1) no comment
ad 2) the area in within your new objects will be duplicated
<<minimum-x,minimum-y,minimum-z>> <<maximum-x,maximum-y,maximum-z>>
ad 3) a random rotation applied to every duplicate (set all to 0 to not rotate at all)

the script works fine, just one thing......maybe you know how to do it. It would be fine if you can select an object and the script would take it's coordinates and then duplicate only in these coordinates

I'm just trying to fill a wagon full of objects, and the volume is not a primitve cube......so it would be nice if I create an temporary object which fits in the wagon, then select it and the script would duplicate in this object

maybe somebody knows how to do it? :)

CGTalk Moderation
01-13-2006, 10:00 AM
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.