Cafu Engine
MapModel.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
6 
7 #ifndef CAFU_MAP_MODEL_HPP_INCLUDED
8 #define CAFU_MAP_MODEL_HPP_INCLUDED
9 
10 #include "MapPrimitive.hpp"
11 #include "Models/AnimExpr.hpp"
12 #include "Util/Util.hpp"
13 
14 
15 class MapDocumentT;
16 class CafuModelT;
17 
18 
19 class MapModelT : public MapPrimitiveT
20 {
21  public:
22 
23  MapModelT(MapDocumentT& MapDoc, const wxString& ModelFileName, const Vector3fT& Position);
24  MapModelT(MapDocumentT& MapDoc, const wxString& ModelFileName, const wxString& CollisionModelFileName, const wxString& Label, const Vector3fT& Position, const Vector3fT& Angles, float Scale, int Sequence, float FrameOffset, float FrameTimeScale, bool Animated);
25 
26  /// The copy constructor for copying a model.
27  /// @param Model The model to copy-construct this model from.
28  MapModelT(const MapModelT& Model);
29 
30 
31  // Implementations and overrides for base class methods.
32  MapModelT* Clone() const override;
33 
34 
35  // MapElementT implementation.
36  BoundingBox3fT GetBB() const;
37 
38  void Render2D(Renderer2DT& Renderer) const;
39  void Render3D(Renderer3DT& Renderer) const;
40 
41  bool TracePixel(const wxPoint& Pixel, int Radius, const ViewWindow2DT& ViewWin) const;
42  wxString GetDescription() const { return "Model"; }
43 
44  // Implement the MapElementT transformation methods.
45  TrafoMementoT* GetTrafoState() const override;
46  void RestoreTrafoState(const TrafoMementoT* TM) override;
47  void TrafoMove(const Vector3fT& Delta, bool LockTexCoords) override;
48  void TrafoRotate(const Vector3fT& RefPoint, const cf::math::AnglesfT& Angles, bool LockTexCoords) override;
49  void TrafoScale(const Vector3fT& RefPoint, const Vector3fT& Scale, bool LockTexCoords) override;
50  void TrafoMirror(unsigned int NormalAxis, float Dist, bool LockTexCoords) override;
51  void Transform(const Matrix4x4fT& Matrix, bool LockTexCoords) override;
52 
53  void Load_cmap(TextParserT& TP, MapDocumentT& MapDoc, bool IgnoreGroups) override;
54  void Save_cmap(std::ostream& OutFile, unsigned long ModelNr, const MapDocumentT& MapDoc) const;
55 
56  // The TypeSys related declarations for this class.
57  virtual const cf::TypeSys::TypeInfoT* GetType() const { return &TypeInfo; }
58  static void* CreateInstance(const cf::TypeSys::CreateParamsT& Params);
59  static const cf::TypeSys::TypeInfoT TypeInfo;
60 
61 
62  private:
63 
64  friend class InspDlgPrimitivePropsT;
65  friend class CommandModifyModelT;
66 
67  wxString m_ModelFileName;
68  const CafuModelT* m_Model;
69  Vector3fT m_Origin;
70  wxString m_CollModelFileName;
71  wxString m_Label;
72  cf::math::AnglesfT m_Angles;
73  float m_Scale;
74  mutable IntrusivePtrT<AnimExprStandardT> m_AnimExpr; ///< The current expression used for configuring the pose of the model.
75  float m_FrameOffset;
76  float m_FrameTimeScale;
77  bool m_Animated;
78  mutable TimerT m_Timer;
79 };
80 
81 #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
This class represents a native Cafu model.
Definition: Model_cmdl.hpp:45
This class represents a CaWE "map" document.
Definition: MapDocument.hpp:45
Definition: ModifyModel.hpp:18
This class adds no functionality of its own, but only exists for proper type separation.
Definition: MapPrimitive.hpp:21
An instance of this class encapsulates the transform-related state of a MapElementT.
Definition: MapElement.hpp:39
Definition: DialogInsp-PrimitiveProps.hpp:21
void RestoreTrafoState(const TrafoMementoT *TM) override
Restores the transform-related state of this element from the given memento.
Definition: MapModel.cpp:224
void TrafoMove(const Vector3fT &Delta, bool LockTexCoords) override
Translates this element by the given vector (in world-space).
Definition: MapModel.cpp:236
void TrafoMirror(unsigned int NormalAxis, float Dist, bool LockTexCoords) override
Mirrors this element along the given mirror plane (in world-space).
Definition: MapModel.cpp:281
Definition: MapModel.hpp:19
A platform independent timer class that allows to measure the time passed since its construction or t...
Definition: Util.hpp:24
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: MapModel.cpp:290
void TrafoScale(const Vector3fT &RefPoint, const Vector3fT &Scale, bool LockTexCoords) override
Scales this element about the given reference point (in world-space).
Definition: MapModel.cpp:273
Definition: ChildFrameViewWin2D.hpp:24
MapModelT * Clone() const override
The virtual copy constructor.
Definition: MapModel.cpp:92
TrafoMementoT * GetTrafoState() const override
Returns a memento that encapsulates the transform-related state of this element.
Definition: MapModel.cpp:218
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: MapModel.cpp:244
Definition: TypeSys.hpp:52
This class keeps type information (about an entity class that occurs in the game).
Definition: TypeSys.hpp:79
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: MapModel.cpp:185
BoundingBox3fT GetBB() const
Returns the spatial bounding-box of this map element.
Definition: MapModel.cpp:98
This is a class for parsing text.
Definition: TextParser.hpp:21