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

  1. //=============================================================================
  2. // SpiralStairBuilder: Builds a spiral staircase.
  3. //=============================================================================
  4. class SpiralStairBuilder
  5.     extends BrushBuilder;
  6.  
  7. var() int InnerRadius, StepWidth, StepHeight, StepThickness, NumStepsPer360, NumSteps;
  8. var() name GroupName;
  9. var() bool SlopedCeiling, SlopedFloor, CounterClockwise;
  10.  
  11. function BuildCurvedStair( int Direction )
  12. {
  13.     local rotator RotStep;
  14.     local vector vtx, NewVtx, Template[8];
  15.     local int x, y, idx, VertexStart;
  16.  
  17.     RotStep.Yaw = 65536.0f * ((360.0f / NumStepsPer360) / 360.0f);
  18.     if( CounterClockwise )
  19.     {
  20.         RotStep.Yaw *= -1;
  21.         Direction *= -1;
  22.     }
  23.  
  24.     // Generate the vertices for the first stair.
  25.     idx = 0;
  26.     VertexStart = GetVertexCount();
  27.     vtx.x = InnerRadius;
  28.     for( x = 0 ; x < 2 ; x++ )
  29.     {
  30.         NewVtx = vtx >> (RotStep * x);
  31.  
  32.         vtx.z = 0;
  33.         if( SlopedCeiling && x == 1 )
  34.             vtx.z = StepHeight;
  35.         Vertex3f( NewVtx.x, NewVtx.y, vtx.z );
  36.         Template[idx].x = NewVtx.x;        Template[idx].y = NewVtx.y;        Template[idx].z = vtx.z;        idx++;
  37.  
  38.         vtx.z = StepThickness;
  39.         if( SlopedFloor && x == 0 )
  40.             vtx.z -= StepHeight;
  41.         Vertex3f( NewVtx.x, NewVtx.y, vtx.z );
  42.         Template[idx].x = NewVtx.x;        Template[idx].y = NewVtx.y;        Template[idx].z = vtx.z;        idx++;
  43.     }
  44.  
  45.     vtx.x = InnerRadius + StepWidth;
  46.     for( x = 0 ; x < 2 ; x++ )
  47.     {
  48.         NewVtx = vtx >> (RotStep * x);
  49.  
  50.         vtx.z = 0;
  51.         if( SlopedCeiling && x == 1 )
  52.             vtx.z = StepHeight;
  53.         Vertex3f( NewVtx.x, NewVtx.y, vtx.z );
  54.         Template[idx].x = NewVtx.x;        Template[idx].y = NewVtx.y;        Template[idx].z = vtx.z;        idx++;
  55.  
  56.         vtx.z = StepThickness;
  57.         if( SlopedFloor && x == 0 )
  58.             vtx.z -= StepHeight;
  59.         Vertex3f( NewVtx.x, NewVtx.y, vtx.z );
  60.         Template[idx].x = NewVtx.x;        Template[idx].y = NewVtx.y;        Template[idx].z = vtx.z;        idx++;
  61.     }
  62.  
  63.     // Create steps from the template
  64.     for( x = 0 ; x < NumSteps - 1 ; x++ )
  65.     {
  66.         if( SlopedFloor )
  67.         {
  68.             Poly3i( Direction, VertexStart + 3, VertexStart + 1, VertexStart + 5, 'steptop' );
  69.             Poly3i( Direction, VertexStart + 3, VertexStart + 5, VertexStart + 7, 'steptop' );
  70.         }
  71.         else
  72.             Poly4i( Direction, VertexStart + 3, VertexStart + 1, VertexStart + 5, VertexStart + 7, 'steptop' );
  73.  
  74.         Poly4i( Direction, VertexStart + 0, VertexStart + 1, VertexStart + 3, VertexStart + 2, 'inner' );
  75.         Poly4i( Direction, VertexStart + 5, VertexStart + 4, VertexStart + 6, VertexStart + 7, 'outer' );
  76.         Poly4i( Direction, VertexStart + 1, VertexStart + 0, VertexStart + 4, VertexStart + 5, 'stepfront' );
  77.         Poly4i( Direction, VertexStart + 2, VertexStart + 3, VertexStart + 7, VertexStart + 6, 'stepback' );
  78.  
  79.         if( SlopedCeiling )
  80.         {
  81.             Poly3i( Direction, VertexStart + 0, VertexStart + 2, VertexStart + 6, 'stepbottom' );
  82.             Poly3i( Direction, VertexStart + 0, VertexStart + 6, VertexStart + 4, 'stepbottom' );
  83.         }
  84.         else
  85.             Poly4i( Direction, VertexStart + 0, VertexStart + 2, VertexStart + 6, VertexStart + 4, 'stepbottom' );
  86.  
  87.         VertexStart = GetVertexCount();
  88.         for( y = 0 ; y < 8 ; y++ )
  89.         {
  90.             NewVtx = Template[y] >> (RotStep * (x + 1));
  91.             Vertex3f( NewVtx.x, NewVtx.y, NewVtx.z + (Stepheight * (x + 1)) );
  92.         }
  93.     }
  94. }
  95.  
  96. function bool Build()
  97. {
  98.     if( InnerRadius<1 || StepWidth<1 || NumSteps<1 || NumStepsPer360<3 )
  99.         return BadParameters();
  100.  
  101.     BeginBrush( false, GroupName );
  102.     BuildCurvedStair( +1 );
  103.     return EndBrush();
  104. }
  105.  
  106. defaultproperties
  107. {
  108.     InnerRadius=64
  109.     StepWidth=256
  110.     StepHeight=16
  111.     StepThickness=32
  112.     NumStepsPer360=8
  113.     NumSteps=8
  114.     SlopedCeiling=true
  115.     SlopedFloor=false
  116.     GroupName="Spiral"
  117.     CounterClockwise=0
  118.     BitmapFilename="BBSpiralStair"
  119.     ToolTip="Spiral Staircase"
  120. }
  121.