| 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.0
00009  //  tornado.f5@worldnet.att.net
00010  //  (c) 2002 Nick "ZxAnPhOrIaN" Parker
00011  //
00012  //=============================================================================
00013  class ZxAnPhOrIaNConeBuilder expands ZxAnPhOrIaNBuilders config(ZxAnPhOrIaNbrushBuilders);
00014  
00015  
00016  // S__________________T___________________R__________________U____________C______T_______S
00017  
00018      struct TopTipLocationStruct
00019  {
00020  
00021      var() config float Height, CapLocationX, CapLocationY;
00022  
00023  };
00024          var() config TopTipLocationStruct TopTipLocation;
00025          var() config TopTipLocationStruct BottomTipLocation;
00026  
00027      struct DimensionsStruct
00028  {
00029      var() config bool UseRadius;
00030      var() config float Radius, Length, Width, OffsetX, OffsetY, OffsetZ;
00031  };
00032          var() config DimensionsStruct OuterDimensions;
00033          var() config DimensionsStruct InnerDimensions;
00034  
00035      struct RotationStruct
00036  {
00037      var() config float RotationX, RotationY;
00038  };
00039          var() config RotationStruct TopRotation;
00040          var() config RotationStruct BottomRotation;
00041  
00042      struct RandomiserTBStruct
00043  {
00044      var() float Height[2], Radius[2], CapLocationX[2], CapLocationY[2];
00045  };
00046          var() RandomiserTBStruct RandomiserTop;
00047          var() RandomiserTBStruct RandomiserBottom;
00048  
00049      struct RandomiserMStruct
00050  {
00051      var() int Sides[2];
00052  };
00053      var() RandomiserMStruct RandomiserMisc;
00054  
00055  
00056  
00057  // O______T_____H_____E_________R____V_____A_____R___I______A_B______L________E________S
00058          var() config int Sides;
00059          var() config name GroupName;
00060          var() config bool HasBottom, MergeCoplanars ;
00061          var() export bool SaveConfiguration;
00062  
00063  
00064      enum PresetsEnum
00065  {
00066  No_Preset,
00067  Randomiser,
00068  DefaultBBProperties
00069  };
00070      var() config PresetsEnum Presets;
00071  
00072      var int HB;
00073  
00074  
00075  function DoPresets()
00076  {
00077  // P_____________R___________E______________S____________E________T_______S_____
00078  
00079      if( Presets == DefaultBBProperties)
00080  {
00081  TopRotation.RotationX = 1;
00082  TopRotation.RotationY = 1;
00083  BottomRotation.RotationX = 1;
00084  BottomRotation.RotationY = 1;
00085  HasBottom = False;
00086  MergeCoplanars = True;
00087  Presets = No_Preset;
00088  InnerDimensions.OffsetZ = 0;
00089  OuterDimensions.OffsetZ = 0;
00090  GroupName = 'ZxanCone';
00091  Sides = 8;
00092  TopTipLocation.Height = 512;
00093  BottomTipLocation.Height = -512;
00094  OuterDimensions.Radius = 512;
00095  InnerDimensions.Radius = 256;
00096  OuterDimensions.Length = 512;
00097  OuterDimensions.Width = 512;
00098  InnerDimensions.Width = 256;
00099  InnerDimensions.Length = 256;
00100  OuterDimensions.UseRadius = True;
00101  InnerDimensions.UseRadius = True;
00102  TopTipLocation.CapLocationX = 0;
00103  TopTipLocation.CapLocationY = 0;
00104  BottomTipLocation.CapLocationX = 0;
00105  BottomTipLocation.CapLocationY = 0;
00106  OuterDimensions.OffsetX = 0;
00107  OuterDimensions.OffsetY = 0;
00108  InnerDimensions.OffsetX = 0;
00109  InnerDimensions.OffsetY = 0;
00110  }
00111  
00112  
00113  if( Presets == Randomiser)
00114  {
00115      TopTipLocation.Height = RandRange( RandomiserTop.Height[0], RandomiserTop.Height[1]);
00116      BottomTipLocation.Height = RandRange(RandomiserBottom.Height[0], RandomiserBottom.Height[1]);
00117      OuterDimensions.Radius = RandRange(RandomiserTop.Radius[0], RandomiserTop.Radius[1] ) ;
00118      InnerDimensions.Radius = RandRange(RandomiserBottom.Radius[0], RandomiserBottom.Radius[1]);
00119      TopTipLocation.CapLocationX = RandRange(RandomiserTop.CapLocationX[0], RandomiserTop.CapLocationX[1]);
00120      TopTipLocation.CapLocationY = RandRange(RandomiserTop.CapLocationY[0], RandomiserTop.CapLocationY[1]);
00121      BottomTipLocation.CapLocationX =RandRange(RandomiserBottom.CapLocationX[0], RandomiserBottom.CapLocationX[1]);
00122      BottomTipLocation.CapLocationY =RandRange(RandomiserBottom.CapLocationY[0], RandomiserBottom.CapLocationY[1]);
00123      Sides = RandRange(RandomiserMisc.Sides[0], RandomiserMisc.Sides[1]);
00124      HasBottom = False;
00125  
00126  // How to Choose between the different options
00127  HB = RandRange(0, 5000);
00128      if( HB >= 2500)
00129  HasBottom = True;
00130  
00131  }
00132  
00133  }
00134  
00135  
00136  
00137  function BuildCone( int Direction, int Sides, name Item, TopTipLocationStruct TopTipLocation, DimensionsStruct OuterDimensions, RotationStruct TopRotation)
00138  {
00139  
00140      local int n,i,j,q;
00141      n = GetVertexCount();
00142  
00143  
00144      // Vertices.
00145      if(OuterDimensions.UseRadius == True)
00146  {   for( i=0; i<Sides; i++ )
00147      {   Vertex3f( OuterDimensions.OffsetX+OuterDimensions.Radius*sin((2*i+TopRotation.RotationX)*pi/Sides), OuterDimensions.OffsetY+OuterDimensions.Radius*cos((2*i+TopRotation.RotationY)*pi/Sides), OuterDimensions.OffsetZ ); }
00148   }
00149      else
00150  {
00151  for( i=0; i<Sides; i++ )
00152      {   Vertex3f( OuterDimensions.OffsetX+ OuterDimensions.Width*sin((2*i+TopRotation.RotationX)*pi/Sides), OuterDimensions.OffsetY+OuterDimensions.Length*cos((2*i+TopRotation.RotationY)*pi/Sides), OuterDimensions.OffsetZ );
00153   }
00154      }
00155      Vertex3f( TopTipLocation.CapLocationX, TopTipLocation.CapLocationY, TopTipLocation.Height );
00156  
00157  
00158      // Polys.
00159      for( i=0; i<Sides; i++ )
00160  {       Poly3i( Direction, n+i, n+Sides, n+((i+1)%Sides),Item ); }
00161  }
00162  
00163  function bool Build()
00164  {
00165      local int i;
00166  
00167      DoPresets();
00168  
00169      if( Sides<3 )
00170          return BadParameters();
00171      if( TopTipLocation.Height<=0 || OuterDimensions.Radius<=0 )
00172          return BadParameters();
00173      if( HasBottom && InnerDimensions.Radius<=0 )
00174          return BadParameters();
00175      if( HasBottom && BottomTipLocation.Height>TopTipLocation.Height )
00176          return BadParameters();
00177      if( SaveConfiguration == True)
00178          SaveConfiguration = False;
00179          SaveConfig();
00180  
00181  
00182  
00183  
00184  
00185  
00186  
00187  // S+_____________T+_________________A+______________R+___________________T+__________
00188      BeginBrush( MergeCoplanars, GroupName );
00189      BuildCone( +1, Sides, 'Top', TopTipLocation, OuterDimensions, TopRotation);
00190      if( HasBottom )
00191      {
00192          BuildCone( -1, Sides, 'Cap',BottomTipLocation, InnerDimensions, BottomRotation );
00193          if( OuterDimensions.Radius==InnerDimensions.Radius ^^ OuterDimensions.Radius!=InnerDimensions.Radius)
00194              for( i=0; i<Sides; i++ )
00195                  Poly4i( 1, i, ((i+1)%Sides), Sides+1+((i+1)%Sides), Sides+1+i, 'Bottom' );
00196      }
00197      else
00198      {
00199          PolyBegin( 1, 'Bottom' );
00200          for( i=0; i<Sides; i++ )
00201              Polyi( i );
00202          PolyEnd();
00203      }
00204      return EndBrush();
00205  }

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

Mapping Topics

Mapping Lessons

UnrealEd Interface

Questions&Answers

Scripting Topics

Scripting Lessons

Making Mods

Class Tree

Questions&Answers

Modeling Topics

Questions&Answers

Log In