## Editor
Class SpiralStairBuilder

source: C:\XIII\Editor\Classes\SpiralStairBuilder.uc

    Core.Object
       |
       +--Editor.BrushBuilder
          |
          +--Editor.SpiralStairBuilder

Direct Known Subclasses:None

class SpiralStairBuilder
extends Editor.BrushBuilder

    //=============================================================================
    // SpiralStairBuilder: Builds a spiral staircase.
    //=============================================================================

Variables
`SlopedFloor,` | `CounterClockwise`
`name` | `GroupName`
`NumStepsPer360,` | `NumSteps`

Function Summary
`bool` | `Build()`
`void` | `BuildCurvedStair(int Direction)`

Source Code

    00001	//=============================================================================
    00002	// SpiralStairBuilder: Builds a spiral staircase.
    00003	//=============================================================================
    00004	class SpiralStairBuilder
    00005		extends BrushBuilder;
    00006
    00007	var() int InnerRadius, StepWidth, StepHeight, StepThickness, NumStepsPer360, NumSteps;
    00008	var() name GroupName;
    00009	var() bool SlopedCeiling, SlopedFloor, CounterClockwise;
    00010
    00011	function BuildCurvedStair( int Direction )
    00012	{
    00013		local rotator RotStep, NewRot;
    00014		local vector vtx, NewVtx, Template[8];
    00015		local int x, y, idx, VertexStart;
    00016
    00017		RotStep.Yaw = 65536.0f * ((360.0f / NumStepsPer360) / 360.0f);
    00018		if( CounterClockwise )
    00019		{
    00020			RotStep.Yaw *= -1;
    00021			Direction *= -1;
    00022		}
    00023
    00024		// Generate the vertices for the first stair.
    00025		idx = 0;
    00026		VertexStart = GetVertexCount();
    00027		vtx.x = InnerRadius;
    00028		for( x = 0 ; x < 2 ; x++ )
    00029		{
    00030			NewVtx = vtx >> (RotStep * x);
    00031
    00032			vtx.z = 0;
    00033			if( SlopedCeiling && x == 1 )
    00034				vtx.z = StepHeight;
    00035			Vertex3f( NewVtx.x, NewVtx.y, vtx.z );
    00036			Template[idx].x = NewVtx.x;		Template[idx].y = NewVtx.y;		Template[idx].z = vtx.z;		idx++;
    00037
    00038			vtx.z = StepThickness;
    00039			if( SlopedFloor && x == 0 )
    00040				vtx.z -= StepHeight;
    00041			Vertex3f( NewVtx.x, NewVtx.y, vtx.z );
    00042			Template[idx].x = NewVtx.x;		Template[idx].y = NewVtx.y;		Template[idx].z = vtx.z;		idx++;
    00043		}
    00044
    00045		vtx.x = InnerRadius + StepWidth;
    00046		for( x = 0 ; x < 2 ; x++ )
    00047		{
    00048			NewVtx = vtx >> (RotStep * x);
    00049
    00050			vtx.z = 0;
    00051			if( SlopedCeiling && x == 1 )
    00052				vtx.z = StepHeight;
    00053			Vertex3f( NewVtx.x, NewVtx.y, vtx.z );
    00054			Template[idx].x = NewVtx.x;		Template[idx].y = NewVtx.y;		Template[idx].z = vtx.z;		idx++;
    00055
    00056			vtx.z = StepThickness;
    00057			if( SlopedFloor && x == 0 )
    00058				vtx.z -= StepHeight;
    00059			Vertex3f( NewVtx.x, NewVtx.y, vtx.z );
    00060			Template[idx].x = NewVtx.x;		Template[idx].y = NewVtx.y;		Template[idx].z = vtx.z;		idx++;
    00061		}
    00062
    00063		// Create steps from the template
    00064		for( x = 0 ; x < NumSteps - 1 ; x++ )
    00065		{
    00066			if( SlopedFloor )
    00067			{
    00068				Poly3i( Direction, VertexStart + 3, VertexStart + 1, VertexStart + 5, 'steptop' );
    00069				Poly3i( Direction, VertexStart + 3, VertexStart + 5, VertexStart + 7, 'steptop' );
    00070			}
    00071			else
    00072				Poly4i( Direction, VertexStart + 3, VertexStart + 1, VertexStart + 5, VertexStart + 7, 'steptop' );
    00073
    00074			Poly4i( Direction, VertexStart + 0, VertexStart + 1, VertexStart + 3, VertexStart + 2, 'inner' );
    00075			Poly4i( Direction, VertexStart + 5, VertexStart + 4, VertexStart + 6, VertexStart + 7, 'outer' );
    00076			Poly4i( Direction, VertexStart + 1, VertexStart + 0, VertexStart + 4, VertexStart + 5, 'stepfront' );
    00077			Poly4i( Direction, VertexStart + 2, VertexStart + 3, VertexStart + 7, VertexStart + 6, 'stepback' );
    00078
    00079			if( SlopedCeiling )
    00080			{
    00081				Poly3i( Direction, VertexStart + 0, VertexStart + 2, VertexStart + 6, 'stepbottom' );
    00082				Poly3i( Direction, VertexStart + 0, VertexStart + 6, VertexStart + 4, 'stepbottom' );
    00083			}
    00084			else
    00085				Poly4i( Direction, VertexStart + 0, VertexStart + 2, VertexStart + 6, VertexStart + 4, 'stepbottom' );
    00086
    00087			VertexStart = GetVertexCount();
    00088			for( y = 0 ; y < 8 ; y++ )
    00089			{
    00090				NewVtx = Template[y] >> (RotStep * (x + 1));
    00091				Vertex3f( NewVtx.x, NewVtx.y, NewVtx.z + (Stepheight * (x + 1)) );
    00092			}
    00093		}
    00094	}
    00095
    00096	function bool Build()
    00097	{
    00098		if( InnerRadius<1 || StepWidth<1 || NumSteps<1 || NumStepsPer360<3 )
    00099			return BadParameters();
    00100
    00101		BeginBrush( false, GroupName );
    00102		BuildCurvedStair( +1 );
    00103		return EndBrush();
    00104	}
    00105
    00106	defaultproperties
    00107	{
    00108	     InnerRadius=64
    00109	     StepWidth=256
    00110	     StepHeight=16
    00111	     StepThickness=32
    00112	     NumStepsPer360=8
    00113	     NumSteps=8
    00114	     GroupName="Spiral"
    00115	     SlopedCeiling=True
    00116	     BitmapFilename="BBSpiralStair"
    00117	     ToolTip="Spiral Staircase"
    00118	}

End Source Code