Legacy:Zxanphorian Brushbuilders

From Unreal Wiki, The Unreal Engine Documentation Site

Cone Builder [[Image:Legacy_BBZxanCone.png|]]

<uscript line> //============================================================================= // ZxanphorianConeBuilder. // This is my FIRST brush builder for UnrealEd! // What it does is build a better cone than the one that Epic made. // //_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_- // // version 1.2 // tornado.f5@worldnet.att.net // (c) 2002 Nick "Zxanphorian" Parker // //============================================================================= class ZxanphorianConeBuilder extends ZxanphorianBuilders config(ZxanphorianbrushBuilders);


// _--__--__--__--_STRUCTS_--__--__--__--_

struct TopTipLocationStruct {

var() config float Height, CapLocationX, CapLocationY;

}; struct TipLocationsStruct { var() config TopTipLocationStruct TopTipLocation; var() config TopTipLocationStruct BottomTipLocation; }; var() config TipLocationsStruct TipLocations;


struct DimensionsStruct { var() config bool UseRadius; var() config float Radius, Length, Width, OffsetX, OffsetY, OffsetZ; }; struct DimensionStruct { var() config DimensionsStruct OuterDimensions; var() config DimensionsStruct InnerDimensions; }; var() config DimensionStruct Dimensions;



struct RotationStruct { var() config float RotationX, RotationY; }; struct RotationsStruct { var() config RotationStruct TopRotation; var() config RotationStruct BottomRotation; }; var() config RotationsStruct Rotations;


struct RandomiserTBStruct { var() float Height[2], Radius[2], CapLocationX[2], CapLocationY[2]; }; struct RandomiserMStruct { var() int Sides[2]; }; struct RandomisersStruct { var() RandomiserTBStruct RandomiserTop; var() RandomiserTBStruct RandomiserBottom; var() RandomiserMStruct RandomiserMisc; }; var() RandomisersStruct Randomisers;


// _--__--__--__--_OTHER VARIABLES_--__--__--__--_ var() config int Sides; var() config name GroupName; var() config bool HasBottom, MergeCoplanars ; var() export bool SaveConfiguration;


enum PresetsEnum { No_Preset, Randomiser, DefaultBBProperties }; var() config PresetsEnum Presets;

enum HelpEnum { ChooseATopic, TipLocations, Dimensions, Rotations, Randomisers, RegularOptions, Presets }; var() config HelpEnum HelpTopics; enum AboutEnum { DisplayOff, DisplayOn, }; var() config AboutEnum AboutBrushbuilder;

var int HB;


function DoPresets() { // _--__--__--__--_PRESETS_--__--__--__--_

if( Presets == DefaultBBProperties) { TipLocations.TopTipLocation.Height=512.000000; TipLocations.TopTipLocation.CapLocationX=0.000000; TipLocations.TopTipLocation.CapLocationY=0.000000; TipLocations.BottomTipLocation.Height=-512.000000; TipLocations.BottomTipLocation.CapLocationX=0.000000; TipLocations.BottomTipLocation.CapLocationY=0.000000;


Dimensions.OuterDimensions.UseRadius=True; Dimensions.OuterDimensions.Radius=512.000000; Dimensions.OuterDimensions.Length=512.000000; Dimensions.OuterDimensions.Width=512.000000; Dimensions.OuterDimensions.OffsetX=0.000000; Dimensions.OuterDimensions.OffsetY=0.000000; Dimensions.OuterDimensions.OffsetZ=0.000000; Dimensions.InnerDimensions.UseRadius=True; Dimensions.InnerDimensions.Radius=256.000000; Dimensions.InnerDimensions.Length=256.000000; Dimensions.InnerDimensions.Width=256.000000; Dimensions.InnerDimensions.OffsetX=0.000000; Dimensions.InnerDimensions.OffsetY=0.000000; Dimensions.InnerDimensions.OffsetZ=0.000000;


Rotations.TopRotation.RotationX=1.000000; Rotations.TopRotation.RotationY=1.000000; Rotations.BottomRotation.RotationX=1.000000; Rotations.TopRotation.RotationY=1.000000;


Sides=8; GroupName='ZxanCone'; HasBottom=False; MergeCoplanars=True; Presets=No_Preset; HelpTopics=ChooseATopic; AboutBrushbuilder=DisplayOff; }


if( Presets == Randomiser) { TipLocations.TopTipLocation.Height = RandRange( Randomisers.RandomiserTop.Height[0], Randomisers.RandomiserTop.Height[1]); TipLocations.BottomTipLocation.Height = RandRange(Randomisers.RandomiserBottom.Height[0], Randomisers.RandomiserBottom.Height[1]); Dimensions.OuterDimensions.Radius = RandRange(Randomisers.RandomiserTop.Radius[0], Randomisers.RandomiserTop.Radius[1] ) ; Dimensions.InnerDimensions.Radius = RandRange(Randomisers.RandomiserBottom.Radius[0], Randomisers.RandomiserBottom.Radius[1]); TipLocations.TopTipLocation.CapLocationX = RandRange(Randomisers.RandomiserTop.CapLocationX[0], Randomisers.RandomiserTop.CapLocationX[1]); TipLocations.TopTipLocation.CapLocationY = RandRange(Randomisers.RandomiserTop.CapLocationY[0], Randomisers.RandomiserTop.CapLocationY[1]); TipLocations.BottomTipLocation.CapLocationX =RandRange(Randomisers.RandomiserBottom.CapLocationX[0], Randomisers.RandomiserBottom.CapLocationX[1]); TipLocations.BottomTipLocation.CapLocationY =RandRange(Randomisers.RandomiserBottom.CapLocationY[0], Randomisers.RandomiserBottom.CapLocationY[1]); Sides = RandRange(Randomisers.RandomiserMisc.Sides[0], Randomisers.RandomiserMisc.Sides[1]); HasBottom = False;

// How to Choose between the different options HB = RandRange(0, 5000); if( HB >= 2500) HasBottom = True;

}

}


