| Home Page | Recent Changes | Preferences

Zxanphorian Brushbuilders

Cone Builder [BBZxanCone]

00001  //=============================================================================
00002  // ZxanphorianConeBuilder.
00003  // This is my FIRST brush builder for UnrealEd!
00004  // What it does is build a better cone than the one that Epic made.
00005  //
00006  //_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-
00007  //
00008  //  version 1.2
00009  //  tornado.f5@worldnet.att.net
00010  //  (c) 2002 Nick "Zxanphorian" Parker
00011  //
00012  //=============================================================================
00013  class ZxanphorianConeBuilder extends ZxanphorianBuilders config(ZxanphorianbrushBuilders);
00014  
00015  
00016  // _--__--__--__--_STRUCTS_--__--__--__--_
00017  
00018      struct TopTipLocationStruct
00019  {
00020  
00021      var() config float Height, CapLocationX, CapLocationY;
00022  
00023  };
00024      struct TipLocationsStruct
00025  {
00026  var() config TopTipLocationStruct TopTipLocation;
00027  var() config TopTipLocationStruct BottomTipLocation;
00028  };
00029  var() config TipLocationsStruct TipLocations;
00030  
00031  
00032  
00033      struct DimensionsStruct
00034  {
00035      var() config bool UseRadius;
00036      var() config float Radius, Length, Width, OffsetX, OffsetY, OffsetZ;
00037  };
00038      struct DimensionStruct
00039  {
00040      var() config DimensionsStruct OuterDimensions;
00041      var() config DimensionsStruct InnerDimensions;
00042  };
00043      var() config DimensionStruct Dimensions;
00044  
00045  
00046  
00047  
00048      struct RotationStruct
00049  {
00050      var() config float RotationX, RotationY;
00051  };
00052      struct RotationsStruct {
00053      var() config RotationStruct TopRotation;
00054      var() config RotationStruct BottomRotation;
00055  };
00056      var() config RotationsStruct Rotations;
00057  
00058  
00059      struct RandomiserTBStruct
00060  {
00061      var() float Height[2], Radius[2], CapLocationX[2], CapLocationY[2];
00062  };
00063  struct RandomiserMStruct
00064  {
00065      var() int Sides[2];
00066  };
00067      struct RandomisersStruct
00068  {
00069      var() RandomiserTBStruct RandomiserTop;
00070      var() RandomiserTBStruct RandomiserBottom;
00071      var() RandomiserMStruct RandomiserMisc;
00072  };
00073      var() RandomisersStruct Randomisers;
00074  
00075  
00076  
00077  // _--__--__--__--_OTHER VARIABLES_--__--__--__--_
00078          var() config int Sides;
00079          var() config name GroupName;
00080          var() config bool HasBottom, MergeCoplanars ;
00081          var() export bool SaveConfiguration;
00082  
00083  
00084      enum PresetsEnum
00085  {
00086  No_Preset,
00087  Randomiser,
00088  DefaultBBProperties
00089  };
00090      var() config PresetsEnum Presets;
00091  
00092  enum HelpEnum
00093  {
00094  ChooseATopic,
00095  TipLocations,
00096  Dimensions,
00097  Rotations,
00098  Randomisers,
00099  RegularOptions,
00100  Presets
00101  };
00102      var() config HelpEnum HelpTopics;
00103  enum AboutEnum
00104  {
00105  DisplayOff,
00106  DisplayOn,
00107  };
00108      var() config AboutEnum AboutBrushbuilder;
00109  
00110      var int HB;
00111  
00112  
00113  function DoPresets()
00114  {
00115  // _--__--__--__--_PRESETS_--__--__--__--_
00116  
00117      if( Presets == DefaultBBProperties)
00118  {
00119  TipLocations.TopTipLocation.Height=512.000000;
00120  TipLocations.TopTipLocation.CapLocationX=0.000000;
00121  TipLocations.TopTipLocation.CapLocationY=0.000000;
00122  TipLocations.BottomTipLocation.Height=-512.000000;
00123  TipLocations.BottomTipLocation.CapLocationX=0.000000;
00124  TipLocations.BottomTipLocation.CapLocationY=0.000000;
00125  
00126  
00127  Dimensions.OuterDimensions.UseRadius=True;
00128  Dimensions.OuterDimensions.Radius=512.000000;
00129  Dimensions.OuterDimensions.Length=512.000000;
00130  Dimensions.OuterDimensions.Width=512.000000;
00131  Dimensions.OuterDimensions.OffsetX=0.000000;
00132  Dimensions.OuterDimensions.OffsetY=0.000000;
00133  Dimensions.OuterDimensions.OffsetZ=0.000000;
00134  Dimensions.InnerDimensions.UseRadius=True;
00135  Dimensions.InnerDimensions.Radius=256.000000;
00136  Dimensions.InnerDimensions.Length=256.000000;
00137  Dimensions.InnerDimensions.Width=256.000000;
00138  Dimensions.InnerDimensions.OffsetX=0.000000;
00139  Dimensions.InnerDimensions.OffsetY=0.000000;
00140  Dimensions.InnerDimensions.OffsetZ=0.000000;
00141  
00142  
00143  Rotations.TopRotation.RotationX=1.000000;
00144  Rotations.TopRotation.RotationY=1.000000;
00145  Rotations.BottomRotation.RotationX=1.000000;
00146  Rotations.TopRotation.RotationY=1.000000;
00147  
00148  
00149  Sides=8;
00150  GroupName='ZxanCone';
00151  HasBottom=False;
00152  MergeCoplanars=True;
00153  Presets=No_Preset;
00154  HelpTopics=ChooseATopic;
00155  AboutBrushbuilder=DisplayOff;
00156  }
00157  
00158  
00159  if( Presets == Randomiser)
00160  {
00161      TipLocations.TopTipLocation.Height = RandRange( Randomisers.RandomiserTop.Height[0], Randomisers.RandomiserTop.Height[1]);
00162      TipLocations.BottomTipLocation.Height = RandRange(Randomisers.RandomiserBottom.Height[0], Randomisers.RandomiserBottom.Height[1]);
00163      Dimensions.OuterDimensions.Radius = RandRange(Randomisers.RandomiserTop.Radius[0], Randomisers.RandomiserTop.Radius[1] ) ;
00164      Dimensions.InnerDimensions.Radius = RandRange(Randomisers.RandomiserBottom.Radius[0], Randomisers.RandomiserBottom.Radius[1]);
00165      TipLocations.TopTipLocation.CapLocationX = RandRange(Randomisers.RandomiserTop.CapLocationX[0], Randomisers.RandomiserTop.CapLocationX[1]);
00166      TipLocations.TopTipLocation.CapLocationY = RandRange(Randomisers.RandomiserTop.CapLocationY[0], Randomisers.RandomiserTop.CapLocationY[1]);
00167      TipLocations.BottomTipLocation.CapLocationX =RandRange(Randomisers.RandomiserBottom.CapLocationX[0], Randomisers.RandomiserBottom.CapLocationX[1]);
00168      TipLocations.BottomTipLocation.CapLocationY =RandRange(Randomisers.RandomiserBottom.CapLocationY[0], Randomisers.RandomiserBottom.CapLocationY[1]);
00169      Sides = RandRange(Randomisers.RandomiserMisc.Sides[0], Randomisers.RandomiserMisc.Sides[1]);
00170      HasBottom = False;
00171  
00172  // How to Choose between the different options
00173  HB = RandRange(0, 5000);
00174      if( HB >= 2500)
00175  HasBottom = True;
00176  
00177  }
00178  
00179  }
00180  
00181  
00182  
00183  function BuildCone( int Direction, int Sides, name Item, TipLocationsStruct TipLocations, TopTipLocationStruct TopTipLocation, DimensionStruct Dimensions, DimensionsStruct OuterDimensions, RotationsStruct Rotations, RotationStruct TopRotation)
00184  {
00185  
00186      local int n,i,j,q;
00187      n = GetVertexCount();
00188  
00189  
00190      // Vertices.
00191      if(Dimensions.OuterDimensions.UseRadius == True)
00192  {   for( i=0; i<Sides; i++ )
00193      {   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 ); }
00194   }
00195      else
00196  {
00197  for( i=0; i<Sides; i++ )
00198      {   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 );
00199   }
00200      }
00201      Vertex3f( TipLocations.TopTipLocation.CapLocationX, TipLocations.TopTipLocation.CapLocationY, TipLocations.TopTipLocation.Height );
00202  
00203  
00204      // Polys.
00205      for( i=0; i<Sides; i++ )
00206  {       Poly3i( Direction, n+i, n+Sides, n+((i+1)%Sides),Item ); }
00207  }
00208  
00209  function bool Build()
00210  {
00211      local int i;
00212  
00213      DoPresets();
00214  
00215      if( Sides<3 )
00216          return BadParameters();
00217      if( TipLocations.TopTipLocation.Height<=0 || Dimensions.OuterDimensions.Radius<=0 )
00218          return BadParameters();
00219      if( HasBottom && Dimensions.InnerDimensions.Radius<=0 )
00220          return BadParameters();
00221      if( HasBottom && TipLocations.BottomTipLocation.Height>TipLocations.TopTipLocation.Height )
00222          return BadParameters();
00223      if( SaveConfiguration == True)
00224          SaveConfiguration = False;
00225          SaveConfig();
00226  
00227  
00228  
00229  
00230  
00231  
00232  
00233  // _--__--__--__--_START_--__--__--__--_
00234  // _--__--__--__--_START_--__--__--__--_
00235      BeginBrush( MergeCoplanars, GroupName );
00236      BuildCone( +1, Sides, 'Top', TipLocations, TipLocations.TopTipLocation, Dimensions, Dimensions.OuterDimensions, Rotations, Rotations.TopRotation);
00237      if( HasBottom )
00238      {
00239          BuildCone( -1, Sides, 'Cap', TipLocations, TipLocations.BottomTipLocation, Dimensions, Dimensions.InnerDimensions, Rotations, Rotations.BottomRotation );
00240          if( Dimensions.OuterDimensions.Radius==Dimensions.InnerDimensions.Radius ^^ Dimensions.OuterDimensions.Radius!=Dimensions.InnerDimensions.Radius)
00241              for( i=0; i<Sides; i++ )
00242                  Poly4i( 1, i, ((i+1)%Sides), Sides+1+((i+1)%Sides), Sides+1+i, 'Bottom' );
00243      }
00244      else
00245      {
00246          PolyBegin( 1, 'Bottom' );
00247          for( i=0; i<Sides; i++ )
00248              Polyi( i );
00249          PolyEnd();
00250      }
00251      return EndBrush();
00252  }
00253  
00254  defaultproperties {
00255  BitmapFilename="BBZxanCone"
00256  Tooltip="Zxanphorian's Cone Brushbuilder"
00257      
00258  TipLocations=(TopTipLocation=(Height=512.000000,CapLocationX=0.000000,CapLocationY=0.000000),BottomTipLocation=(Height=-512.000000,CapLocationX=0.000000,CapLocationY=0.000000))
00259  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))
00260  Rotations=(TopRotation=(RotationX=1.000000,RotationY=1.000000),BottomRotation=(RotationX=1.000000,RotationY=1.000000))
00261  Sides=8
00262  GroupName=ZxanCone
00263  HasBottom=False
00264  MergeCoplanars=True
00265  Presets=No_Preset
00266  HelpTopics=ChooseATopic
00267  AboutBrushbuilder=DisplayOff
00268      }

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

Dropped Options

Problems

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 );
    }
}

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


Category Custom Class

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Image Uploads

Random Page

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

FAQs

Help Desk

Mapping Topics

Mapping Lessons

UnrealEd Interface

UnrealScript Topics

UnrealScript Lessons

Making Mods

Class Tree

Modeling Topics

Chongqing Page

Log In