Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7520 in orxonox.OLD


Ignore:
Timestamp:
May 3, 2006, 4:14:27 PM (18 years ago)
Author:
amaechler
Message:

branches/atmospheric_engine:

Location:
branches/atmospheric_engine/src/lib/graphics/effects
Files:
2 edited

Legend:

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

    r7519 r7520  
    2121
    2222#include "shell_command.h"
     23
     24#define NUM_PANELS 6    /* number of panels in scene */
     25
     26typedef struct
     27{
     28        float x;
     29        float y;
     30        float z;
     31} world_vector;         /* vertex data */
     32
     33world_vector vertices[NUM_PANELS*4] = {
     34        {-5.0, -10.0, 0.0},{5.0, -10.0, 0.0},{5.0, 0.0, 0.0},{-5.0, 0.0, 0.0},
     35        {-5.0, -10.0, 10.0},{-5.0, -10.0, 0.0},{-5.0, 0.0, 0.0},{-5.0, 0.0, 10.0},
     36        {-5.0, -10.0, 20.0},{-5.0, -10.0, 10.0},{-5.0, 0.0, 10.0},{-5.0, 0.0, 20.0},
     37        {5.0, -10.0, 0.0},{5.0, -10.0, 10.0},{5.0, 0.0, 10.0},{5.0, 0.0, 0.0},
     38        {5.0, -10.0, 10.0},{5.0, -10.0, 20.0},{5.0, 0.0, 20.0},{5.0, 0.0, 10.0},
     39        {-5.0, -10.0, 10.0},{5.0, -10.0, 10.0},{5.0, -10.0, 0.0},{-5.0, -10.0, 0.0}
     40};
    2341
    2442using namespace std;
     
    5674
    5775bool VolFogEffect::init()
    58 {}
     76{
     77
     78};
    5979
    6080
     
    7191
    7292
     93void setFogColor(int v)
     94{
     95        float z;        /* distance of vertex from edge of fog volume */
     96        float f;        /* fog factor */
     97
     98        z = 0.0 - vertices[v].y;
     99        f = (10.0 - z) / (10.0 - 0.0);  /* linear fog: f = (end - z)/(end - start) */
     100        glColor4f(0.6, 0.2, 0.0, f);
     101}
     102
     103        int v;          /* store of next vertex ref */
     104
    73105/**
    74106 * draws the effect, if needed
     
    76108void VolFogEffect::draw() const
    77109{
    78   PRINTF(0)("DRAW VolFogEffect\n");
     110        // int v;               /* store of next vertex ref */
     111        int ref;
     112
     113        PRINTF(0)("DRAW VolFogEffect\n");
     114
     115        for (ref=0; ref<NUM_PANELS; ref++) {
     116
     117                /* disable writes to z buffer (if fog area) */
     118                glDepthMask(GL_FALSE);
     119       
     120                v = ref * 4;
     121
     122                /* restore z buffer writes, set blend params & disable texturing */
     123
     124                glDepthMask(GL_TRUE);
     125                glEnable(GL_BLEND);
     126                glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA);
     127                glDisable(GL_TEXTURE_2D);
     128
     129                /* draw the fog panel */
     130
     131                v = ref * 4;
     132                glBegin(GL_QUADS);
     133                setFogColor(v);
     134                glVertex3f(vertices[v].x, vertices[v].y, vertices[v].z); v++;
     135                setFogColor(v);
     136                glVertex3f(vertices[v].x, vertices[v].y, vertices[v].z); v++;
     137                setFogColor(v);
     138                glVertex3f(vertices[v].x, vertices[v].y, vertices[v].z); v++;
     139                setFogColor(v);
     140                glVertex3f(vertices[v].x, vertices[v].y, vertices[v].z);
     141                glEnd();
     142
     143                /* restore rendering state */
     144
     145                glEnable(GL_TEXTURE_2D);
     146                glDisable(GL_BLEND);
     147        }
     148
     149       
    79150}
    80151
  • branches/atmospheric_engine/src/lib/graphics/effects/volfog_effect.h

    r7519 r7520  
    2323    virtual bool deactivate();
    2424
     25    void test(int t);
     26
     27
    2528    virtual void draw() const;
    2629    virtual void tick(float dt);
    2730
    28     void test(int t);
    29 
    3031  private:
     32    void set_fog_colour(int v);
    3133
    3234};
Note: See TracChangeset for help on using the changeset viewer.