Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7951 in orxonox.OLD for branches/atmospheric_engine/src


Ignore:
Timestamp:
May 29, 2006, 1:29:35 PM (18 years ago)
Author:
hdavid
Message:

branches/atmospheric_engine: work on the billboard

Location:
branches/atmospheric_engine/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/atmospheric_engine/src/lib/graphics/effects/atmospheric_engine.cc

    r7836 r7951  
    127127    for (it = weatherEffects->begin(); it != weatherEffects->end(); it++)
    128128    {
    129       printf("%s::%s \n", (*it)->getClassName(), (*it)->getName());
     129      //printf("%s::%s \n", (*it)->getClassName(), (*it)->getName());
    130130      dynamic_cast<WeatherEffect*>(*it)->tick(dt);
    131131    }
  • branches/atmospheric_engine/src/lib/graphics/effects/lightening_effect.cc

    r7810 r7951  
    1818#include "util/loading/load_param.h"
    1919#include "util/loading/factory.h"
    20 #include "render2D/image_plane.h"
     20#include "effects/billboard.h"
    2121
    2222#include "glincl.h"
     
    3232 
    3333 
    34   lightening = new ImagePlane(NULL);
    35   lightening->setTexture("maps/lightning_bolt.png");
    36   lightening->setSize(50, 50);
    37   lightening->setAbsCoor2D(10,10);
    38   lightening->setVisibility(true);
     34  billboard = new Billboard(NULL);
     35  billboard->setTexture("maps/lightning_bolt.png");
     36  //billboard->setSize(50, 50);
     37  //billboard->setAbsCoor2D(10,10);
     38  //billboard->setVisibility(true);
    3939 
    4040 
     
    5050{
    5151        this->deactivate();
    52   delete lightening;
     52  delete billboard;
    5353}
    5454
  • branches/atmospheric_engine/src/lib/graphics/effects/lightening_effect.h

    r7810 r7951  
    1515
    1616
    17 class ImagePlane;
     17class Billboard;
    1818
    1919class LighteningEffect : public WeatherEffect
     
    3333
    3434        private:
    35     ImagePlane* lightening;
     35    Billboard* billboard;
    3636
    3737};
  • branches/atmospheric_engine/src/world_entities/Makefile.am

    r7155 r7951  
    2828                \
    2929                \
    30                 effects/explosion.cc
     30                effects/explosion.cc \
     31                effects/billboard.cc
    3132
    3233
     
    5657                \
    5758                effects/explosion.h \
     59                effects/billboard.h \
    5860                \
    5961                $(WorldEntities_HEADERS_)
  • branches/atmospheric_engine/src/world_entities/effects/billboard.cc

    r7810 r7951  
    22   orxonox - the future of 3D-vertical-scrollers
    33
    4    Copyright (C) 2004 orx
     4   Copyright (C) 2006 orx
    55
    66   This program is free software; you can redistribute it and/or modify
     
    99   any later version.
    1010
    11    ### File Specific
    12    main-programmer: Patrick Boenzli
     11### File Specific:
     12   main-programmer: David Hasenfratz
    1313*/
    14 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
    1514
     15#include "billboard.h"
    1616
    17 #include "lightning_bolt.h"
     17#include "util/loading/load_param.h"
     18#include "util/loading/factory.h"
    1819
    19 #include "util/loading/factory.h"
     20#include "graphics_engine.h"
    2021#include "material.h"
    21 
    22 #include "util/loading/resource_manager.h"
    23 
     22#include "glincl.h"
     23#include "state.h"
    2424
    2525
    2626using namespace std;
    2727
    28 CREATE_FACTORY(LightningBolt, CL_LIGHTNING_BOLT);
     28
     29CREATE_FACTORY(Billboard, CL_BILLBOARD);
    2930
    3031
    3132/**
    32  *  standard constructor
    33 */
    34 LightningBolt::LightningBolt (const TiXmlElement* root)
     33 * standart constructor
     34 */
     35Billboard::Billboard (const TiXmlElement* root)
    3536{
    36   this->setClassID(CL_LIGHTNING_BOLT, "LightningBolt");
     37  this->init();
    3738
    38   this->toList(OM_COMMON);
    39 
    40   this->bRender = false;
    41   this->time = 0.0;
    42   this->flashFrequency = 0.6f;
    43   this->flashConstTime = 0.07f;
    44 
    45   this->material = new Material();
    46   this->material->setDiffuseMap("maps/lightning_bolt.png");
    47   //this->offset = Vector(-1440.00, 100.00, 280.00);
    48 
    49   this->setAbsCoor(offset);
    50   this->width = 100.0f;
    51   this->height = 300.0f;
    52   this->bNewCoordinate = false;
    53 
    54   this->seedX = 200.f;
    55   this->seedZ = 500.0f;
    56   this->seedTime = 4.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);
     39  if( root)
     40    this->loadParams(root);
    6441}
    6542
    6643
    6744/**
    68  *  standard deconstructor
    69 */
    70 LightningBolt::~LightningBolt ()
     45 * destroys a Billboard
     46 */
     47Billboard::~Billboard ()
    7148{
    72 }
    73 
    74 void LightningBolt::activate()
    75 {
    76 }
    77 
    78 
    79 void LightningBolt::deactivate()
    80 {
    81 
     49  if (this->material)
     50    delete this->material;
    8251}
    8352
    8453
    8554/**
    86  *  signal tick, time dependent things will be handled here
    87  * @param time since last tick
    88 */
    89 void LightningBolt::tick (float dt)
     55 * initializes the Billboard
     56 */
     57void Billboard::init()
    9058{
    91   this->time += dt;
     59  this->setClassID(CL_BILLBOARD, "Billboard");
     60  this->setName("Billboard");
    9261
    93   if( this->time > this->flashFrequency)
    94   {
    95     this->bRender = true;
    96     this->time = 0.0f;
    97     this->soundSource.play(this->thunderBuffer);
    98   }
    99   else if( this->bRender && this->time > this->flashConstTime)
    100   {
    101     this->bRender = false;
    102     this->time = 0.0f;
    103     this->bNewCoordinate = true;
    104   }
    105 
    106   if( this->bNewCoordinate)
    107   {
    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);
    110     this->bNewCoordinate = false;
    111   }
     62  this->material = new Material();
     63  this->setTexture("pictures/error_texture.png");
     64  this->setAbsCoor(0, 0, 0);
     65  this->setVisibiliy(true);
     66  this->setSize(10, 10);
    11267}
    11368
    11469
    115 void LightningBolt::draw() const
     70/**
     71 *  load params
     72 * @param root TiXmlElement object
     73 */
     74void Billboard::loadParams(const TiXmlElement* root)
    11675{
    117   if( this->bRender)
    118   {
     76  LoadParam(root, "texture", this->material, Material, setDiffuseMap)
     77      .describe("the texture-file to load onto the Billboard");
    11978
    120     glPushMatrix();
    121     glTranslatef (this->getAbsCoor ().x,
    122                   this->getAbsCoor ().y,
    123                   this->getAbsCoor ().z);
    124 
    125     glRotatef(90, 0.0f,1.0f,0.0f);
    126 
    127 //     Vector tmpRot = drawPart->orientation.getSpacialAxis();
    128 //     glRotatef (drawPart->orientation.getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
    129 
    130 //     glPushAttrib(GL_ENABLE_BIT);
    131 //     glDisable(GL_LIGHTING);
    132 //     glDisable(GL_BLEND);
    133 
    134     this->material->select();
    135 
    136     glBegin(GL_QUADS);
    137     glTexCoord2f(1.0f, 1.0f); glVertex3f(-width/2, -height/2,  0.0f);
    138     glTexCoord2f(0.0f, 1.0f); glVertex3f( width/2, -height/2,  0.0f);
    139     glTexCoord2f(0.0f, 0.0f); glVertex3f( width/2,  height/2,  0.0f);
    140     glTexCoord2f(1.0f, 0.0f); glVertex3f(-width/2,  height/2,  0.0f);
    141     glEnd();
    142 
    143 //     glPopAttrib();
    144 
    145     glPopMatrix();
    146   }
     79  LoadParam(root, "size", this, Billboard, setSize)
     80      .describe("the size of the Billboard in Pixels");
    14781}
    14882
    14983
     84/**
     85 * sets the size of the Billboard.
     86 * @param size the size in pixels
     87 */
     88void Billboard::setSize(float sizeX, float sizeY)
     89{
     90  this->sizeX = sizeX;
     91  this->sizeY = sizeY;
     92}
     93
     94
     95/**
     96 * sets the material to load
     97 * @param textureFile The texture-file to load
     98 */
     99void Billboard::setTexture(const std::string& textureFile)
     100{
     101  this->material->setDiffuseMap(textureFile);
     102}
     103
     104
     105/**
     106 * ticks the Billboard
     107 * @param dt the time to ticks
     108 */
     109void Billboard::tick(float dt)
     110{/*
     111  float z = 0.0f;
     112  glReadPixels ((int)this->getAbsCoor2D().x,
     113                 GraphicsEngine::getInstance()->getResolutionY()-(int)this->getAbsCoor2D().y-1,
     114                 1,
     115                 1,
     116                 GL_DEPTH_COMPONENT,
     117                 GL_FLOAT,
     118                 &z);
     119
     120  GLdouble objX=.0, objY=.0, objZ=.0;
     121  gluUnProject(this->getAbsCoor2D().x,
     122               GraphicsEngine::getInstance()->getResolutionY()-this->getAbsCoor2D().y-1,
     123               .99,  // z
     124               GraphicsEngine::modMat,
     125               GraphicsEngine::projMat,
     126               GraphicsEngine::viewPort,
     127               &objX,
     128               &objY,
     129  &objZ );*/
     130}
     131
     132
     133/**
     134 * draws the billboard
     135 */
     136void Billboard::draw() const
     137{
     138  if( !this->isVisible())
     139    return;
     140
     141  glPushMatrix();
     142
     143  glTranslatef(this->getAbsCoor().x, this->getAbsCoor().y, this->getAbsCoor().z);
     144  this->material->select();
     145
     146  glBegin(GL_QUADS);
     147  glTexCoord2f(1.0f, 1.0f); glVertex3f(-sizeX/2, -sizeY/2,  0.0f);
     148  glTexCoord2f(0.0f, 1.0f); glVertex3f( sizeX/2, -sizeY/2,  0.0f);
     149  glTexCoord2f(0.0f, 0.0f); glVertex3f( sizeX/2,  sizeY/2,  0.0f);
     150  glTexCoord2f(1.0f, 0.0f); glVertex3f(-sizeX/2,  sizeY/2,  0.0f);
     151  glEnd();
     152
     153  glPopMatrix();
     154}
  • branches/atmospheric_engine/src/world_entities/effects/billboard.h

    r7810 r7951  
    11/*!
    2  * @file lightning_bolt.h
    3  * @brief a LightningBolt Projectile
     2 * @file billboard.h
    43 */
    54
    6 #ifndef _LIGHTNING_BOLT_H
    7 #define _LIGHTNING_BOLT_H
     5#ifndef _BILLBOARD_H
     6#define _BILLBOARD_H
    87
    98#include "world_entity.h"
    109
    11 #include "sound_buffer.h"
    12 #include "sound_source.h"
     10class Material;
     11class TiXmlElement;
    1312
    14 class Material;
    15 
    16 class LightningBolt : public WorldEntity
     13class Billboard : public WorldEntity
    1714{
    1815  public:
    19     LightningBolt(const TiXmlElement* root = NULL);
    20     virtual ~LightningBolt ();
     16    Billboard(const TiXmlElement* root = NULL);
     17    virtual ~Billboard();
    2118
    22     virtual void activate();
    23     virtual void deactivate();
     19    void init();
     20    void loadParams(const TiXmlElement* root);
    2421
    25     virtual void tick(float time);
     22    void setSize(float sizeX, float sizeY);
     23    void setTexture(const std::string& textureFile);
     24
     25    virtual void tick(float dt);
    2626    virtual void draw() const;
    2727
    2828  private:
    29     float flashFrequency;                   //!< frequency to activate itself
    30     float flashRisingTime;                  //!< time to rise
    31     float flashConstTime;                   //!< time to be drawn
    32     float flashFallTime;                    //!< time to fall
    33 
    34     float time;                             //!< time
    35 
    36     bool  bRender;
    37     bool  bNewCoordinate;
    38     Material*      material;
    39     Vector         offset;
    40     float width;
    41     float height;
    42 
    43     float seedX;
    44     float seedZ;
    45     float seedTime;
    46 
    47     SoundSource    soundSource;
    48     SoundBuffer*   thunderBuffer;
     29    Material*        material;
     30    float sizeX;
     31    float sizeY;
    4932};
    5033
    51 #endif /* _LIGHTNING_BOLT_H */
     34#endif /* _BILLBOARD_H */
Note: See TracChangeset for help on using the changeset viewer.