Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8079 in orxonox.OLD


Ignore:
Timestamp:
Jun 1, 2006, 4:15:34 PM (18 years ago)
Author:
amaechler
Message:

branches/atmospheric_engine: cloud hacking

Location:
branches/atmospheric_engine/src
Files:
3 edited

Legend:

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

    r8056 r8079  
    1111### File Specific:
    1212        main-programmer: hdavid, amaechler
     13        Taken from SkySphere
    1314*/
    1415
    15 // TODO: Vektortextur erzeugen und Regionen auswählen, Sky...
     16// TODO: Vektortextur erzeugen und Regionen auswaehlen, Sky...
    1617
    1718#include "cloud_effect.h"
     
    2122
    2223#include "glincl.h"
    23 //#include "graphics_engine.h"
    2424#include "material.h"
    2525#include <math.h>
    2626#include "material.h"
     27#include "state.h"
     28#include "p_node.h"
    2729
    2830#include "parser/tinyxml/tinyxml.h"
     
    4749{
    4850        this->deactivate();
     51
     52        //delete this->skyMaterial;
     53        //gluDeleteQuadric(this->sphereObj);
    4954}
     55
     56
     57bool CloudEffect::init()
     58{
     59  PRINTF(1)("Initializing CloudEffect\n");
     60
     61  this->sphereObj = gluNewQuadric();
     62  //this->setParentMode(PNODE_MOVEMENT);
     63
     64  gluQuadricTexture(this->sphereObj, GL_TRUE);
     65  this->setRadius(2000.0);
     66
     67  mover = 0.0f;
     68
     69  // Initializing default values
     70  this->cloudSpeed = 2.0f;
     71        this->cloudTexture = "pictures/sky/cloud1.jpg";
     72}
     73
    5074
    5175void CloudEffect::loadParams(const TiXmlElement* root)
     
    5377        WeatherEffect::loadParams(root);
    5478
    55         LoadParam(root, "animSpeed", this, CloudEffect, setCloudAnimation);
    56 
     79        LoadParam(root, "speed", this, CloudEffect, setCloudAnimation);
     80        LoadParam(root, "texture", this, CloudEffect, setCloudTexture);
    5781}
    5882
    5983
    60 bool CloudEffect::init()
    61 {
    62         // default values
    63         this->cloudAnimTimeStep = 0;
    64 
    65         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    66         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    67         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    68         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    69 
    70         glGenTextures(2, &texID[0]);
    71 
    72         // Generate noise map a
    73         //CloudEffect::genNoiseMap(cloudMap32_a);
    74        
    75         if (this->cloudAnimTimeStep > 0) {
    76                 // Generate noise map b
    77                 //CloudEffect::genNoiseMap(cloudMap32_b);
    78         }
    79 
    80   this->material = new Material();
    81 
    82 }
    83 
    8484bool CloudEffect::activate()
    8585{
    86         PRINTF(0)( "Activating CloudEffect\n");
     86        PRINTF(0)( "Activating CloudEffect with Material %s\n", this->cloudTexture.c_str());
    8787
     88        this->cloudMaterial = new Material("Sky");
     89  // this->setTexture(this->cloudTexture);
     90  this->cloudMaterial->setIllum(3);
     91  this->cloudMaterial->setAmbient(1.0, 1.0, 1.0);
     92
     93  this->cloudMaterial->setDiffuseMap(this->cloudTexture);
    8894
    8995}
     
    103109        */
    104110
    105         // glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     111  glMatrixMode(GL_MODELVIEW);
     112  glPushMatrix();
    106113
    107   this->material->setDiffuseMap("maps/lightning_bolt.png");
    108   this->material->select();
     114  // Move sphere along with the camera
     115  Vector r = State::getCameraNode()->getAbsCoor();
     116  glTranslatef(r.x, r.y, r.z);
    109117
    110         glPushMatrix();
    111         // glEnable(GL_TEXTURE_2D);
     118        // Sky movement
     119        glRotatef(mover, 1, 0, 0);
    112120
    113         // glBindTexture(GL_TEXTURE_2D, texID[0]);
    114         PRINTF(0)("Draw tralala\n");
    115 
    116         // FIXME : Bind this to the sky - how do I do this?
    117         glBegin(GL_QUADS);
    118                 glTexCoord2f(0.0f, 0.0f);
    119                 glVertex3f(20, 20,  60);        // Bottom Left Of The Texture and Quad
    120 
    121                 glTexCoord2f(1.0f, 0.0f);
    122                 glVertex3f(60, 20,  60);        // Bottom Right Of The Texture and Quad
    123 
    124                 glTexCoord2f(1.0f, 1.0f);
    125                 glVertex3f(60, 60,  60);        // Top Right Of The Texture and Quad
    126 
    127                 glTexCoord2f(0.0f, 1.0f);
    128                 glVertex3f(20, 60,  60);        // Top Left Of The Texture and Quad
    129         glEnd();
    130 
     121  cloudMaterial->select();
     122  gluSphere(this->sphereObj, this->sphereRadius, 20, 20);
    131123  glPopMatrix();
    132 
    133124}
    134125
    135126void CloudEffect::tick (float dt)
    136127{
    137        
     128  mover = mover + this->cloudSpeed * dt;
    138129}
     130
     131
     132/**
     133 *  sets the Radius of the Sphere.
     134 * @param radius The Radius of The Sphere
     135*/
     136void CloudEffect::setRadius(float radius)
     137{
     138  this->sphereRadius = radius;
     139}
     140
     141
  • branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.h

    r8052 r8079  
    66#define _CLOUD_EFFECT
    77
    8 #include "vector.h"
    9 #include "vector2D.h"
    10 
    118#include "weather_effect.h"
    129
     
    1411#include "sound_source.h"
    1512
     13#include "world_entity.h"
     14#include "glincl.h"
     15
    1616class Material;
    17 
     17class Vector;
    1818
    1919class CloudEffect : public WeatherEffect
     
    3333                virtual void tick(float dt);
    3434
    35                 inline void setCloudAnimation(float timestep) { this->cloudAnimTimeStep = timestep; }
     35                void setRadius(float radius);
     36                void setTexture(char* fileName);
     37
    3638
    3739        private:
    38                 // Basic noise maps 32x32
    39                 float                                                                                                           cloudMap32_a[32 * 32];
    40                 float                                                                                                           cloudMap32_b[32 * 32];
    41                 float                                                                                                           cloudMap32_c[32 * 32];
     40                void initialize(char* fileName);
    4241
    43                 // The cloud map 256x256
    44                 float                                                                                                           cloudMap256[256 * 256];
     42                GLUquadricObj*                  sphereObj;                                                      // A Placeholder for the SkySphere.
     43                Material*                                               cloudMaterial;                                  // A Material for the SkySphere.
     44                float                                                           sphereRadius;                                           // Radius of the SkySphere.
     45                float                                                   mover;
     46                float                                                           cloudSpeed;
     47                std::string                             cloudTexture;
    4548
    46                 // Temporary array to hold texture RGB values
    47                 char                                                                                                                    cloudTexture[256][256][3];
    48 
    49                 GLuint                                                                                                          texID[2];
    50                 float                                                                                                           timer;
    51 
    52                 bool                                                                                                                    cloudAnimTimeStep;
    53 
    54                 float                                                                                                           noise(int x, int y, int random);
    55                 float                                                                                                           interpolate(float x, float y, float  *map);
    56                 void                                                                                                            overlapOctaves();
    57                 void                                                                                                            expFilter();
    58 
    59                 void                                                                                                            genNoiseMap(float  *map);
    60                 void                                                                                                            genCloudTexture();
    61                 void                                                                                                            calcAnimMap(float timer);
    62                 Material*       material;
     49                inline void setCloudTexture(const std::string& file) { this->cloudTexture = file; }
     50                inline void setCloudAnimation(float speed) { this->cloudSpeed = speed; }
    6351
    6452};
  • branches/atmospheric_engine/src/world_entities/space_ships/helicopter.cc

    r7810 r8079  
    217217  State::getCameraTargetNode()->setParentSoft(this->getWeaponManager().getFixedTarget());
    218218
    219   this->soundSource.loop(this->chopperBuffer);
     219  this->soundSource.loop(this->chopperBuffer, 0.8f);
    220220  // PRINTF(0)( "Playing ChopperSound\n" );
    221221}
Note: See TracChangeset for help on using the changeset viewer.