int CHudLensflare::Draw(float flTime) { return 0; vec3_t sunangles, sundir , suntarget; vec3_t v_forward, v_right, v_up, angles; vec3_t forward, right, up, screen; pmtrace_t tr,tr1; //Sun position if(Sunanglex != NULL && Sunangley != NULL) { sunangles.x = Sunanglex; sunangles.y = Sunangley; } else { sunangles.x = -90; sunangles.y = 0; } text[0] = SPR_Load("sprites/lens/lens21.spr"); red[0] = green[0] = blue[0] = 1.0; scale[0] = 25; multi[0] = -0.45; text[1] = SPR_Load("sprites/lens/lens7.spr"); red[1] = green[0] = blue[0] = 1.0; scale[1] = 25; multi[1] = 0.2; text[2] = SPR_Load("sprites/lens/glow01.spr"); red[2] = 132/255; green[2] = 1.0; blue[2] = 153/255; scale[2] = 35; multi[2] = 0.3; text[3] = SPR_Load("sprites/lens/glow.spr"); red[3] = 1.0; green[3] = 164/255; blue[3] = 164/255; scale[3] = 40; multi[3] = 0.46; text[4] = SPR_Load("sprites/lens/lens11.spr"); red[4] = 1.0; green[4] = 164/255; blue[4] = 164/255; scale[4] = 52; multi[4] = 0.5; text[5] = SPR_Load("sprites/lens/lens7.spr"); red[5] = green[5] = blue[5] = 1.0; scale[5] = 31; multi[5] = 0.54; text[6] = SPR_Load("sprites/lens/lens7.spr"); red[6] = 0.6; green[6] = 1.0; blue[6] = 0.6; scale[6] = 26; multi[6] = 0.64; text[7] = SPR_Load("sprites/lens/glow01.spr"); red[7] = 0.5; green[7] = 1.0; blue[7] = 0.5; scale[7] = 20; multi[7] = 0.77; text[8] = SPR_Load("sprites/lens/lens11.spr"); text[9] = SPR_Load("sprites/lens/lens21.spr"); flPlayerBlend = 0.0; flPlayerBlend2 = 0.0; AngleVectors( v_angles, forward, null, null ); AngleVectors( sunangles, sundir, null, null ); suntarget = v_origin + sundir * 16384; tr = *(gEngfuncs.PM_TraceLine( v_origin, suntarget, PM_TRACELINE_PHYSENTSONLY, 2, -1 )); if( gEngfuncs.PM_PointContents( tr.endpos, null ) == CONTENTS_SKY) { flPlayerBlend = max( DotProduct( forward, sundir ) - 0.63, 0.0 ) * 5.8; if (flPlayerBlend > 1.0 ) flPlayerBlend = 1.0; flPlayerBlend4 = max( DotProduct( forward, sundir ) - 0.85, 0.0 ) * 5; if (flPlayerBlend4 > 1.0 ) flPlayerBlend4 = 1.0; flPlayerBlend6 = max( DotProduct( forward, sundir ) - 0.55, 0.0 ) * 5.7; if (flPlayerBlend6 > 1.0 ) flPlayerBlend6 = 1.0; flPlayerBlend2 = flPlayerBlend6 * 100.0 ; flPlayerBlend3 = flPlayerBlend * 190.0 ; flPlayerBlend5 = flPlayerBlend4 * 222.0 ; vec3_t normal,point,origin; gEngfuncs.GetViewAngles((float*)normal); AngleVectors(normal,forward,right,up); VectorCopy( tr.endpos, origin ); gEngfuncs.pTriAPI->WorldToScreen( tr.endpos, screen ); Suncoordx = XPROJECT( screen[ 0 ] ); Suncoordy = YPROJECT( screen[ 1 ] ); if (Suncoordx < XRES( -10 ) || Suncoordx > XRES( 650 ) || Suncoordy < YRES( -10 ) || Suncoordy > YRES( 490 )) return 1; Screenmx = ScreenWidth/2; Screenmy = ScreenHeight/2; Sundistx = Screenmx - Suncoordx; Sundisty = Screenmy - Suncoordy; gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(SPR_Load("sprites/lens/lensflare1.spr")) , 0);//use hotglow, or any other sprite for the texture gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling gEngfuncs.pTriAPI->Color4f(255/255, 255/255 , 255/255, flPlayerBlend3/255.0); gEngfuncs.pTriAPI->Brightness(flPlayerBlend3/255.0); gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx + 190, Suncoordy + 190, 0); //top left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx + 190, Suncoordy - 190, 0); //bottom left gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx - 190, Suncoordy - 190, 0); //bottom right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx - 190, Suncoordy + 190, 0); //top right gEngfuncs.pTriAPI->End(); //end our list of vertexes gEngfuncs.pTriAPI->RenderMode(kRenderNormal); gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(SPR_Load("sprites/lens/glow1.spr")) , 0);//use hotglow, or any other sprite for the texture gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling gEngfuncs.pTriAPI->Color4f(255/255, 255/255 , 255/255, flPlayerBlend3/255.0); gEngfuncs.pTriAPI->Brightness(flPlayerBlend3/255.0); gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx + 160, Suncoordy + 160, 0); //top left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx + 160, Suncoordy - 160, 0); //bottom left gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx - 160, Suncoordy - 160, 0); //bottom right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx - 160, Suncoordy + 160, 0); //top right gEngfuncs.pTriAPI->End(); //end our list of vertexes gEngfuncs.pTriAPI->RenderMode(kRenderNormal); gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(SPR_Load("sprites/lens/lensglare1.spr")) , 0);//use hotglow, or any other sprite for the texture gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling gEngfuncs.pTriAPI->Color4f(1.0, 1.0 , 1.0, flPlayerBlend5/255.0); gEngfuncs.pTriAPI->Brightness(flPlayerBlend5/255.0); gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(0, 0, 0); //top left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(0, ScreenHeight, 0); //bottom left gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(ScreenWidth, ScreenHeight, 0); //bottom right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(ScreenWidth, 0, 0); //top right gEngfuncs.pTriAPI->End(); //end our list of vertexes gEngfuncs.pTriAPI->RenderMode(kRenderNormal); int i = 1; Lensx[i] = (Suncoordx + (Sundistx * multi[i])); Lensy[i] = (Suncoordy + (Sundisty * multi[i])); gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0); //hotglow, or any other sprite for the texture gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] + scale[i], 0); //top left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] - scale[i], 0); //bottom left gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] - scale[i], 0); //bottom right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] + scale[i], 0); //top right gEngfuncs.pTriAPI->End(); //end our list of vertexes gEngfuncs.pTriAPI->RenderMode(kRenderNormal); i++; Lensx[i] = (Suncoordx + (Sundistx * multi[i])); Lensy[i] = (Suncoordy + (Sundisty * multi[i])); gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0); //hotglow, or any other sprite for the texture gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] + scale[i], 0); //top left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] - scale[i], 0); //bottom left gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] - scale[i], 0); //bottom right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] + scale[i], 0); //top right gEngfuncs.pTriAPI->End(); //end our list of vertexes gEngfuncs.pTriAPI->RenderMode(kRenderNormal); i++; Lensx[i] = (Suncoordx + (Sundistx * multi[i])); Lensy[i] = (Suncoordy + (Sundisty * multi[i])); gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0); //hotglow, or any other sprite for the texture gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] + scale[i], 0); //top left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] - scale[i], 0); //bottom left gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] - scale[i], 0); //bottom right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] + scale[i], 0); //top right gEngfuncs.pTriAPI->End(); //end our list of vertexes gEngfuncs.pTriAPI->RenderMode(kRenderNormal); i++; Lensx[i] = (Suncoordx + (Sundistx * multi[i])); Lensy[i] = (Suncoordy + (Sundisty * multi[i])); gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0); //hotglow, or any other sprite for the texture gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] + scale[i], 0); //top left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] - scale[i], 0); //bottom left gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] - scale[i], 0); //bottom right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] + scale[i], 0); //top right gEngfuncs.pTriAPI->End(); //end our list of vertexes gEngfuncs.pTriAPI->RenderMode(kRenderNormal); i++; Lensx[i] = (Suncoordx + (Sundistx * multi[i])); Lensy[i] = (Suncoordy + (Sundisty * multi[i])); gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0); //hotglow, or any other sprite for the texture gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] + scale[i], 0); //top left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] - scale[i], 0); //bottom left gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] - scale[i], 0); //bottom right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] + scale[i], 0); //top right gEngfuncs.pTriAPI->End(); //end our list of vertexes gEngfuncs.pTriAPI->RenderMode(kRenderNormal); i++; Lensx[i] = (Suncoordx + (Sundistx * multi[i])); Lensy[i] = (Suncoordy + (Sundisty * multi[i])); gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0); //hotglow, or any other sprite for the texture gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] + scale[i], 0); //top left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] - scale[i], 0); //bottom left gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] - scale[i], 0); //bottom right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] + scale[i], 0); //top right gEngfuncs.pTriAPI->End(); //end our list of vertexes gEngfuncs.pTriAPI->RenderMode(kRenderNormal); i++; Lensx[i] = (Suncoordx + (Sundistx * multi[i])); Lensy[i] = (Suncoordy + (Sundisty * multi[i])); gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0); //hotglow, or any other sprite for the texture gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] + scale[i], 0); //top left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] - scale[i], 0); //bottom left gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] - scale[i], 0); //bottom right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] + scale[i], 0); //top right gEngfuncs.pTriAPI->End(); //end our list of vertexes gEngfuncs.pTriAPI->RenderMode(kRenderNormal); i++; int scale1 = 32; int Lensx1,Lensy1 = 0; Lensx1 = (Suncoordx + (Sundistx * 0.88)); Lensy1 = (Suncoordy + (Sundisty * 0.88)); gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0); //hotglow, or any other sprite for the texture gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling gEngfuncs.pTriAPI->Color4f(0.9, 0.9 , 0.9, flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 + scale1, Lensy1 + scale1, 0); //top left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 + scale1, Lensy1 - scale1, 0); //bottom left gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 - scale1, Lensy1 - scale1, 0); //bottom right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 - scale1, Lensy1 + scale1, 0); //top right gEngfuncs.pTriAPI->End(); //end our list of vertexes gEngfuncs.pTriAPI->RenderMode(kRenderNormal); i++; scale1 = 140; Lensx1 = (Suncoordx + (Sundistx * 1.1)); Lensy1 = (Suncoordy + (Sundisty * 1.1)); gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0); //hotglow, or any other sprite for the texture gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling gEngfuncs.pTriAPI->Color4f(0.9, 0.9 , 0.9, flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 + scale1, Lensy1 + scale1, 0); //top left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 + scale1, Lensy1 - scale1, 0); //bottom left gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 - scale1, Lensy1 - scale1, 0); //bottom right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 - scale1, Lensy1 + scale1, 0); //top right gEngfuncs.pTriAPI->End(); //end our list of vertexes gEngfuncs.pTriAPI->RenderMode(kRenderNormal); } return 1; }
void CHudLensFlare :: DrawLight ( void ) { // hud éteint if ( ! (m_iFlags & HUD_ACTIVE)) return; // initialisation triapi int modelindex; struct model_s *mod = gEngfuncs.CL_LoadModel( FLASH_SPR , &modelindex ); gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)mod, 0 ); gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd ); //mode de transparence gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //(des)activer le face culling gEngfuncs.pTriAPI->Brightness( 0.15 ); gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 0.75, 0.5 ); vec3_t v_forward, v_right, v_up, vertex; AngleVectors ( v_angles, v_forward, v_right, v_up ); gruntlight_t *p = m_pLight; while ( p != NULL ) { cl_entity_t *ent = gEngfuncs.GetEntityByIndex( p->index ); // vecteurs // attach 0 : muzzleflash // attach 1 : right hand vec3_t vecOrigin = ent->attachment[2]; vec3_t vecDirFlash = ( ent->attachment[3] - ent->attachment[2] ).Normalize(); pmtrace_t tr = *( gEngfuncs.PM_TraceLine( vecOrigin, vecOrigin+vecDirFlash*256, PM_WORLD_ONLY, 2, 1 ) ); /* pmtrace_t tr; gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); gEngfuncs.pEventAPI->EV_PlayerTrace( vecOrigin, vecOrigin+vecDirFlash*256, PM_WORLD_ONLY, -1, &tr ); */ gEngfuncs.pTriAPI->Begin( TRI_TRIANGLES ); //démarrage du tracé, en mode triangles . gEngfuncs.pTriAPI->TexCoord2f( 0.5, 1 ); vertex = vecOrigin; gEngfuncs.pTriAPI->Vertex3f( vertex.x, vertex.y, vertex.z ); gEngfuncs.pTriAPI->TexCoord2f( 0, 1-tr.fraction ); vertex = vecOrigin + vecDirFlash*256*tr.fraction + v_up * 12*tr.fraction; gEngfuncs.pTriAPI->Vertex3f( vertex.x, vertex.y, vertex.z ); gEngfuncs.pTriAPI->TexCoord2f( 1, 1-tr.fraction ); vertex = vecOrigin + vecDirFlash*256*tr.fraction - v_up * 12*tr.fraction; gEngfuncs.pTriAPI->Vertex3f( vertex.x, vertex.y, vertex.z ); gEngfuncs.pTriAPI->End(); //fin du tracé p = p->pNext; } // ----------- lens flare----------- p = m_pLight; while ( p != NULL ) { cl_entity_t *ent = gEngfuncs.GetEntityByIndex( p->index ); vec3_t vecOrigin = ent->attachment[3]; vec3_t vecDirFlash = ( ent->attachment[3] - ent->attachment[2] ).Normalize(); vec3_t vecScrPos; // test de présence à l'écran if ( gEngfuncs.pTriAPI->WorldToScreen ( vecOrigin, vecScrPos ) ) { p = p->pNext; continue; } vecScrPos [0] = XPROJECT ( vecScrPos [0] ); vecScrPos [1] = YPROJECT ( vecScrPos [1] ); if ( vecScrPos[0] < XRES(-10) || vecScrPos[0] > XRES(650) || vecScrPos[1] < YRES(-10) || vecScrPos[1] > YRES(490) ) { p = p->pNext; continue; } // test de direction vec3_t vecAngFlash, vecAngDelta; VectorAngles ( -vecDirFlash, vecAngFlash ); VectorAngles ( ((vecOrigin-v_origin).Normalize()), vecAngDelta ); float flDifX = (float)fabs( (int)(vecAngFlash.x-vecAngDelta.x)%360 ); flDifX = flDifX > 180 ? flDifX - 360 : flDifX; flDifX = flDifX < -180 ? flDifX + 360 : flDifX; float flDifY = (float)fabs( (int)(vecAngDelta.y-vecAngFlash.y)%360 ); flDifY = flDifY > 180 ? flDifY - 360 : flDifY; flDifY = flDifY < -180 ? flDifY + 360 : flDifY; if ( fabs( flDifX ) > 45 || fabs( flDifY ) > 45 ) { p = p->pNext; continue; } // test de visibilité pmtrace_t tr = *( gEngfuncs.PM_TraceLine( v_origin, vecOrigin, PM_TRACELINE_ANYVISIBLE, 2, 1 ) ); if ( tr.fraction != 1.0 ) { p = p->pNext; continue; } // brillance - position sur l'écran float brightnessratio = 1; float pixelDist = sqrt ( (vecScrPos[0]-XRES(320))*(vecScrPos[0]-XRES(320)) +(vecScrPos[1]-YRES(240))*(vecScrPos[1]-YRES(240)) ); float maxdist = sqrt ( XRES(330)*XRES(330) + YRES(250)*YRES(250) ); brightnessratio *= pixelDist < XRES(80) ? 1.2 : 1.2 * ( 1 - (pixelDist-XRES(80)) / (maxdist-XRES(80))); // brillance - angle brightnessratio *= fabs( flDifY ) < 25 ? 1 : 1 - ( (fabs(flDifY)-25)/20 ); brightnessratio *= fabs( flDifX ) < 25 ? 1 : 1 - ( (fabs(flDifX)-25)/20 ); // affichage vec3_t vecFlareOrg = v_origin + (vecOrigin - v_origin).Normalize()*10; vec3_t vecFlareEnd = v_origin + v_forward*10; vec3_t flUnit = (vecFlareEnd - vecFlareOrg) / 100; for ( int i=0; i<MAX_FLARE; i++ ) { // initialisation triapi mod = gEngfuncs.CL_LoadModel( lensflare_spritename[i] , &modelindex ); gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)mod, 0 ); gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd ); //mode de transparence gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //(des)activer le face culling gEngfuncs.pTriAPI->Brightness( 200 ); gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0/*0.75*/, (float)((float)lensflare_spritevars[i][2] / 256.0f) * brightnessratio ); vec3_t pos = vecFlareOrg + flUnit * lensflare_spritevars[i][0]; vec3_t vertex; gEngfuncs.pTriAPI->Begin( TRI_QUADS ); //démarrage du tracé, en mode quads . gEngfuncs.pTriAPI->TexCoord2f( 0,0 ); vertex = pos + v_up * lensflare_spritevars[i][1] / 20 - v_right * lensflare_spritevars[i][1] / 20; gEngfuncs.pTriAPI->Vertex3f( vertex.x, vertex.y, vertex.z ); gEngfuncs.pTriAPI->TexCoord2f( 1, 0 ); vertex = pos + v_up * lensflare_spritevars[i][1] / 20 + v_right * lensflare_spritevars[i][1] / 20; gEngfuncs.pTriAPI->Vertex3f( vertex.x, vertex.y, vertex.z ); gEngfuncs.pTriAPI->TexCoord2f( 1, 1 ); vertex = pos - v_up * lensflare_spritevars[i][1] / 20 + v_right * lensflare_spritevars[i][1] / 20; gEngfuncs.pTriAPI->Vertex3f( vertex.x, vertex.y, vertex.z ); gEngfuncs.pTriAPI->TexCoord2f( 0, 1 ); vertex = pos - v_up * lensflare_spritevars[i][1] / 20 - v_right * lensflare_spritevars[i][1] / 20; gEngfuncs.pTriAPI->Vertex3f( vertex.x, vertex.y, vertex.z ); gEngfuncs.pTriAPI->End(); //fin du tracé } // flash blanc // initialisation triapi mod = gEngfuncs.CL_LoadModel( "sprites/lensflare05.spr" , &modelindex ); gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)mod, 0 ); gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd ); //mode de transparence gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //(des)activer le face culling gEngfuncs.pTriAPI->Brightness( 200 ); gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0, (float)(220.0f / 256.0f) * brightnessratio ); vec3_t pos = vecOrigin + vecDirFlash * 2; vec3_t vertex; gEngfuncs.pTriAPI->Begin( TRI_QUADS ); //démarrage du tracé, en mode quads . gEngfuncs.pTriAPI->TexCoord2f( 0,0 ); vertex = pos + v_up * FLASH_BLANC_SIZE - v_right * FLASH_BLANC_SIZE; gEngfuncs.pTriAPI->Vertex3f( vertex.x, vertex.y, vertex.z ); gEngfuncs.pTriAPI->TexCoord2f( 1, 0 ); vertex = pos + v_up * FLASH_BLANC_SIZE + v_right * FLASH_BLANC_SIZE; gEngfuncs.pTriAPI->Vertex3f( vertex.x, vertex.y, vertex.z ); gEngfuncs.pTriAPI->TexCoord2f( 1, 1 ); vertex = pos - v_up * FLASH_BLANC_SIZE + v_right * FLASH_BLANC_SIZE; gEngfuncs.pTriAPI->Vertex3f( vertex.x, vertex.y, vertex.z ); gEngfuncs.pTriAPI->TexCoord2f( 0, 1 ); vertex = pos - v_up * FLASH_BLANC_SIZE - v_right * FLASH_BLANC_SIZE; gEngfuncs.pTriAPI->Vertex3f( vertex.x, vertex.y, vertex.z ); gEngfuncs.pTriAPI->End(); //fin du tracé p = p->pNext; } }