1 ////////////////////////////////////////////////////////////////////////////////
2 //    Scorched3D (c) 2000-2011
3 //
4 //    This file is part of Scorched3D.
5 //
6 //    Scorched3D is free software; you can redistribute it and/or modify
7 //    it under the terms of the GNU General Public License as published by
8 //    the Free Software Foundation; either version 2 of the License, or
9 //    (at your option) any later version.
10 //
11 //    Scorched3D is distributed in the hope that it will be useful,
12 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //    GNU General Public License for more details.
15 //
16 //    You should have received a copy of the GNU General Public License along
17 //    with this program; if not, write to the Free Software Foundation, Inc.,
18 //    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 ////////////////////////////////////////////////////////////////////////////////
20 
21 #include <sprites/NapalmRenderer.h>
22 #include <sprites/ExplosionTextures.h>
23 #include <client/ScorchedClient.h>
24 #include <landscapemap/LandscapeMaps.h>
25 #include <common/Defines.h>
26 
NapalmRenderer(GLTextureSet * set)27 NapalmRenderer::NapalmRenderer(GLTextureSet *set) :
28 	textureNo_(0.0f), set_(set)
29 {
30 	int noTextures = set_->getNoTextures();
31 	plus_ = int(RAND * noTextures);
32 }
33 
~NapalmRenderer()34 NapalmRenderer::~NapalmRenderer()
35 {
36 }
37 
draw(Particle * particle)38 void NapalmRenderer::draw(Particle *particle)
39 {
40 	particle->position_[2] =
41 		ScorchedClient::instance()->getLandscapeMaps().getGroundMaps().getHeight(
42 			(int) particle->position_[0],
43 			(int) particle->position_[1]).asFloat() + particle->size_[1] * 2.0f;
44 }
45 
simulate(Particle * particle,float timepassed)46 void NapalmRenderer::simulate(Particle *particle, float timepassed)
47 {
48 	int noTextures = set_->getNoTextures();
49 	textureNo_ += 0.1f;
50 	int no = (int(textureNo_) + plus_) % noTextures;
51 	particle->texture_ = set_->getTexture(no);
52 }
53