Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

Editor.LinearStairBuilder


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
//=============================================================================
// LinearStairBuilder: Builds a Linear Staircase.
//=============================================================================
class LinearStairBuilder
	extends BrushBuilder;

var() int StepLength, StepHeight, StepWidth, NumSteps, AddToFirstStep;
var() name GroupName;

event bool Build()
{
	local int i, LastIdx, CurrentX, CurrentY, CurrentZ, Adjustment;

	// Check for bad input.
	if( StepLength<=0 || StepHeight<=0 || StepWidth<=0 )
		return BadParameters();
	if( Numsteps<=1 || Numsteps>45 )
		return BadParameters("NumSteps must be greater than 1 and less than 45.");

	//
	// Build the brush.
	//
	BeginBrush( false, GroupName );

	CurrentX = 0;
	CurrentY = 0;
	CurrentZ = 0;

	LastIdx = GetVertexCount();

	// Bottom poly.
	Vertex3f( 0,						0,			-StepHeight );
	Vertex3f( 0,						StepWidth,	-StepHeight );
	Vertex3f( StepLength * NumSteps,	StepWidth,	-StepHeight );
	Vertex3f( StepLength * NumSteps,	0,			-StepHeight );
	Poly4i(1, 0, 1, 2, 3, 'Base');
	LastIdx += 4;

	// Back poly.
	Vertex3f( StepLength * NumSteps,	StepWidth,	-StepHeight );
	Vertex3f( StepLength * NumSteps,	StepWidth,	(StepHeight * (NumSteps - 1)) + AddToFirstStep );
	Vertex3f( StepLength * NumSteps,	0,			(StepHeight * (NumSteps - 1)) + AddToFirstStep );
	Vertex3f( StepLength * NumSteps,	0,			-StepHeight );
	Poly4i(1, 4, 5, 6, 7, 'Back');
	LastIdx += 4;

	// Tops of steps.
	for( i = 0 ; i < Numsteps ; i++ )
	{
		CurrentX = (i * StepLength);
		CurrentZ = (i * StepHeight) + AddToFirstStep;

		// Top of the step
		Vertex3f( CurrentX,					CurrentY,				CurrentZ );
		Vertex3f( CurrentX,					CurrentY + StepWidth,	CurrentZ );
		Vertex3f( CurrentX + StepLength,	CurrentY + StepWidth,	CurrentZ );
		Vertex3f( CurrentX + StepLength,	CurrentY,				CurrentZ );

		Poly4i(1,
			LastIdx+(i*4)+3,
			LastIdx+(i*4)+2,
			LastIdx+(i*4)+1,
			LastIdx+(i*4), 'Step');
	}
	LastIdx += (NumSteps*4);

	// Fronts of steps.
	for( i = 0 ; i < Numsteps ; i++ )
	{
		CurrentX = (i * StepLength);
		CurrentZ = (i * StepHeight) + AddToFirstStep;
		if( i == 0 )
			Adjustment = AddToFirstStep;
		else
			Adjustment = 0;

		// Top of the step
		Vertex3f( CurrentX,		CurrentY,				CurrentZ );
		Vertex3f( CurrentX,		CurrentY,				CurrentZ - StepHeight - Adjustment );
		Vertex3f( CurrentX,		CurrentY + StepWidth,	CurrentZ - StepHeight - Adjustment );
		Vertex3f( CurrentX,		CurrentY + StepWidth,	CurrentZ );

		Poly4i(1,
			LastIdx+(i*12)+3,
			LastIdx+(i*12)+2,
			LastIdx+(i*12)+1,
			LastIdx+(i*12), 'Rise');

		// Sides of the step
		Vertex3f( CurrentX,								CurrentY,		CurrentZ );
		Vertex3f( CurrentX,								CurrentY,		CurrentZ - StepHeight - Adjustment );
		Vertex3f( CurrentX + (StepLength*(Numsteps-i)),	CurrentY,		CurrentZ - StepHeight - Adjustment );
		Vertex3f( CurrentX + (StepLength*(Numsteps-i)),	CurrentY,		CurrentZ );

		Poly4i(1,
			LastIdx+(i*12)+4,
			LastIdx+(i*12)+5,
			LastIdx+(i*12)+6,
			LastIdx+(i*12)+7, 'Side');

		Vertex3f( CurrentX,								CurrentY + StepWidth,		CurrentZ );
		Vertex3f( CurrentX,								CurrentY + StepWidth,		CurrentZ - StepHeight - Adjustment );
		Vertex3f( CurrentX + (StepLength*(Numsteps-i)),	CurrentY + StepWidth,		CurrentZ - StepHeight - Adjustment );
		Vertex3f( CurrentX + (StepLength*(Numsteps-i)),	CurrentY + StepWidth,		CurrentZ );

		Poly4i(1,
			LastIdx+(i*12)+11,
			LastIdx+(i*12)+10,
			LastIdx+(i*12)+9,
			LastIdx+(i*12)+8, 'Side');
	}

	return EndBrush();
}

defaultproperties
{
     StepLength=32
     StepHeight=16
     StepWidth=256
     NumSteps=8
     GroupName="LinearStair"
     BitmapFilename="BBLinearStair"
     ToolTip="Linear Staircase"
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: pr 5-2-2018 12:35:50.000 - Creation time: sk 18-3-2018 09:50:12.014 - Created with UnCodeX