Cafu Engine
ToolCamera.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_TOOL_CAMERA_HPP_INCLUDED
8 #define CAFU_TOOL_CAMERA_HPP_INCLUDED
9 
10 #include "Tool.hpp"
11 #include "Math3D/Vector3.hpp"
12 #include "Templates/Array.hpp"
13 
14 
15 class CameraT;
17 class ViewWindowT;
18 
19 
20 class ToolCameraT : public ToolT
21 {
22  public:
23 
24  ToolCameraT(MapDocumentT& MapDoc, ToolManagerT& ToolMan, wxWindow* ParentOptionsBar);
25  ~ToolCameraT();
26 
27  const ArrayT<CameraT*>& GetCameras() const { return m_Cameras; }
28  CameraT* GetActiveCamera() const { return m_Cameras[m_ActiveCameraNr]; }
29  void AddCamera(CameraT* Camera);
30  void DeleteActiveCamera();
31  void NotifyCameraChanged(const CameraT* Camera);
32 
33 
34  // Implementations/overrides of ToolT methods.
35  int GetWxEventID() const { return ChildFrameT::ID_MENU_TOOLS_TOOL_CAMERA; }
36  wxWindow* GetOptionsBar();
37 
38  bool OnKeyDown2D (ViewWindow2DT& ViewWindow, wxKeyEvent& KE);
39  bool OnLMouseDown2D(ViewWindow2DT& ViewWindow, wxMouseEvent& ME);
40  bool OnLMouseUp2D (ViewWindow2DT& ViewWindow, wxMouseEvent& ME);
41  bool OnMouseMove2D (ViewWindow2DT& ViewWindow, wxMouseEvent& ME);
42 
43  bool OnKeyDown3D (ViewWindow3DT& ViewWindow, wxKeyEvent& KE);
44  bool OnMouseMove3D (ViewWindow3DT& ViewWindow, wxMouseEvent& ME);
45 
46  void RenderTool2D(Renderer2DT& Renderer) const;
47 
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;
52 
53 
54  private:
55 
56  enum CameraPartT
57  {
58  POSITION,
59  LOOKAT
60  };
61 
62  enum ToolStateT
63  {
64  IDLE,
65  DRAG_CAM_POS,
66  DRAG_CAM_DIR
67  };
68 
69 
70  /// Determines if in ViewWindow at PointWS (in window space) is one of our cameras (i.e. the position or look-at point of one of our cameras).
71  bool FindCamera(ViewWindow2DT& ViewWindow, const wxPoint& PointWS, unsigned long& CamNr, CameraPartT& CamPart) const;
72 
73  /// Handles key down events that are common to the 2D and 3D views.
74  bool OnKeyDown(ViewWindowT& ViewWindow, wxKeyEvent& KE);
75 
76 
77  ArrayT<CameraT*> m_Cameras; ///< The cameras that have been created, there is always at least one.
78  unsigned long m_ActiveCameraNr; ///< The index number of the camera that is currently active.
79  ToolStateT m_ToolState; ///< The state this tool is currently in.
80 
81  OptionsBar_CameraToolT* m_OptionsBar; ///< The options bar for this tool.
82 };
83 
84 #endif
bool OnLMouseDown2D(ViewWindow2DT &ViewWindow, wxMouseEvent &ME)
Also used for LMB "double-click" events (use ME.ButtonDClick() for distinction).
Definition: ToolCamera.cpp:145
This class implements the rendering into a 2D view.
Definition: Renderer2D.hpp:22
This class represents a CaWE "map" document.
Definition: MapDocument.hpp:45
wxWindow * GetOptionsBar()
Returns the options bar window associated with this tool. NULL if no options bar has been assigned...
Definition: ToolCamera.cpp:131
This class implements a camera.
Definition: Camera.hpp:17
Definition: ToolCamera.hpp:20
int GetWxEventID() const
Returns the ID of the wxWidgets event (menu selection or toolbar button click) that is associated wit...
Definition: ToolCamera.hpp:35
This class represents a (superclass of a) 2D or 3D map view window.
Definition: ChildFrameViewWin.hpp:21
The options bar for the Camera tool.
Definition: ToolOptionsBars.hpp:49
Definition: ChildFrameViewWin2D.hpp:24
Definition: ChildFrameViewWin3D.hpp:21
Definition: ToolManager.hpp:20
This is the base class for all tools in the map editor.
Definition: Tool.hpp:34
Definition: TypeSys.hpp:52
This class keeps type information (about an entity class that occurs in the game).
Definition: TypeSys.hpp:79