Changeset 7520 in orxonox.OLD for branches/atmospheric_engine
- Timestamp:
- May 3, 2006, 4:14:27 PM (19 years ago)
- 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 21 21 22 22 #include "shell_command.h" 23 24 #define NUM_PANELS 6 /* number of panels in scene */ 25 26 typedef struct 27 { 28 float x; 29 float y; 30 float z; 31 } world_vector; /* vertex data */ 32 33 world_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 }; 23 41 24 42 using namespace std; … … 56 74 57 75 bool VolFogEffect::init() 58 {} 76 { 77 78 }; 59 79 60 80 … … 71 91 72 92 93 void 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 73 105 /** 74 106 * draws the effect, if needed … … 76 108 void VolFogEffect::draw() const 77 109 { 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 79 150 } 80 151 -
branches/atmospheric_engine/src/lib/graphics/effects/volfog_effect.h
r7519 r7520 23 23 virtual bool deactivate(); 24 24 25 void test(int t); 26 27 25 28 virtual void draw() const; 26 29 virtual void tick(float dt); 27 30 28 void test(int t);29 30 31 private: 32 void set_fog_colour(int v); 31 33 32 34 };
Note: See TracChangeset
for help on using the changeset viewer.