PDGL_API void pdglVertex3f(float x, float y, float z) { if(pglVertex3f) { pglVertex3f(x, y, z); return; } pglVertex3f=pdglGetProcAddress("glVertex3f"); pglVertex3f(x, y, z); }
// render bounding box static void RenderWireframeBox( FLOAT3D vMinVtx, FLOAT3D vMaxVtx, COLOR col) { // only for OpenGL (for now) if( _pGfx->gl_eCurrentAPI!=GAT_OGL) return; // prepare wireframe OpenGL settings gfxDisableDepthTest(); gfxDisableDepthWrite(); gfxDisableBlend(); gfxDisableAlphaTest(); gfxDisableTexture(); // fill vertex array so it represents bounding box FLOAT3D vBoxVtxs[8]; vBoxVtxs[0] = FLOAT3D( vMinVtx(1), vMinVtx(2), vMinVtx(3)); vBoxVtxs[1] = FLOAT3D( vMaxVtx(1), vMinVtx(2), vMinVtx(3)); vBoxVtxs[2] = FLOAT3D( vMaxVtx(1), vMinVtx(2), vMaxVtx(3)); vBoxVtxs[3] = FLOAT3D( vMinVtx(1), vMinVtx(2), vMaxVtx(3)); vBoxVtxs[4] = FLOAT3D( vMinVtx(1), vMaxVtx(2), vMinVtx(3)); vBoxVtxs[5] = FLOAT3D( vMaxVtx(1), vMaxVtx(2), vMinVtx(3)); vBoxVtxs[6] = FLOAT3D( vMaxVtx(1), vMaxVtx(2), vMaxVtx(3)); vBoxVtxs[7] = FLOAT3D( vMinVtx(1), vMaxVtx(2), vMaxVtx(3)); // connect vertices into lines of bounding box INDEX iBoxLines[12][2]; iBoxLines[ 0][0] = 0; iBoxLines[ 0][1] = 1; iBoxLines[ 1][0] = 1; iBoxLines[ 1][1] = 2; iBoxLines[ 2][0] = 2; iBoxLines[ 2][1] = 3; iBoxLines[ 3][0] = 3; iBoxLines[ 3][1] = 0; iBoxLines[ 4][0] = 0; iBoxLines[ 4][1] = 4; iBoxLines[ 5][0] = 1; iBoxLines[ 5][1] = 5; iBoxLines[ 6][0] = 2; iBoxLines[ 6][1] = 6; iBoxLines[ 7][0] = 3; iBoxLines[ 7][1] = 7; iBoxLines[ 8][0] = 4; iBoxLines[ 8][1] = 5; iBoxLines[ 9][0] = 5; iBoxLines[ 9][1] = 6; iBoxLines[10][0] = 6; iBoxLines[10][1] = 7; iBoxLines[11][0] = 7; iBoxLines[11][1] = 4; // for all vertices in bounding box glCOLOR(col); pglBegin( GL_LINES); for( INDEX i=0; i<12; i++) { // get starting and ending vertices of one line FLOAT3D &v0 = vBoxVtxs[iBoxLines[i][0]]; FLOAT3D &v1 = vBoxVtxs[iBoxLines[i][1]]; pglVertex3f( v0(1), v0(2), v0(3)); pglVertex3f( v1(1), v1(2), v1(3)); } pglEnd(); OGL_CHECKERROR; }
/* ================ CL_UpdateParticle update particle color, position etc ================ */ void CL_UpdateParticle( particle_t *p, float ft ) { float time3 = 15.0 * ft; float time2 = 10.0 * ft; float time1 = 5.0 * ft; float dvel = 4 * ft; float grav = ft * clgame.movevars.gravity * 0.05f; float size = 1.5f; int i, iRamp, alpha = 255; vec3_t right, up; rgb_t color; r_stats.c_particle_count++; switch( p->type ) { case pt_static: break; case pt_tracer: case pt_clientcustom: if( p->callback ) { p->callback( p, ft ); } if( p->type == pt_tracer ) return; // already drawed break; case pt_fire: p->ramp += time1; if( p->ramp >= 6 ) p->die = -1; else p->color = ramp3[(int)p->ramp]; p->vel[2] += grav; break; case pt_explode: p->ramp += time2; if( p->ramp >= 8 ) p->die = -1; else p->color = ramp1[(int)p->ramp]; for( i = 0; i < 3; i++ ) p->vel[i] += p->vel[i] * dvel; p->vel[2] -= grav; break; case pt_explode2: p->ramp += time3; if( p->ramp >= 8 ) p->die = -1; else p->color = ramp2[(int)p->ramp]; for( i = 0; i < 3; i++ ) p->vel[i] -= p->vel[i] * ft; p->vel[2] -= grav; break; case pt_blob: case pt_blob2: p->ramp += time2; iRamp = (int)p->ramp >> SIMSHIFT; if( iRamp >= SPARK_COLORCOUNT ) { p->ramp = 0.0f; iRamp = 0; } p->color = CL_LookupColor( gSparkRamp[iRamp][0], gSparkRamp[iRamp][1], gSparkRamp[iRamp][2] ); for( i = 0; i < 2; i++ ) p->vel[i] -= p->vel[i] * 0.5f * ft; p->vel[2] -= grav * 5.0f; if( Com_RandomLong( 0, 3 )) { p->type = pt_blob; alpha = 0; } else { p->type = pt_blob2; alpha = 255; } break; case pt_grav: p->vel[2] -= grav * 20; break; case pt_slowgrav: p->vel[2] -= grav; break; case pt_vox_grav: p->vel[2] -= grav * 8; break; case pt_vox_slowgrav: p->vel[2] -= grav * 4; break; } #if 0 // HACKHACK a scale up to keep particles from disappearing size += (p->org[0] - RI.vieworg[0]) * RI.vforward[0]; size += (p->org[1] - RI.vieworg[1]) * RI.vforward[1]; size += (p->org[2] - RI.vieworg[2]) * RI.vforward[2]; if( size < 20.0f ) size = 1.0f; else size = 1.0f + size * 0.004f; #endif // scale the axes by radius VectorScale( RI.vright, size, right ); VectorScale( RI.vup, size, up ); p->color = bound( 0, p->color, 255 ); VectorSet( color, clgame.palette[p->color][0], clgame.palette[p->color][1], clgame.palette[p->color][2] ); GL_SetRenderMode( kRenderTransTexture ); pglColor4ub( color[0], color[1], color[2], alpha ); GL_Bind( GL_TEXTURE0, cls.particleImage ); // add the 4 corner vertices. pglBegin( GL_QUADS ); pglTexCoord2f( 0.0f, 1.0f ); pglVertex3f( p->org[0] - right[0] + up[0], p->org[1] - right[1] + up[1], p->org[2] - right[2] + up[2] ); pglTexCoord2f( 0.0f, 0.0f ); pglVertex3f( p->org[0] + right[0] + up[0], p->org[1] + right[1] + up[1], p->org[2] + right[2] + up[2] ); pglTexCoord2f( 1.0f, 0.0f ); pglVertex3f( p->org[0] + right[0] - up[0], p->org[1] + right[1] - up[1], p->org[2] + right[2] - up[2] ); pglTexCoord2f( 1.0f, 1.0f ); pglVertex3f( p->org[0] - right[0] - up[0], p->org[1] - right[1] - up[1], p->org[2] - right[2] - up[2] ); pglEnd(); if( p->type != pt_clientcustom ) { // update position. VectorMA( p->org, ft, p->vel, p->org ); } }