> Is there any example of the WorldToScreen function in the triAPI?
>  Or how about some documentation, or an explaination of what you
> have to do to use it?

int CHudTarget::Draw(float flTime)
{
        cl_entity_t *pEnt, *pPlayer = gEngfuncs.GetLocalPlayer();
        if (!pPlayer) return 1;

        vec3_t sloc; // Screen location of each ent.
        wrect_t rect = gHUD.GetSpriteRect(Sprite);
        int sprw = rect.right - rect.left, sprh = rect.bottom - rect.top;

        for (int i = 0; i < MAX_EDICTS; i++)
        {
                pEnt = gEngfuncs.GetEntityByIndex(i);

                //              if (pl && pl->player && pl->curstate.health > 0 && 
pl->curstate.solid
!= SOLID_NOT)

                if (!pEnt || pEnt->origin.Length() < 1 ||
                          pEnt->curstate.health < 1 ||
                                pEnt->curstate.solid == SOLID_NOT) continue;

                //if (pEnt == pPlayer) continue;

                if (PosInCone(pEnt->curstate.origin, 120))
                        {
                                // This is inefficient. Should check the return value 
(1 if off screen)
                                if 
(!gEngfuncs.pTriAPI->WorldToScreen(pEnt->curstate.origin, sloc))
                                {
                                        //gEngfuncs.Con_Printf("Location (%d): %.2f, 
%.2f\n", i, sloc.x,
sloc.y);

                                                SPR_Set(gHUD.GetSprite(Sprite), 0, 
255, 0);
                                                SPR_DrawAdditive(0,
                                                                       ScreenWidth/2 + 
sloc.x * ScreenWidth/2 - sprw / 2,
                                                                       ScreenHeight/2 
- sloc.y * ScreenHeight/2 - sprh / 2,
                                                                                       
                          &rect);




                                }
                        }
        }


        return 1;
}


-James "Corvidae" Williams ([EMAIL PROTECTED])
Administrator, Wavelength Forums (http://www.planethalflife.com/wavelength)
Co-Leader / Coder, Underhive (http://www.underhive.com)

_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to