--
[ Picked text/plain from multipart/alternative ]
Hey fellow HLCoders,

I've been subscribed to hlcoders for quite some time but I have my first
post worthy message :D. I am currently working on a replacement renderer for
half life 1. I currently have it working with both maps (without lightmaps)
and models( without lighting ). Currently I am trying to get decals up and
running. Using unions and the memory viewer in visual studio. I have
determined that the decal_s structure in half life is different than the
structure in the com_model.h header file, much like other structures in
opengl that sneaky bastard found based on the quake source. From what I have
tested it looks like the decal_s structure is actually:

#pragma pack( 1 )
struct decal_s
{
    decal_t     *pnext;         // linked list for each surface
    msurface_t  *psurface;      // Surface id for persistence / unlinking
    float       dx;             // Offsets into surface texture (in texture
coordinates, so we don't need floats)
    float       dy;
    float       scale;          // Scale
    short       texture;        // Texture, offset from the base decal index
    short       flags;          // Decal flags

    short       entityIndex;    // Entity this is attached to
};
#pragma pack( )

I was wondering if anyone at valve could confirm or deny the correctness of
this structure under opengl.  I have also been attempting to render the
decals using the snippet below but i can't seem to get the proper scaling on
the decal's size.

float flXScale = pDecal->scale * flWidth;  // flWidth is the decal's width
float flYScale = pDecal->scale * flHeight; // flHeight is the decal's height

// Render Polygon, testing
glBegin( GL_POLYGON );
for( uiCurPoly; uiCurPoly < uiMaxPoly; ++uiCurPoly, pVertData += VERTEXSIZE
)
{
    float flXCoord = ( pVertData[3] - pDecal->dx ) + ( ( pVertData[3] -
pDecal->dx ) * flXScale );    // generates position correctly
    float flYCoord = ( pVertData[4] - pDecal->dy ) + ( ( pVertData[4] -
pDecal->dy ) * flYScale );   // generates position correctly
    glTexCoord2f( flXCoord, flYCoord );

    glVertex3fv( pVertData );
}
glEnd( );

I have tried using both the surfaces texture coordinates(pVertData[3 and 4])
as well as the lightmap data(pVertData[5 and 6]) to set the decal
postion/scale. It seems that the texture coordinates give me the best
results in terms of position but neither correctly scale the decal.

Is my best bet going to be to overwrite the R_DecalShoot function in the
r_efx with my own custom decal function? (This creates issues with player
spray's.)

During my research I also found that some decals do not respond when
updating the dx, dy parameters of the decal_s, I assume that the decal code
may have been updated at some point to clip decals so they use less
polygon's than the surface they are attached to.

So if any one has any decal related advice, it would be greatly appreciated.

Thanks,
Jason "ssjason123" Matson
--

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

Reply via email to