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 "MapPrimitive.hpp"
11 #include "Plants/Tree.hpp"
14 class MapDocumentT;
15 struct PlantDescriptionT;
16 class PlantDescrManT;
19 class MapPlantT : public MapPrimitiveT
20 {
21  public:
23  MapPlantT();
24  MapPlantT(const PlantDescriptionT* PlantDescription, unsigned long RandomSeed, const Vector3fT& Position);
26  /// The copy constructor for copying a plant.
27  /// @param Plant The plant to copy-construct this plant from.
28  MapPlantT(const MapPlantT& Plant);
31  // Implementations and overrides for base class methods.
32  MapPlantT* Clone() const override;
35  // MapElementT implementation.
36  BoundingBox3fT GetBB() const;
38  void Render2D(Renderer2DT& Renderer) const;
39  void Render3D(Renderer3DT& Renderer) const;
41  bool TracePixel(const wxPoint& Pixel, int Radius, const ViewWindow2DT& ViewWin) const;
42  wxString GetDescription() const { return "Plant"; }
43  bool IsTranslucent() const { return true; }
45  // Implement the MapElementT transformation methods.
46  TrafoMementoT* GetTrafoState() const override;
47  void RestoreTrafoState(const TrafoMementoT* TM) override;
48  void TrafoMove(const Vector3fT& Delta, bool LockTexCoords) override;
49  void TrafoRotate(const Vector3fT& RefPoint, const cf::math::AnglesfT& Angles, bool LockTexCoords) override;
50  void TrafoScale(const Vector3fT& RefPoint, const Vector3fT& Scale, bool LockTexCoords) override;
51  void TrafoMirror(unsigned int NormalAxis, float Dist, bool LockTexCoords) override;
52  void Transform(const MatrixT& Matrix, bool LockTexCoords) override;
54  void Load_cmap(TextParserT& TP, MapDocumentT& MapDoc, bool IgnoreGroups) override;
55  void Save_cmap(std::ostream& OutFile, unsigned long PlantNr, const MapDocumentT& MapDoc) const;
57  // The TypeSys related declarations for this class.
58  virtual const cf::TypeSys::TypeInfoT* GetType() const { return &TypeInfo; }
59  static void* CreateInstance(const cf::TypeSys::CreateParamsT& Params);
60  static const cf::TypeSys::TypeInfoT TypeInfo;
63  private:
65  friend class InspDlgPrimitivePropsT;
66  friend class CommandChangePlantSeedT;
67  friend class CommandChangePlantDescrT;
69  TreeT m_Tree;
70  unsigned long m_RandomSeed;
71  cf::math::AnglesfT m_Angles;
72  Vector3fT m_Position;
73  wxString m_DescrFileName;
74 };
76 #endif
bool IsTranslucent() const
Returns whether this map element is (entirely or partially) translucent.
Definition: MapPlant.hpp:43
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
Definition: MapPlant.hpp:19
TrafoMementoT * GetTrafoState() const override
Returns a memento that encapsulates the transform-related state of this element.
Definition: MapPlant.cpp:183
void Transform(const MatrixT &Matrix, bool LockTexCoords) override
Why does this method not replace all the other Trafo*() methods? This method is the most generic...
Definition: MapPlant.cpp:255
This class represents a CaWE "map" document.
Definition: MapDocument.hpp:45
void RestoreTrafoState(const TrafoMementoT *TM) override
Restores the transform-related state of this element from the given memento.
Definition: MapPlant.cpp:189
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: MapPlant.cpp:150
The plant description manager holds and manages all plant descriptions so they can be shared with mul...
Definition: PlantDescrMan.hpp:19
MapPlantT * Clone() const override
The virtual copy constructor.
Definition: MapPlant.cpp:66
This class adds no functionality of its own, but only exists for proper type separation.
Definition: MapPrimitive.hpp:21
Contains a plant description that has all the information needed to create a plant.
Definition: PlantDescription.hpp:23
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: MapPlant.cpp:209
Describes a renderable tree.
Definition: Tree.hpp:27
An instance of this class encapsulates the transform-related state of a MapElementT.
Definition: MapElement.hpp:39
Definition: DialogInsp-PrimitiveProps.hpp:21
void TrafoScale(const Vector3fT &RefPoint, const Vector3fT &Scale, bool LockTexCoords) override
Scales this element about the given reference point (in world-space).
Definition: MapPlant.cpp:238
void TrafoMove(const Vector3fT &Delta, bool LockTexCoords) override
Translates this element by the given vector (in world-space).
Definition: MapPlant.cpp:201
Definition: ChangePlantSeed.hpp:17
void TrafoMirror(unsigned int NormalAxis, float Dist, bool LockTexCoords) override
Mirrors this element along the given mirror plane (in world-space).
Definition: MapPlant.cpp:246
BoundingBox3fT GetBB() const
Returns the spatial bounding-box of this map element.
Definition: MapPlant.cpp:72
Definition: ChildFrameViewWin2D.hpp:24
Definition: ChangePlantDescr.hpp:17
Definition: TypeSys.hpp:52
This class keeps type information (about an entity class that occurs in the game).
Definition: TypeSys.hpp:79
This is a class for parsing text.
Definition: TextParser.hpp:21