function BuildCone( int Direction, int Sides, name Item, TipLocationsStruct TipLocations, TopTipLocationStruct TopTipLocation, DimensionStruct Dimensions, DimensionsStruct OuterDimensions, RotationsStruct Rotations, RotationStruct TopRotation) {

local int n,i,j,q; n = GetVertexCount();


// Vertices. if(Dimensions.OuterDimensions.UseRadius == True) { for( i=0; i<Sides; i++ ) { Vertex3f( Dimensions.OuterDimensions.OffsetX+Dimensions.OuterDimensions.Radius*sin((2*i+Rotations.BottomRotation.RotationX)*pi/Sides), Dimensions.OuterDimensions.OffsetY+Dimensions.OuterDimensions.Radius*cos((2*i+Rotations.BottomRotation.RotationY)*pi/Sides), Dimensions.OuterDimensions.OffsetZ ); }

}

else { for( i=0; i<Sides; i++ ) { Vertex3f( Dimensions.OuterDimensions.OffsetX+ Dimensions.OuterDimensions.Width*sin((2*i+Rotations.BottomRotation.RotationX)*pi/Sides), Dimensions.OuterDimensions.OffsetY+Dimensions.OuterDimensions.Length*cos((2*i+Rotations.BottomRotation.RotationY)*pi/Sides), Dimensions.OuterDimensions.OffsetZ );

}

} Vertex3f( TipLocations.TopTipLocation.CapLocationX, TipLocations.TopTipLocation.CapLocationY, TipLocations.TopTipLocation.Height );


// Polys. for( i=0; i<Sides; i++ ) { Poly3i( Direction, n+i, n+Sides, n+((i+1)%Sides),Item ); } }

function bool Build() { local int i;

DoPresets();

if( Sides<3 ) return BadParameters(); if( TipLocations.TopTipLocation.Height<=0 || Dimensions.OuterDimensions.Radius<=0 ) return BadParameters(); if( HasBottom && Dimensions.InnerDimensions.Radius<=0 ) return BadParameters(); if( HasBottom && TipLocations.BottomTipLocation.Height>TipLocations.TopTipLocation.Height ) return BadParameters(); if( SaveConfiguration == True) SaveConfiguration = False; SaveConfig();




// _--__--__--__--_START_--__--__--__--_ // _--__--__--__--_START_--__--__--__--_ BeginBrush( MergeCoplanars, GroupName ); BuildCone( +1, Sides, 'Top', TipLocations, TipLocations.TopTipLocation, Dimensions, Dimensions.OuterDimensions, Rotations, Rotations.TopRotation); if( HasBottom ) { BuildCone( -1, Sides, 'Cap', TipLocations, TipLocations.BottomTipLocation, Dimensions, Dimensions.InnerDimensions, Rotations, Rotations.BottomRotation ); if( Dimensions.OuterDimensions.Radius==Dimensions.InnerDimensions.Radius ^^ Dimensions.OuterDimensions.Radius!=Dimensions.InnerDimensions.Radius) for( i=0; i<Sides; i++ ) Poly4i( 1, i, ((i+1)%Sides), Sides+1+((i+1)%Sides), Sides+1+i, 'Bottom' ); } else { PolyBegin( 1, 'Bottom' ); for( i=0; i<Sides; i++ ) Polyi( i ); PolyEnd(); } return EndBrush(); }

defaultproperties { BitmapFilename="BBZxanCone" Tooltip="Zxanphorian's Cone Brushbuilder"

TipLocations=(TopTipLocation=(Height=512.000000,CapLocationX=0.000000,CapLocationY=0.000000),BottomTipLocation=(Height=-512.000000,CapLocationX=0.000000,CapLocationY=0.000000)) Dimensions=(OuterDimensions=(UseRadius=True,Radius=512.000000,Length=512.000000,Width=512.000000,OffsetX=0.000000,OffsetY=0.000000,OffsetZ=0.000000),InnerDimensions=(UseRadius=True,Radius=256.000000,Length=256.000000,Width=256.000000,OffsetX=0.000000,OffsetY=0.000000,OffsetZ=0.000000)) Rotations=(TopRotation=(RotationX=1.000000,RotationY=1.000000),BottomRotation=(RotationX=1.000000,RotationY=1.000000)) Sides=8 GroupName=ZxanCone HasBottom=False MergeCoplanars=True Presets=No_Preset HelpTopics=ChooseATopic AboutBrushbuilder=DisplayOff } </uscript>

Options that I want to implement but don't know how

Dropped Options

Problems

<uscript> function bool SafePoly4i( int Direction , int p0 , int p1 , int p2 , int p3 , optional name ItemName, optional int PolyFlags ) { if( isCoplanar4v(getVertex(p0),getVertex(p1),getVertex(p2),getVertex(p3)) ) LogPoly4i( Direction , p0 , p1 , p2 , p3 , ItemName, PolyFlags ); else { LogPoly3i( Direction , p0 , p1 , p2 , ItemName, PolyFlags ); LogPoly3i( Direction , p2 , p3 , p0 , ItemName, PolyFlags ); } } </uscript>

Tarquin: the above function has the right order for 4 vertices whether in one square or two triangles. The safety-checking isn't quite up to scratch, so you can try it as is, but it will probably end up making triangles in cases when it shouldn't. BTW, I've put a link to this page on User Projects instead of RC. I don't think there's that many people who are making brushbuilders, so it's not really top news.

Suggestions

Comments