3 Copyright (C) 2013 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 Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser 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 #include "content_cso.h"
21 #include <IBillboardSceneNode.h>
22 #include "client/tile.h"
23 #include "clientenvironment.h"
28 class SmokePuffCSO: public ClientSimpleObject
31 scene::IBillboardSceneNode *m_spritenode = nullptr;
33 SmokePuffCSO(scene::ISceneManager *smgr,
34 ClientEnvironment *env, const v3f &pos, const v2f &size)
36 infostream<<"SmokePuffCSO: constructing"<<std::endl;
37 m_spritenode = smgr->addBillboardSceneNode(
38 NULL, v2f(1,1), pos, -1);
39 m_spritenode->setMaterialTexture(0,
40 env->getGameDef()->tsrc()->getTextureForMesh("smoke_puff.png"));
41 m_spritenode->setMaterialFlag(video::EMF_LIGHTING, false);
42 m_spritenode->setMaterialFlag(video::EMF_BILINEAR_FILTER, false);
43 //m_spritenode->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF);
44 m_spritenode->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL);
45 m_spritenode->setMaterialFlag(video::EMF_FOG_ENABLE, true);
46 m_spritenode->setColor(video::SColor(255,0,0,0));
47 m_spritenode->setVisible(true);
48 m_spritenode->setSize(size);
49 /* Update brightness */
52 MapNode n = env->getMap().getNode(floatToInt(pos, BS), &pos_ok);
53 light = pos_ok ? decode_light(n.getLightBlend(env->getDayNightRatio(),
54 env->getGameDef()->ndef()->getLightingFlags(n)))
56 video::SColor color(255,light,light,light);
57 m_spritenode->setColor(color);
59 virtual ~SmokePuffCSO()
61 infostream<<"SmokePuffCSO: destructing"<<std::endl;
62 m_spritenode->remove();
64 void step(float dtime)
68 m_to_be_removed = true;
73 ClientSimpleObject* createSmokePuff(scene::ISceneManager *smgr,
74 ClientEnvironment *env, v3f pos, v2f size)
76 return new SmokePuffCSO(smgr, env, pos, size);