// This command will auto generate a train track along a selected curve; global proc re_createMineTracks2() { string $lssl[] = `ls -sl`; string $trainTrack = `group -empty -name "train_track_#"`; string $trussGroup = `group -empty -name "Truss_#"`; /// Tweakables float $trackWidth = 1; int $sleeperGapDistance= 2; //////////////////////////////// float $curveLength = `arclen $lssl[0]`; int $sleeperCount = $curveLength / $sleeperGapDistance; float $sleeperWidth = (($trackWidth/2)+$trackWidth); float $sleeperHeight = (($trackWidth/6)); float $sleeperDepth = (($trackWidth/4)); //Make Sleeper and Rails string $cube[] = `polyCube -w $sleeperWidth -h $sleeperHeight -d $sleeperDepth -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1`; string $curve1 = `curve -d 3 -p 0 0.1330775619 -2.962576412e-017 -p -0.02170390143 0.1329227539 -2.955701557e-017 -p -0.03870106516 0.1344080357 -3.021661321e-017 -p -0.03887509593 0.1183756972 -2.309682466e-017 -p -0.03941043771 0.1054866858 -1.737295377e-017 -p -0.03946561244 0.0966728723 -1.345883429e-017 -p -0.03270661637 0.09564120055 -1.300068e-017 -p -0.0197958682 0.09437602771 -1.243883039e-017 -p -0.009379566368 0.08393225375 -7.800863067e-018 -p -0.01166494143 0.02260646918 1.943325615e-017 -p -0.009388195026 0.02439292943 1.863990843e-017 -p -0.03780605442 0.01252868781 2.390869011e-017 -p -0.05655320773 0.009565594249 2.522456799e-017 -p -0.06671129012 0.008215180199 2.58242723e-017 -p -0.06671129012 0.005076440719 2.721815263e-017 -p -0.06671129012 0.002223041199 2.848531657e-017 -p -0.06671129012 -0.0003450183712 2.962576412e-017 -p -0.04669790309 -0.0003450183712 2.962576412e-017 -p -0.02446080638 -0.0003450183712 2.962576412e-017 -p 0.02446080638 -0.0003450183712 2.962576412e-017 -p 0.04669790309 -0.0003450183712 2.962576412e-017 -p 0.06671129012 -0.0003450183712 2.962576412e-017 -p 0.06671129012 0.002223041199 2.848531657e-017 -p 0.06671129012 0.005076440719 2.721815263e-017 -p 0.06671129012 0.008215180199 2.58242723e-017 -p 0.05655320773 0.009565594249 2.522456799e-017 -p 0.03780605442 0.01252868781 2.390869011e-017 -p 0.009388195026 0.02439292943 1.863990843e-017 -p 0.01166494143 0.02260646918 1.943325615e-017 -p 0.009379566368 0.08393225375 -7.800863067e-018 -p 0.0197958682 0.09437602771 -1.243883039e-017 -p 0.03270661637 0.09564120055 -1.300068e-017 -p 0.03946561244 0.0966728723 -1.345883429e-017 -p 0.03941043771 0.1054866858 -1.737295377e-017 -p 0.03887509593 0.1183756972 -2.309682466e-017 -p 0.03870106516 0.1344080357 -3.021661321e-017 -p 0.02170390143 0.1329227539 -2.955701557e-017 -p 0 0.1330775619 -2.962576412e-017`; string $curve2 = `curve -d 3 -p 0 0.1330775619 -2.962576412e-017 -p -0.02170390143 0.1329227539 -2.955701557e-017 -p -0.03870106516 0.1344080357 -3.021661321e-017 -p -0.03887509593 0.1183756972 -2.309682466e-017 -p -0.03941043771 0.1054866858 -1.737295377e-017 -p -0.03946561244 0.0966728723 -1.345883429e-017 -p -0.03270661637 0.09564120055 -1.300068e-017 -p -0.0197958682 0.09437602771 -1.243883039e-017 -p -0.009379566368 0.08393225375 -7.800863067e-018 -p -0.01166494143 0.02260646918 1.943325615e-017 -p -0.009388195026 0.02439292943 1.863990843e-017 -p -0.03780605442 0.01252868781 2.390869011e-017 -p -0.05655320773 0.009565594249 2.522456799e-017 -p -0.06671129012 0.008215180199 2.58242723e-017 -p -0.06671129012 0.005076440719 2.721815263e-017 -p -0.06671129012 0.002223041199 2.848531657e-017 -p -0.06671129012 -0.0003450183712 2.962576412e-017 -p -0.04669790309 -0.0003450183712 2.962576412e-017 -p -0.02446080638 -0.0003450183712 2.962576412e-017 -p 0.02446080638 -0.0003450183712 2.962576412e-017 -p 0.04669790309 -0.0003450183712 2.962576412e-017 -p 0.06671129012 -0.0003450183712 2.962576412e-017 -p 0.06671129012 0.002223041199 2.848531657e-017 -p 0.06671129012 0.005076440719 2.721815263e-017 -p 0.06671129012 0.008215180199 2.58242723e-017 -p 0.05655320773 0.009565594249 2.522456799e-017 -p 0.03780605442 0.01252868781 2.390869011e-017 -p 0.009388195026 0.02439292943 1.863990843e-017 -p 0.01166494143 0.02260646918 1.943325615e-017 -p 0.009379566368 0.08393225375 -7.800863067e-018 -p 0.0197958682 0.09437602771 -1.243883039e-017 -p 0.03270661637 0.09564120055 -1.300068e-017 -p 0.03946561244 0.0966728723 -1.345883429e-017 -p 0.03941043771 0.1054866858 -1.737295377e-017 -p 0.03887509593 0.1183756972 -2.309682466e-017 -p 0.03870106516 0.1344080357 -3.021661321e-017 -p 0.02170390143 0.1329227539 -2.955701557e-017 -p 0 0.1330775619 -2.962576412e-017`; move -a (($trackWidth/2)*-1) ($sleeperHeight/2) 0 $curve1; move -a (($trackWidth/2)) ($sleeperHeight/2) 0 $curve2; ////////// Parent everything to the sleeper parent $curve1 $cube[0]; parent $curve2 $cube[0]; /// Duplicate along the curve and loft the rails pathAnimation -fractionMode true -follow true -followAxis z -upAxis y -worldUpType "vector" -worldUpVector 0 1 0 -inverseUp false -inverseFront false -bank false -startTimeU 1 -endTimeU $sleeperCount $cube[0] $lssl[0]; string $rail1 = "loft -ch 1 -u 1 -c 0 -ar 1 -d 3 -ss 1 -rn 0 -po 1 -rsn true "; string $rail2 = "loft -ch 1 -u 1 -c 0 -ar 1 -d 3 -ss 1 -rn 0 -po 1 -rsn true "; float $lastTopLoc1[]; float $lastMiddleLoc1[]; float $lastBottomLoc1[]; float $lastTopLoc2[]; float $lastMiddleLoc2[]; float $lastBottomLoc2[]; float $width = ($sleeperDepth/3); string $support1 = `curve -d 1 -p ($width*-1) 0 ($width*-1) -p $width 0 ($width*-1) -p $width 0 $width -p ($width*-1) 0 $width -p ($width*-1) 0 ($width*-1)`; $width = ($sleeperDepth/5); string $support2 = `curve -d 1 -p ($width*-1) 0 ($width*-1) -p $width 0 ($width*-1) -p $width 0 $width -p ($width*-1) 0 $width -p ($width*-1) 0 ($width*-1)`; for ($i = 1; ($sleeperCount+1) > $i; ++$i) { currentTime $i; select $cube[0]; duplicate; string $tmp[] = `ls -sl`; $rail1 += (" "+($tmp[0]+"|"+$curve1)); $rail2 += (" "+($tmp[0]+"|"+$curve2)); parent $tmp[0] $trainTrack; //Create the Truss System Under The Tracks float $loc1[] = `xform -q -ws -t ($tmp[0]+"|"+$curve1)`; float $loc2[] = `xform -q -ws -t ($tmp[0]+"|"+$curve2)`; float $top1Y = $loc1[1]-($sleeperHeight/2); float $top2Y = $loc2[1]-($sleeperHeight/2); float $bottom1X = ($loc1[0] - $loc2[0]) + $loc1[0]; float $bottom1Z = $loc1[2] - $loc2[2] + $loc1[2]; float $bottom2X = ($loc2[0] - $loc1[0]) + $loc2[0]; float $bottom2Z = $loc2[2] - $loc1[2] + $loc2[2]; string $leftCurve = `curve -d 1 -p $loc1[0] $top1Y $loc1[2] -p $bottom1X 0 $bottom1Z -k 0 -k 1`; string $rightCurve = `curve -d 1 -p $loc2[0] $top2Y $loc2[2] -p $bottom2X 0 $bottom2Z -k 0 -k 1`; float $truss1Loc[] = `pointOnCurve -pr 0.5 -p $rightCurve`; float $truss2Loc[] = `pointOnCurve -pr 0.5 -p $leftCurve`; string $leftTrussCurve = `curve -d 1 -p $loc1[0] $top1Y $loc1[2] -p $truss1Loc[0] $truss1Loc[1] $truss1Loc[2] -k 0 -k 1`; string $rightTrussCurve = `curve -d 1 -p $loc2[0] $top2Y $loc2[2] -p $truss2Loc[0] $truss2Loc[1] $truss2Loc[2] -k 0 -k 1`; string $leftTrussCurve2 = `curve -d 1 -p $truss1Loc[0] $truss1Loc[1] $truss1Loc[2] -p $bottom1X 0 $bottom1Z -k 0 -k 1`; string $rightTrussCurve2 = `curve -d 1 -p $truss2Loc[0] $truss2Loc[1] $truss2Loc[2] -p $bottom2X 0 $bottom2Z -k 0 -k 1`; parent $leftTrussCurve $trussGroup; parent $rightTrussCurve $trussGroup; parent $leftTrussCurve2 $trussGroup; parent $rightTrussCurve2 $trussGroup; parent $leftCurve $trussGroup; parent $rightCurve $trussGroup; /// string $modelTmp[] = `extrude -ch true -rn false -po 1 -et 2 -ucp 1 -fpt 1 -upn 1 -rotation 0 -scale 1 -rsp 1 $support2 $leftTrussCurve2`; parent $modelTmp $trussGroup; $modelTmp = `extrude -ch true -rn false -po 1 -et 2 -ucp 1 -fpt 1 -upn 1 -rotation 0 -scale 1 -rsp 1 $support2 $rightTrussCurve2` ; parent $modelTmp $trussGroup; $modelTmp = `extrude -ch true -rn false -po 1 -et 2 -ucp 1 -fpt 1 -upn 1 -rotation 0 -scale 1 -rsp 1 $support2 $leftTrussCurve` ; parent $modelTmp $trussGroup; $modelTmp = `extrude -ch true -rn false -po 1 -et 2 -ucp 1 -fpt 1 -upn 1 -rotation 0 -scale 1 -rsp 1 $support2 $rightTrussCurve` ; parent $modelTmp $trussGroup; /// $modelTmp = `extrude -ch true -rn false -po 1 -et 2 -ucp 1 -fpt 1 -upn 1 -rotation 0 -scale 1 -rsp 1 $support1 $leftCurve` ; parent $modelTmp $trussGroup; $modelTmp = `extrude -ch true -rn false -po 1 -et 2 -ucp 1 -fpt 1 -upn 1 -rotation 0 -scale 1 -rsp 1 $support1 $rightCurve` ; parent $modelTmp $trussGroup; //////////////////////// Create the Side Bracing if($i > 1) { string $leftSideTruss1 = `curve -d 1 -p $loc1[0] $top1Y $loc1[2] -p $lastMiddleLoc2[0] $lastMiddleLoc2[1] $lastMiddleLoc2[2] -k 0 -k 1`; string $rightSideTruss1 = `curve -d 1 -p $loc2[0] $top2Y $loc2[2] -p $lastMiddleLoc1[0] $lastMiddleLoc1[1] $lastMiddleLoc1[2] -k 0 -k 1`; string $leftSideTruss2 = `curve -d 1 -p $lastTopLoc1[0] $lastTopLoc1[1] $lastTopLoc1[2] -p $truss1Loc[0] $truss1Loc[1] $truss1Loc[2] -k 0 -k 1`; string $rightSideTruss2 = `curve -d 1 -p $lastTopLoc2[0] $lastTopLoc2[1] $lastTopLoc2[2] -p $truss2Loc[0] $truss2Loc[1] $truss2Loc[2] -k 0 -k 1`; parent $leftSideTruss1 $trussGroup; parent $rightSideTruss1 $trussGroup; parent $leftSideTruss2 $trussGroup; parent $rightSideTruss2 $trussGroup; string $model[] = `extrude -ch true -rn false -po 1 -et 2 -ucp 1 -fpt 1 -upn 1 -rotation 0 -scale 1 -rsp 1 $support2 $leftSideTruss1`; parent $model $trussGroup; $model = `extrude -ch true -rn false -po 1 -et 2 -ucp 1 -fpt 1 -upn 1 -rotation 0 -scale 1 -rsp 1 $support2 $rightSideTruss1`; parent $model $trussGroup; $model = `extrude -ch true -rn false -po 1 -et 2 -ucp 1 -fpt 1 -upn 1 -rotation 0 -scale 1 -rsp 1 $support2 $leftSideTruss2`; parent $model $trussGroup; $model = `extrude -ch true -rn false -po 1 -et 2 -ucp 1 -fpt 1 -upn 1 -rotation 0 -scale 1 -rsp 1 $support2 $rightSideTruss2`; parent $model $trussGroup; } $lastTopLoc1[0] = $loc1[0]; $lastMiddleLoc1[0] = $truss1Loc[0]; $lastBottomLoc1[0] = $bottom1X; $lastTopLoc1[1] = $top1Y; $lastMiddleLoc1[1] = $truss1Loc[1]; $lastBottomLoc1[1] = 0; $lastTopLoc1[2] = $loc1[2]; $lastMiddleLoc1[2] = $truss1Loc[2]; $lastBottomLoc1[3] = $bottom1Z; $lastTopLoc2[0] = $loc2[0]; $lastMiddleLoc2[0] = $truss2Loc[0]; $lastBottomLoc2[0] = $bottom2X; $lastTopLoc2[1] = $top2Y; $lastMiddleLoc2[1] = $truss2Loc[1]; $lastBottomLoc2[1] = 0; $lastTopLoc2[2] = $loc2[2]; $lastMiddleLoc2[2] = $truss2Loc[2]; $lastBottomLoc2[3] = $bottom2Z; } eval $rail1; string $tmp2[] = `ls -sl`; parent $tmp2[0] $trainTrack; eval $rail2; string $tmp3[] = `ls -sl`; parent $tmp3[0] $trainTrack; delete $cube[0]; }