## Editor
Class CylinderBuilder

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

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

Direct Known Subclasses:None

class CylinderBuilder
extends Editor.BrushBuilder

    //=============================================================================
    // CylinderBuilder: Builds a 3D cylinder brush.
    //=============================================================================

Variables
`name` | `GroupName`
`AlignToSide,` | `Hollow`
`OuterRadius,` | `InnerRadius`
`int` | `Sides`

Function Summary
`bool` | `Build()`
`void` | `BuildCylinder(int Direction, bool AlignToSide, int Sides, float Height, float Radius)`

Source Code

    00001	//=============================================================================
    00002	// CylinderBuilder: Builds a 3D cylinder brush.
    00003	//=============================================================================
    00004	class CylinderBuilder
    00005		extends BrushBuilder;
    00006
    00007	var() float Height, OuterRadius, InnerRadius;
    00008	var() int Sides;
    00009	var() name GroupName;
    00010	var() bool AlignToSide, Hollow;
    00011
    00012	function BuildCylinder( int Direction, bool AlignToSide, int Sides, float Height, float Radius )
    00013	{
    00014		local int n,i,j,q,Ofs;
    00015		n = GetVertexCount();
    00016		if( AlignToSide )
    00017		{
    00018			Radius /= cos(pi/Sides);
    00019			Ofs = 1;
    00020		}
    00021
    00022		// Vertices.
    00023		for( i=0; i<Sides; i++ )
    00024			for( j=-1; j<2; j+=2 )
    00025				Vertex3f( Radius*sin((2*i+Ofs)*pi/Sides), Radius*cos((2*i+Ofs)*pi/Sides), j*Height/2 );
    00026
    00027		// Polys.
    00028		for( i=0; i<Sides; i++ )
    00029			Poly4i( Direction, n+i*2, n+i*2+1, n+((i*2+3)%(2*Sides)), n+((i*2+2)%(2*Sides)), 'Wall' );
    00030	}
    00031
    00032	function bool Build()
    00033	{
    00034		local int i,j,k;
    00035
    00036		if( Sides<3 )
    00037			return BadParameters();
    00038		if( Height<=0 || OuterRadius<=0 )
    00039			return BadParameters();
    00040		if( Hollow && (InnerRadius<=0 || InnerRadius>=OuterRadius) )
    00041			return BadParameters();
    00042
    00043		BeginBrush( false, GroupName );
    00044		BuildCylinder( +1, AlignToSide, Sides, Height, OuterRadius );
    00045		if( Hollow )
    00046		{
    00047			BuildCylinder( -1, AlignToSide, Sides, Height, InnerRadius );
    00048			for( j=-1; j<2; j+=2 )
    00049				for( i=0; i<Sides; i++ )
    00050					Poly4i( j, i*2+(1-j)/2, ((i+1)%Sides)*2+(1-j)/2, ((i+1)%Sides)*2+(1-j)/2+Sides*2, i*2+(1-j)/2+Sides*2, 'Cap' );
    00051		}
    00052		else
    00053		{
    00054			for( j=-1; j<2; j+=2 )
    00055			{
    00056				PolyBegin( j, 'Cap' );
    00057				for( i=0; i<Sides; i++ )
    00058					Polyi( i*2+(1-j)/2 );
    00059				PolyEnd();
    00060			}
    00061		}
    00062		return EndBrush();
    00063	}
    00064
    00065	defaultproperties
    00066	{
    00067	     Height=256.000000
    00068	     OuterRadius=512.000000
    00069	     InnerRadius=384.000000
    00070	     Sides=8
    00071	     GroupName="Cylinder"
    00072	     AlignToSide=True
    00073	     BitmapFilename="BBCylinder"
    00074	     ToolTip="Cylinder"
    00075	}

End Source Code