Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7112 in orxonox.OLD for trunk


Ignore:
Timestamp:
Feb 8, 2006, 1:53:01 AM (19 years ago)
Author:
patrick
Message:

trunk: working thunder

Location:
trunk/src/world_entities/effects
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/effects/lightning_bolt.cc

    r7111 r7112  
    2020#include "material.h"
    2121
     22#include "resource_manager.h"
     23
     24
     25
    2226using namespace std;
    2327
     
    3741  this->time = 0.0;
    3842  this->flashFrequency = 0.6f;
    39   this->flashConstTime = 0.1f;
     43  this->flashConstTime = 0.07f;
    4044
    4145  this->material = new Material();
    4246  this->material->setDiffuseMap("maps/lightning_bolt.png");
    43   this->offset = Vector(-1440.00, 100.00, 280.00);
     47  //this->offset = Vector(-1440.00, 100.00, 280.00);
    4448
    4549  this->setAbsCoor(offset);
    4650  this->width = 100.0f;
    4751  this->height = 300.0f;
     52  this->bNewCoordinate = false;
     53
     54  this->seedX = 200.f;
     55  this->seedZ = 500.0f;
     56  this->seedTime = 2.0f;
     57
     58  this->soundSource.setSourceNode(this);
     59
     60  //load sound
     61  if (this->thunderBuffer != NULL)
     62    ResourceManager::getInstance()->unload(this->thunderBuffer);
     63  this->thunderBuffer = (SoundBuffer*)ResourceManager::getInstance()->load("sound/thunder.wav", WAV);
    4864}
    4965
     
    7389void LightningBolt::tick (float dt)
    7490{
    75 
    76 
    77 
    78 
    7991  this->time += dt;
    80   PRINTF(0)("time: %f, bRender: %i\n", this->time, this->bRender);
    8192
    8293  if( this->time > this->flashFrequency)
     
    8495    this->bRender = true;
    8596    this->time = 0.0f;
     97    this->soundSource.play(this->thunderBuffer);
    8698  }
    8799  else if( this->bRender && this->time > this->flashConstTime)
    88100  {
    89101    this->bRender = false;
    90     this->time = 0.0;
     102    this->time = 0.0f;
     103    this->bNewCoordinate = true;
    91104  }
    92   else
     105
     106  if( this->bNewCoordinate)
    93107  {
     108    this->flashFrequency = this->seedTime * (float)rand()/(float)RAND_MAX + 0.1;
     109    this->setAbsCoor( - 800.0f - this->seedX * (float)rand()/(float)RAND_MAX, 250.00, -200.0f + this->seedZ * (float)rand()/(float)RAND_MAX);
    94110
     111    PRINTF(0)("timeout: %f\n", this->flashFrequency);
     112    this->getAbsCoor().debug();
     113
     114    this->bNewCoordinate = false;
    95115  }
    96116}
     
    101121  if( this->bRender)
    102122  {
    103     PRINTF(0)("draw\n");
    104123
    105124    glPushMatrix();
     
    108127                  this->getAbsCoor ().z);
    109128
    110 //     glRotatef(axis, 0.0f, 1.0f, 0.0f);
     129    glRotatef(90, 0.0f,1.0f,0.0f);
     130
     131//     Vector tmpRot = drawPart->orientation.getSpacialAxis();
     132//     glRotatef (drawPart->orientation.getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
    111133
    112134//     glPushAttrib(GL_ENABLE_BIT);
  • trunk/src/world_entities/effects/lightning_bolt.h

    r7111 r7112  
    88
    99#include "world_entity.h"
     10
     11#include "sound_buffer.h"
     12#include "sound_source.h"
    1013
    1114class Material;
     
    3235
    3336    bool  bRender;
     37    bool  bNewCoordinate;
    3438    Material*      material;
    3539    Vector         offset;
    3640    float width;
    3741    float height;
     42
     43    float seedX;
     44    float seedZ;
     45    float seedTime;
     46
     47    SoundSource    soundSource;
     48    SoundBuffer*   thunderBuffer;
    3849};
    3950
Note: See TracChangeset for help on using the changeset viewer.