| 1 | /* |
|---|
| 2 | ================================================================================= |
|---|
| 3 | This file is part of Cafu, the open-source game engine and graphics engine |
|---|
| 4 | for multiplayer, cross-platform, real-time 3D action. |
|---|
| 5 | Copyright (C) 2002-2012 Carsten Fuchs Software. |
|---|
| 6 | |
|---|
| 7 | Cafu is free software: you can redistribute it and/or modify it under the terms |
|---|
| 8 | of the GNU General Public License as published by the Free Software Foundation, |
|---|
| 9 | either version 3 of the License, or (at your option) any later version. |
|---|
| 10 | |
|---|
| 11 | Cafu is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
|---|
| 12 | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|---|
| 13 | PURPOSE. See the GNU General Public License for more details. |
|---|
| 14 | |
|---|
| 15 | You should have received a copy of the GNU General Public License |
|---|
| 16 | along with Cafu. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 17 | |
|---|
| 18 | For support and more information about Cafu, visit us at <http://www.cafu.de>. |
|---|
| 19 | ================================================================================= |
|---|
| 20 | */ |
|---|
| 21 | |
|---|
| 22 | #ifndef CAFU_TOOL_CAMERA_HPP_INCLUDED |
|---|
| 23 | #define CAFU_TOOL_CAMERA_HPP_INCLUDED |
|---|
| 24 | |
|---|
| 25 | #include "Tool.hpp" |
|---|
| 26 | #include "Math3D/Vector3.hpp" |
|---|
| 27 | #include "Templates/Array.hpp" |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | class CameraT; |
|---|
| 31 | class OptionsBar_CameraToolT; |
|---|
| 32 | class ViewWindowT; |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | class ToolCameraT : public ToolT |
|---|
| 36 | { |
|---|
| 37 | public: |
|---|
| 38 | |
|---|
| 39 | ToolCameraT(MapDocumentT& MapDoc, ToolManagerT& ToolMan, wxWindow* ParentOptionsBar); |
|---|
| 40 | ~ToolCameraT(); |
|---|
| 41 | |
|---|
| 42 | const ArrayT<CameraT*>& GetCameras() const { return m_Cameras; } |
|---|
| 43 | CameraT* GetActiveCamera() const { return m_Cameras[m_ActiveCameraNr]; } |
|---|
| 44 | void AddCamera(CameraT* Camera); |
|---|
| 45 | void DeleteActiveCamera(); |
|---|
| 46 | void NotifyCameraChanged(const CameraT* Camera); |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | // Implementations/overrides of ToolT methods. |
|---|
| 50 | int GetWxEventID() const { return ChildFrameT::ID_MENU_TOOLS_TOOL_CAMERA; } |
|---|
| 51 | wxWindow* GetOptionsBar(); |
|---|
| 52 | |
|---|
| 53 | bool OnKeyDown2D (ViewWindow2DT& ViewWindow, wxKeyEvent& KE); |
|---|
| 54 | bool OnLMouseDown2D(ViewWindow2DT& ViewWindow, wxMouseEvent& ME); |
|---|
| 55 | bool OnLMouseUp2D (ViewWindow2DT& ViewWindow, wxMouseEvent& ME); |
|---|
| 56 | bool OnMouseMove2D (ViewWindow2DT& ViewWindow, wxMouseEvent& ME); |
|---|
| 57 | |
|---|
| 58 | bool OnKeyDown3D (ViewWindow3DT& ViewWindow, wxKeyEvent& KE); |
|---|
| 59 | bool OnMouseMove3D (ViewWindow3DT& ViewWindow, wxMouseEvent& ME); |
|---|
| 60 | |
|---|
| 61 | void RenderTool2D(Renderer2DT& Renderer) const; |
|---|
| 62 | |
|---|
| 63 | // The TypeSys related declarations for this class. |
|---|
| 64 | virtual const cf::TypeSys::TypeInfoT* GetType() const { return &TypeInfo; } |
|---|
| 65 | static void* CreateInstance(const cf::TypeSys::CreateParamsT& Params); |
|---|
| 66 | static const cf::TypeSys::TypeInfoT TypeInfo; |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | private: |
|---|
| 70 | |
|---|
| 71 | enum CameraPartT |
|---|
| 72 | { |
|---|
| 73 | POSITION, |
|---|
| 74 | LOOKAT |
|---|
| 75 | }; |
|---|
| 76 | |
|---|
| 77 | enum ToolStateT |
|---|
| 78 | { |
|---|
| 79 | IDLE, |
|---|
| 80 | DRAG_CAM_POS, |
|---|
| 81 | DRAG_CAM_DIR |
|---|
| 82 | }; |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | /// 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). |
|---|
| 86 | bool FindCamera(ViewWindow2DT& ViewWindow, const wxPoint& PointWS, unsigned long& CamNr, CameraPartT& CamPart) const; |
|---|
| 87 | |
|---|
| 88 | /// Handles key down events that are common to the 2D and 3D views. |
|---|
| 89 | bool OnKeyDown(ViewWindowT& ViewWindow, wxKeyEvent& KE); |
|---|
| 90 | |
|---|
| 91 | |
|---|
| 92 | ArrayT<CameraT*> m_Cameras; ///< The cameras that have been created, there is always at least one. |
|---|
| 93 | unsigned long m_ActiveCameraNr; ///< The index number of the camera that is currently active. |
|---|
| 94 | ToolStateT m_ToolState; ///< The state this tool is currently in. |
|---|
| 95 | |
|---|
| 96 | OptionsBar_CameraToolT* m_OptionsBar; ///< The options bar for this tool. |
|---|
| 97 | }; |
|---|
| 98 | |
|---|
| 99 | #endif |
|---|