Cafu Engine
MapBrushT Class Reference
Inheritance diagram for MapBrushT:

Public Member Functions

 MapBrushT (const ArrayT< Vector3fT > &HullVertices, EditorMaterialI *Material, bool FaceAligned, const MapBrushT *RefBrush=NULL)
 Constructor for creating a MapBrushT from the convex hull over the given vertices. More...
 
 MapBrushT (const ArrayT< Plane3fT > &Planes, EditorMaterialI *Material, bool FaceAligned)
 Constructor for creating a MapBrushT from the intersection of the given planes. More...
 
 MapBrushT (const MapBrushT &Brush)
 The copy constructor for copying a brush. More...
 
MapBrushTClone () const override
 The virtual copy constructor. More...
 
void Render2D (Renderer2DT &Renderer) const
 
void Render3D (Renderer3DT &Renderer) const
 
bool IsTranslucent () const
 Returns whether this map element is (entirely or partially) translucent. More...
 
BoundingBox3fT GetBB () const
 Returns the spatial bounding-box of this map element. More...
 
bool TraceRay (const Vector3fT &RayOrigin, const Vector3fT &RayDir, float &Fraction, unsigned long &FaceNr) const
 Traces a ray against this map element, and returns whether it was hit. More...
 
bool TracePixel (const wxPoint &Pixel, int Radius, const ViewWindow2DT &ViewWin) const
 This method determines if this map element is intersected/affected by the specified disc in ViewWin. More...
 
void Save_cmap (std::ostream &OutFile, unsigned long BrushNr, const MapDocumentT &MapDoc) const
 
wxString GetDescription () const
 
TrafoMementoTGetTrafoState () const override
 Returns a memento that encapsulates the transform-related state of this element. More...
 
void RestoreTrafoState (const TrafoMementoT *TM) override
 Restores the transform-related state of this element from the given memento. More...
 
void TrafoMove (const Vector3fT &Delta, bool LockTexCoords) override
 Translates this element by the given vector (in world-space). More...
 
void TrafoRotate (const Vector3fT &RefPoint, const cf::math::AnglesfT &Angles, bool LockTexCoords) override
 Rotates this element about the given reference point (in world-space). More...
 
void TrafoScale (const Vector3fT &RefPoint, const Vector3fT &Scale, bool LockTexCoords) override
 Scales this element about the given reference point (in world-space). More...
 
void TrafoMirror (unsigned int NormalAxis, float Dist, bool LockTexCoords) override
 Mirrors this element along the given mirror plane (in world-space). More...
 
void Transform (const Matrix4x4fT &Matrix, bool LockTexCoords) override
 Why does this method not replace all the other Trafo*() methods? This method is the most generic, allowing transformations that e.g. More...
 
void Split (const Plane3T< float > &Plane, MapBrushT **Front=NULL, MapBrushT **Back=NULL) const
 This method splits the brush along the given plane and returns the front piece, the back piece, or both. More...
 
bool Subtract (const MapBrushT *B, ArrayT< MapBrushT * > &Result) const
 Subtracts from this brush A the given volume B, Result = A \ B. More...
 
const ArrayT< MapFaceT > & GetFaces () const
 Returns the faces of this brush. More...
 
ArrayT< MapFaceT > & GetFaces ()
 
bool IsValid () const
 Returns whether this brush is valid. TODO: ctors should throw exceptions instead! More...
 
virtual const
cf::TypeSys::TypeInfoT
GetType () const
 
- Public Member Functions inherited from MapPrimitiveT
 MapPrimitiveT (const wxColour &Color)
 The default constructor. More...
 
 MapPrimitiveT (const MapPrimitiveT &Prim)
 The copy constructor for copying a primitive. More...
 
wxColour GetColor (bool ConsiderGroup=true) const
 This method returns the "inherent" color of this map element. More...
 
- Public Member Functions inherited from MapElementT
 MapElementT ()
 The default constructor. More...
 
 MapElementT (const MapElementT &Elem)
 The copy constructor for copying a map element. More...
 
virtual ~MapElementT ()
 The virtual destructor. More...
 
virtual void Load_cmap (TextParserT &TP, MapDocumentT &MapDoc, bool IgnoreGroups)
 
MapEditor::CompMapEntityTGetParent () const
 Returns the entity that this element is a part of, or NULL if the element has no parent entity. More...
 
void SetParent (MapEditor::CompMapEntityT *Ent)
 Sets the parent entity that is element is a part of. More...
 
bool IsSelected () const
 Returns whether this element is currently selected in the map document. More...
 
void SetSelected (bool Selected=true)
 Sets the selection state of this element. More...
 
