/* ============= DeformText Change a polygon into a bunch of text polygons ============= */ void DeformText( const char *text ) { int i; vec3_t origin, width, height; int len; int ch; byte color[4]; float bottom, top; vec3_t mid; height[0] = 0; height[1] = 0; height[2] = -1; CrossProduct( tess.normal[0], height, width ); // find the midpoint of the box VectorClear( mid ); bottom = WORLD_SIZE; //999999; // WORLD_SIZE instead of MAX_WORLD_COORD so guaranteed to be... top = -WORLD_SIZE; //-999999; // ... outside the legal range. for ( i = 0 ; i < 4 ; i++ ) { VectorAdd( tess.xyz[i], mid, mid ); if ( tess.xyz[i][2] < bottom ) { bottom = tess.xyz[i][2]; } if ( tess.xyz[i][2] > top ) { top = tess.xyz[i][2]; } } VectorScale( mid, 0.25f, origin ); // determine the individual character size height[0] = 0; height[1] = 0; height[2] = ( top - bottom ) * 0.5f; VectorScale( width, height[2] * -0.75f, width ); // determine the starting position len = strlen( text ); VectorMA( origin, (len-1), width, origin ); // clear the shader indexes tess.numIndexes = 0; tess.numVertexes = 0; color[0] = color[1] = color[2] = color[3] = 255; // draw each character for ( i = 0 ; i < len ; i++ ) { ch = text[i]; ch &= 255; if ( ch != ' ' ) { int row, col; float frow, fcol, size; row = ch>>4; col = ch&15; frow = row*0.0625f; fcol = col*0.0625f; size = 0.0625f; RB_AddQuadStampExt( origin, width, height, color, fcol, frow, fcol + size, frow + size ); } VectorMA( origin, -2, width, origin ); }
/* ============= DeformText Change a polygon into a bunch of text polygons ============= */ void DeformText( const char *text ) { int i; vec3_t origin, width, height; int len; int ch; float color[4]; float bottom, top; vec3_t mid; vec3_t fNormal; height[0] = 0; height[1] = 0; height[2] = -1; R_VaoUnpackNormal(fNormal, tess.normal[0]); CrossProduct( fNormal, height, width ); // find the midpoint of the box VectorClear( mid ); bottom = 999999; top = -999999; for ( i = 0 ; i < 4 ; i++ ) { VectorAdd( tess.xyz[i], mid, mid ); if ( tess.xyz[i][2] < bottom ) { bottom = tess.xyz[i][2]; } if ( tess.xyz[i][2] > top ) { top = tess.xyz[i][2]; } } VectorScale( mid, 0.25f, origin ); // determine the individual character size height[0] = 0; height[1] = 0; height[2] = ( top - bottom ) * 0.5f; VectorScale( width, height[2] * -0.75f, width ); // determine the starting position len = strlen( text ); VectorMA( origin, ( len - 1 ), width, origin ); // clear the shader indexes tess.numIndexes = 0; tess.numVertexes = 0; tess.firstIndex = 0; color[0] = color[1] = color[2] = color[3] = 1.0f; // draw each character for ( i = 0 ; i < len ; i++ ) { ch = text[i]; ch &= 255; if ( ch != ' ' ) { int row, col; float frow, fcol, size; row = ch >> 4; col = ch & 15; frow = row * 0.0625f; fcol = col * 0.0625f; size = 0.0625f; RB_AddQuadStampExt( origin, width, height, color, fcol, frow, fcol + size, frow + size ); } VectorMA( origin, -2, width, origin ); }
/* * DeformText * * Change a polygon into a bunch of text polygons */ void DeformText(const char *text) { int i; Vec3 origin, width, height; int len; int ch; float color[4]; float bottom, top; Vec3 mid; height[0] = 0; height[1] = 0; height[2] = -1; crossv3(tess.normal[0], height, width); /* find the midpoint of the box */ clearv3(mid); bottom = 999999; top = -999999; for(i = 0; i < 4; i++){ addv3(tess.xyz[i], mid, mid); if(tess.xyz[i][2] < bottom){ bottom = tess.xyz[i][2]; } if(tess.xyz[i][2] > top){ top = tess.xyz[i][2]; } } scalev3(mid, 0.25f, origin); /* determine the individual character size */ height[0] = 0; height[1] = 0; height[2] = (top - bottom) * 0.5f; scalev3(width, height[2] * -0.75f, width); /* determine the starting position */ len = strlen(text); saddv3(origin, (len-1), width, origin); /* clear the shader indexes */ tess.numIndexes = 0; tess.numVertexes = 0; tess.firstIndex = 0; color[0] = color[1] = color[2] = color[3] = 1.0f; /* draw each character */ for(i = 0; i < len; i++){ ch = text[i]; ch &= 255; if(ch != ' '){ int row, col; float frow, fcol, size; row = ch>>4; col = ch&15; frow = row*0.0625f; fcol = col*0.0625f; size = 0.0625f; RB_AddQuadStampExt(origin, width, height, color, fcol, frow, fcol + size, frow + size); } saddv3(origin, -2, width, origin); }
/* ============== RB_AddQuadStamp ============== */ void RB_AddQuadStamp( vec3_t origin, vec3_t left, vec3_t up, float color[4] ) { RB_AddQuadStampExt( origin, left, up, color, 0, 0, 1, 1 ); }
// Change a polygon into a bunch of text polygons void DeformText( const char *text ) { int i; vector3 origin, width, height; int len; int ch; byte color[4]; float bottom, top; vector3 mid; height.x = 0; height.y = 0; height.z = -1; CrossProduct( &tess.normal[0], &height, &width ); // find the midpoint of the box VectorClear( &mid ); bottom = 999999; top = -999999; for ( i = 0 ; i < 4 ; i++ ) { VectorAdd( &tess.xyz[i], &mid, &mid ); if ( tess.xyz[i].z < bottom ) { bottom = tess.xyz[i].z; } if ( tess.xyz[i].z > top ) { top = tess.xyz[i].z; } } VectorScale( &mid, 0.25f, &origin ); // determine the individual character size height.x = 0; height.y = 0; height.z = ( top - bottom ) * 0.5f; VectorScale( &width, height.z * -0.75f, &width ); // determine the starting position len = strlen( text ); VectorMA( &origin, (float)(len-1), &width, &origin ); // clear the shader indexes tess.numIndexes = 0; tess.numVertexes = 0; color[0] = color[1] = color[2] = color[3] = 255; // draw each character for ( i = 0 ; i < len ; i++ ) { ch = text[i]; ch &= 255; if ( ch != ' ' ) { int row, col; float frow, fcol, size; row = ch>>4; col = ch&15; frow = row*0.0625f; fcol = col*0.0625f; size = 0.0625f; RB_AddQuadStampExt( &origin, &width, &height, color, fcol, frow, fcol + size, frow + size ); } VectorMA( &origin, -2, &width, &origin ); }