I don't need to test my programs. I have an error-correcting modem.

Legacy:Zxanphorian Brushbuilders

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search

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

  1. //=============================================================================
  2. // ZxanphorianConeBuilder.
  3. // This is my FIRST brush builder for UnrealEd!
  4. // What it does is build a better cone than the one that Epic made.
  5. //
  6. //_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-_=_-
  7. //
  8. //	version 1.2
  9. //	tornado.f5@worldnet.att.net
  10. //	(c) 2002 Nick "Zxanphorian" Parker
  11. //
  12. //=============================================================================
  13. class ZxanphorianConeBuilder extends ZxanphorianBuilders config(ZxanphorianbrushBuilders);
  14.  
  15.  
  16. // _--__--__--__--_STRUCTS_--__--__--__--_
  17.  
  18. 	struct TopTipLocationStruct
  19. {
  20.  
  21. 	var() config float Height, CapLocationX, CapLocationY;
  22.  
  23. };
  24. 	struct TipLocationsStruct
  25. {
  26. var() config TopTipLocationStruct TopTipLocation;
  27. var() config TopTipLocationStruct BottomTipLocation;
  28. };
  29. var() config TipLocationsStruct TipLocations;
  30.  
  31.  
  32.  
  33. 	struct DimensionsStruct
  34. {
  35. 	var() config bool UseRadius;
  36. 	var() config float Radius, Length, Width, OffsetX, OffsetY, OffsetZ;
  37. };
  38. 	struct DimensionStruct
  39. {
  40. 	var() config DimensionsStruct OuterDimensions;
  41. 	var() config DimensionsStruct InnerDimensions;
  42. };
  43. 	var() config DimensionStruct Dimensions;
  44.  
  45.  
  46.  
  47.  
  48. 	struct RotationStruct
  49. {
  50. 	var() config float RotationX, RotationY;
  51. };
  52. 	struct RotationsStruct {
  53. 	var() config RotationStruct TopRotation;
  54. 	var() config RotationStruct BottomRotation;
  55. };
  56. 	var() config RotationsStruct Rotations;
  57.  
  58.  
  59. 	struct RandomiserTBStruct
  60. {
  61. 	var() float Height[2], Radius[2], CapLocationX[2], CapLocationY[2];
  62. };
  63. struct RandomiserMStruct
  64. {
  65. 	var() int Sides[2];
  66. };
  67. 	struct RandomisersStruct
  68. {
  69. 	var() RandomiserTBStruct RandomiserTop;
  70. 	var() RandomiserTBStruct RandomiserBottom;
  71. 	var() RandomiserMStruct RandomiserMisc;
  72. };
  73. 	var() RandomisersStruct Randomisers;
  74.  
  75.  
  76.  
  77. // _--__--__--__--_OTHER VARIABLES_--__--__--__--_
  78. 		var() config int Sides;
  79. 		var() config name GroupName;
  80. 		var() config bool HasBottom, MergeCoplanars ;
  81. 		var() export bool SaveConfiguration;
  82.  
  83.  
  84. 	enum PresetsEnum
  85. {
  86. No_Preset,
  87. Randomiser,
  88. DefaultBBProperties
  89. };
  90. 	var() config PresetsEnum Presets;
  91.  
  92. enum HelpEnum
  93. {
  94. ChooseATopic,
  95. TipLocations,
  96. Dimensions,
  97. Rotations,
  98. Randomisers,
  99. RegularOptions,
  100. Presets
  101. };
  102. 	var() config HelpEnum HelpTopics;
  103. enum AboutEnum
  104. {
  105. DisplayOff,
  106. DisplayOn,
  107. };
  108. 	var() config AboutEnum AboutBrushbuilder;
  109.  
  110. 	var int HB;
  111.  
  112.  
  113. function DoPresets()
  114. {
  115. // _--__--__--__--_PRESETS_--__--__--__--_
  116.  
  117. 	if( Presets == DefaultBBProperties)
  118. {
  119. TipLocations.TopTipLocation.Height=512.000000;
  120. TipLocations.TopTipLocation.CapLocationX=0.000000;
  121. TipLocations.TopTipLocation.CapLocationY=0.000000;
  122. TipLocations.BottomTipLocation.Height=-512.000000;
  123. TipLocations.BottomTipLocation.CapLocationX=0.000000;
  124. TipLocations.BottomTipLocation.CapLocationY=0.000000;
  125.  
  126.  
  127. Dimensions.OuterDimensions.UseRadius=True;
  128. Dimensions.OuterDimensions.Radius=512.000000;
  129. Dimensions.OuterDimensions.Length=512.000000;
  130. Dimensions.OuterDimensions.Width=512.000000;
  131. Dimensions.OuterDimensions.OffsetX=0.000000;
  132. Dimensions.OuterDimensions.OffsetY=0.000000;
  133. Dimensions.OuterDimensions.OffsetZ=0.000000;
  134. Dimensions.InnerDimensions.UseRadius=True;
  135. Dimensions.InnerDimensions.Radius=256.000000;
  136. Dimensions.InnerDimensions.Length=256.000000;
  137. Dimensions.InnerDimensions.Width=256.000000;
  138. Dimensions.InnerDimensions.OffsetX=0.000000;
  139. Dimensions.InnerDimensions.OffsetY=0.000000;
  140. Dimensions.InnerDimensions.OffsetZ=0.000000;
  141.  
  142.  
  143. Rotations.TopRotation.RotationX=1.000000;
  144. Rotations.TopRotation.RotationY=1.000000;
  145. Rotations.BottomRotation.RotationX=1.000000;
  146. Rotations.TopRotation.RotationY=1.000000;
  147.  
  148.  
  149. Sides=8;
  150. GroupName='ZxanCone';
  151. HasBottom=False;
  152. MergeCoplanars=True;
  153. Presets=No_Preset;
  154. HelpTopics=ChooseATopic;
  155. AboutBrushbuilder=DisplayOff;
  156. }
  157.  
  158.  
  159. if( Presets == Randomiser)
  160. {
  161. 	TipLocations.TopTipLocation.Height = RandRange( Randomisers.RandomiserTop.Height[0], Randomisers.RandomiserTop.Height[1]);
  162. 	TipLocations.BottomTipLocation.Height = RandRange(Randomisers.RandomiserBottom.Height[0], Randomisers.RandomiserBottom.Height[1]);
  163. 	Dimensions.OuterDimensions.Radius = RandRange(Randomisers.RandomiserTop.Radius[0], Randomisers.RandomiserTop.Radius[1] ) ;
  164. 	Dimensions.InnerDimensions.Radius = RandRange(Randomisers.RandomiserBottom.Radius[0], Randomisers.RandomiserBottom.Radius[1]);
  165. 	TipLocations.TopTipLocation.CapLocationX = RandRange(Randomisers.RandomiserTop.CapLocationX[0], Randomisers.RandomiserTop.CapLocationX[1]);
  166. 	TipLocations.TopTipLocation.CapLocationY = RandRange(Randomisers.RandomiserTop.CapLocationY[0], Randomisers.RandomiserTop.CapLocationY[1]);
  167. 	TipLocations.BottomTipLocation.CapLocationX =RandRange(Randomisers.RandomiserBottom.CapLocationX[0], Randomisers.RandomiserBottom.CapLocationX[1]);
  168. 	TipLocations.BottomTipLocation.CapLocationY =RandRange(Randomisers.RandomiserBottom.CapLocationY[0], Randomisers.RandomiserBottom.CapLocationY[1]);
  169. 	Sides = RandRange(Randomisers.RandomiserMisc.Sides[0], Randomisers.RandomiserMisc.Sides[1]);
  170. 	HasBottom = False;
  171.  
  172. // How to Choose between the different options
  173. HB = RandRange(0, 5000);
  174. 	if( HB >= 2500)
  175. HasBottom = True;
  176.  
  177. }
  178.  
  179. }
  180.  
  181.  
  182.  
  183. function BuildCone( int Direction, int Sides, name Item, TipLocationsStruct TipLocations, TopTipLocationStruct TopTipLocation, DimensionStruct Dimensions, DimensionsStruct OuterDimensions, RotationsStruct Rotations, RotationStruct TopRotation)
  184. {
  185.  
  186. 	local int n,i,j,q;
  187. 	n = GetVertexCount();
  188.  
  189.  
  190. 	// Vertices.
  191. 	if(Dimensions.OuterDimensions.UseRadius == True)
  192. {	for( i=0; i<Sides; i++ )
  193. 	{	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 ); }
  194.  }
  195. 	else
  196. {
  197. for( i=0; i<Sides; i++ )
  198. 	{	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 );
  199.  }
  200. 	}
  201. 	Vertex3f( TipLocations.TopTipLocation.CapLocationX, TipLocations.TopTipLocation.CapLocationY, TipLocations.TopTipLocation.Height );
  202.  
  203.  
  204. 	// Polys.
  205. 	for( i=0; i<Sides; i++ )
  206. {		Poly3i( Direction, n+i, n+Sides, n+((i+1)%Sides),Item ); }
  207. }
  208.  
  209. function bool Build()
  210. {
  211. 	local int i;
  212.  
  213. 	DoPresets();
  214.  
  215. 	if( Sides<3 )
  216. 		return BadParameters();
  217. 	if( TipLocations.TopTipLocation.Height<=0 || Dimensions.OuterDimensions.Radius<=0 )
  218. 		return BadParameters();
  219. 	if( HasBottom && Dimensions.InnerDimensions.Radius<=0 )
  220. 		return BadParameters();
  221. 	if( HasBottom && TipLocations.BottomTipLocation.Height>TipLocations.TopTipLocation.Height )
  222. 		return BadParameters();
  223. 	if( SaveConfiguration == True)
  224. 		SaveConfiguration = False;
  225. 		SaveConfig();
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233. // _--__--__--__--_START_--__--__--__--_
  234. // _--__--__--__--_START_--__--__--__--_
  235. 	BeginBrush( MergeCoplanars, GroupName );
  236. 	BuildCone( +1, Sides, 'Top', TipLocations, TipLocations.TopTipLocation, Dimensions, Dimensions.OuterDimensions, Rotations, Rotations.TopRotation);
  237. 	if( HasBottom )
  238. 	{
  239. 		BuildCone( -1, Sides, 'Cap', TipLocations, TipLocations.BottomTipLocation, Dimensions, Dimensions.InnerDimensions, Rotations, Rotations.BottomRotation );
  240. 		if( Dimensions.OuterDimensions.Radius==Dimensions.InnerDimensions.Radius ^^ Dimensions.OuterDimensions.Radius!=Dimensions.InnerDimensions.Radius)
  241. 			for( i=0; i<Sides; i++ )
  242. 				Poly4i( 1, i, ((i+1)%Sides), Sides+1+((i+1)%Sides), Sides+1+i, 'Bottom' );
  243. 	}
  244. 	else
  245. 	{
  246. 		PolyBegin( 1, 'Bottom' );
  247. 		for( i=0; i<Sides; i++ )
  248. 			Polyi( i );
  249. 		PolyEnd();
  250. 	}
  251. 	return EndBrush();
  252. }
  253.  
  254. defaultproperties {
  255. BitmapFilename="BBZxanCone"
  256. Tooltip="Zxanphorian's Cone Brushbuilder"
  257.  
  258. TipLocations=(TopTipLocation=(Height=512.000000,CapLocationX=0.000000,CapLocationY=0.000000),BottomTipLocation=(Height=-512.000000,CapLocationX=0.000000,CapLocationY=0.000000))
  259. 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))
  260. Rotations=(TopRotation=(RotationX=1.000000,RotationY=1.000000),BottomRotation=(RotationX=1.000000,RotationY=1.000000))
  261. Sides=8
  262. GroupName=ZxanCone
  263. HasBottom=False
  264. MergeCoplanars=True
  265. Presets=No_Preset
  266. HelpTopics=ChooseATopic
  267. AboutBrushbuilder=DisplayOff
  268. 	}

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

Dropped Options[edit]

Problems[edit]

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[edit]

Comments[edit]