VHS
09-23-2008, 01:44 PM
Helle there :arteest:
Anyone who can help me get this script working,
it should be some buttons and when you hit it there will be grass
global proc string xxCreateStraw()
{
//Create variables
string $currentCone[];
int $grassType;
float $strawHeight;
float $moveCone;
float $strawBend;
int $strawSubDivY;
int $detail;
float $translateX;
float $translateZ;
float $minX;
float $maxX;
float $minZ;
float $maxZ;
// assign values to variables
// get min and max for X and Z
$minX = `floatFieldGrp -query -value1 grassGen_X_ffGrp`;
$maxX = `floatFieldGrp -query -value2 grassGen_X_ffGrp`;
$minZ = `floatFieldGrp -query -value1 grassGen_Z_ffGrp`;
$maxZ = `floatFieldGrp -query -value2 grassGen_Z_ffGrp`;
$translateX = rand($min,$maxX);
$translateZ = rand($minZ,$maxZ);
// get style and detale for grass.
$grassType = `radioButtonGrp -query -select grassGenTypeRBGrp`;
$detal
//Assign variables
$grassType = 2;
$detail = 2;
$translateX = rand(1,-1);
$translateZ = rand(1,-1);
//Switch for grass type
switch ( $grassType )
{
case 1 :
{
$strawHeight = rand(0.25,0.5);
$strawBend = rand(0.1,0.5);
switch ( $detail )
{
case 1 :
{
$strawSubDivY = 2;
}
break;
case 2 :
{
$strawSubDivY = 4;
}
break;
case 3 :
{
$strawSubDivY = 6;
}
break;
default :
{
$strawSubDivY = 4;
}
break;
}
}
break;
case 2 :
{
$strawHeight = rand(0.75,1.5);
$strawBend = rand(0.25,0.75);
switch ( $detail )
{
case 1 :
{
$strawSubDivY = 3;
}
break;
case 2 :
{
$strawSubDivY = 6;
}
break;
case 3 :
{
$strawSubDivY = 9;
}
break;
default :
{
$strawSubDivY = 5;
}
break;
}
}
break;
case 3 :
{
$strawHeight = rand(1.5,3);
$strawBend = rand(0.25,1);
switch ( $detail )
{
case 1 :
{
$strawSubDivY = 5;
}
break;
case 2 :
{
$strawSubDivY = 10;
}
break;
case 3 :
{
$strawSubDivY = 30;
}
break;
default :
{
$strawSubDivY = 10;
}
break;
}
}
break;
default :
{
$strawHeight = 1;
$strawBend = 0.25;
$strawSubDivY = 5;
}
break;
}
$moveCone = $strawHeight * 0.5;
//Create the cone
polyCone
-radius 0.1
-height $strawHeight
-subdivisionsX 3
-subdivisionsY $strawSubDivY
-subdivisionsZ 0
-axis 0 1 0
-roundCap 0
-createUVs 1
-constructionHistory 0;
$currentCone = `ls -sl`;
//Move and scale cone
move -y $moveCone;
scale -x 0.1;
//Soften and harden
polySoftEdge
-angle 1
-constructionHistory 0;
//Create and move deformer
nonLinear
-type bend
-lowBound -1
-highBound 1
-curvature $strawBend;
move -y 0;
//Reselect and delete history
select -r $currentCone[0];
DeleteHistory;
// Move/rotate straw randomly
xform
-relative
-translation $translateX 0 $translateZ
-rotation 0 `rand(360)` 0;
return $currentCone[0];
}
global proc dsCreateGrass()
{
// Varibles
int $numberOfStraws;
int $squareUnitcount;
float $minX;
float $maxX;
float $minZ;
float $maxZ;
// assign values to variables
$minX = `floatFieldGrp -query -value1 grassGen_X_ffGrp`;
$maxX = `floatFieldGrp -query -value2 grassGen_X_ffGrp`;
$minZ = `floatFieldGrp -query -value1 grassGen_Z_ffGrp`;
$maxZ = `floatFieldGrp -query -value2 grassGen_Z_ffGrp`;
SquareUnitCount = `intFieldGrp -query -value1 grassGenDensityIF`;
$numberOfStraws = 100;
// Loop to create some straws
for { $i=0; $i<$numberOfStraws $i++ }
{
$allTheStraws[$i] = `dsCreateStraw`;
}
select -r $allTheStraws;
polyUnite -ch 0;
}
Anyone who can help me get this script working,
it should be some buttons and when you hit it there will be grass
global proc string xxCreateStraw()
{
//Create variables
string $currentCone[];
int $grassType;
float $strawHeight;
float $moveCone;
float $strawBend;
int $strawSubDivY;
int $detail;
float $translateX;
float $translateZ;
float $minX;
float $maxX;
float $minZ;
float $maxZ;
// assign values to variables
// get min and max for X and Z
$minX = `floatFieldGrp -query -value1 grassGen_X_ffGrp`;
$maxX = `floatFieldGrp -query -value2 grassGen_X_ffGrp`;
$minZ = `floatFieldGrp -query -value1 grassGen_Z_ffGrp`;
$maxZ = `floatFieldGrp -query -value2 grassGen_Z_ffGrp`;
$translateX = rand($min,$maxX);
$translateZ = rand($minZ,$maxZ);
// get style and detale for grass.
$grassType = `radioButtonGrp -query -select grassGenTypeRBGrp`;
$detal
//Assign variables
$grassType = 2;
$detail = 2;
$translateX = rand(1,-1);
$translateZ = rand(1,-1);
//Switch for grass type
switch ( $grassType )
{
case 1 :
{
$strawHeight = rand(0.25,0.5);
$strawBend = rand(0.1,0.5);
switch ( $detail )
{
case 1 :
{
$strawSubDivY = 2;
}
break;
case 2 :
{
$strawSubDivY = 4;
}
break;
case 3 :
{
$strawSubDivY = 6;
}
break;
default :
{
$strawSubDivY = 4;
}
break;
}
}
break;
case 2 :
{
$strawHeight = rand(0.75,1.5);
$strawBend = rand(0.25,0.75);
switch ( $detail )
{
case 1 :
{
$strawSubDivY = 3;
}
break;
case 2 :
{
$strawSubDivY = 6;
}
break;
case 3 :
{
$strawSubDivY = 9;
}
break;
default :
{
$strawSubDivY = 5;
}
break;
}
}
break;
case 3 :
{
$strawHeight = rand(1.5,3);
$strawBend = rand(0.25,1);
switch ( $detail )
{
case 1 :
{
$strawSubDivY = 5;
}
break;
case 2 :
{
$strawSubDivY = 10;
}
break;
case 3 :
{
$strawSubDivY = 30;
}
break;
default :
{
$strawSubDivY = 10;
}
break;
}
}
break;
default :
{
$strawHeight = 1;
$strawBend = 0.25;
$strawSubDivY = 5;
}
break;
}
$moveCone = $strawHeight * 0.5;
//Create the cone
polyCone
-radius 0.1
-height $strawHeight
-subdivisionsX 3
-subdivisionsY $strawSubDivY
-subdivisionsZ 0
-axis 0 1 0
-roundCap 0
-createUVs 1
-constructionHistory 0;
$currentCone = `ls -sl`;
//Move and scale cone
move -y $moveCone;
scale -x 0.1;
//Soften and harden
polySoftEdge
-angle 1
-constructionHistory 0;
//Create and move deformer
nonLinear
-type bend
-lowBound -1
-highBound 1
-curvature $strawBend;
move -y 0;
//Reselect and delete history
select -r $currentCone[0];
DeleteHistory;
// Move/rotate straw randomly
xform
-relative
-translation $translateX 0 $translateZ
-rotation 0 `rand(360)` 0;
return $currentCone[0];
}
global proc dsCreateGrass()
{
// Varibles
int $numberOfStraws;
int $squareUnitcount;
float $minX;
float $maxX;
float $minZ;
float $maxZ;
// assign values to variables
$minX = `floatFieldGrp -query -value1 grassGen_X_ffGrp`;
$maxX = `floatFieldGrp -query -value2 grassGen_X_ffGrp`;
$minZ = `floatFieldGrp -query -value1 grassGen_Z_ffGrp`;
$maxZ = `floatFieldGrp -query -value2 grassGen_Z_ffGrp`;
SquareUnitCount = `intFieldGrp -query -value1 grassGenDensityIF`;
$numberOfStraws = 100;
// Loop to create some straws
for { $i=0; $i<$numberOfStraws $i++ }
{
$allTheStraws[$i] = `dsCreateStraw`;
}
select -r $allTheStraws;
polyUnite -ch 0;
}
