MarSTDv2004: CBrush Class Reference

MarSTDv2004

CBrush Class Reference

Collaboration diagram for CBrush:

Collaboration graph
[legend]
List of all members.

Detailed Description

The brush class is used to define a convex volume enclosed by planes. The brush is defined by planes and can be converted to a mesh. Note the planes' normals must point outwards for a valid volume to be enclosed. Brushes can be added, subtracted and or-ed together using CSG.
// Example:

void make_random_shape(CMesh& mesh, float radius) {

        // Probably not the most optimized way to do this. ;)
        
        CBrush brush;
        CVector origin; // Origin = (0.0, 0.0, 0.0).
        
        for (int i = 0; i < 3; i++)
        {
        
                CPlane* plane = brush.add(new CPlane);
                
                // Make a random normal.
                
                for (int j = 0; j < 3; j++)
                        plane->normal[j] = (rand() & 1023) / 1023.0 - 0.5;
                        
                plane.normal.normalize();
                
                // Offset plane from origin.
                
                plane->distance = radius;               
                
                // Make sure every plane's normal points away from origin.
                
                if (plane * origin > 0.0)
                        plane = - plane;
        
        }
        
        // Convert brush to mesh, and move polygons to output mesh.
        
        CMesh* tmp = brush.mesh();
        
        tmp->move(mesh);
        
        delete tmp;

}

Definition at line 72 of file CBrush.h.

Public Member Functions

CPlaneadd (CPlane *plane)
CPlaneaddHead (CPlane *plane)
CPlaneaddTail (CPlane *plane)
void remove (CPlane *plane)
CPlaneunlink (CPlane *plane)
void clear ()
bool convex ()
 Returns true if this is a convex brush.
CPolyinitial (CPlane *plane)
CPolypoly (CPlane *plane)
CMeshmesh ()
CEdgepoints ()
CBrushcopy ()
 Returns a copy of the brush.
CBrushclip (CPlane *plane)
 Clips the brush, returning the resulting brush.
CBrushunlink ()

Public Attributes

CPlaneplaneHead
 First plane in DLL.
CPlaneplaneTail
 Last plane in DLL.
int planeCount
 Number of planes in DLL.
void * data
 Custom data field.
CBrushprev
CBrushnext

Member Function Documentation

CPoly* CBrush::initial CPlane plane  ) 
 

Creates an "initial" polygon. An initial polygon is a polygon that has a very large size and lies on the specified plane. This "initial" polygon will be used further to clip against the brush's other planes to create one of the brush's side faces.

Parameters:
plane The plane we will create the initial polygon for. Assumes the plane is normalized.

CPoly* CBrush::poly CPlane plane  ) 
 

Creates a polygon (brush side) for the given plane.

Parameters:
plane The plane we will create the brush side for.

CMesh* CBrush::mesh  ) 
 

Convert the brush to a mesh.

CEdge* CBrush::points  ) 
 

Return the corner points of the brush converted to wireframe. This will NOT remove duplicate points.


The documentation for this class was generated from the following file:
Generated on Tue Feb 8 21:59:30 2005 for MarSTDv2004 by  doxygen 1.4.1