home *** CD-ROM | disk | FTP | other *** search
/ Game Level Design / GLDesign.bin / Software / UnrealEngine2Runtime / UE2Runtime-22262001_Demo.exe / Editor / Classes / TetrahedronBuilder.uc < prev    next >
Text File  |  2003-10-22  |  2KB  |  65 lines

  1. //=============================================================================
  2. // TetrahedronBuilder: Builds an octahedron (not tetrahedron) - experimental.
  3. //=============================================================================
  4. class TetrahedronBuilder
  5.     extends BrushBuilder;
  6.  
  7. var() float Radius;
  8. var() int SphereExtrapolation;
  9. var() name GroupName;
  10.  
  11. function Extrapolate( int a, int b, int c, int Count, float Radius )
  12. {
  13.     local int ab,bc,ca;
  14.     if( Count>1 )
  15.     {
  16.         ab=Vertexv( Radius*Normal(GetVertex(a)+GetVertex(b)) );
  17.         bc=Vertexv( Radius*Normal(GetVertex(b)+GetVertex(c)) );
  18.         ca=Vertexv( Radius*Normal(GetVertex(c)+GetVertex(a)) );
  19.         Extrapolate(a,ab,ca,Count-1,Radius);
  20.         Extrapolate(b,bc,ab,Count-1,Radius);
  21.         Extrapolate(c,ca,bc,Count-1,Radius);
  22.         Extrapolate(ab,bc,ca,Count-1,Radius);
  23.         //wastes shared vertices
  24.     }
  25.     else Poly3i(+1,a,b,c);
  26. }
  27.  
  28. function BuildTetrahedron( float R, int SphereExtrapolation )
  29. {
  30.     vertex3f( R,0,0);
  31.     vertex3f(-R,0,0);
  32.     vertex3f(0, R,0);
  33.     vertex3f(0,-R,0);
  34.     vertex3f(0,0, R);
  35.     vertex3f(0,0,-R);
  36.  
  37.     Extrapolate(2,1,4,SphereExtrapolation,Radius);
  38.     Extrapolate(1,3,4,SphereExtrapolation,Radius);
  39.     Extrapolate(3,0,4,SphereExtrapolation,Radius);
  40.     Extrapolate(0,2,4,SphereExtrapolation,Radius);
  41.     Extrapolate(1,2,5,SphereExtrapolation,Radius);
  42.     Extrapolate(3,1,5,SphereExtrapolation,Radius);
  43.     Extrapolate(0,3,5,SphereExtrapolation,Radius);
  44.     Extrapolate(2,0,5,SphereExtrapolation,Radius);
  45. }
  46.  
  47. event bool Build()
  48. {
  49.     if( Radius<=0 || SphereExtrapolation<=0 )
  50.         return BadParameters();
  51.  
  52.     BeginBrush( false, GroupName );
  53.     BuildTetrahedron( Radius, SphereExtrapolation );
  54.     return EndBrush();
  55. }
  56.  
  57. defaultproperties
  58. {
  59.     Radius=256
  60.     SphereExtrapolation=1
  61.     GroupName=Tetrahedron
  62.     BitmapFilename="BBSphere"
  63.     ToolTip="Tetrahedron (Sphere)"
  64. }
  65.