Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9320 in orxonox.OLD for branches


Ignore:
Timestamp:
Jul 18, 2006, 11:04:32 AM (18 years ago)
Author:
bensch
Message:

valgrind stuff

Location:
branches/proxy/src
Files:
4 edited

Legend:

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

    r9235 r9320  
    11/*
    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.
     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.
    1010
    1111### File Specific:
    12         main-programmer: hdavid, amaechler
     12        main-programmer: hdavid, amaechler
    1313*/
    1414
     
    3535SHELL_COMMAND(deactivate, SnowEffect, deactivateSnow);
    3636
    37 using namespace std;
    3837
    3938CREATE_SCRIPTABLE_CLASS(SnowEffect, CL_SNOW_EFFECT,
     
    4645SnowEffect::SnowEffect(const TiXmlElement* root)
    4746{
    48         this->setClassID(CL_SNOW_EFFECT, "SnowEffect");
    49 
    50         this->init();
    51 
    52         if (root != NULL)
    53                 this->loadParams(root);
    54 
    55         //load wind sound
    56         if (this->snowWindForce >= 1) {
    57                 if (this->windBuffer != NULL)
    58                         ResourceManager::getInstance()->unload(this->windBuffer);
    59           this->windBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/atmosphere/wind.wav", WAV);
    60         }
     47        this->setClassID(CL_SNOW_EFFECT, "SnowEffect");
     48
     49        this->init();
     50
     51        if (root != NULL)
     52                this->loadParams(root);
     53
     54        this->windBuffer = NULL;
     55        //load wind sound
     56        if (this->snowWindForce >= 1) {
     57          this->windBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/atmosphere/wind.wav", WAV);
     58        }
    6159
    6260  if(snowActivate) {
    63                 this->activate();
     61                this->activate();
    6462    SnowEffect::snowParticles->precache((int) this->snowLife);
    6563  }
     
    6967SnowEffect::~SnowEffect()
    7068{
    71         this->deactivate();
     69        this->deactivate();
    7270}
    7371
     
    7674void SnowEffect::loadParams(const TiXmlElement* root)
    7775{
    78         WeatherEffect::loadParams(root);
    79 
    80         LoadParam(root, "numParticles", this, SnowEffect, numParticles);
    81         LoadParam(root, "materialTexture", this, SnowEffect, materialTexture);
    82         LoadParam(root, "lifeSpans", this, SnowEffect, lifeSpan);
    83         LoadParam(root, "radius", this, SnowEffect, radius);
    84         LoadParam(root, "mass", this, SnowEffect, mass);
    85         LoadParam(root, "emissionRate", this, SnowEffect, emissionRate);
    86         LoadParam(root, "emissionVelocity", this, SnowEffect, emissionVelocity);
    87         LoadParam(root, "wind", this, SnowEffect, wind);
    88         LoadParam(root, "size", this, SnowEffect, size);
    89         LoadParam(root, "coord", this, SnowEffect, coord);
     76        WeatherEffect::loadParams(root);
     77
     78        LoadParam(root, "numParticles", this, SnowEffect, numParticles);
     79        LoadParam(root, "materialTexture", this, SnowEffect, materialTexture);
     80        LoadParam(root, "lifeSpans", this, SnowEffect, lifeSpan);
     81        LoadParam(root, "radius", this, SnowEffect, radius);
     82        LoadParam(root, "mass", this, SnowEffect, mass);
     83        LoadParam(root, "emissionRate", this, SnowEffect, emissionRate);
     84        LoadParam(root, "emissionVelocity", this, SnowEffect, emissionVelocity);
     85        LoadParam(root, "wind", this, SnowEffect, wind);
     86        LoadParam(root, "size", this, SnowEffect, size);
     87        LoadParam(root, "coord", this, SnowEffect, coord);
    9088  LoadParam(root, "cloudcolor", this, SnowEffect, setCloudColor);
    9189  LoadParam(root, "skycolor", this, SnowEffect, setSkyColor);
    9290  LoadParam(root, "fadetime", this, SnowEffect, setFadeTime);
    9391
    94         LOAD_PARAM_START_CYCLE(root, element);
    95         {
    96                 LoadParam_CYCLE(element, "option", this, SnowEffect, setSnowOption);
    97         }
    98         LOAD_PARAM_END_CYCLE(element);
     92        LOAD_PARAM_START_CYCLE(root, element);
     93        {
     94                LoadParam_CYCLE(element, "option", this, SnowEffect, setSnowOption);
     95        }
     96        LOAD_PARAM_END_CYCLE(element);
    9997}
    10098
    10199void SnowEffect::init()
    102100{
    103         this->emitter = new PlaneEmitter();
    104 
    105         // Default values
    106         this->snowActivate = false;
    107         this->snowMove = false;
    108         this->particles = 12000;
    109         this->texture = "maps/snow_flake_01_32x32.png";
    110         this->snowLife = 8;
    111         this->randomLife = 2;
    112         this->snowRadius = 3.5;
    113         this->randomRadius = 1;
    114         this->snowMass = 1.0;
    115         this->randomMass = 0.3;
    116         this->rate = 900;
    117         this->velocity = -100;
    118         this->randomVelocity = 5;
    119         this->angle = 0.5;
    120         this->randomAngle = 0.2;
    121         this->alpha = 0.5;
    122         this->snowSize = Vector2D(2500, 2500);
    123         this->snowCoord = Vector(100,450,400);
    124         this->snowWindForce = 1;
    125  
     101        this->emitter = new PlaneEmitter();
     102
     103        // Default values
     104        this->snowActivate = false;
     105        this->snowMove = false;
     106        this->particles = 12000;
     107        this->texture = "maps/snow_flake_01_32x32.png";
     108        this->snowLife = 8;
     109        this->randomLife = 2;
     110        this->snowRadius = 3.5;
     111        this->randomRadius = 1;
     112        this->snowMass = 1.0;
     113        this->randomMass = 0.3;
     114        this->rate = 900;
     115        this->velocity = -100;
     116        this->randomVelocity = 5;
     117        this->angle = 0.5;
     118        this->randomAngle = 0.2;
     119        this->alpha = 0.5;
     120        this->snowSize = Vector2D(2500, 2500);
     121        this->snowCoord = Vector(100,450,400);
     122        this->snowWindForce = 1;
     123
    126124  this->fadeTime = 10;
    127125  this->cloudColor = Vector(0.2f, 0.2f, 0.2f);
     
    131129void SnowEffect::activate()
    132130{
    133         PRINTF(3)("Activating SnowEffect\n");
    134 
    135         this->snowActivate = true;
    136 
    137         SnowEffect::snowParticles = new SpriteParticles(particles);
    138         SnowEffect::snowParticles->setName("SnowEffectTrailParticles");
    139         SnowEffect::snowParticles->setMaterialTexture(texture);
    140         SnowEffect::snowParticles->setLifeSpan(snowLife, randomLife);
    141         SnowEffect::snowParticles->setRadius(0.0, snowRadius, randomRadius);
    142         SnowEffect::snowParticles->setRadius(0.2, snowRadius, randomRadius*0.8);
    143         SnowEffect::snowParticles->setRadius(1.0, snowRadius, randomRadius*0.5);
    144         SnowEffect::snowParticles->setMass(0, snowMass, randomMass);
    145         SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
    146         SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
    147         SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0);
    148 
    149         this->emitter->setSystem(SnowEffect::snowParticles);
    150 
    151         this->emitter->setRelCoor(snowCoord);
    152         this->emitter->setEmissionRate(rate);
    153         this->emitter->setEmissionVelocity(velocity, randomVelocity);
    154         this->emitter->setSpread(angle * this->snowWindForce , randomAngle * this->snowWindForce);
    155         this->emitter->setSize(snowSize);
     131        PRINTF(3)("Activating SnowEffect\n");
     132
     133        this->snowActivate = true;
     134
     135        SnowEffect::snowParticles = new SpriteParticles(particles);
     136        SnowEffect::snowParticles->setName("SnowEffectTrailParticles");
     137        SnowEffect::snowParticles->setMaterialTexture(texture);
     138        SnowEffect::snowParticles->setLifeSpan(snowLife, randomLife);
     139        SnowEffect::snowParticles->setRadius(0.0, snowRadius, randomRadius);
     140        SnowEffect::snowParticles->setRadius(0.2, snowRadius, randomRadius*0.8);
     141        SnowEffect::snowParticles->setRadius(1.0, snowRadius, randomRadius*0.5);
     142        SnowEffect::snowParticles->setMass(0, snowMass, randomMass);
     143        SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
     144        SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
     145        SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0);
     146
     147        this->emitter->setSystem(SnowEffect::snowParticles);
     148
     149        this->emitter->setRelCoor(snowCoord);
     150        this->emitter->setEmissionRate(rate);
     151        this->emitter->setEmissionVelocity(velocity, randomVelocity);
     152        this->emitter->setSpread(angle * this->snowWindForce , randomAngle * this->snowWindForce);
     153        this->emitter->setSize(snowSize);
    156154
    157155  if (this->snowWindForce != 0)
    158156    this->soundSource.play(this->windBuffer, 0.1f * this->snowWindForce, true);
    159  
     157
    160158  // Store cloud- and sky color before the snow
    161159  this->oldCloudColor = CloudEffect::cloudColor;
     
    171169void SnowEffect::deactivate()
    172170{
    173         PRINTF(3)("Deactivating SnowEffect\n");
    174 
    175         this->snowActivate = false;
    176         this->emitter->setSystem(NULL);
    177 
    178         if (this->windBuffer != NULL)
    179                 ResourceManager::getInstance()->unload(this->windBuffer);
    180  
     171        PRINTF(3)("Deactivating SnowEffect\n");
     172
     173        this->snowActivate = false;
     174        this->emitter->setSystem(NULL);
     175
     176        if (this->windBuffer != NULL)
     177                ResourceManager::getInstance()->unload(this->windBuffer);
     178
    181179  // Restore the old cloud- and sky color
    182180  CloudEffect::changeCloudColor(this->oldCloudColor, this->fadeTime);
     
    186184void SnowEffect::draw() const
    187185{
    188         if (!this->snowActivate)
    189                 return;
     186        if (!this->snowActivate)
     187                return;
    190188}
    191189
    192190void SnowEffect::tick(float dt)
    193191{
    194         if (!this->snowActivate)
    195                 return;
    196 
    197         /*
    198         float distance = (State::getCameraNode()->getAbsCoor() - Vector(snowCoord.x, State::getCameraNode()->getAbsCoor().y, snowCoord.z)).len();
    199 
    200         if(activated)
    201         {
    202         if(distance > 0.3*snowSize.x || distance > 0.3*snowSize.y)
    203                         this->deactivate();
    204         else if(distance > 0.25*snowSize.x || distance > 0.25*snowSize.y)
    205         this->alpha = 0.15;
    206         else if(distance > 0.2*snowSize.x || distance > 0.2*snowSize.y)
    207         this->alpha = 0.25;
    208         else if(distance > 0.1*snowSize.x || distance > 0.1*snowSize.y)
    209         this->alpha = 0.4;
    210 
    211         SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
    212         SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
    213         SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0);
    214         }
    215         else
    216         {
    217         if(distance < 0.3*snowSize.x || distance < 0.3*snowSize.y )
    218         this->activate();
    219         if( distance < 0.25*snowSize.x || distance < 0.25*snowSize.y )
    220         this->alpha = 0.25;
    221         else if( distance < 0.2*snowSize.x || distance < 0.2*snowSize.y )
    222         this->alpha = 0.4;
    223         else if( distance < 0.1*snowSize.x || distance < 0.1*snowSize.y )
    224         this->alpha = 0.5;
    225 
    226         SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
    227         SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
    228         SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0);
    229         }*/
    230 
    231         if (this->snowMove) {
    232                 this->snowCoord = State::getCameraNode()->getAbsCoor();
    233                 this->emitter->setRelCoor(this->snowCoord.x , this->snowCoord.y+300, this->snowCoord.z);
    234         }
    235 }
     192        if (!this->snowActivate)
     193                return;
     194
     195        /*
     196        float distance = (State::getCameraNode()->getAbsCoor() - Vector(snowCoord.x, State::getCameraNode()->getAbsCoor().y, snowCoord.z)).len();
     197
     198        if(activated)
     199        {
     200        if(distance > 0.3*snowSize.x || distance > 0.3*snowSize.y)
     201                        this->deactivate();
     202        else if(distance > 0.25*snowSize.x || distance > 0.25*snowSize.y)
     203        this->alpha = 0.15;
     204        else if(distance > 0.2*snowSize.x || distance > 0.2*snowSize.y)
     205        this->alpha = 0.25;
     206        else if(distance > 0.1*snowSize.x || distance > 0.1*snowSize.y)
     207        this->alpha = 0.4;
     208
     209        SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
     210        SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
     211        SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0);
     212        }
     213        else
     214        {
     215        if(distance < 0.3*snowSize.x || distance < 0.3*snowSize.y )
     216        this->activate();
     217        if( distance < 0.25*snowSize.x || distance < 0.25*snowSize.y )
     218        this->alpha = 0.25;
     219        else if( distance < 0.2*snowSize.x || distance < 0.2*snowSize.y )
     220        this->alpha = 0.4;
     221        else if( distance < 0.1*snowSize.x || distance < 0.1*snowSize.y )
     222        this->alpha = 0.5;
     223
     224        SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
     225        SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
     226        SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0);
     227        }*/
     228
     229        if (this->snowMove) {
     230                this->snowCoord = State::getCameraNode()->getAbsCoor();
     231                this->emitter->setRelCoor(this->snowCoord.x , this->snowCoord.y+300, this->snowCoord.z);
     232        }
     233}
  • branches/proxy/src/lib/graphics/effects/snow_effect.h

    r9235 r9320  
    101101
    102102private:
    103     int         particles;
     103    int               particles;
    104104    std::string       texture;
    105     float       snowLife, randomLife;
    106     float       snowRadius, randomRadius;
    107     float       snowMass, randomMass;
    108     float         rate;
    109     float         velocity, randomVelocity;
    110     float         angle, randomAngle;
    111     float         alpha;
    112     float         fadeTime;
    113     Vector        snowCoord;
    114     Vector2D      snowSize;
    115     int       snowWindForce;
     105    float             snowLife, randomLife;
     106    float             snowRadius, randomRadius;
     107    float             snowMass, randomMass;
     108    float             rate;
     109    float             velocity, randomVelocity;
     110    float             angle, randomAngle;
     111    float             alpha;
     112    float             fadeTime;
     113    Vector            snowCoord;
     114    Vector2D          snowSize;
     115    int               snowWindForce;
    116116
    117     bool        snowMove;
    118     bool        snowActivate;
     117    bool              snowMove;
     118    bool              snowActivate;
    119119
    120120    PlaneEmitter*     emitter;
    121121
    122122    static SpriteParticles*   snowParticles;
    123     OrxSound::SoundSource   soundSource;
     123    OrxSound::SoundSource     soundSource;
    124124    OrxSound::SoundBuffer*    windBuffer;
    125125
    126     Vector oldSkyColor;
    127     Vector oldCloudColor;
    128     Vector skyColor;
    129     Vector cloudColor;
     126    Vector            oldSkyColor;
     127    Vector            oldCloudColor;
     128    Vector            skyColor;
     129    Vector            cloudColor;
    130130};
    131131
  • branches/proxy/src/subprojects/recapture_mouse/Makefile.am

    r9317 r9320  
    2727
    2828recapturemouse_SOURCES= \
    29                 ../framework.cc \
    30                 recapturer.cc \
    31                 $(MAINSRCDIR)/world_entities/space_ships/space_ship.cc \
    32                 $(MAINSRCDIR)/world_entities/weapons/test_gun.cc
    33 
     29                recapturer.cc
  • branches/proxy/src/subprojects/recapture_mouse/recapturer.cc

    r9318 r9320  
    1616*/
    1717
    18 #include "framework.h"
     18#include "event_handler.h"
    1919
    20 #include "light.h"
     20int verbose = 3;
    2121
    22 #include "objModel.h"
    23 #include "md2/md2Model.h"
    24 #include "primitive_model.h"
    25 #include <stdlib.h>
    26 
    27 #include "vertex_array_model.h"
    28 
    29 #include "util/loading/resource_manager.h"
    30 
    31 Model* obj;
    32 
    33 void Framework::moduleInit(int argc, char** argv)
     22int main(int argc, char** argv)
    3423{
    35   ResourceManager::getInstance()->addImageDir("./");
    36 
    37   for (int i = 0; i < argc; i++)
    38   {
    39     printf("%s\n", argv[i]);
    40   }
    41   ResourceManager::getInstance()->addImageDir("");
    42 
    43 
    44   if (argc>=3)
    45   {
    46     if( strstr(argv[1], ".obj") != NULL)
    47       obj = new OBJModel (argv[1], atof(argv[2]));
    48     else if( strstr(argv[1], ".md2") != NULL)
    49     {
    50       obj = new MD2Model(argv[1], argv[2]);
    51       ((MD2Model*)obj)->tick(0.1f);
    52     }
    53   }
    54   else if (argc>=2)
    55   {
    56     if( strstr(argv[1], ".obj") != NULL)
    57       obj = new OBJModel(argv[1]);
    58     else if( strstr(argv[1], ".md2") != NULL) {
    59       obj = new MD2Model(argv[1], "fake_texture.bad");
    60       obj = new MD2Model(argv[1], argv[2]);
    61       ((MD2Model*)obj)->tick(0.1f);
    62     }
    63   }
    64  // else
    65     obj = new PrimitiveModel(PRIM_CYLINDER);
    66 
    67 
    68   ResourceManager::getInstance()->debug();
    69 
    70   LightManager* lightMan = LightManager::getInstance();
    71   lightMan->setAmbientColor(.1,.1,.1);
    72   (new Light())->setAbsCoor(5.0, 10.0, 40.0);
    73   (new Light())->setAbsCoor(-10, -20, -100);
     24  EventHandler::getInstance()->grabEvents(true);
     25  EventHandler::getInstance()->grabEvents(false);
     26  exit(-1);
    7427}
    75 
    76 void Framework::moduleEventHandler(SDL_Event* event)
    77 {
    78   switch (event->type)
    79     {
    80     case SDL_KEYDOWN:
    81       switch (event->key.keysym.sym)
    82         {
    83         case SDLK_i:
    84           break;
    85         }
    86     }
    87 }
    88 
    89 void Framework::moduleTick(float dt)
    90 {
    91 
    92 }
    93 
    94 void Framework::moduleDraw(void) const
    95 {
    96   LightManager::getInstance()->draw();
    97   obj->draw();
    98 
    99 }
    100 
    101 
    102 void Framework::moduleHelp(void) const
    103 {
    104 
    105 }
Note: See TracChangeset for help on using the changeset viewer.