//////////////////////////////////////////////////////////////////////////////// // Scorched3D (c) 2000-2011 // // This file is part of Scorched3D. // // Scorched3D is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // Scorched3D is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. //////////////////////////////////////////////////////////////////////////////// #include #include #include #include #include #include #include #include #include REGISTER_CLASS_SOURCE(ExplosionLaserBeamRenderer); GLTextureReference ExplosionLaserBeamRenderer::_texture(ImageID(S3D::eModLocation, "data/textures/waves.bmp", "data/textures/waves.bmp", false)); ExplosionLaserBeamRenderer::~ExplosionLaserBeamRenderer() { } ExplosionLaserBeamRenderer::ExplosionLaserBeamRenderer(): totalTime_(0), time_(0), size_(12.0f), angle_(0) { } void ExplosionLaserBeamRenderer::init(unsigned int playerId, Vector &position, Vector &velocity, const char *data) { if (0 != strcmp("none", data)) { SoundBuffer *firedSound = Sound::instance()->fetchOrCreateBuffer( S3D::getModFile(data)); SoundUtils::playAbsoluteSound(VirtualSoundPriority::eAction, firedSound, position); } for (int j=0;jgetTextureSetByName("particle"); emmiter.emitLinear(800, newPos1, newPos2, ScorchedClient::instance()->getParticleEngine(), ParticleRendererQuads::getInstance(), texture, false); } void ExplosionLaserBeamRenderer::draw(Action *action) { GLState currentState(GLState::TEXTURE_ON | GLState::BLEND_ON); _texture.draw(); glPushMatrix(); glTranslatef(position_[0],position_[1],0.0f); glScalef(time_*0.05f,time_*0.05f,1.0f); for (int j=0;j100) tempheight=100; Vector height(0,0,tempheight); glColor4f(0.0f,0.6f,0.9f, 0.4f); for (int i=0;i<(sides+1);i++){ glNormal3fv ((float*)(points[j][i%sides])); if (i%2){ glTexCoord2f(0.0f, 0.0f+((layers-j)*time_)); }else{ glTexCoord2f(2.0f, 0.0f+((layers-j)*time_)); } glVertex3fv((float*)(points[j][i%sides]+height)); glNormal3fv ((float*)(points[j][i%sides])); if (i%2){ glTexCoord2f(0.0f, (float)(tempheight/10)+((layers-j)*time_)); }else{ glTexCoord2f(2.0f, (float)(tempheight/10)+((layers-j)*time_)); } glVertex3fv((float*)(points[j][i%sides])); } for (int i=0;i<(sides+1);i++){ glNormal3fv ((float*)(points[j][i%sides])); if (i%2){ glTexCoord2f(0.0f, 0.0f-((layers-j)*time_)); }else{ glTexCoord2f(2.0f, 0.0f-((layers-j)*time_)); } glVertex3fv((float*)(points[j][i%sides])); glNormal3fv ((float*)(points[j][i%sides])); if (i%2){ glTexCoord2f(0.0f, (float)(tempheight/10)-((layers-j)*time_)); }else{ glTexCoord2f(2.0f, (float)(tempheight/10)-((layers-j)*time_)); } glVertex3fv((float*)(points[j][i%sides]+height)); } glEnd(); } glPopMatrix(); } void ExplosionLaserBeamRenderer::simulate(Action *action, float frameTime, bool &remove) { totalTime_ += frameTime; time_ += frameTime; angle_=(angle_+3.0f); if (angle_>360.0f){ angle_=0.0f; } if ((time_)>size_){ remove=true; }else{ remove=false; } }