GroupTGetGroup () const
 Returns NULL when this map element is in no group, or the pionter to the group it is a member of otherwise. More...
 
void SetGroup (GroupT *Group)
 Sets the group this element is a member of (use NULL for "no group"). More...
 
bool IsVisible () const
 Returns whether this map element is currently visible (in the 2D, 3D and other views). More...
 
bool CanSelect () const
 Returns whether this map element can currently be selected (in the 2D, 3D and other views). More...
 
void GetToggleEffects (ArrayT< MapElementT * > &RemoveFromSel, ArrayT< MapElementT * > &AddToSel, bool AutoGroupEntities)
 Computes how the selection must be changed in order to toggle the given element when the element's entity and group memberships are taken into account. More...
 
virtual void AdvanceTime (float t)
 This is periodically called in order to have the element advance its internal clock by t seconds. More...
 
unsigned int GetFrameCount () const
 
void SetFrameCount (unsigned int FrameCount)
 

Static Public Member Functions

static MapBrushTCreate_cmap (TextParserT &TP, MapDocumentT &MapDoc, unsigned long EntityNr, unsigned long BrushNr, bool IgnoreGroups)
 EntityNr and BrushNr are provided by the caller, just for better error reporting. More...
 
static MapBrushTCreate_D3_map (TextParserT &TP, const Vector3fT &Origin, unsigned long EntityNr, unsigned long PrimitiveNr, EditorMatManT &MatMan)
 EntityNr and PrimitiveNr are provided by the caller, just for better error reporting. More...
 
static MapBrushTCreate_HL1_map (TextParserT &TP, unsigned long EntityNr, unsigned long BrushNr, EditorMatManT &MatMan)
 EntityNr and BrushNr are provided by the caller, just for better error reporting. More...
 
static MapBrushTCreate_HL2_vmf (TextParserT &TP, EditorMatManT &MatMan)
 
static MapBrushTCreateBlock (const BoundingBox3fT &Box, EditorMaterialI *Material)
 Named constructor for creating a block brush. More...
 
static MapBrushTCreateWedge (const BoundingBox3fT &Box, EditorMaterialI *Material)
 Named constructor for creating a wedge brush. More...
 
static MapBrushTCreateCylinder (const BoundingBox3fT &Box, const unsigned long NrOfSides, EditorMaterialI *Material)
 Named constructor for creating a cylinder brush. More...
 
static MapBrushTCreatePyramid (const BoundingBox3fT &Box, const unsigned long NrOfSides, EditorMaterialI *Material)
 Named constructor for creating a pyramid brush. More...
 
static MapBrushTCreateSphere (const BoundingBox3fT &Box, const unsigned long NrOfSides, EditorMaterialI *Material)
 Named constructor for creating a sphere brush. More...
 
static void * CreateInstance (const cf::TypeSys::CreateParamsT &Params)
 
- Static Public Member Functions inherited from MapPrimitiveT
static void * CreateInstance (const cf::TypeSys::CreateParamsT &Params)
 
- Static Public Member Functions inherited from MapElementT
static void * CreateInstance (const cf::TypeSys::CreateParamsT &Params)
 

Static Public Attributes

static const cf::TypeSys::TypeInfoT TypeInfo
 
- Static Public Attributes inherited from MapPrimitiveT
static const cf::TypeSys::TypeInfoT TypeInfo
 
- Static Public Attributes inherited from MapElementT
static const cf::TypeSys::TypeInfoT TypeInfo
 

Additional Inherited Members

- Protected Attributes inherited from MapElementT
MapEditor::CompMapEntityTm_Parent
 The entity that this element is a part of. More...
 
bool m_IsSelected
 Is this element currently selected in the map document? More...
 
GroupTm_Group
 The group this element is in, NULL if in no group. More...
 
unsigned int m_FrameCount
 The number of the frame in which this element was last rendered in a 3D view, used in order to avoid processing/rendering it twice. More...
 

Constructor & Destructor Documentation

MapBrushT::MapBrushT ( const ArrayT< Vector3fT > &  HullVertices,
EditorMaterialI Material,
bool  FaceAligned,
const MapBrushT RefBrush = NULL 
)

Constructor for creating a MapBrushT from the convex hull over the given vertices.

Parameters
HullVerticesThe vertices over whose convex hull this brush is built.
MaterialThe material to be applied to the new faces.
FaceAlignedWhether the u and v axes of the brush faces are initialized face aligned or world aligned.
RefBrushIf non-NULL, the data of the faces of RefBrush is reused as much as possible for the faces of the new brush. This is very useful e.g. for the Edit Vertices tool, where edits should generally preserve face data.
MapBrushT::MapBrushT ( const ArrayT< Plane3fT > &  Planes,
EditorMaterialI Material,
bool  FaceAligned 
)

