## Editor
Class ConeBuilder

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

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

Direct Known Subclasses:None

class ConeBuilder
extends Editor.BrushBuilder

    //=============================================================================
    // ConeBuilder: Builds a 3D cone brush, compatible with cylinder of same size.
    //=============================================================================

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

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

Source Code

    00001	//=============================================================================
    00002	// ConeBuilder: Builds a 3D cone brush, compatible with cylinder of same size.
    00003	//=============================================================================
    00004	class ConeBuilder
    00005		extends BrushBuilder;
    00006
    00007	var() float Height, CapHeight, OuterRadius, InnerRadius;
    00008	var() int Sides;
    00009	var() name GroupName;
    00010	var() bool AlignToSide, Hollow;
    00011
    00012	function BuildCone( int Direction, bool AlignToSide, int Sides, float Height, float Radius, name Item )
    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			Vertex3f( Radius*sin((2*i+Ofs)*pi/Sides), Radius*cos((2*i+Ofs)*pi/Sides), 0 );
    00025		Vertex3f( 0, 0, Height );
    00026
    00027		// Polys.
    00028		for( i=0; i<Sides; i++ )
    00029			Poly3i( Direction, n+i, n+Sides, n+((i+1)%Sides), Item );
    00030	}
    00031
    00032	function bool Build()
    00033	{
    00034		local int i;
    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		if( Hollow && CapHeight>Height )
    00043			return BadParameters();
    00044		if( Hollow && (CapHeight==Height && InnerRadius==OuterRadius) )
    00045			return BadParameters();
    00046
    00047		BeginBrush( false, GroupName );
    00048		BuildCone( +1, AlignToSide, Sides, Height, OuterRadius, 'Top' );
    00049		if( Hollow )
    00050		{
    00051			BuildCone( -1, AlignToSide, Sides, CapHeight, InnerRadius, 'Cap' );
    00052			if( OuterRadius!=InnerRadius )
    00053				for( i=0; i<Sides; i++ )
    00054					Poly4i( 1, i, ((i+1)%Sides), Sides+1+((i+1)%Sides), Sides+1+i, 'Bottom' );
    00055		}
    00056		else
    00057		{
    00058			PolyBegin( 1, 'Bottom' );
    00059			for( i=0; i<Sides; i++ )
    00060				Polyi( i );
    00061			PolyEnd();
    00062		}
    00063		return EndBrush();
    00064	}
    00065
    00066	defaultproperties
    00067	{
    00068	     Height=256.000000
    00069	     CapHeight=256.000000
    00070	     OuterRadius=512.000000
    00071	     InnerRadius=384.000000
    00072	     Sides=8
    00073	     GroupName="Cone"
    00074	     AlignToSide=True
    00075	     BitmapFilename="BBCone"
    00076	     ToolTip="Cone"
    00077	}

End Source Code