SuperTuxKart
model_view_widget.hpp
1 // SuperTuxKart - a fun racing game with go-kart
2 // Copyright (C) 2009-2015 Marianne Gagnon
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 3
7 // of the License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 
18 
19 
20 #ifndef HEADER_MODELVIEW_HPP
21 #define HEADER_MODELVIEW_HPP
22 
23 #include <IMesh.h>
24 
25 #include "graphics/irr_driver.hpp"
26 #include "guiengine/widgets/icon_button_widget.hpp"
27 #include "utils/aligned_array.hpp"
28 #include "utils/leak_check.hpp"
29 #include "utils/ptr_vector.hpp"
30 
31 class RenderInfo;
32 
33 namespace GUIEngine
34 {
39  {
40  enum RotationMode
41  {
42  ROTATE_OFF,
43  ROTATE_CONTINUOUSLY,
44  ROTATE_TO
45  };
46  RotationMode m_rotation_mode;
47  float m_rotation_speed;
48  float m_rotation_target;
49 
51  std::vector<core::matrix4> m_model_location;
52  std::vector<std::pair<int, int> > m_model_frames;
53  std::vector<float> m_model_animation_speed;
54  std::vector<std::string> m_bone_attached;
55  std::unique_ptr<RenderTarget> m_render_target;
56  float m_angle;
57 
58  bool m_rtt_unsupported;
59 
60  scene::ISceneNode *m_rtt_main_node;
61 
62  scene::ICameraSceneNode *m_camera;
63 
64  scene::ISceneNode *m_light;
65 
66  std::shared_ptr<RenderInfo> m_render_info;
67 
68  unsigned m_rtt_size;
69 
70  public:
71 
72  LEAK_CHECK()
73 
74  ModelViewWidget(unsigned rtt_size = 512);
75  virtual ~ModelViewWidget();
76 
77  void add();
78  void clearModels();
79  void addModel(irr::scene::IMesh* mesh,
80  const core::matrix4& location = core::matrix4(),
81  const int start_loop_frame=-1,
82  const int end_loop_frame=-1,
83  float animation_speed = 0.0f,
84  const std::string& bone_name = std::string());
85 
86  void update(float delta);
87 
88  void setRTTSize(unsigned rtt_size) { m_rtt_size = rtt_size; }
89 
90  virtual void elementRemoved();
91 
93  void setRotateOff();
94 
96  void setRotateContinuously(float speed);
97 
99  void setRotateTo(float targetAngle, float speed);
100 
102  bool isRotating();
103 
104  void clearRttProvider();
105 
106  void setupRTTScene();
107 
108  void drawRTTScene(const irr::core::rect<s32>& dest_rect) const;
109 
110  std::shared_ptr<RenderInfo> getModelViewRenderInfo() { return m_render_info; }
111  };
112 
113 }
114 
115 #endif
void setRotateOff()
Disables any model rotation.
Definition: model_view_widget.cpp:335
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:31
void update(float delta)
Override in children to possibly receive updates (you may need to register to them first)
Definition: model_view_widget.cpp:128
virtual void elementRemoved()
Called when irrLicht widgets cleared.
Definition: model_view_widget.cpp:362
void add()
Implement callback from base class Widget.
Definition: model_view_widget.cpp:70
A button widget with an icon and optionnaly a label beneath.
Definition: icon_button_widget.hpp:43
A model view widget.
Definition: model_view_widget.hpp:38
Definition: render_info.hpp:27
void setRotateContinuously(float speed)
Makes the model rotate at given speed (in degrees per second)
Definition: model_view_widget.cpp:341
void setRotateTo(float targetAngle, float speed)
Rotate to 'targetAngle' in degrees at given speed (in degrees per second)
Definition: model_view_widget.cpp:348
bool isRotating()
Returns information if currently kart is rotating.
Definition: model_view_widget.cpp:356