3 Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef CONTENT_CAO_HEADER
21 #define CONTENT_CAO_HEADER
23 #include "clientobject.h"
24 #include "content_object.h"
25 #include "utility.h" // For IntervalLimiter
31 struct SmoothTranslator
36 f32 anim_time_counter;
56 void update(v3f vect_new)
60 if(anim_time < 0.001 || anim_time > 1.0)
61 anim_time = anim_time_counter;
63 anim_time = anim_time * 0.9 + anim_time_counter * 0.1;
64 anim_time_counter = 0;
68 void translate(f32 dtime)
70 anim_time_counter = anim_time_counter + dtime;
71 anim_counter = anim_counter + dtime;
72 v3f vect_move = vect_aim - vect_old;
75 moveratio = anim_time_counter / anim_time;
76 // Move a bit less than should, to avoid oscillation
77 moveratio = moveratio * 0.8;
80 vect_show = vect_old + vect_move * moveratio;
89 class TestCAO : public ClientActiveObject
97 return ACTIVEOBJECT_TYPE_TEST;
100 static ClientActiveObject* create();
102 void addToScene(scene::ISceneManager *smgr);
103 void removeFromScene();
104 void updateLight(u8 light_at_pos);
105 v3s16 getLightPosition();
106 void updateNodePos();
108 void step(float dtime, ClientEnvironment *env);
110 void processMessage(const std::string &data);
113 scene::IMeshSceneNode *m_node;
121 class ItemCAO : public ClientActiveObject
129 return ACTIVEOBJECT_TYPE_ITEM;
132 static ClientActiveObject* create();
134 void addToScene(scene::ISceneManager *smgr);
135 void removeFromScene();
136 void updateLight(u8 light_at_pos);
137 v3s16 getLightPosition();
138 void updateNodePos();
140 void step(float dtime, ClientEnvironment *env);
142 void processMessage(const std::string &data);
144 void initialize(const std::string &data);
146 core::aabbox3d<f32>* getSelectionBox()
147 {return &m_selection_box;}
152 core::aabbox3d<f32> m_selection_box;
153 scene::IMeshSceneNode *m_node;
155 std::string m_inventorystring;
162 class RatCAO : public ClientActiveObject
170 return ACTIVEOBJECT_TYPE_RAT;
173 static ClientActiveObject* create();
175 void addToScene(scene::ISceneManager *smgr);
176 void removeFromScene();
177 void updateLight(u8 light_at_pos);
178 v3s16 getLightPosition();
179 void updateNodePos();
181 void step(float dtime, ClientEnvironment *env);
183 void processMessage(const std::string &data);
185 void initialize(const std::string &data);
187 core::aabbox3d<f32>* getSelectionBox()
188 {return &m_selection_box;}
193 core::aabbox3d<f32> m_selection_box;
194 scene::IMeshSceneNode *m_node;
197 SmoothTranslator pos_translator;
204 class Oerkki1CAO : public ClientActiveObject
208 virtual ~Oerkki1CAO();
212 return ACTIVEOBJECT_TYPE_OERKKI1;
215 static ClientActiveObject* create();
217 void addToScene(scene::ISceneManager *smgr);
218 void removeFromScene();
219 void updateLight(u8 light_at_pos);
220 v3s16 getLightPosition();
221 void updateNodePos();
223 void step(float dtime, ClientEnvironment *env);
225 void processMessage(const std::string &data);
227 void initialize(const std::string &data);
229 core::aabbox3d<f32>* getSelectionBox()
230 {return &m_selection_box;}
232 {return pos_translator.vect_show;}
233 //{return m_position;}
236 IntervalLimiter m_attack_interval;
237 core::aabbox3d<f32> m_selection_box;
238 scene::IMeshSceneNode *m_node;
241 SmoothTranslator pos_translator;
242 float m_damage_visual_timer;
243 bool m_damage_texture_enabled;
250 class FireflyCAO : public ClientActiveObject
254 virtual ~FireflyCAO();
258 return ACTIVEOBJECT_TYPE_FIREFLY;
261 static ClientActiveObject* create();
263 void addToScene(scene::ISceneManager *smgr);
264 void removeFromScene();
265 void updateLight(u8 light_at_pos);
266 v3s16 getLightPosition();
267 void updateNodePos();
269 void step(float dtime, ClientEnvironment *env);
271 void processMessage(const std::string &data);
273 void initialize(const std::string &data);
275 core::aabbox3d<f32>* getSelectionBox()
276 {return &m_selection_box;}
281 core::aabbox3d<f32> m_selection_box;
282 scene::IMeshSceneNode *m_node;
285 SmoothTranslator pos_translator;