Core.Object | +--Editor.BrushBuilder | +--Editor.CurvedStairBuilder
NumSteps,
AddToFirstStep
bool
CounterClockwise
name
GroupName
Build()
void
BuildCurvedStair(int Direction)
00001 //============================================================================= 00002 // CurvedStairBuilder: Builds a curved staircase. 00003 //============================================================================= 00004 class CurvedStairBuilder 00005 extends BrushBuilder; 00006 00007 var() int InnerRadius, StepHeight, StepWidth, AngleOfCurve, NumSteps, AddToFirstStep; 00008 var() name GroupName; 00009 var() bool CounterClockwise; 00010 00011 function BuildCurvedStair( int Direction ) 00012 { 00013 local rotator RotStep; 00014 local vector vtx, NewVtx; 00015 local int x, z, InnerStart, OuterStart, BottomInnerStart, BottomOuterStart, Adjustment; 00016 00017 RotStep.Yaw = (65536.0f * (AngleOfCurve / 360.0f)) / NumSteps; 00018 00019 if( CounterClockwise ) 00020 { 00021 RotStep.Yaw *= -1; 00022 Direction *= -1; 00023 } 00024 00025 // Generate the inner curve points. 00026 InnerStart = GetVertexCount(); 00027 vtx.x = InnerRadius; 00028 for( x = 0 ; x < (NumSteps + 1) ; x++ ) 00029 { 00030 if( x == 0 ) 00031 Adjustment = AddToFirstStep; 00032 else 00033 Adjustment = 0; 00034 00035 NewVtx = vtx >> (RotStep * x); 00036 00037 Vertex3f( NewVtx.x, NewVtx.y, vtx.z - Adjustment ); 00038 vtx.z += StepHeight; 00039 Vertex3f( NewVtx.x, NewVtx.y, vtx.z ); 00040 } 00041 00042 // Generate the outer curve points. 00043 OuterStart = GetVertexCount(); 00044 vtx.x = InnerRadius + StepWidth; 00045 vtx.z = 0; 00046 for( x = 0 ; x < (NumSteps + 1) ; x++ ) 00047 { 00048 if( x == 0 ) 00049 Adjustment = AddToFirstStep; 00050 else 00051 Adjustment = 0; 00052 00053 NewVtx = vtx >> (RotStep * x); 00054 00055 Vertex3f( NewVtx.x, NewVtx.y, vtx.z - Adjustment ); 00056 vtx.z += StepHeight; 00057 Vertex3f( NewVtx.x, NewVtx.y, vtx.z ); 00058 } 00059 00060 // Generate the bottom inner curve points. 00061 BottomInnerStart = GetVertexCount(); 00062 vtx.x = InnerRadius; 00063 vtx.z = 0; 00064 for( x = 0 ; x < (NumSteps + 1) ; x++ ) 00065 { 00066 NewVtx = vtx >> (RotStep * x); 00067 Vertex3f( NewVtx.x, NewVtx.y, vtx.z - AddToFirstStep ); 00068 } 00069 00070 // Generate the bottom outer curve points. 00071 BottomOuterStart = GetVertexCount(); 00072 vtx.x = InnerRadius + StepWidth; 00073 for( x = 0 ; x < (NumSteps + 1) ; x++ ) 00074 { 00075 NewVtx = vtx >> (RotStep * x); 00076 Vertex3f( NewVtx.x, NewVtx.y, vtx.z - AddToFirstStep ); 00077 } 00078 00079 for( x = 0 ; x < NumSteps ; x++ ) 00080 { 00081 Poly4i( Direction, InnerStart + (x * 2) + 2, InnerStart + (x * 2) + 1, OuterStart + (x * 2) + 1, OuterStart + (x * 2) + 2, 'steptop' ); 00082 Poly4i( Direction, InnerStart + (x * 2) + 1, InnerStart + (x * 2), OuterStart + (x * 2), OuterStart + (x * 2) + 1, 'stepfront' ); 00083 Poly4i( Direction, BottomInnerStart + x, InnerStart + (x * 2) + 1, InnerStart + (x * 2) + 2, BottomInnerStart + x + 1, 'innercurve' ); 00084 Poly4i( Direction, OuterStart + (x * 2) + 1, BottomOuterStart + x, BottomOuterStart + x + 1, OuterStart + (x * 2) + 2, 'outercurve' ); 00085 Poly4i( Direction, BottomInnerStart + x, BottomInnerStart + x + 1, BottomOuterStart + x + 1, BottomOuterStart + x, 'Bottom' ); 00086 } 00087 00088 // Back panel. 00089 Poly4i( Direction, BottomInnerStart + NumSteps, InnerStart + (NumSteps * 2), OuterStart + (NumSteps * 2), BottomOuterStart + NumSteps, 'back' ); 00090 } 00091 00092 function bool Build() 00093 { 00094 local int i,j,k; 00095 00096 if( AngleOfCurve<1 || AngleOfCurve>360 ) 00097 return BadParameters("Angle is out of range."); 00098 if( InnerRadius<1 || StepWidth<1 || NumSteps<1 ) 00099 return BadParameters(); 00100 00101 BeginBrush( false, GroupName ); 00102 BuildCurvedStair( +1 ); 00103 return EndBrush(); 00104 } 00105 00106 defaultproperties 00107 { 00108 InnerRadius=240 00109 StepHeight=16 00110 StepWidth=256 00111 AngleOfCurve=90 00112 NumSteps=4 00113 GroupName=CStair 00114 BitmapFilename="BBCurvedStair" 00115 ToolTip="Curved Staircase" 00116 }