Building Construction


This page provides a technical breakdown of an animation of building construction).

 


//---Building construction animation Version 1

//make sure to select the objects first
//The order of your selection will affect the order of animation
//use undo if you want to clean the keyframs generated
//Ming Tang. 2007

 

proc builder ()

{

//-------construction sequence auto keyframe
//-------copyright Ming Tang. 2007

int $startFrame = `intSliderGrp -q -v startFrame`;
int $internalFrame = `intSliderGrp -q -v internalFrame`;
int $dropDuration = `intSliderGrp -q -v dropDuration`;
float $dropHeight = `intSliderGrp -q -v dropHeight`;

string $list[] = {};
string $list[] = `ls -sl`;

//define the start frame of animtion
int $start=$startFrame;

//define the time length between two structures generation
int $interval=$internalFrame;

//define the time length of drop translation
//int $drop=$dropDuration;
int $drop=$dropDuration;

//define the distance of movement
$distance=$dropHeight;
//int $distance=10;

//define the axis of movement
//not avaliable right now

 

//string $profile;
//print($list);

 

//-------don't change the code below

$i = 0;
while($i < size($list)){

//create keyframe animation

setAttr ($list[$i] + ".visibility") 0;

//set visiblility and the first keyframe
currentTime (0+$start);
setKeyframe ($list[$i]+".v");

//set visibility and the second keyframe
currentTime ($i*$interval+$start);
setAttr ($list[$i] + ".visibility") 1;

setKeyframe ($list[$i]+".v");

//set move values

select -r ($list[$i]);
move -r 0 $distance 0;
setKeyframe ($list[$i]+".ty");

//set move values for the third keyframe
currentTime ($i*$interval+$start+$drop);
move -r 0 (-$distance) 0;
setKeyframe ($list[$i]+".ty");

 

$i++;
}
}
//builder;

//---------------------------

//--------create break

proc breakIt ()

{
string $myobject[] = `ls -sl`;

//print ("the quary name is" + $myobject[0]);

$item = $myobject[0] + ".f[0:9999]";

select -cl;

select -r $item;

polyChipOff -kft 0 -dup 0 -ls 0.95 0.95 0.95;
polyPerformAction polySeparate o 0;

//find the root node of a curve transformation node

string $shape[] = `listRelatives -shapes $myobject[0]`;

polySeparate -ch 1 $shape[0];
}

//------------create window

global proc construction ()
{

if (`window -exists constructionWindow`) { deleteUI constructionWindow; }

 

window
-widthHeight 300 300
-title "construction animation Builder"
-sizeable true
constructionWindow;

columnLayout;

intSliderGrp -label "start Frame"
-field true
-fieldStep 1
-sliderStep 1
-value 2
startFrame;

intSliderGrp -label "internal Frame"
-field true
-value 3
internalFrame;

intSliderGrp -label "drop duration"
-field true
-value 5
dropDuration;

intSliderGrp -label "drop Height"
-field true
-value 5
dropHeight;

text -l "";
separator -w 800;
text -l "";

button -label "Animate Construction"
-command "builder" buildIt;

button -label "break components"
-command "breakIt" breakIt;

showWindow;
}

construction;




this is an early version rendered.

 

 

Latest version.



 

Window

 

 

 

//---Building construction animation Version 2

 

//version II: you can skip the "create beams" option
//transparent glass shader added
//duplication of beam and panel added.
//make sure to select the objects first
//The order of your selection will affect the order of animation
//use undo if you want to clean the keyframs generated
//Ming Tang. 2007

 

proc builder ()

{

//-------construction sequence auto keyframe
//-------copyright Ming Tang. 2007

int $startFrame = `intSliderGrp -q -v startFrame`;
int $internalFrame = `intSliderGrp -q -v internalFrame`;
int $dropDuration = `intSliderGrp -q -v dropDuration`;
float $dropHeight = `intSliderGrp -q -v dropHeight`;

string $list[] = {};
string $list[] = `ls -sl`;

//define the start frame of animtion
int $start=$startFrame;

//define the time length between two structures generation
int $interval=$internalFrame;

//define the time length of drop translation
//int $drop=$dropDuration;
int $drop=$dropDuration;

//define the distance of movement
$distance=$dropHeight;
//int $distance=10;

//define the axis of movement
//not avaliable right now

 

//string $profile;
//print($list);

 

//-------don't change the code below

$i = 0;
while($i < size($list)){

//create keyframe animation

setAttr ($list[$i] + ".visibility") 0;

//set visiblility and the first keyframe
currentTime (0+$start);
setKeyframe ($list[$i]+".v");

//set visibility and the second keyframe
currentTime ($i*$interval+$start);
setAttr ($list[$i] + ".visibility") 1;

setKeyframe ($list[$i]+".v");

//set move values

select -r ($list[$i]);
move -r 0 $distance 0;
setKeyframe ($list[$i]+".ty");

//set move values for the third keyframe
currentTime ($i*$interval+$start+$drop);
move -r 0 (-$distance) 0;
setKeyframe ($list[$i]+".ty");

 

$i++;
}

//---change the time line
$maxtime = $startFrame + $internalFrame * size($list) + $dropDuration;
playbackOptions -min 1 -max $maxtime ;
}
//builder;

