| 1 | /* |
|---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
|---|
| 3 | |
|---|
| 4 | Copyright (C) 2004 orx |
|---|
| 5 | |
|---|
| 6 | This program 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, or (at your option) |
|---|
| 9 | any later version. |
|---|
| 10 | |
|---|
| 11 | ### File Specific: |
|---|
| 12 | main-programmer: hdavid, amaechler |
|---|
| 13 | */ |
|---|
| 14 | |
|---|
| 15 | #include "snow_effect.h" |
|---|
| 16 | |
|---|
| 17 | #include "util/loading/load_param.h" |
|---|
| 18 | #include "util/loading/factory.h" |
|---|
| 19 | |
|---|
| 20 | #include "glincl.h" |
|---|
| 21 | #include "debug.h" |
|---|
| 22 | |
|---|
| 23 | #include "state.h" |
|---|
| 24 | #include "sprite_particles.h" |
|---|
| 25 | #include "plane_emitter.h" |
|---|
| 26 | |
|---|
| 27 | #include "parser/tinyxml/tinyxml.h" |
|---|
| 28 | |
|---|
| 29 | //SHELL_COMMAND(activate, SnowEffect, activateSnow); |
|---|
| 30 | |
|---|
| 31 | using namespace std; |
|---|
| 32 | |
|---|
| 33 | CREATE_FACTORY(SnowEffect, CL_SNOW_EFFECT); |
|---|
| 34 | |
|---|
| 35 | SnowEffect::SnowEffect(const TiXmlElement* root) |
|---|
| 36 | { |
|---|
| 37 | this->setClassID(CL_SNOW_EFFECT, "SnowEffect"); |
|---|
| 38 | |
|---|
| 39 | if (root != NULL) |
|---|
| 40 | this->loadParams(root); |
|---|
| 41 | |
|---|
| 42 | this->init(); |
|---|
| 43 | |
|---|
| 44 | this->activate(); |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | SnowEffect::~SnowEffect() |
|---|
| 49 | { |
|---|
| 50 | this->deactivate(); |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | SpriteParticles* SnowEffect::snowParticles = NULL; |
|---|
| 54 | |
|---|
| 55 | void SnowEffect::loadParams(const TiXmlElement* root) |
|---|
| 56 | { |
|---|
| 57 | WeatherEffect::loadParams(root); |
|---|
| 58 | |
|---|
| 59 | // LoadParam(root, "snow-mode", this, SnowEffect, setSnowMode); |
|---|
| 60 | // LoadParam(root, "snow-density", this, SnowEffect, setSnowDensity); |
|---|
| 61 | // LoadParam(root, "snow-color", this, SnowEffect, setSnowColor); |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 66 | bool SnowEffect::init() |
|---|
| 67 | { |
|---|
| 68 | this->emitter = new PlaneEmitter(); |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | bool SnowEffect::activate() |
|---|
| 74 | { |
|---|
| 75 | PRINTF(0)("Activating Snow Effect\n"); |
|---|
| 76 | |
|---|
| 77 | SnowEffect::snowParticles = new SpriteParticles(10000); |
|---|
| 78 | SnowEffect::snowParticles->setName("SnowEffectTrailParticles"); |
|---|
| 79 | SnowEffect::snowParticles->setMaterialTexture("maps/snow_flake_01_32x32.png"); |
|---|
| 80 | //SnowEffect::snowParticles->setSize(1); |
|---|
| 81 | SnowEffect::snowParticles->setLifeSpan(8, 2); |
|---|
| 82 | SnowEffect::snowParticles->setRadius(0.0, 5.0, 10.0); |
|---|
| 83 | SnowEffect::snowParticles->setRadius(0.2, 5.0, 10); |
|---|
| 84 | SnowEffect::snowParticles->setRadius(1.0, 5.0, 10); |
|---|
| 85 | SnowEffect::snowParticles->setMass(0, 1.0, .3); |
|---|
| 86 | SnowEffect::snowParticles->setColor(0,1, 1, 1,.5); |
|---|
| 87 | SnowEffect::snowParticles->setColor(.5, .6, .6, .6, .2); |
|---|
| 88 | SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0); |
|---|
| 89 | |
|---|
| 90 | |
|---|
| 91 | this->emitter->setSystem(SnowEffect::snowParticles); |
|---|
| 92 | |
|---|
| 93 | // this->updateNode(0); |
|---|
| 94 | this->emitter->setEmissionRate(900); |
|---|
| 95 | this->emitter->setEmissionVelocity(150, 50); |
|---|
| 96 | this->emitter->setSpread(0, .3); |
|---|
| 97 | this->emitter->setSize(1200, 1200); |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | bool SnowEffect::deactivate() |
|---|
| 102 | { |
|---|
| 103 | PRINTF(0)("Deactivating Snow Effect\n"); |
|---|
| 104 | |
|---|
| 105 | this->emitter->setSystem(NULL); |
|---|
| 106 | } |
|---|
| 107 | |
|---|
| 108 | void SnowEffect::draw() const |
|---|
| 109 | { |
|---|
| 110 | } |
|---|
| 111 | |
|---|
| 112 | void SnowEffect::tick(float dt) |
|---|
| 113 | { |
|---|
| 114 | } |
|---|