/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program 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, or (at your option) any later version. ### File Specific: main-programmer: hdavid, amaechler */ #include "rain_effect.h" #include "util/loading/load_param.h" #include "util/loading/factory.h" #include "glincl.h" using namespace std; CREATE_FACTORY(RainEffect, CL_RAIN_EFFECT); RainEffect::RainEffect(const TiXmlElement* root) { this->setClassID(CL_RAIN_EFFECT, "RainEffect"); // this->rainMode = GL_LINEAR; // this->rainDensity = 0.001f; // this->rainStart = 10.0f; // this->rainEnd = 1000.0f; if (root != NULL) this->loadParams(root); this->activate(); } RainEffect::~RainEffect() { this->deactivate(); } void RainEffect::loadParams(const TiXmlElement* root) { WeatherEffect::loadParams(root); // LoadParam(root, "rain-mode", this, RainEffect, setRainMode); // LoadParam(root, "rain-density", this, RainEffect, setRainDensity); // LoadParam(root, "rain-color", this, RainEffect, setRainColor); } bool RainEffect::init() {} bool RainEffect::activate() { // PRINTF(0)( "Enabling Rain Effect, mode: %i, density: %f, start: %f, end: %f, color %f, %f, %f\n", this->rainMode, this->rainDensity, this->rainStart, this->rainEnd, this->colorVector.x, this->colorVector.y, this->colorVector.z); // // glEnable(GL_RAIN); // { // //GLfloat rainColor[4] = {0.7, 0.6, 0.6, 1.0}; // GLfloat rainColor[4] = { colorVector.x, colorVector.y, colorVector.z, 1.0}; // // glRaini(GL_RAIN_MODE, this->rainMode); // glRainfv(GL_RAIN_COLOR, rainColor); // glRainf(GL_RAIN_DENSITY, this->rainDensity); // glHint(GL_RAIN_HINT, GL_DONT_CARE); // glRainf(GL_RAIN_START, this->rainStart); // glRainf(GL_RAIN_END, this->rainEnd); // // //glRaini(GL_RAIN_COORDINATE_SOURCE, GL_RAIN_COORDINATE); // } // glClearColor(0.5, 0.5, 0.5, 1.0); } bool RainEffect::deactivate() { PRINTF(0)("Deactivating Rain Effect\n"); // glDisable(GL_RAIN); } void RainEffect::draw() { Particle* drawPart = particles; glDepthMask(GL_FALSE); glPushAttrib(GL_ENABLE_BIT); glDisable(GL_LIGHTING); glDisable(GL_TEXTURE_2D); glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA); glLineWidth(2.0); glBegin(GL_LINES); while (likely(drawPart != NULL)) { // printf("%f %f %f %f\n", drawPart->color[0], drawPart->color[1], drawPart->color[2], drawPart->color[3]); glColor4fv(drawPart->color); glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z); glVertex3f(drawPart->position.x - drawPart->velocity.x * drawPart->radius, drawPart->position.y - drawPart->velocity.y * drawPart->radius, drawPart->position.z - drawPart->velocity.z * drawPart->radius); drawPart = drawPart->next; } glEnd(); glDepthMask(GL_TRUE); glPopAttrib(); }