Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8474 in orxonox.OLD


Ignore:
Timestamp:
Jun 15, 2006, 3:59:39 PM (18 years ago)
Author:
hdavid
Message:

branches/atmospheric_engine: cloud effect

Location:
branches/atmospheric_engine/src/lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/atmospheric_engine/src/lib/collision_reaction/collision_handle.cc

    r8190 r8474  
    9393
    9494  // add element
    95    PRINTF(0)("addTarget: %i \n", target);
     95   //PRINTF(0)("addTarget: %i \n", target);
    9696   this->targetList.push_back(target);
    9797}
  • branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.cc

    r8455 r8474  
    2121#include "util/loading/resource_manager.h"
    2222
    23 #include "glincl.h"
    2423#include "material.h"
    2524#include <math.h>
     
    3130#include "parser/tinyxml/tinyxml.h"
    3231
    33 #include "sglmodel.h"
    3432
    3533using namespace std;
     
    4341{
    4442        this->setClassID(CL_CLOUD_EFFECT, "CloudEffect");
     43//  this->toList(OM_ENVIRON);
    4544
    4645        this->init();
     
    4948                this->loadParams(root);
    5049
    51         if(cloudActivate)
     50        //if(cloudActivate)
    5251                this->activate();
    5352}
     
    5655{
    5756        this->deactivate();
    58 
    59         delete this->cloudMaterial;
    60 
    61         cloudModel.Delete();
    62         Shader::unload(this->cloudShader);
    63 
    6457}
    6558
     
    6760void CloudEffect::init()
    6861{
    69         PRINTF(1)("Initializing CloudEffect\n");
     62        PRINTF(0)("Initializing CloudEffect\n");
     63 
     64    /// initialization of the texture coords, speeds etc...
     65/*  this->move = 0.0f;
     66  this->g_WaterUV = 35.0f;
     67  this->kNormalMapScale = 0.25f;
     68  this->g_WaterFlow = 0.0015f;*/
     69 
     70  cloudMaterial.setDiffuseMap("pictures/sky/cloud1.jpg", GL_TEXTURE_2D, 0);
    7071
    71         // Default values
    72         this->cloudActivate = false;
    73         this->cloudTint[4] = ( 0.9f, 0.7f, 0.7f, 1.0f );
    74         this->cloudScroll = 1.0f;
    75         this->time = 0.0f;
    76         //g_cloud_texture = 0;
     72  shader = new Shader(ResourceManager::getInstance()->getDataDir() + "/shaders/cloud.vert",
     73                      ResourceManager::getInstance()->getDataDir() + "/shaders/cloud.frag");
     74 
     75  this->shader->activateShader();
    7776
    78         this->cloudTexture = "pictures/sky/cloud1.jpg";
    79 
    80         // cloudModel.Load(ResourceManager::getInstance()->getDataDir() + "/models/cloud.sgl");
    81         // cloudModel.Unitize();
    82 
    83         // Get the bounding box of the sky dome
    84         float bbox[3] = {0};
    85         cloudModel.GetDimensions(bbox[0], bbox[1], bbox[2]);
    86 
    87         // Load Shaders
    88         this->cloudShader = new Shader( ResourceManager::getInstance()->getDataDir() + "/shaders/sky.vert", ResourceManager::getInstance()->getDataDir() +"/shaders/sky.frag");
    89 
    90         // Tell the shader the bounding box of the sky dome
    91         this->cloudShader->bindShader("bbox", bbox, 4);
    92 
    93         // Initialze Cloud Material
    94         this->cloudMaterial = new Material("Sky");
    95         this->cloudMaterial->setIllum(3);
    96         this->cloudMaterial->setAmbient(1.0, 1.0, 1.0);
    97         this->cloudMaterial->setDiffuseMap(this->cloudTexture);
    98 
     77  Shader::Uniform(shader, "Noise").set(0);
     78  Shader::Uniform(shader, "SkyColor").set(0.0f, 0.0f, 0.8f);
     79  Shader::Uniform(shader, "CloudColor").set(0.8f, 0.8f, 0.8f);
     80 
     81  // Change: Have to be updated each frame!like camerpos in mapped_water.cc
     82  Shader::Uniform(shader, "Offset").set(0.0f, 0.0f, 0.0f);
     83 
     84  Shader::Uniform(shader, "LightPos").set(100.0f, 100.0f, 100.0f);
     85  Shader::Uniform(shader, "Scale").set(1.0f);
     86 
     87  this->shader->deactivateShader();
    9988}
    10089
     
    10695        // LoadParam(root, "speed", this, CloudEffect, setCloudAnimation);
    10796        // LoadParam(root, "texture", this, CloudEffect, setCloudTexture);
    108 
     97  /*
    10998        LOAD_PARAM_START_CYCLE(root, element);
    11099        {
    111100                LoadParam_CYCLE(element, "option", this, CloudEffect, setCloudOption);
    112101        }
    113         LOAD_PARAM_END_CYCLE(element);
     102  LOAD_PARAM_END_CYCLE(element);*/
    114103}
    115104
     
    117106void CloudEffect::activate()
    118107{
    119         PRINTF(0)( "Activating CloudEffect with Material %s\n", this->cloudTexture.c_str());
     108        PRINTF(0)( "Activating\n");
    120109
    121         this->cloudActivate = true;
     110//      this->cloudActivate = true;
    122111}
    123112
     
    126115        PRINTF(0)("Deactivating CloudEffect\n");
    127116
    128         this->cloudActivate = false;
     117//      this->cloudActivate = false;
    129118}
    130119
    131120void CloudEffect::draw() const
    132121{
    133         if (!this->cloudActivate)
    134                 return;
     122        //if (!this->cloudActivate)
     123        //      return;
    135124
    136         //      glMatrixMode(GL_MODELVIEW);
    137         //      glPushMatrix();
    138         //
    139         //      // Move sphere along with the camera
    140         //      Vector r = State::getCameraNode()->getAbsCoor();
    141         //      glTranslatef(r.x, r.y, r.z);
    142         //
    143         //      // Sky movement
    144         //      glRotatef(mover, 0, 0, 1);
    145         //
    146         //      cloudMaterial->select();
    147         //      gluSphere(this->sphereObj, this->sphereRadius, 20, 20);
    148         //      glPopMatrix();
     125  //glMatrixMode(GL_MODELVIEW);
     126  //glColor4f(1,1,1,1);
     127  glPushMatrix();
     128  //glTranslatef(0,this->waterHeight,0);
    149129
    150         // ******
     130  cloudMaterial.unselect();
     131  cloudMaterial.select();
    151132
    152         glMatrixMode(GL_MODELVIEW);
    153         glPushMatrix();
     133  this->shader->activateShader();
    154134
    155         // glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    156         // glShadeModel(GL_SMOOTH);
    157         // glEnable(GL_DEPTH_TEST);
    158         // glEnable(GL_CULL_FACE);
    159         // glCullFace(GL_BACK);
    160         // glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
    161135
    162         // glLineWidth(3.0f);
     136  glBegin(GL_QUADS);
     137 
     138  glTexCoord2f(1.0f, 1.0f); glVertex3f(0.0f, 0.0f,  0.0f);
     139  glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.0f, 0.0f,  100.0f);
     140  glTexCoord2f(0.0f, 0.0f); glVertex3f( 100.0f, 0.0f,  100.0f);
     141  glTexCoord2f(1.0f, 0.0f); glVertex3f(100.0f, 0.0f,  0.0f);
     142 
     143  glEnd();
    163144
    164         static float time = 0.0f;
    165         // static vector3f eye = {0.0f, 0.0f, 0.0f}, look = {0.0f, 0.0f, 1.0f}, up = {0.0f, 1.0f, 0.0f};
     145  this->shader->deactivateShader();
    166146
    167         // glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    168         // glLoadIdentity();
    169         // gluLookAt(eye[x], eye[y], eye[z], look[x], look[y], look[z], up[x], up[y], up[z]);
     147  cloudMaterial.unselect();
    170148
    171         // Turn off the depth buffer when rendering the background
    172         // glDisable(GL_DEPTH_TEST);
    173 
    174         this->cloudShader->activateShader();
    175 
    176         /* Select the shader program and update parameters. */
    177         /* The "time" parameter controls the cloud scrolling. */
    178         this->cloudShader->bindShader("time", &time, 1);
    179         /* The "horizon" parameter controls the sky tinting. */
    180         this->cloudShader->bindShader("horizon", cloudTint, 4);
    181 
    182         glActiveTexture(GL_TEXTURE0 + 0);
    183         glActiveTexture(GL_TEXTURE0 + 1);
    184 
    185         // Load the cloud texture
    186         //glBindTexture(GL_TEXTURE_2D, g_cloud_texture);
    187         this->cloudMaterial->select();
    188 
    189         // Render the sky dome
    190         cloudModel.Render();
    191 
    192         // Unselect the shader
    193         Shader::deactivateShader();
    194 
    195         /* Turn on the depth buffer when rendering the foreground. */
    196         // glEnable(GL_DEPTH_TEST);
    197 
    198         /* Render the forground, for example, a teapot or bunny. */
    199         //    glEnable(GL_LIGHTING);
    200         //    glColor3f(0.0f, 1.0f, 0.0f);
    201         //    glBegin(GL_QUADS);
    202         //    glNormal3f( 0.0f,  1.0f,  0.0f);
    203         //    glVertex3f( 20.0f, -1.0f,  20.0f);
    204         //    glVertex3f( 20.0f, -1.0f, -20.0f);
    205         //    glVertex3f(-20.0f, -1.0f, -20.0f);
    206         //    glVertex3f(-20.0f, -1.0f,  20.0f);
    207         //    glEnd();
    208         //    glDisable(GL_LIGHTING);
    209 
    210         glPopMatrix();
     149  glPopMatrix();
    211150
    212151}
     
    214153void CloudEffect::tick (float dt)
    215154{
    216         if (!this->cloudActivate)
    217                 return;
    218 
    219         // Update the timer for scrolling the clouds
    220         time = time + ((1.0f / 2000.0f) * cloudScroll);
     155        //if (!this->cloudActivate)
     156        //      return;
    221157}
    222158
  • branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.h

    r8457 r8474  
    1212
    1313#include "world_entity.h"
    14 #include "glincl.h"
    15 
    16 #include "sglmodel.h"
    17 
    18 class Shader;
    19 class Material;
    20 class Vector;
     14#include "material.h"
     15#include "shader.h"
    2116
    2217class CloudEffect : public WeatherEffect {
     
    4237    virtual void tick(float dt);
    4338
    44     inline void setCloudOption(const std::string& option) {
     39    /*inline void setCloudOption(const std::string& option) {
    4540        if (option == "activate")
    46             this->cloudActivate = true;
    47     }
     41    this->cloudActivate = true;
     42}*/
    4843
    4944
    5045private:
    51     void initialize(char* fileName);
     46    //void initialize(char* fileName);
    5247
    53     bool        cloudActivate;
     48    //bool        cloudActivate;
    5449
    55     Material*     cloudMaterial;    // A Material for the Sphere.
    56 
    57     std::string     cloudTexture;
    58 
    59     Sglmodel_sgl      cloudModel;
    60     Shader*       cloudShader;
    61 
    62     GLfloat       cloudTint[4];
    63     GLfloat       cloudScroll;
    64 
    65     float       time;
    66 
     50    Material                 cloudMaterial;
     51    Shader*                 shader;
    6752};
    6853
Note: See TracChangeset for help on using the changeset viewer.