//---------------------------

//--------create break

proc breakIt ()

{

string $myobject[] = `ls -sl`;

//---assign a transparent glass
shadingNode -asShader blinn -n glass;
setAttr "glass.transparency" -type double3 0.5 0.5 0.5 ;
setAttr "glass.color" -type double3 0.4 0.5 0.7 ;
select -r $myobject[0] ;
rename "roof_panel";
//--roof_panel is the name comes from beam generation
defaultNavigation -source glass -destination |roof_panel|roof_panelShape.instObjGroups[0] -connectToExisting;

//print ("the quary name is" + $myobject[0]);

$item = "roof_panel" + ".f[0:9999]";

select -cl;

select -r $item;

polyChipOff -kft 0 -dup 0 -ls 0.95 0.95 0.95;
polyPerformAction polySeparate o 0;

//find the root node of a curve transformation node

string $shape[] = `listRelatives -shapes roof_panel`;

polySeparate -ch 1 $shape[0];

}

//-----proc building beams
proc beam ()
{
//select faces

string $myobject[] = `ls -sl`;

print ("the quary name is" + $myobject[0]);

//---duplicate the roof--
duplicate;
string $roof[] = `ls -sl`;
//-----------

$item = $myobject[0] + ".f[0:9999]";

select -cl;

select -r $item;

//extrude along y to get the height, double faces were made

polyExtrudeFacet -ch 1 -kft 0 -t 0 -1 0;

doDelete;

select -r $item ;

//triangulate the beam into a diagonal structure

polyTriangulate -ch 1 $item ;

//create the hole inside the beams

polyExtrudeFacet -ch 1 -kft 0 -lsx 0.8 -lsy 0.8 -lsz 0.8;

doDelete;

//extrude the beam to create thickness

select -r $item ;

polyExtrudeFacet -ch 1 -kft 0 -ltx 0 -lty 0 -ltz 0.02;

//----rename the beam
select -r $myobject[0];
rename "beam01";

//----reselect the roof for the next operation
select -r $roof[0];
rename "roof_panel";
}

 

//------------create UI window

global proc construction ()
{

if (`window -exists constructionWindow`) { deleteUI constructionWindow; }

 

window
-widthHeight 300 300
-title "construction animation Builder"
-sizeable true
constructionWindow;

columnLayout;

intSliderGrp -label "start Frame"
-field true
-fieldStep 1
-sliderStep 1
-value 2
startFrame;

intSliderGrp -label "internal Frame"
-field true
-value 3
internalFrame;

intSliderGrp -label "drop duration"
-field true
-value 5
dropDuration;

intSliderGrp -label "drop Height"
-field true
-value 5
dropHeight;

text -l "";
separator -w 800;
text -l "";

//---create button 1
button -label "createe beams"
-command "beam" beam;
text -l "";
separator -w 800;
text -l "";

//---create button 2
button -label "createe panel components"
-command "breakIt" breakIt;
text -l "";
separator -w 800;
text -l "";

//---create button 3
button -label "Animate Construction"
-command "builder" buildIt;

 

showWindow;
}

construction;

 
 

//version 3: Final GUI


//transparent glass shader added
//duplication of beam and panel added.
//make sure to select the objects first
//The order of your selection will affect the order of animation
//use undo if you want to clean the keyframs generated
//Ming Tang. 2007

 

proc builder ()