Constructor for creating a MapBrushT from the intersection of the given planes.

Parameters
PlanesThe planes whose intersection forms this brush.
MaterialThe material to be applied to the new faces.
FaceAlignedWhether the u and v axes of the brush faces are initialized face aligned or world aligned.
MapBrushT::MapBrushT ( const MapBrushT Brush)

The copy constructor for copying a brush.

Parameters
BrushThe brush to copy-construct this brush from.

Member Function Documentation

MapBrushT * MapBrushT::Clone ( ) const
overridevirtual

The virtual copy constructor.

Creates a copy of this primitive that is of the same class as the original, even when called via a base class pointer (the caller doesn't need to know the exact derived class).

Implements MapPrimitiveT.

MapBrushT * MapBrushT::Create_cmap ( TextParserT TP,
MapDocumentT MapDoc,
unsigned long  EntityNr,
unsigned long  BrushNr,
bool  IgnoreGroups 
)
static

EntityNr and BrushNr are provided by the caller, just for better error reporting.

MapBrushT * MapBrushT::Create_D3_map ( TextParserT TP,
const Vector3fT Origin,
unsigned long  EntityNr,
unsigned long  PrimitiveNr,
EditorMatManT MatMan 
)
static

EntityNr and PrimitiveNr are provided by the caller, just for better error reporting.

MapBrushT * MapBrushT::Create_HL1_map ( TextParserT TP,
unsigned long  EntityNr,
unsigned long  BrushNr,
EditorMatManT MatMan 
)
static

EntityNr and BrushNr are provided by the caller, just for better error reporting.

MapBrushT * MapBrushT::CreateBlock ( const BoundingBox3fT Box,
EditorMaterialI Material 
)
static

Named constructor for creating a block brush.

MapBrushT * MapBrushT::CreateCylinder ( const BoundingBox3fT Box,
const unsigned long  NrOfSides,
EditorMaterialI Material 
)
static

Named constructor for creating a cylinder brush.

MapBrushT * MapBrushT::CreatePyramid ( const BoundingBox3fT Box,
const unsigned long  NrOfSides,
EditorMaterialI Material 
)
static

Named constructor for creating a pyramid brush.

MapBrushT * MapBrushT::CreateSphere ( const BoundingBox3fT Box,
const unsigned long  NrOfSides,
EditorMaterialI Material 
)
static

Named constructor for creating a sphere brush.

MapBrushT * MapBrushT::CreateWedge ( const BoundingBox3fT Box,
EditorMaterialI Material 
)
static

Named constructor for creating a wedge brush.

BoundingBox3fT MapBrushT::GetBB ( ) const
virtual

Returns the spatial bounding-box of this map element.

Implements MapElementT.

const ArrayT<MapFaceT>& MapBrushT::GetFaces ( ) const
inline

Returns the faces of this brush.

TrafoMementoT * MapBrushT::GetTrafoState ( ) const
overridevirtual

Returns a memento that encapsulates the transform-related state of this element.

The method saves all state in the memento that calls to the Trafo*() methods can possibly modify.

Reimplemented from MapElementT.

bool MapBrushT::IsTranslucent ( ) const
virtual

Returns whether this map element is (entirely or partially) translucent.

Translucent map elements are typically implemented with "alpha blending" and require rendering in back-to-front order.

See Also
EditorMaterialI::IsTranslucent()

Reimplemented from MapElementT.

bool MapBrushT::IsValid ( ) const
inline

Returns whether this brush is valid. TODO: ctors should throw exceptions instead!

void MapBrushT::RestoreTrafoState ( const TrafoMementoT TM)
overridevirtual

Restores the transform-related state of this element from the given memento.

The method restores all state from the memento that calls to the Trafo*() methods have possibly modified.

Reimplemented from MapElementT.

void MapBrushT::Split ( const Plane3T< float > &  Plane,
MapBrushT **  Front = NULL,
MapBrushT **  Back = NULL 
) const

This method splits the brush along the given plane and returns the front piece, the back piece, or both.

Parameters
PlaneThe plane along which to split this brush.
FrontThe address of the pointer to the front piece, if the caller is interested in obtaining it (NULL otherwise).
BackThe address of the pointer to the back piece, if the caller is interested in obtaining it (NULL otherwise).
bool MapBrushT::Subtract ( const MapBrushT B,
ArrayT< MapBrushT * > &  Result 
) const

Subtracts from this brush A the given volume B, Result = A \ B.

Parameters
BThe volume that is to be subtracted ("carved") from this brush A, defined as another MapBrushT.
ResultThe array in which the subtraction result is returned.
Returns
true when this brush A and the carver B intersected and thus the subtraction result is actually different from this brush, and false otherwise (A and B didn't overlap / intersect at all). In the latter case, the caller should delete all brushes that the method might have put into the Result array during the course of its computations.
bool MapBrushT::TracePixel ( const wxPoint &  Pixel,
int  Radius,
const ViewWindow2DT ViewWin 
) const
virtual

This method determines if this map element is intersected/affected by the specified disc in ViewWin.

The disc for the test is defined by the given center pixel and the given radius. For example, the caller can learn by the result of this method whether the map element should respond to a mouse-click at the same pixel. Therefore, this method can be considered as the 2D analogue of the TraceRay() method.

Reimplemented from MapElementT.

bool MapBrushT::TraceRay ( const Vector3fT RayOrigin,
const Vector3fT RayDir,
float &  Fraction,
unsigned long &  FaceNr 
) const
virtual

Traces a ray against this map element, and returns whether it was hit.

The ray for the trace is defined by RayOrigin + RayDir*Fraction, where Fraction is a scalar >= 0. If a hit was detected, the Fraction is returned. Hit brushes return the number of the hit face as well. This method has been implemented mainly for "picking", that is, left-click selection in the 3D views (it makes sure that also objects that "clip nothing" in the engine can be picked), but it can also be used for any other purpose.

Parameters
RayOriginThe point in world space where the ray starts.
RayDirA unit vector in world space that describes the direction the ray extends to.
FractionOn hit, the scalar along RayDir at which the hit occurred is returned here.
FaceNrIf this map element is a brush and it was hit, the number of the hit face is returned here.
Returns
true if the ray hit this map element, false otherwise. Additional hit data (i.e. Fraction and FaceNr) is returned via reference paramaters.

Reimplemented from MapElementT.

void MapBrushT::TrafoMirror ( unsigned int  NormalAxis,
float  Dist,
bool  LockTexCoords 
)
overridevirtual

Mirrors this element along the given mirror plane (in world-space).

Parameters
NormalAxisThe number of the axis along which the normal vector of the mirror plane points: 0, 1 or 2 for the x-, y- or z-axis respectively.
DistThe position of the mirror plane along its normal vector, where it intersects the NormalAxis.
LockTexCoordsTransform the texture-space along with the geometry. Note that the mirroring is not necessarily "perfect", because for some elements like models or plants, only their point of origin can be mirrored, but not their mesh.

Reimplemented from MapElementT.

void MapBrushT::TrafoMove ( const Vector3fT Delta,
bool  LockTexCoords 
)
overridevirtual

Translates this element by the given vector (in world-space).

Parameters
DeltaThe offset by which to translate the element.
LockTexCoordsTransform the texture-space along with the geometry.

Reimplemented from MapElementT.

void MapBrushT::TrafoRotate ( const Vector3fT RefPoint,
const cf::math::AnglesfT Angles,
bool  LockTexCoords 
)
overridevirtual

Rotates this element about the given reference point (in world-space).

Parameters
RefPointThe reference point (origin) for the rotation.
AnglesThe rotation angles for the three axes.
LockTexCoordsTransform the texture-space along with the geometry.

Reimplemented from MapElementT.

void MapBrushT::TrafoScale ( const Vector3fT RefPoint,
const Vector3fT Scale,
bool  LockTexCoords 
)
overridevirtual

Scales this element about the given reference point (in world-space).

Parameters
RefPointThe reference point (origin) for the scale.
ScaleThe scale factors for the three axes.
LockTexCoordsTransform the texture-space along with the geometry.
Exceptions
DivisionByZeroE,e.g.when Scale is too small and the element becomes degenerate (e.g. a brush with too small faces).

Reimplemented from MapElementT.

void MapBrushT::Transform ( const Matrix4x4fT Matrix,
bool  LockTexCoords 
)
overridevirtual

Why does this method not replace all the other Trafo*() methods? This method is the most generic, allowing transformations that e.g.

are non-orthogonal (like shears or non-uniform scales). This in turn conflicts with map primitives that can only store and deal with a restricted fixed set of transformations, e.g. an origin, a rotation and a uniform scale. These values cannot properly be re-computed from a general matrix with non-orthogonal basis vectors.

Parameters
MatrixThe matrix that describes the transform to be applied.
LockTexCoordsTransform the texture-space along with the geometry.

Reimplemented from MapElementT.


The documentation for this class was generated from the following files: