#include "vector.h"
#include "polygon.h"
#include "vertex.h"
#include "quat.h"
Go to the source code of this file.
Compounds | |
class | DECAL |
Functions | |
void | CreateDecal (VECTOR pt, POLYGON *face, DECAL *decal) |
void | RenderBulletDecal (DECAL decal) |
void | RenderBurnDecal (DECAL decal) |
void | DrawImpactFlash () |
void | DrawMuzzleFlash () |
void | DrawDecals () |
|
Definition at line 53 of file decal.cpp. References VERTEX::coords, VECTOR::CrossVector(), VERTEX::normal, VECTOR::Normalize(), VECTOR::Set(), DECAL::Size, DECAL::Vertex, POLYGON::Vertex, VECTOR::x, VECTOR::y, and VECTOR::z. Referenced by UpdateBullets().
00054 { 00055 VECTOR axis[3] = 00056 { 00057 VECTOR(1.0f, 0.0f, 0.0f), 00058 VECTOR(0.0f, 1.0f, 0.0f), 00059 VECTOR(0.0f, 0.0f, 1.0f) 00060 }; 00061 VECTOR poly_normal(fabs(face->Vertex[0].normal.x), fabs(face->Vertex[0].normal.y), fabs(face->Vertex[0].normal.z)); 00062 poly_normal.Normalize(); 00063 VECTOR up, right, temp; 00064 int major; 00065 00066 if (poly_normal.x > poly_normal.y && poly_normal.x > poly_normal.z) 00067 major = 0; 00068 else if (poly_normal.y > poly_normal.x && poly_normal.y > poly_normal.z) 00069 major = 1; 00070 else 00071 major = 2; 00072 00073 // build right vector by hand 00074 if (poly_normal.x == 1.0 || poly_normal.y == 1.0 || poly_normal.z == 1.0) 00075 { 00076 if ((major == 0 && face->Vertex[0].normal.x > 0.0) || major == 1) 00077 right.Set(0.0, 0.0, -1.0); 00078 else if (major == 0) 00079 right.Set(0.0, 0.0, 1.0); 00080 else 00081 right.Set(1.0 * face->Vertex[0].normal.z, 0.0, 0.0); 00082 } 00083 else 00084 { 00085 temp = face->Vertex[0].normal; 00086 axis[major].CrossVector(temp); 00087 right = axis[major]; 00088 } 00089 00090 temp.x = -face->Vertex[0].normal.x; 00091 temp.y = -face->Vertex[0].normal.y; 00092 temp.z = -face->Vertex[0].normal.z; 00093 temp.CrossVector(right); 00094 up = temp; 00095 up.Normalize(); 00096 right.Normalize(); 00097 00098 // make the face 00099 decal->Vertex[0].coords.x = pt.x + ((-right.x - up.x) * decal->Size); 00100 decal->Vertex[0].coords.y = pt.y + ((-right.y - up.y) * decal->Size); 00101 decal->Vertex[0].coords.z = pt.z + ((-right.z - up.z) * decal->Size); 00102 decal->Vertex[1].coords.x = pt.x + ((right.x - up.x) * decal->Size); 00103 decal->Vertex[1].coords.y = pt.y + ((right.y - up.y) * decal->Size); 00104 decal->Vertex[1].coords.z = pt.z + ((right.z - up.z) * decal->Size); 00105 decal->Vertex[2].coords.x = pt.x + ((right.x + up.x) * decal->Size); 00106 decal->Vertex[2].coords.y = pt.y + ((right.y + up.y) * decal->Size); 00107 decal->Vertex[2].coords.z = pt.z + ((right.z + up.z) * decal->Size); 00108 decal->Vertex[3].coords.x = pt.x + ((-right.x + up.x) * decal->Size); 00109 decal->Vertex[3].coords.y = pt.y + ((-right.y + up.y) * decal->Size); 00110 decal->Vertex[3].coords.z = pt.z + ((-right.z + up.z) * decal->Size); 00111 } |
|
Definition at line 243 of file decal.cpp. References DECAL::active, currentCamera, DrawImpactFlash(), DrawMuzzleFlash(), DECAL::Orientation, and DECAL::Position. Referenced by DrawGLScene().
00244 { 00245 // If the impact-flash decal is active then render it 00246 if (impactflashdecal.active) 00247 { 00248 impactflashdecal.active = false; 00249 DrawImpactFlash(); 00250 } 00251 00252 // If the muzzle-flash decal is active then render it 00253 if (muzzleflashdecal.active) 00254 { 00255 muzzleflashdecal.active = false; 00256 muzzleflashdecal.Position = camera[currentCamera].Position; 00257 muzzleflashdecal.Orientation = camera[currentCamera].Orientation; 00258 DrawMuzzleFlash(); 00259 } 00260 } |
|
Definition at line 162 of file decal.cpp. References DECAL::CollisionVector, MATRIX::Element, VECTOR::Normalize(), VECTOR::x, VECTOR::y, and VECTOR::z. Referenced by DrawDecals().
00163 { 00164 float halfwidth = 1.0; 00165 float halfheight = 1.0; 00166 00167 MATRIX mat; 00168 glGetFloatv(GL_MODELVIEW_MATRIX, mat.Element); 00169 00170 VECTOR right; 00171 right.x = mat.Element[0]; 00172 right.y = mat.Element[4]; 00173 right.z = mat.Element[8]; 00174 right.Normalize(); 00175 right.x *= halfwidth; 00176 right.y *= halfwidth; 00177 right.z *= halfwidth; 00178 00179 VECTOR up; 00180 up.x = mat.Element[1]; 00181 up.y = mat.Element[5]; 00182 up.z = mat.Element[9]; 00183 up.Normalize(); 00184 up.x *= halfheight; 00185 up.y *= halfheight; 00186 up.z *= halfheight; 00187 00188 glEnable(GL_BLEND); 00189 glDepthMask(0); 00190 glBlendFunc(GL_SRC_ALPHA, GL_ONE); 00191 glDisable(GL_LIGHTING); 00192 // glColor4f(1.0, 1.0, 1.0, 1.0); 00193 glDisable(GL_CULL_FACE); 00194 glBindTexture(GL_TEXTURE_2D, texture[6].TexID); 00195 glBegin(GL_QUADS); 00196 glTexCoord2f(0.0f, 0.0f); glVertex3f(impactflashdecal.CollisionVector.x + (-right.x - up.x), impactflashdecal.CollisionVector.y + (-right.y - up.y), impactflashdecal.CollisionVector.z + (-right.z - up.z)); 00197 glTexCoord2f(1.0f, 0.0f); glVertex3f(impactflashdecal.CollisionVector.x + (right.x - up.x), impactflashdecal.CollisionVector.y + (right.y - up.y), impactflashdecal.CollisionVector.z + (right.z - up.z)); 00198 glTexCoord2f(1.0f, 1.0f); glVertex3f(impactflashdecal.CollisionVector.x + (right.x + up.x), impactflashdecal.CollisionVector.y + (right.y + up.y), impactflashdecal.CollisionVector.z + (right.z + up.z)); 00199 glTexCoord2f(0.0f, 1.0f); glVertex3f(impactflashdecal.CollisionVector.x + (up.x - right.x), impactflashdecal.CollisionVector.y + (up.y - right.y), impactflashdecal.CollisionVector.z + (up.z - right.z)); 00200 glEnd(); 00201 glEnable(GL_DEPTH_TEST); 00202 glDepthMask(1); 00203 glDisable(GL_BLEND); 00204 glEnable(GL_LIGHTING); 00205 glEnable(GL_CULL_FACE); 00206 } |
|
Definition at line 208 of file decal.cpp. References MATRIX::Element, DECAL::Orientation, DECAL::Position, MATRIX::QuatToMatrix(), DECAL::Size, VECTOR::x, VECTOR::y, and VECTOR::z. Referenced by DrawDecals().
00209 { 00210 MATRIX Matrix; 00211 glPushMatrix(); 00212 glTranslatef(muzzleflashdecal.Position.x,muzzleflashdecal.Position.y,muzzleflashdecal.Position.z); 00213 Matrix.QuatToMatrix(muzzleflashdecal.Orientation); 00214 glMultMatrixf(Matrix.Element); 00215 glTranslatef(0.0,-4.0,-10.0); 00216 00217 glEnable(GL_BLEND); 00218 glDepthMask(0); 00219 glBlendFunc(GL_SRC_ALPHA, GL_ONE); 00220 glDisable(GL_LIGHTING); 00221 glColor4f(1.0, 1.0, 1.0, 1.0); 00222 glBindTexture(GL_TEXTURE_2D, texture[5].TexID); 00223 glDisable(GL_CULL_FACE); 00224 00225 glBegin(GL_QUADS); 00226 glTexCoord2f(0.0f, 0.0f); 00227 glVertex3f(-muzzleflashdecal.Size, -muzzleflashdecal.Size, 0.0); 00228 glTexCoord2f(1.0f, 0.0f); 00229 glVertex3f(muzzleflashdecal.Size, -muzzleflashdecal.Size, 0.0); 00230 glTexCoord2f(1.0f, 1.0f); 00231 glVertex3f(muzzleflashdecal.Size, muzzleflashdecal.Size, 0.0); 00232 glTexCoord2f(0.0f, 1.0f); 00233 glVertex3f(-muzzleflashdecal.Size, muzzleflashdecal.Size, 0.0); 00234 glEnd(); 00235 00236 glEnable(GL_CULL_FACE); 00237 glDepthMask(1); 00238 glDisable(GL_BLEND); 00239 glEnable(GL_LIGHTING); 00240 glPopMatrix(); 00241 } |
|
Definition at line 113 of file decal.cpp. References VERTEX::coords, DECAL::Vertex, and VECTOR::x. Referenced by RenderBSP().
00114 { 00115 float mat_ambient[] = { 0.8, 0.8, 0.8, 1.0 }; 00116 float mat_diffuse[] = { 0.8, 0.8, 0.8, 1.0 }; 00117 glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); 00118 glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); 00119 00120 glEnable(GL_BLEND); 00121 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 00122 glEnable(GL_ALPHA_TEST); 00123 glAlphaFunc(GL_GREATER, 0); 00124 00125 glBindTexture(GL_TEXTURE_2D, texture[7].TexID); 00126 00127 glBegin(GL_QUADS); 00128 glTexCoord2f(0.0f, 0.0f); 00129 glVertex3fv(&decal.Vertex[0].coords.x); 00130 glTexCoord2f(1.0f, 0.0f); 00131 glVertex3fv(&decal.Vertex[1].coords.x); 00132 glTexCoord2f(1.0f, 1.0f); 00133 glVertex3fv(&decal.Vertex[2].coords.x); 00134 glTexCoord2f(0.0f, 1.0f); 00135 glVertex3fv(&decal.Vertex[3].coords.x); 00136 glEnd(); 00137 00138 glDisable(GL_BLEND); 00139 glDisable(GL_ALPHA_TEST); 00140 } |
|
Definition at line 142 of file decal.cpp. References VERTEX::coords, DECAL::Vertex, and VECTOR::x. Referenced by RenderBSP().
00143 { 00144 glEnable(GL_BLEND); 00145 glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_ALPHA); 00146 glBindTexture(GL_TEXTURE_2D, texture[4].TexID); 00147 00148 glBegin(GL_QUADS); 00149 glTexCoord2f(0.0f, 0.0f); 00150 glVertex3fv(&decal.Vertex[0].coords.x); 00151 glTexCoord2f(1.0f, 0.0f); 00152 glVertex3fv(&decal.Vertex[1].coords.x); 00153 glTexCoord2f(1.0f, 1.0f); 00154 glVertex3fv(&decal.Vertex[2].coords.x); 00155 glTexCoord2f(0.0f, 1.0f); 00156 glVertex3fv(&decal.Vertex[3].coords.x); 00157 glEnd(); 00158 00159 glDisable(GL_BLEND); 00160 } |