Yes, it does... here's how I did it, I'm calling this from
HUD_DrawTransparentTriangles (well, not exactly this, it's somewhat
different in Poke646, but the idea & maths is the same):
--- snip ---
#define SCOPE_DISTANCE 10
#define M_PI 3.14159265358979323846
extern vec3_t v_angles, v_origin;
void CSniperScope::DrawScope( void )
{
if( !fActive )
return;
cl_entity_t *player;
// make sure the player is up and running
player = gEngfuncs.GetLocalPlayer();
if ( !player )
return;
// load sniper scope sprite if necessary
if ( hsprSniperScope == 0 )
{
char sz[256];
sprintf( sz, "sprites/scopeborder.spr" );
hsprSniperScope = SPR_Load( sz );
}
vec3_t viewAngles, v_up, v_right, v_forward;
gEngfuncs.GetViewAngles( viewAngles );
AngleVectors( viewAngles, v_forward, v_right, v_up );
// the sprite's origin
vec3_t org = v_origin + v_forward * SCOPE_DISTANCE;
// adjust size to fov (simple triangular maths)
float fovadjust = tan( gHUD.m_iFOV / 360.0 * M_PI );
float size = (SCOPE_DISTANCE + 1.0) * fovadjust; // little bigger than
necessary
// use this to overlap the triangles a bit
float pixel = size / 256.0;
float r, g, b, brightness;
r = g = b = brightness = 1.0;
vec3_t temporg;
// now set up triapi code
gEngfuncs.pTriAPI->RenderMode( kRenderTransTexture );
gEngfuncs.pTriAPI->CullFace( TRI_NONE );
for( int i = 0; i < 4; i++ )
{
if ( !gEngfuncs.pTriAPI->SpriteTexture( (struct model_s
*)gEngfuncs.GetSpritePointer( hsprSniperScope ), i ))
{
return;
}
gEngfuncs.pTriAPI->Color4f( r, g, b , brightness);
gEngfuncs.pTriAPI->Begin( TRI_QUADS );
gEngfuncs.pTriAPI->Brightness( 1 );
gEngfuncs.pTriAPI->TexCoord2f( 0, 1 );
switch( i )
{
case 0: temporg = org + (v_right * -size); break;
case 1: temporg = org; break;
case 2: temporg = org + (v_right * -size) + (v_up * -size); break;
case 3: temporg = org + (v_up * -size); break;
}
gEngfuncs.pTriAPI->Vertex3fv( temporg );
gEngfuncs.pTriAPI->Brightness( 1 );
gEngfuncs.pTriAPI->TexCoord2f( 0, 0 );
switch( i )
{
case 0: temporg = org + (v_right * -size) + (v_up * size); break;
case 1: temporg = org + (v_up * size); break;
case 2: temporg = org + (v_right * -size) + (v_up * pixel); break;
case 3: temporg = org; break;
}
gEngfuncs.pTriAPI->Vertex3fv( temporg );
gEngfuncs.pTriAPI->Brightness( 1 );
gEngfuncs.pTriAPI->TexCoord2f( 1, 0 );
switch( i )
{
case 0: temporg = org + (v_up * size); break;
case 1: temporg = org + (v_right * size) + (v_up * size); break;
case 2: temporg = org; break;
case 3: temporg = org + (v_right * size) + (v_up * pixel); break;
}
gEngfuncs.pTriAPI->Vertex3fv( temporg );
gEngfuncs.pTriAPI->Brightness( 1 );
gEngfuncs.pTriAPI->TexCoord2f( 1, 1 );
switch( i )
{
case 0: temporg = org; break;
case 1: temporg = org + (v_right * size); break;
case 2: temporg = org + (v_up * -size); break;
case 3: temporg = org + (v_right * size) + (v_up * -size); break;
}
gEngfuncs.pTriAPI->Vertex3fv( temporg );
gEngfuncs.pTriAPI->End();
}
}
-- snap --
cya,
TheTinySteini
----- Original Message -----
From: "Cortex" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, April 29, 2002 7:56 PM
Subject: Re: [hlcoders] Scope Sprites
I don't understand how you got it to work using TriApi ! How did you get the
coordinate of the polys you had to display ? It has to depend from the view
angles, don't they ?
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders