home *** CD-ROM | disk | FTP | other *** search
/ Game Level Design / GLDesign.bin / Software / UnrealEngine2Runtime / UE2Runtime-22262001_Demo.exe / Editor / Classes / CubeBuilder.uc < prev    next >
Text File  |  2003-10-22  |  2KB  |  78 lines

  1. //=============================================================================
  2. // CubeBuilder: Builds a 3D cube brush.
  3. //=============================================================================
  4. class CubeBuilder
  5.     extends BrushBuilder;
  6.  
  7. var() float Height, Width, Breadth;
  8. var() float WallThickness;
  9. var() name GroupName;
  10. var() bool Hollow;
  11. var() bool Tessellated;
  12.  
  13. function BuildCube( int Direction, float dx, float dy, float dz, bool _tessellated )
  14. {
  15.     local int n,i,j,k;
  16.     n = GetVertexCount();
  17.  
  18.     for( i=-1; i<2; i+=2 )
  19.         for( j=-1; j<2; j+=2 )
  20.             for( k=-1; k<2; k+=2 )
  21.                 Vertex3f( i*dx/2, j*dy/2, k*dz/2 );
  22.  
  23.     // If the user wants a Tessellated cube, create the sides out of tris instead of quads.
  24.     if( _tessellated )
  25.     {
  26.         Poly3i(Direction,n+0,n+1,n+3);
  27.         Poly3i(Direction,n+0,n+3,n+2);
  28.         Poly3i(Direction,n+2,n+3,n+7);
  29.         Poly3i(Direction,n+2,n+7,n+6);
  30.         Poly3i(Direction,n+6,n+7,n+5);
  31.         Poly3i(Direction,n+6,n+5,n+4);
  32.         Poly3i(Direction,n+4,n+5,n+1);
  33.         Poly3i(Direction,n+4,n+1,n+0);
  34.         Poly3i(Direction,n+3,n+1,n+5);
  35.         Poly3i(Direction,n+3,n+5,n+7);
  36.         Poly3i(Direction,n+0,n+2,n+6);
  37.         Poly3i(Direction,n+0,n+6,n+4);
  38.     }
  39.     else
  40.     {
  41.         Poly4i(Direction,n+0,n+1,n+3,n+2);
  42.         Poly4i(Direction,n+2,n+3,n+7,n+6);
  43.         Poly4i(Direction,n+6,n+7,n+5,n+4);
  44.         Poly4i(Direction,n+4,n+5,n+1,n+0);
  45.         Poly4i(Direction,n+3,n+1,n+5,n+7);
  46.         Poly4i(Direction,n+0,n+2,n+6,n+4);
  47.     }
  48. }
  49.  
  50. event bool Build()
  51. {
  52.     if( Height<=0 || Width<=0 || Breadth<=0 )
  53.         return BadParameters();
  54.     if( Hollow && (Height<=WallThickness || Width<=WallThickness || Breadth<=WallThickness) )
  55.         return BadParameters();
  56.     if( Hollow && Tessellated )
  57.         return BadParameters("The 'Tessellated' option can't be specified with the 'Hollow' option.");
  58.  
  59.     BeginBrush( false, GroupName );
  60.     BuildCube( +1, Breadth, Width, Height, Tessellated );
  61.     if( Hollow )
  62.         BuildCube( -1, Breadth-WallThickness, Width-WallThickness, Height-WallThickness, Tessellated );
  63.     return EndBrush();
  64. }
  65.  
  66. defaultproperties
  67. {
  68.     Height=256
  69.     Width=256
  70.     Breadth=256
  71.     WallThickness=16
  72.     GroupName=Cube
  73.     Hollow=false
  74.     Tessellated=false
  75.     BitmapFilename="BBCube"
  76.     ToolTip="Cube"
  77. }
  78.