## Editor
Class CubeBuilder

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

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

Direct Known Subclasses:None

class CubeBuilder
extends Editor.BrushBuilder

    //=============================================================================
    // CubeBuilder: Builds a 3D cube brush.
    //=============================================================================

Variables
`Width,` | `Breadth`
`name` | `GroupName`
`bool` | `Hollow`
`bool` | `Tessellated`
`float` | `WallThickness`

Function Summary
`void` | `BuildCube(int Direction, float dx, float dy, float dz, bool _tessellated)`

Source Code

    00001	//=============================================================================
    00002	// CubeBuilder: Builds a 3D cube brush.
    00003	//=============================================================================
    00004	class CubeBuilder
    00005		extends BrushBuilder;
    00006
    00007	var() float Height, Width, Breadth;
    00008	var() float WallThickness;
    00009	var() name GroupName;
    00010	var() bool Hollow;
    00011	var() bool Tessellated;
    00012
    00013	function BuildCube( int Direction, float dx, float dy, float dz, bool _tessellated )
    00014	{
    00015		local int n,i,j,k;
    00016		n = GetVertexCount();
    00017
    00018		for( i=-1; i<2; i+=2 )
    00019			for( j=-1; j<2; j+=2 )
    00020				for( k=-1; k<2; k+=2 )
    00021					Vertex3f( i*dx/2, j*dy/2, k*dz/2 );
    00022
    00023		// If the user wants a Tessellated cube, create the sides out of tris instead of quads.
    00024		if( _tessellated )
    00025		{
    00026			Poly3i(Direction,n+0,n+1,n+3);
    00027			Poly3i(Direction,n+0,n+3,n+2);
    00028			Poly3i(Direction,n+2,n+3,n+7);
    00029			Poly3i(Direction,n+2,n+7,n+6);
    00030			Poly3i(Direction,n+6,n+7,n+5);
    00031			Poly3i(Direction,n+6,n+5,n+4);
    00032			Poly3i(Direction,n+4,n+5,n+1);
    00033			Poly3i(Direction,n+4,n+1,n+0);
    00034			Poly3i(Direction,n+3,n+1,n+5);
    00035			Poly3i(Direction,n+3,n+5,n+7);
    00036			Poly3i(Direction,n+0,n+2,n+6);
    00037			Poly3i(Direction,n+0,n+6,n+4);
    00038		}
    00039		else
    00040		{
    00041			Poly4i(Direction,n+0,n+1,n+3,n+2);
    00042			Poly4i(Direction,n+2,n+3,n+7,n+6);
    00043			Poly4i(Direction,n+6,n+7,n+5,n+4);
    00044			Poly4i(Direction,n+4,n+5,n+1,n+0);
    00045			Poly4i(Direction,n+3,n+1,n+5,n+7);
    00046			Poly4i(Direction,n+0,n+2,n+6,n+4);
    00047		}
    00048	}
    00049
    00050	event bool Build()
    00051	{
    00052		if( Height<=0 || Width<=0 || Breadth<=0 )
    00053			return BadParameters();
    00054		if( Hollow && (Height<=WallThickness || Width<=WallThickness || Breadth<=WallThickness) )
    00055			return BadParameters();
    00056		if( Hollow && Tessellated )
    00057			return BadParameters("The 'Tessellated' option can't be specified with the 'Hollow' option.");
    00058
    00059		BeginBrush( false, GroupName );
    00060		BuildCube( +1, Breadth, Width, Height, Tessellated );
    00061		if( Hollow )
    00062			BuildCube( -1, Breadth-WallThickness, Width-WallThickness, Height-WallThickness, Tessellated );
    00063		return EndBrush();
    00064	}
    00065
    00066	defaultproperties
    00067	{
    00068	     Height=256.000000
    00069	     width=256.000000
    00070	     Breadth=256.000000
    00071	     WallThickness=16.000000
    00072	     GroupName="Cube"
    00073	     BitmapFilename="BBCube"
    00074	     ToolTip="Cube"
    00075	}

End Source Code