{

//-------construction sequence auto keyframe
//-------copyright Ming Tang. 2007

int $startFrame = `intSliderGrp -q -v startFrame`;
int $internalFrame = `intSliderGrp -q -v internalFrame`;
int $dropDuration = `intSliderGrp -q -v dropDuration`;
//float $dropHeight = `intSliderGrp -q -v dropHeight`;
float $dropX = `textField -q -text dropX`;
float $dropY = `textField -q -text dropY`;
float $dropZ = `textField -q -text dropZ`;

string $list[] = {};
string $list[] = `ls -sl`;

//define the start frame of animtion
int $start=$startFrame;

//define the time length between two structures generation
int $interval=$internalFrame;

//define the time length of drop translation
//int $drop=$dropDuration;
int $drop=$dropDuration;

//define the distance of movement
//$distance=$dropHeight;
//int $distance=10;

//define the axis of movement
//not avaliable right now

 

//string $profile;
//print($list);

 

//-------don't change the code below

$i = 0;
while($i < size($list)){

//create keyframe animation

setAttr ($list[$i] + ".visibility") 0;

//set visiblility and the first keyframe
currentTime (0+$start);
setKeyframe ($list[$i]+".v");

//set visibility and the second keyframe
currentTime ($i*$interval+$start);
setAttr ($list[$i] + ".visibility") 1;

setKeyframe ($list[$i]+".v");

//set move values

select -r ($list[$i]);
//move -r 0 $distance 0;
//setKeyframe ($list[$i]+".ty");
move -r $dropX $dropY $dropZ;
setKeyframe ($list[$i]+".tx");
setKeyframe ($list[$i]+".ty");
setKeyframe ($list[$i]+".tz");

//set move values for the third keyframe
currentTime ($i*$interval+$start+$drop);
//move -r 0 (-$distance) 0;
//setKeyframe ($list[$i]+".ty");
move -r (-$dropX) (-$dropY) (-$dropZ);
setKeyframe ($list[$i]+".tx");
setKeyframe ($list[$i]+".ty");
setKeyframe ($list[$i]+".tz");

$i++;
}
//---change the time line
$maxtime = $startFrame + $internalFrame * size($list) + $dropDuration;
playbackOptions -min 1 -max $maxtime ;
}

//builder;

//---------------------------

//--------create break

proc breakIt ()

{

string $myobject[] = `ls -sl`;

//---assign a transparent glass
shadingNode -asShader blinn -n glass;
setAttr "glass.transparency" -type double3 0.5 0.5 0.5 ;
setAttr "glass.color" -type double3 0.4 0.5 0.7 ;
select -r $myobject[0] ;
rename "roof_panel";
//--roof_panel is the name comes from beam generation
defaultNavigation -source glass -destination |roof_panel|roof_panelShape.instObjGroups[0] -connectToExisting;

//print ("the quary name is" + $myobject[0]);

$item = "roof_panel" + ".f[0:9999]";

select -cl;

select -r $item;

polyChipOff -kft 0 -dup 0 -ls 0.95 0.95 0.95;
polyPerformAction polySeparate o 0;

//find the root node of a curve transformation node

string $shape[] = `listRelatives -shapes roof_panel`;

polySeparate -ch 1 $shape[0];

}

//-----proc building beams
proc beam ()
{
//select faces

string $myobject[] = `ls -sl`;

print ("the quary name is" + $myobject[0]);

//---duplicate the roof--
duplicate;
string $roof[] = `ls -sl`;
//-----------

$item = $myobject[0] + ".f[0:9999]";

select -cl;

select -r $item;

//extrude along y to get the height, double faces were made

polyExtrudeFacet -ch 1 -kft 0 -t 0 -1 0;

doDelete;

select -r $item ;

//triangulate the beam into a diagonal structure

polyTriangulate -ch 1 $item ;

//create the hole inside the beams

polyExtrudeFacet -ch 1 -kft 0 -lsx 0.8 -lsy 0.8 -lsz 0.8;

doDelete;

//extrude the beam to create thickness

select -r $item ;

polyExtrudeFacet -ch 1 -kft 0 -ltx 0 -lty 0 -ltz 0.02;

//----rename the beam
select -r $myobject[0];
rename "beam01";

//----reselect the roof for the next operation
select -r $roof[0];
rename "roof_panel";
}

 

//------------create UI window

global proc construction ()
{

if (`window -exists constructionWindow`) { deleteUI constructionWindow; }

 

window
-widthHeight 300 300
-title "construction animation Builder"
-sizeable true
constructionWindow;

 

//scrollLayout;
columnLayout;
//break
text -l "Step 1: Define the timeline of animation";
text -l "";

intSliderGrp -label "start Frame"
-field true
-fieldStep 1
-sliderStep 1
-value 2
startFrame;

intSliderGrp -label "internal Frame"
-field true
-value 3
internalFrame;

intSliderGrp -label "drop duration"
-field true
-value 5
dropDuration;
setParent ..;

/*
intSliderGrp -label "drop Height"
-field true
-value 5
dropHeight;
*/

//break
text -l "";
separator -w 800;
text -l "Step 2: Define the distance of movement. Accept negative value";
text -l "";

//add three drop values

rowColumnLayout -numberOfColumns 2
-column