Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/atmospheric_engine/src/lib/graphics/effects/lightening_effect.cc @ 8056

Last change on this file since 8056 was 8050, checked in by hdavid, 19 years ago

branches/atmospheric_engine: basic lightening effect with billboard works

File size: 3.0 KB
Line 
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 "lightening_effect.h"
16
17#include "state.h"
18#include "util/loading/load_param.h"
19#include "util/loading/factory.h"
20#include "effects/billboard.h"
21
22#include "glincl.h"
23#include "parser/tinyxml/tinyxml.h"
24
25using namespace std;
26
27CREATE_FACTORY(LighteningEffect, CL_LIGHTENING_EFFECT);
28
29LighteningEffect::LighteningEffect(const TiXmlElement* root)
30{
31        this->setClassID(CL_LIGHTENING_EFFECT, "LighteningEffect");
32 
33        this->init();
34
35        if (root != NULL)
36                this->loadParams(root);
37
38        this->activate();
39}
40
41LighteningEffect::~LighteningEffect()
42{
43        this->deactivate();
44}
45
46void LighteningEffect::loadParams(const TiXmlElement* root)
47{
48        WeatherEffect::loadParams(root);
49}
50
51
52bool LighteningEffect::init()
53{
54  this->time = 0.0;
55  this->flashFrequency = 0.6f;
56  this->flashConstTime = 0.07f;
57
58  //this->material = new Material();
59  //this->material->setDiffuseMap("maps/lightning_bolt.png");
60  //this->offset = Vector(-1440.00, 100.00, 280.00);
61
62//  this->billboard->setAbsCoor(50, 0, 0);
63  this->width = 20.0f;
64  this->height = 5.0f;
65  this->bNewCoordinate = false;
66
67  this->seedX = 20.f;
68  this->seedZ = 50.0f;
69  this->seedTime = 4.0f;
70
71  this->billboard = new Billboard(NULL);
72  this->billboard->setTexture("maps/lightning_bolt.png");
73  this->billboard->setSize(this->width, this->height);
74  this->billboard->setAbsCoor(50, 0, 0);
75  this->billboard->setVisibiliy(false);
76  //this->billboard->setAbsCoor(50, 0, 0);
77  //this->billboard->setVisibiliy(true);
78
79/*
80  this->soundSource = NULL;
81  this->thunderBuffer = NULL;
82
83  this->soundSource.setSourceNode(this);
84
85  //load sound
86  if (this->thunderBuffer != NULL)
87    ResourceManager::getInstance()->unload(this->thunderBuffer);
88  this->thunderBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/thunder.wav", WAV);*/
89}
90
91
92bool LighteningEffect::activate()
93{
94        PRINTF(0)( "Activating LighteningEffect\n" );
95
96}
97
98
99bool LighteningEffect::deactivate()
100{
101        PRINTF(0)("Deactivating LighteningEffect\n");
102}
103
104void LighteningEffect::tick (float dt)
105{
106  this->time += dt;
107
108  if( this->time > this->flashFrequency)
109  {
110    this->billboard->setVisibiliy(true);
111    this->time = 0.0f;
112    //this->soundSource.play(this->thunderBuffer);
113  }
114  else if( this->billboard->isVisible() && this->time > this->flashConstTime)
115  {
116    this->billboard->setVisibiliy(false);
117    this->time = 0.0f;
118    this->bNewCoordinate = true;
119  }
120
121  if( this->bNewCoordinate)
122  {
123    //this->flashFrequency = this->seedTime * (float)rand()/(float)RAND_MAX + 0.1;
124    //this->billboard>setAbsCoor( - 800.0f - this->seedX * (float)rand()/(float)RAND_MAX, 250.00, -200.0f + this->seedZ * (float)rand()/(float)RAND_MAX);
125    this->bNewCoordinate = false;
126  }
127}
Note: See TracBrowser for help on using the repository browser.