Brush.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
5 */
6
7 #ifndef CAFU_MATH_BRUSH_HPP_INCLUDED
8 #define CAFU_MATH_BRUSH_HPP_INCLUDED
9
10 #include "BoundingBox.hpp"
11 #include "Plane3.hpp"
12 #include "Templates/Array.hpp"
13
14
15 /// This classes describes the trace (Verfolgungsergebnis) of a vector or a bounding box with regards to a brush.
16 /// The name VB_TraceT means "vector-brush trace".
17 template<class T>
19 {
20  public:
21
22  T Fraction; ///< This is how far we got, 0 <= Fraction <= 1.
23  bool StartSolid; ///< Did the movement start inside the brush, "in solid"?
24  Vector3T<T> ImpactNormal; ///< On impact, this is the normal vector of the hit plane.
25
26  /// Constructor.
27  VB_Trace3T(T Fraction_)
28  : Fraction(Fraction_),
29  StartSolid(false)
30  {
31  }
32 };
33
34
35 /// Diese Klasse implementiert Brushes.
36 /// Ein Brush ist nichts weiter als eine Ansammlung (Array) von Planes,
37 /// deren Schnitt ein konvexes, dreidimensionales Polyhedron darstellt.
38 ///
39 /// Eigenschaften des Brushs (Vereinbarungen):
40 /// 1. Die Normalenvektoren der Ebenen müssen nach AUßEN zeigen.
41 template<class T>
42 class Brush3T
43 {
44  public:
45
46  ArrayT< Plane3T<T> > Planes; ///< Array of planes this brush consists of.
47
48
49  /// Default constructor.
50  Brush3T() {}
51
52  /// Generiert einen Brush aus einer BoundingBox 'BB', die vorher nach 'Pos' verschoben wird.
53  Brush3T(const BoundingBox3T<T>& BB, const Vector3T<T>& Pos);
54
55  /// Creates a triangular, zero-volume brush from the vertices A, B and C.
56  /// @param A First vertice.
57  /// @param B Second vertice.
58  /// @param C Third vertice.
59  /// @param Epsilon Tolerance value.
60  /// @param IncludeBevelPlanes If false, only five planes (two for the sides and three for the edges) will be created.
61  /// If true, also bevel planes will be included.
62  Brush3T(const Vector3T<T>& A, const Vector3T<T>& B, const Vector3T<T>& C, const T Epsilon, bool IncludeBevelPlanes = true);
63
64  /// Traces the (relative) bounding box 'BB' from the (absolute) 'Origin' along 'Dir' towards the end position 'Origin+VectorScale(Dir, Trace.Fraction)'.
65  /// The result is returned in 'Trace'.
66  /// This method handles the bloating and unbloating of the brush according to a description by Kekoa Proudfoot:
67  /// Tracing the 'BB' against this brush is reduced to a simple ray collision test against the "bloated" brush.
68  /// @param BB Bounding box to trace.
69  /// @param Origin Origin of the trace.
70  /// @param Dir Direction of the trace.
71  /// @param Trace Trace result.
72  void TraceBoundingBox(const BoundingBox3T<T>& BB, const Vector3T<T>& Origin, const Vector3T<T>& Dir, VB_Trace3T<T>& Trace) const;
73 };
74
75 #endif
This classes describes the trace (Verfolgungsergebnis) of a vector or a bounding box with regards to ...
Definition: Brush.hpp:18
bool StartSolid
Did the movement start inside the brush, "in solid"?
Definition: Brush.hpp:23
This class represents a polymorphic 3-dimensional vector.
Definition: Misc.hpp:11
void TraceBoundingBox(const BoundingBox3T< T > &BB, const Vector3T< T > &Origin, const Vector3T< T > &Dir, VB_Trace3T< T > &Trace) const
Traces the (relative) bounding box 'BB' from the (absolute) 'Origin' along 'Dir' towards the end posi...
Definition: Brush.cpp:43
Diese Klasse implementiert Brushes.
Definition: Brush.hpp:42
Vector3T< T > ImpactNormal
On impact, this is the normal vector of the hit plane.
Definition: Brush.hpp:24
Brush3T()
Default constructor.
Definition: Brush.hpp:50
T Fraction
This is how far we got, 0 <= Fraction <= 1.
Definition: Brush.hpp:22
VB_Trace3T(T Fraction_)
Constructor.
Definition: Brush.hpp:27
Definition: Renderer.hpp:16
ArrayT< Plane3T< T > > Planes
Array of planes this brush consists of.
Definition: Brush.hpp:46
This class represents an axis-aligned bounding-box ("AABB") in 3-dimensional space.
Definition: BoundingBox.hpp:23