Cafu Engine
1 /*
2 Cafu Engine,
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
10 #include "MapElement.hpp"
11 #include "Templates/Pointer.hpp"
14 namespace cf { namespace GameSys { class EntityT; } }
17 /// This class provides a graphical representation of an entity in the Map Editor.
18 /// Contrary to all other MapElementT-derived classes, the parent entity of a MapEntRepresT can never be `NULL`,
19 /// because a representation cannot exist without the object that it represents.
20 class MapEntRepresT : public MapElementT
21 {
22  public:
24  /// The constructor.
27  // Implementations and overrides for base class methods.
28  wxColour GetColor(bool ConsiderGroup=true) const;
29  wxString GetDescription() const;
31  void Render2D(Renderer2DT& Renderer) const;
32  void Render3D(Renderer3DT& Renderer) const;
33  bool IsTranslucent() const;
34  BoundingBox3fT GetBB() const;
35  bool TraceRay(const Vector3fT& RayOrigin, const Vector3fT& RayDir, float& Fraction, unsigned long& FaceNr) const;
36  bool TracePixel(const wxPoint& Pixel, int Radius, const ViewWindow2DT& ViewWin) const;
38  // Implement the MapElementT transformation methods.
39  TrafoMementoT* GetTrafoState() const override;
40  void RestoreTrafoState(const TrafoMementoT* TM) override;
41  void TrafoMove(const Vector3fT& Delta, bool LockTexCoords) override;
42  void TrafoRotate(const Vector3fT& RefPoint, const cf::math::AnglesfT& Angles, bool LockTexCoords) override;
43  void TrafoScale(const Vector3fT& RefPoint, const Vector3fT& Scale, bool LockTexCoords) override;
44  void TrafoMirror(unsigned int NormalAxis, float Dist, bool LockTexCoords) override;
45  void Transform(const Matrix4x4fT& Matrix, bool LockTexCoords) override;
48  // The TypeSys related declarations for this class.
49  virtual const cf::TypeSys::TypeInfoT* GetType() const { return &TypeInfo; }
50  static void* CreateInstance(const cf::TypeSys::CreateParamsT& Params);
51  static const cf::TypeSys::TypeInfoT TypeInfo;
54  private:
56  MapEntRepresT(const MapEntRepresT&); ///< Use of the Copy Constructor is not allowed.
57  void operator = (const MapEntRepresT&); ///< Use of the Assignment Operator is not allowed.
59  bool IsPlayerPrototypeChild() const;
60  BoundingBox3fT GetRepresBB() const;
61 };
63 #endif
This class provides auxiliary means for rendering a 3D view.
Definition: Renderer3D.hpp:30
This class implements the rendering into a 2D view.
Definition: Renderer2D.hpp:22
wxColour GetColor(bool ConsiderGroup=true) const
This method returns the "inherent" color of this map element.
Definition: MapEntRepres.cpp:46
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.
Definition: MapEntRepres.cpp:203
bool IsTranslucent() const
Returns whether this map element is (entirely or partially) translucent.
Definition: MapEntRepres.cpp:172
TrafoMementoT * GetTrafoState() const override
Returns a memento that encapsulates the transform-related state of this element.
Definition: MapEntRepres.cpp:269
void TrafoMove(const Vector3fT &Delta, bool LockTexCoords) override
Translates this element by the given vector (in world-space).
Definition: MapEntRepres.cpp:336
An instance of this class encapsulates the transform-related state of a MapElementT.
Definition: MapElement.hpp:39
void TrafoRotate(const Vector3fT &RefPoint, const cf::math::AnglesfT &Angles, bool LockTexCoords) override
Rotates this element about the given reference point (in world-space).
Definition: MapEntRepres.cpp:347
void TrafoMirror(unsigned int NormalAxis, float Dist, bool LockTexCoords) override
Mirrors this element along the given mirror plane (in world-space).
Definition: MapEntRepres.cpp:384
MapEntRepresT(MapEditor::CompMapEntityT *Parent)
The constructor.
Definition: MapEntRepres.cpp:38
BoundingBox3fT GetBB() const
Returns the spatial bounding-box of this map element.
Definition: MapEntRepres.cpp:178
void RestoreTrafoState(const TrafoMementoT *TM) override
Restores the transform-related state of this element from the given memento.
Definition: MapEntRepres.cpp:275
Definition: ChildFrameViewWin2D.hpp:24
This class provides a graphical representation of an entity in the Map Editor.
Definition: MapEntRepres.hpp:20
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...
Definition: MapEntRepres.cpp:397
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...
Definition: MapEntRepres.cpp:213
This component houses the Map Editor specific parts of its entity.
Definition: CompMapEntity.hpp:30
void TrafoScale(const Vector3fT &RefPoint, const Vector3fT &Scale, bool LockTexCoords) override
Scales this element about the given reference point (in world-space).
Definition: MapEntRepres.cpp:373
Definition: TypeSys.hpp:52
This class keeps type information (about an entity class that occurs in the game).
Definition: TypeSys.hpp:79
This is the base class for all elements ("objects") that can exist in a map.
Definition: MapElement.hpp:57