Form and Space

creating CG 3D since 2001

  • Connect @
  • Linked in
  • Vimeo
  • Twitter
cube array maya mel

Maya: Simple 3D Array

Matthew | April 26, 2012

No Comments

For those of you starting out, here’s a simple array script to create instances of a primitive. You should be able to build onto this script very easily. Play with the numbers, and see how far you can push it. Soon, I’ll modify it so it arrays your selection. I’m working on a ring mail script, and this is a fundamental part of making ring mail.


mls_f3DArray(3, 1.0);

proc mls_f3DArray(int $objCount, float $oSp)
{
           
    int $n = 0;
    string $cube[] = `polyCube -ax 0 1 0`;
    BevelPolygon;
    
    //1D, X
    for($i = 0; $i < $objCount; $i++)
    {
        
        //2D, Y
        for($j = 0; $j < $objCount; $j++)
        {
            
            //3D, Z
            for($k = 0; $k < $objCount; $k++)
            {
        
               string $inst[] = `instance $cube[0]`;
                          
               vector $v = << ($oSp * $i), ($oSp * $j), ($oSp * $k) >>;
                                        
               xform -ws -t ($v.x) ($v.y) ($v.z) $inst[0];
               
               $n++;
               
            } 
        }     
    }
    
    delete $cube;
}


Leave a Reply

Twitter

Subscribers

    396