SuperTuxKart
Loading...
Searching...
No Matches
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 "graphics/irr_driver.hpp"
24#include "guiengine/widgets/icon_button_widget.hpp"
25#include "utils/aligned_array.hpp"
26#include "utils/leak_check.hpp"
27#include "utils/ptr_vector.hpp"
28
29namespace GE { class GERenderInfo; }
30
31namespace GUIEngine
32{
37 {
38 enum RotationMode
39 {
40 ROTATE_OFF,
41 ROTATE_CONTINUOUSLY,
42 ROTATE_TO
43 };
44 RotationMode m_rotation_mode;
45 float m_rotation_speed;
46 float m_rotation_target;
47
49 std::vector<core::matrix4> m_model_location;
50 std::vector<std::pair<int, int> > m_model_frames;
51 std::vector<float> m_model_animation_speed;
52 std::vector<std::string> m_bone_attached;
53 std::unique_ptr<RenderTarget> m_render_target;
54 float m_angle;
55
56 bool m_rtt_unsupported;
57
58 scene::ISceneNode *m_rtt_main_node;
59
60 scene::ICameraSceneNode *m_camera;
61
62 scene::ISceneNode *m_light;
63
64 std::shared_ptr<GE::GERenderInfo> m_render_info;
65
66 unsigned m_rtt_size;
67
68 public:
69
70 LEAK_CHECK()
71
72 ModelViewWidget(unsigned rtt_size = 512);
73 virtual ~ModelViewWidget();
74
75 void add();
76 void clearModels();
77 void addModel(irr::scene::IMesh* mesh,
78 const core::matrix4& location = core::matrix4(),
79 const int start_loop_frame=-1,
80 const int end_loop_frame=-1,
81 float animation_speed = 0.0f,
82 const std::string& bone_name = std::string());
83
84 void update(float delta);
85
86 void setRTTSize(unsigned rtt_size) { m_rtt_size = rtt_size; }
87
88 virtual void elementRemoved();
89
91 void setRotateOff();
92
94 void setRotateContinuously(float speed);
95
97 void setRotateTo(float targetAngle, float speed);
98
100 bool isRotating();
101
102 void clearRttProvider();
103
104 void setupRTTScene();
105
106 void drawRTTScene(const irr::core::rect<s32>& dest_rect) const;
107
108 std::shared_ptr<GE::GERenderInfo> getModelViewRenderInfo() { return m_render_info; }
109 };
110
111}
112
113#endif
A button widget with an icon and optionnaly a label beneath.
Definition: icon_button_widget.hpp:44
A model view widget.
Definition: model_view_widget.hpp:37
virtual void elementRemoved()
Called when irrLicht widgets cleared.
Definition: model_view_widget.cpp:362
void setRotateOff()
Disables any model rotation.
Definition: model_view_widget.cpp:335
bool isRotating()
Returns information if currently kart is rotating.
Definition: model_view_widget.cpp:356
void setRotateTo(float targetAngle, float speed)
Rotate to 'targetAngle' in degrees at given speed (in degrees per second)
Definition: model_view_widget.cpp:348
void update(float delta)
Override in children to possibly receive updates (you may need to register to them first)
Definition: model_view_widget.cpp:127
void setRotateContinuously(float speed)
Makes the model rotate at given speed (in degrees per second)
Definition: model_view_widget.cpp:341
void add()
Implement callback from base class Widget.
Definition: model_view_widget.cpp:69
Definition: ptr_vector.hpp:44
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:33