DebrisActionRenderer.cpp

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 ////////////////////////////////////////////////////////////////////////////////
00020 
00021 #include <sprites/DebrisActionRenderer.h>
00022 #include <3dsparse/ModelStore.h>
00023 #include <common/Defines.h>
00024 #include <GLEXT/GLState.h>
00025 #include <graph/ModelRendererStore.h>
00026 #include <stdlib.h>
00027 
00028 DebrisActionRenderer::DebrisActionRenderer() :
00029         rotationAng_(0)
00030 {
00031         rotationX_ = RAND;
00032         rotationY_ = RAND;
00033         rotationZ_ = RAND;
00034         rotationSpeed_ = 90.0f + 180.0f * RAND;
00035 
00036         if (RAND > 0.5f)
00037         {
00038                 ModelID id;
00039                 id.initFromString("ase", "data/meshes/rock1.ase", 
00040                         "none");
00041                 debris_ = new ModelRendererSimulator(
00042                         ModelRendererStore::instance()->loadModel(id));
00043         }
00044         else
00045         {
00046                 ModelID id;
00047                 id.initFromString("ase", "data/meshes/rock2.ase", 
00048                         "none");
00049                 debris_ = new ModelRendererSimulator(
00050                         ModelRendererStore::instance()->loadModel(id));
00051         }
00052         DIALOG_ASSERT(debris_);
00053 }
00054 
00055 DebrisActionRenderer::~DebrisActionRenderer()
00056 {
00057         delete debris_;
00058         debris_ = 0;
00059 }
00060 
00061 void DebrisActionRenderer::simulate(float timepassed)
00062 {
00063         rotationAng_ += timepassed * rotationSpeed_;
00064 }
00065 
00066 void DebrisActionRenderer::draw(Vector &actualPos)
00067 {
00068         GLState state(GLState::TEXTURE_OFF | GLState::BLEND_OFF);
00069 
00070         glColor3f(0.3f, 0.4f, 0.3f);
00071         glPushMatrix();
00072                 glTranslatef(actualPos[0], actualPos[1], actualPos[2]);
00073                 glRotatef(rotationAng_, rotationX_, rotationY_, rotationZ_);
00074                 debris_->draw();
00075         glPopMatrix();
00076 }

Generated on Mon Feb 16 15:14:47 2009 for Scorched3D by  doxygen 1.5.3