本文整理汇总了C++中R_FindShader函数的典型用法代码示例。如果您正苦于以下问题:C++ R_FindShader函数的具体用法?C++ R_FindShader怎么用?C++ R_FindShader使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了R_FindShader函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Skins_ApplyVariant
static Skins_ApplyVariant(ModelContainer_t *pContainer, SkinSet_t::iterator itEthnic, ShadersForMaterial_t::iterator itMaterialShaders, string strMaterialName, int iVariant)
{
if (itMaterialShaders != (*itEthnic).second.end())
{
LPCSTR psShaderName = (*itMaterialShaders).second[iVariant].c_str(); // shader name to load from skinset
pContainer->MaterialShaders[strMaterialName] = psShaderName;
LPCSTR psLocalTexturePath = R_FindShader( psShaderName ); // shader->texture name
if (psLocalTexturePath && strlen(psLocalTexturePath))
{
TextureHandle_t hTexture = TextureHandle_ForName( psLocalTexturePath );
if (hTexture == -1)
{
hTexture = Texture_Load(psLocalTexturePath);
}
GLuint uiBind = Texture_GetGLBind( hTexture );
pContainer->MaterialBinds[strMaterialName] = uiBind;
}
}
}
示例2: Q_strncpyz
// if return == true, no further action needed by the caller...
//
void *RE_RegisterModels_Malloc(int iSize, void *pvDiskBufferIfJustLoaded, const char *psModelFileName, qboolean *pqbAlreadyFound, memtag_t eTag)
{
char sModelName[MAX_QPATH];
Q_strncpyz(sModelName,psModelFileName,sizeof(sModelName));
Q_strlwr (sModelName);
CachedEndianedModelBinary_t &ModelBin = (*CachedModels)[sModelName];
if (ModelBin.pModelDiskImage == NULL)
{
// ... then this entry has only just been created, ie we need to load it fully...
//
// new, instead of doing a R_Malloc and assigning that we just morph the disk buffer alloc
// then don't thrown it away on return - cuts down on mem overhead
//
// ... groan, but not if doing a limb hierarchy creation (some VV stuff?), in which case it's NULL
//
if ( pvDiskBufferIfJustLoaded )
{
R_MorphMallocTag( pvDiskBufferIfJustLoaded, eTag );
}
else
{
pvDiskBufferIfJustLoaded = R_Malloc(iSize,eTag, qfalse );
}
ModelBin.pModelDiskImage= pvDiskBufferIfJustLoaded;
ModelBin.iAllocSize = iSize;
*pqbAlreadyFound = qfalse;
}
else
{
// if we already had this model entry, then re-register all the shaders it wanted...
//
const int iEntries = ModelBin.ShaderRegisterData.size();
for (int i=0; i<iEntries; i++)
{
int iShaderNameOffset = ModelBin.ShaderRegisterData[i].first;
int iShaderPokeOffset = ModelBin.ShaderRegisterData[i].second;
const char *const psShaderName = &((char*)ModelBin.pModelDiskImage)[iShaderNameOffset];
int *const piShaderPokePtr= (int *) &((char*)ModelBin.pModelDiskImage)[iShaderPokeOffset];
shader_t *sh = R_FindShader( psShaderName, lightmapsNone, stylesDefault, qtrue );
if ( sh->defaultShader )
{
*piShaderPokePtr = 0;
} else {
*piShaderPokePtr = sh->index;
}
}
*pqbAlreadyFound = qtrue; // tell caller not to re-Endian or re-Shader this binary
}
ModelBin.iLastLevelUsedOn = RE_RegisterMedia_GetLevel();
return ModelBin.pModelDiskImage;
}
示例3: Q_strncpyz
// if return == true, no further action needed by the caller...
//
void *RE_RegisterModels_Malloc(int iSize, const char *psModelFileName, qboolean *pqbAlreadyFound, memtag_t eTag)
{
char sModelName[MAX_QPATH];
Q_strncpyz(sModelName,psModelFileName,sizeof(sModelName));
Q_strlwr (sModelName);
CachedEndianedModelBinary_t &ModelBin = CachedModels[sModelName];
if (ModelBin.pModelDiskImage == NULL)
{
// ... then this entry has only just been created, ie we need to load it fully...
//
void *pMalloc = ri.Malloc(iSize,eTag, qfalse );
if (!pMalloc) // not needed anymore, but wtf?
{
ri.Error( ERR_FATAL, "RE_RegisterModels_Malloc(): Failed to alloc %d bytes for \"%s\"!", iSize, psModelFileName );
}
ModelBin.pModelDiskImage= pMalloc;
ModelBin.iAllocSize = iSize;
*pqbAlreadyFound = qfalse;
}
else
{
// if we already had this model entry, then re-register all the shaders it wanted...
//
const int iEntries = ModelBin.ShaderRegisterData.size();
for (int i=0; i<iEntries; i++)
{
int iShaderNameOffset = ModelBin.ShaderRegisterData[i].first;
int iShaderPokeOffset = ModelBin.ShaderRegisterData[i].second;
const char *const psShaderName = &((char*)ModelBin.pModelDiskImage)[iShaderNameOffset];
int *const piShaderPokePtr= (int *) &((char*)ModelBin.pModelDiskImage)[iShaderPokeOffset];
shader_t *sh = R_FindShader( psShaderName, lightmapsNone, stylesDefault, qtrue );
if ( sh->defaultShader )
{
*piShaderPokePtr = 0;
} else {
*piShaderPokePtr = sh->index;
}
}
*pqbAlreadyFound = qtrue; // tell caller not to re-Endian or re-Shader this binary
}
ModelBin.iLastLevelUsedOn = RE_RegisterMedia_GetLevel();
return ModelBin.pModelDiskImage;
}
示例4: R_x42LoadDefaultShaders
static void R_x42LoadDefaultShaders( x42data_t *x42 )
{
uint i;
x42->groupMats = (int*)ri.Hunk_Alloc( sizeof( int ) * x42->header.numGroups, h_low );
for( i = 0; i < x42->header.numGroups; i++ )
{
shader_t *shader = R_FindShader( x42->strings + x42->groups[i].material, LIGHTMAP_NONE, qtrue );
x42->groupMats[i] = shader->defaultShader ? 0 : shader->index;
Q_strlwr( (char*)x42->strings + x42->groups[i].surfaceName );
}
}
示例5: R_LoadModelShadow
// loads a model's shadow script
static void R_LoadModelShadow( idRenderModel* mod ) {
// set default shadow
mod->q3_shadowShader = 0;
// build name
char filename[ 1024 ];
String::StripExtension2( mod->name, filename, sizeof ( filename ) );
String::DefaultExtension( filename, 1024, ".shadow" );
// load file
char* buf;
FS_ReadFile( filename, ( void** )&buf );
if ( !buf ) {
return;
}
char* shadowBits = strchr( buf, ' ' );
if ( shadowBits != NULL ) {
*shadowBits = '\0';
shadowBits++;
if ( String::Length( buf ) >= MAX_QPATH ) {
common->Printf( "R_LoadModelShadow: Shader name exceeds MAX_QPATH\n" );
mod->q3_shadowShader = 0;
} else {
shader_t* sh = R_FindShader( buf, LIGHTMAP_NONE, true );
if ( sh->defaultShader ) {
mod->q3_shadowShader = 0;
} else {
mod->q3_shadowShader = sh->index;
}
}
sscanf( shadowBits, "%f %f %f %f %f %f",
&mod->q3_shadowParms[ 0 ], &mod->q3_shadowParms[ 1 ], &mod->q3_shadowParms[ 2 ],
&mod->q3_shadowParms[ 3 ], &mod->q3_shadowParms[ 4 ], &mod->q3_shadowParms[ 5 ] );
}
FS_FreeFile( buf );
}
示例6: LittleLong
/*
===============
ShaderForShaderNum
===============
*/
static shader_t *ShaderForShaderNum( int shaderNum, const int *lightmapNum, const byte *lightmapStyles, const byte *vertexStyles ) {
shader_t *shader;
dshader_t *dsh;
const byte *styles;
styles = lightmapStyles;
shaderNum = LittleLong( shaderNum );
if ( shaderNum < 0 || shaderNum >= s_worldData.numShaders ) {
ri.Error( ERR_DROP, "ShaderForShaderNum: bad num %i", shaderNum );
}
dsh = &s_worldData.shaders[ shaderNum ];
if (lightmapNum[0] == LIGHTMAP_BY_VERTEX)
{
styles = vertexStyles;
}
if ( r_vertexLight->integer )
{
lightmapNum = lightmapsVertex;
styles = vertexStyles;
}
/* if ( r_fullbright->integer )
{
lightmapNum = lightmapsFullBright;
styles = vertexStyles;
}
*/
shader = R_FindShader( dsh->shader, lightmapNum, styles, qtrue );
// if the shader had errors, just use default shader
if ( shader->defaultShader ) {
return tr.defaultShader;
}
return shader;
}
示例7: R_LoadGLM
qboolean R_LoadGLM( model_t *mod, void *buffer, int filesize, const char *mod_name ) {
int i, j, lodindex, surfindex;
glmHeader_t *header, *glm;
glmLOD_t *lod;
glmLODSurfOffset_t *lod_surf_ofs;
glmSurfHierarchy_t *surfh;
glmVertexTexCoord_t *vcor;
glmSurface_t *surf;
glmTriangle_t *tri;
glmVertex_t *v;
int version;
int size;
shader_t *sh;
vec3_t tempVert;
vec3_t tempNorm;
//int frameSize;
float zrots[3][4];
qboolean do_zrot = qfalse;
zrots[0][0] = 0.0;
zrots[0][1] = -1.0;
zrots[0][2] = 0.0;
zrots[0][3] = 0.0;
zrots[1][0] = 1.0;
zrots[1][1] = 0.0;
zrots[1][2] = 0.0;
zrots[1][3] = 0.0;
zrots[2][0] = 0.0;
zrots[2][1] = 0.0;
zrots[2][2] = 1.0;
zrots[2][3] = 0.0;
if( filesize < sizeof( glmHeader_t ) ) {
return qfalse;
}
header = (glmHeader_t *)buffer;
version = LittleLong( header->version );
if( version != GLM_VERSION ) {
ri.Printf( PRINT_WARNING, "R_LoadGLM: %s has wrong version (%i should be %i)\n", mod_name, version, GLM_VERSION );
return qfalse;
}
size = LittleLong( header->ofsEnd );
if( size > filesize ) {
ri.Printf( PRINT_WARNING, "R_LoadGLM: Header of %s is broken. Wrong filesize declared!\n", mod_name );
return qfalse;
}
mod->type = MOD_GLM;
size = LittleLong(header->ofsEnd);
mod->dataSize += size;
//ri.Printf( PRINT_WARNING, "R_LoadGLM: %s alloc %d\n", mod_name, size );
mod->modelData = ri.Hunk_Alloc( size, h_low );
glm = (glmHeader_t *)mod->modelData;
Com_Memcpy( glm, buffer, size );
LL( glm->ident );
LL( glm->animIndex );
LL( glm->numBones );
LL( glm->numLODs );
LL( glm->ofsLODs );
LL( glm->numSurfaces );
LL( glm->ofsSurfHierarchy );
if ( GLM_CheckRange( glm, glm->ofsSurfHierarchy, glm->numSurfaces, sizeof( glmSurfHierarchy_t ) ) ) {
return qfalse;
}
// swap the surf Hierarchy!
surfh = (glmSurfHierarchy_t *) ( (byte *)glm + glm->ofsSurfHierarchy );
for( surfindex = 0; surfindex < glm->numSurfaces; surfindex++ )
{
Q_strlwr( surfh->name );
LL(surfh->flags);
Q_strlwr( surfh->shader );
//ri.Printf( PRINT_ALL, "surf %d, name '%s' shader '%s'\n", surfindex, surfh->name, surfh->shader );
sh = R_FindShader( surfh->shader, LIGHTMAP_NONE, qtrue );
if ( sh->defaultShader ) {
surfh->shaderIndex = 0;
} else {
LL(surfh->shaderIndex);
surfh->shaderIndex = sh->index;
}
LL(surfh->parentIndex);
LL(surfh->numChildren);
for( i = 0; i < surfh->numChildren; i++ ) {
LL(surfh->childIndexes[i]);
}
surfh = (glmSurfHierarchy_t *) ( (byte *)&surfh->childIndexes[surfh->numChildren] );
}
if ( GLM_CheckRange( glm, glm->ofsLODs, glm->numLODs, sizeof( glmLOD_t ) ) ) {
//.........这里部分代码省略.........
示例8: RE_BeginFrame
//.........这里部分代码省略.........
R_SyncRenderThread();
qglDisable( GL_STENCIL_TEST );
}
r_measureOverdraw->modified = qfalse;
}
if ( mme_saveStencil->integer == 1 ) {
R_SyncRenderThread();
qglEnable( GL_STENCIL_TEST );
qglStencilMask( ~0U );
qglClearStencil( 0U );
qglStencilFunc( GL_ALWAYS, 255U, 255U );
qglStencilOp( GL_KEEP, GL_KEEP, GL_ZERO );
backEnd.doingStencil = qfalse;
} else if ( mme_saveStencil->integer == 2 ) {
R_SyncRenderThread();
qglEnable( GL_STENCIL_TEST );
qglStencilMask( ~0U );
qglClearStencil( 0U );
qglStencilFunc( GL_ALWAYS, 255U, 255U );
qglStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE );
backEnd.doingStencil = qfalse;
} else {
qglDisable( GL_STENCIL_TEST );
}
//
// texturemode stuff
//
if ( r_textureMode->modified ) {
R_SyncRenderThread();
GL_TextureMode( r_textureMode->string );
r_textureMode->modified = qfalse;
}
if ( r_anisotropy->modified ) {
R_SyncRenderThread();
GL_Anisotropy( r_anisotropy->integer );
r_anisotropy->modified = qfalse;
}
//
// gamma stuff
//
if ( r_gamma->modified ) {
r_gamma->modified = qfalse;
R_SyncRenderThread();
R_SetColorMappings();
}
// check for errors
if ( !r_ignoreGLErrors->integer ) {
int err;
R_SyncRenderThread();
if ( ( err = qglGetError() ) != GL_NO_ERROR ) {
ri.Error( ERR_FATAL, "RE_BeginFrame() - glGetError() failed (0x%x)!\n", err );
}
}
if ( mme_worldShader->modified) {
if (R_FindShaderText( mme_worldShader->string )) {
tr.mmeWorldShader = R_FindShader( mme_worldShader->string, LIGHTMAP_NONE, qtrue );
} else {
tr.mmeWorldShader = 0;
}
mme_worldShader->modified = qfalse;
}
if ( mme_pip->integer ) {
tr.mmeWorldShader = R_FindShader( "mme/pip", -1, qtrue );
}
//
// draw buffer stuff
//
cmd = R_GetCommandBuffer( RC_DRAW_BUFFER, sizeof( *cmd ) );
if ( !cmd ) {
return;
}
if ( glConfig.stereoEnabled ) {
if ( stereoFrame == STEREO_LEFT ) {
cmd->buffer = (int)GL_BACK_LEFT;
} else if ( stereoFrame == STEREO_RIGHT ) {
cmd->buffer = (int)GL_BACK_RIGHT;
} else {
ri.Error( ERR_FATAL, "RE_BeginFrame: Stereo is enabled, but stereoFrame was %i", stereoFrame );
}
} else {
if ( stereoFrame != STEREO_CENTER ) {
ri.Error( ERR_FATAL, "RE_BeginFrame: Stereo is disabled, but stereoFrame was %i", stereoFrame );
}
if ( !Q_stricmp( r_drawBuffer->string, "GL_FRONT" ) ) {
cmd->buffer = (int)GL_FRONT;
} else {
cmd->buffer = (int)GL_BACK;
}
}
}
示例9: RE_RegisterIndividualSkin
// given a name, go get the skin we want and return
qhandle_t RE_RegisterIndividualSkin( const char *name , qhandle_t hSkin)
{
skin_t *skin;
skinSurface_t *surf;
char *text, *text_p;
char *token;
char surfName[MAX_QPATH];
// load and parse the skin file
ri->FS_ReadFile( name, (void **)&text );
if ( !text ) {
#ifndef FINAL_BUILD
Com_Printf( "WARNING: RE_RegisterSkin( '%s' ) failed to load!\n", name );
#endif
return 0;
}
assert (tr.skins[hSkin]); //should already be setup, but might be an 3part append
skin = tr.skins[hSkin];
text_p = text;
while ( text_p && *text_p ) {
// get surface name
token = CommaParse( &text_p );
Q_strncpyz( surfName, token, sizeof( surfName ) );
if ( !token[0] ) {
break;
}
// lowercase the surface name so skin compares are faster
Q_strlwr( surfName );
if ( *text_p == ',' ) {
text_p++;
}
if ( !strncmp( token, "tag_", 4 ) ) { //these aren't in there, but just in case you load an id style one...
continue;
}
// parse the shader name
token = CommaParse( &text_p );
if ( !strcmp( &surfName[strlen(surfName)-4], "_off") )
{
if ( !strcmp( token ,"*off" ) )
{
continue; //don't need these double offs
}
surfName[strlen(surfName)-4] = 0; //remove the "_off"
}
if ( (unsigned)skin->numSurfaces >= ARRAY_LEN( skin->surfaces ) )
{
assert( ARRAY_LEN( skin->surfaces ) > (unsigned)skin->numSurfaces );
Com_Printf( "WARNING: RE_RegisterSkin( '%s' ) more than %d surfaces!\n", name, ARRAY_LEN( skin->surfaces ) );
break;
}
surf = (skinSurface_t *) Hunk_Alloc( sizeof( *skin->surfaces[0] ), h_low );
skin->surfaces[skin->numSurfaces] = (_skinSurface_t *)surf;
Q_strncpyz( surf->name, surfName, sizeof( surf->name ) );
if (gServerSkinHack) surf->shader = R_FindServerShader( token, lightmapsNone, stylesDefault, qtrue );
else surf->shader = R_FindShader( token, lightmapsNone, stylesDefault, qtrue );
skin->numSurfaces++;
}
ri->FS_FreeFile( text );
// never let a skin have 0 shaders
if ( skin->numSurfaces == 0 ) {
return 0; // use default skin
}
return hSkin;
}
示例10: R_LoadMD5
//.........这里部分代码省略.........
if ( Q_stricmp( token, "{" ) )
{
ri.Printf( PRINT_WARNING, "R_LoadMD5: expected '{' found '%s' in model '%s'\n", token, modName );
return qfalse;
}
// change to surface identifier
surf->surfaceType = SF_MD5;
// give pointer to model for Tess_SurfaceMD5
surf->model = md5;
// parse shader <name>
token = COM_ParseExt2( &buf_p, qtrue );
if ( Q_stricmp( token, "shader" ) )
{
Q_strncpyz( surf->shader, "<default>", sizeof( surf->shader ) );
surf->shaderIndex = 0;
}
else
{
token = COM_ParseExt2( &buf_p, qfalse );
Q_strncpyz( surf->shader, token, sizeof( surf->shader ) );
//ri.Printf(PRINT_ALL, "R_LoadMD5: '%s' uses shader '%s'\n", modName, surf->shader);
// FIXME .md5mesh meshes don't have surface names
// lowercase the surface name so skin compares are faster
//Q_strlwr(surf->name);
//ri.Printf(PRINT_ALL, "R_LoadMD5: '%s' has surface '%s'\n", modName, surf->name);
// register the shaders
sh = R_FindShader( surf->shader, LIGHTMAP_NONE, qtrue );
if ( sh->defaultShader )
{
surf->shaderIndex = 0;
}
else
{
surf->shaderIndex = sh->index;
}
token = COM_ParseExt2( &buf_p, qtrue );
}
// parse numVerts <number>
if ( Q_stricmp( token, "numVerts" ) )
{
ri.Printf( PRINT_WARNING, "R_LoadMD5: expected 'numVerts' found '%s' in model '%s'\n", token, modName );
return qfalse;
}
token = COM_ParseExt2( &buf_p, qfalse );
surf->numVerts = atoi( token );
if ( surf->numVerts > SHADER_MAX_VERTEXES )
{
ri.Error( ERR_DROP, "R_LoadMD5: '%s' has more than %i verts on a surface (%i)",
modName, SHADER_MAX_VERTEXES, surf->numVerts );
}
surf->verts = ri.Hunk_Alloc( sizeof( *v ) * surf->numVerts, h_low );
for ( j = 0, v = surf->verts; j < surf->numVerts; j++, v++ )
示例11: R_LoadMD3
//.........这里部分代码省略.........
tag = (md3Tag_t *) ( (byte *)mod->md3[lod] + mod->md3[lod]->ofsTags );
for ( i = 0 ; i < mod->md3[lod]->numTags * mod->md3[lod]->numFrames ; i++, tag++) {
for ( j = 0 ; j < 3 ; j++ ) {
tag->origin[j] = LittleFloat( tag->origin[j] );
tag->axis[0][j] = LittleFloat( tag->axis[0][j] );
tag->axis[1][j] = LittleFloat( tag->axis[1][j] );
tag->axis[2][j] = LittleFloat( tag->axis[2][j] );
}
}
#endif
// swap all the surfaces
surf = (md3Surface_t *) ( (byte *)mod->md3[lod] + mod->md3[lod]->ofsSurfaces );
for ( i = 0 ; i < mod->md3[lod]->numSurfaces ; i++) {
LL(surf->flags);
LL(surf->numFrames);
LL(surf->numShaders);
LL(surf->numTriangles);
LL(surf->ofsTriangles);
LL(surf->numVerts);
LL(surf->ofsShaders);
LL(surf->ofsSt);
LL(surf->ofsXyzNormals);
LL(surf->ofsEnd);
if ( surf->numVerts > SHADER_MAX_VERTEXES ) {
ri.Error (ERR_DROP, "R_LoadMD3: %s has more than %i verts on a surface (%i)",
mod_name, SHADER_MAX_VERTEXES, surf->numVerts );
}
if ( surf->numTriangles*3 > SHADER_MAX_INDEXES ) {
ri.Error (ERR_DROP, "R_LoadMD3: %s has more than %i triangles on a surface (%i)",
mod_name, SHADER_MAX_INDEXES / 3, surf->numTriangles );
}
// change to surface identifier
surf->ident = SF_MD3;
// lowercase the surface name so skin compares are faster
Q_strlwr( surf->name );
// strip off a trailing _1 or _2
// this is a crutch for q3data being a mess
j = strlen( surf->name );
if ( j > 2 && surf->name[j-2] == '_' ) {
surf->name[j-2] = 0;
}
// register the shaders
shader = (md3Shader_t *) ( (byte *)surf + surf->ofsShaders );
for ( j = 0 ; j < surf->numShaders ; j++, shader++ ) {
shader_t *sh;
sh = R_FindShader( shader->name, lightmapsNone, stylesDefault, qtrue );
if ( sh->defaultShader ) {
shader->shaderIndex = 0;
} else {
shader->shaderIndex = sh->index;
}
RE_RegisterModels_StoreShaderRequest(mod_name, &shader->name[0], &shader->shaderIndex);
}
#ifndef _M_IX86
//
// optimisation, we don't bother doing this for standard intel case since our data's already in that format...
//
// swap all the triangles
tri = (md3Triangle_t *) ( (byte *)surf + surf->ofsTriangles );
for ( j = 0 ; j < surf->numTriangles ; j++, tri++ ) {
LL(tri->indexes[0]);
LL(tri->indexes[1]);
LL(tri->indexes[2]);
}
// swap all the ST
st = (md3St_t *) ( (byte *)surf + surf->ofsSt );
for ( j = 0 ; j < surf->numVerts ; j++, st++ ) {
st->st[0] = LittleFloat( st->st[0] );
st->st[1] = LittleFloat( st->st[1] );
}
// swap all the XyzNormals
xyz = (md3XyzNormal_t *) ( (byte *)surf + surf->ofsXyzNormals );
for ( j = 0 ; j < surf->numVerts * surf->numFrames ; j++, xyz++ )
{
xyz->xyz[0] = LittleShort( xyz->xyz[0] );
xyz->xyz[1] = LittleShort( xyz->xyz[1] );
xyz->xyz[2] = LittleShort( xyz->xyz[2] );
xyz->normal = LittleShort( xyz->normal );
}
#endif
// find the next surface
surf = (md3Surface_t *)( (byte *)surf + surf->ofsEnd );
}
return qtrue;
}
示例12: R_RMGInit
void R_RMGInit(void)
{
char newSky[MAX_QPATH];
char newFog[MAX_QPATH];
shader_t *fog;
fog_t *gfog;
mgrid_t *grid;
char temp[MAX_QPATH];
int i;
unsigned short *pos;
ri.Cvar_VariableStringBuffer("RMG_sky", newSky, MAX_QPATH);
// Get sunlight - this should set up all the sunlight data
R_FindShader( newSky, lightmapsNone, stylesDefault, qfalse );
// Remap sky
R_RemapShader("textures/tools/_sky", newSky, NULL);
// Fill in the lightgrid with sunlight
if(tr.world->lightGridData)
{
grid = tr.world->lightGridData;
grid->ambientLight[0][0] = (byte)Com_Clampi(0, 255, tr.sunAmbient[0] * 255.0f);
grid->ambientLight[0][1] = (byte)Com_Clampi(0, 255, tr.sunAmbient[1] * 255.0f);
grid->ambientLight[0][2] = (byte)Com_Clampi(0, 255, tr.sunAmbient[2] * 255.0f);
R_ColorShiftLightingBytes(grid->ambientLight[0], grid->ambientLight[0]);
grid->directLight[0][0] = (byte)Com_Clampi(0, 255, tr.sunLight[0]);
grid->directLight[0][1] = (byte)Com_Clampi(0, 255, tr.sunLight[1]);
grid->directLight[0][2] = (byte)Com_Clampi(0, 255, tr.sunLight[2]);
R_ColorShiftLightingBytes(grid->directLight[0], grid->directLight[0]);
NormalToLatLong(tr.sunDirection, grid->latLong);
pos = tr.world->lightGridArray;
for(i=0;i<tr.world->numGridArrayElements;i++)
{
*pos = 0;
pos++;
}
}
// Override the global fog with the defined one
if(tr.world->globalFog != -1)
{
ri.Cvar_VariableStringBuffer("RMG_fog", newFog, MAX_QPATH);
fog = R_FindShader( newFog, lightmapsNone, stylesDefault, qfalse);
if (fog != tr.defaultShader)
{
gfog = tr.world->fogs + tr.world->globalFog;
gfog->parms = *fog->fogParms;
if (gfog->parms.depthForOpaque)
{
gfog->tcScale = 1.0f / ( gfog->parms.depthForOpaque * 8.0f );
tr.distanceCull = gfog->parms.depthForOpaque;
tr.distanceCullSquared = tr.distanceCull * tr.distanceCull;
ri.Cvar_Set("RMG_distancecull", va("%f", tr.distanceCull));
}
else
{
gfog->tcScale = 1.0f;
}
gfog->colorInt = ColorBytes4 ( gfog->parms.color[0],
gfog->parms.color[1],
gfog->parms.color[2], 1.0f );
}
}
ri.Cvar_VariableStringBuffer("RMG_weather", temp, MAX_QPATH);
// Set up any weather effects
switch(atol(temp))
{
case 0:
break;
case 1:
RE_WorldEffectCommand("rain init 1000");
RE_WorldEffectCommand("rain outside");
break;
case 2:
RE_WorldEffectCommand("snow init 1000 outside");
RE_WorldEffectCommand("snow outside");
break;
}
}
示例13: R_LoadMD3
//.........这里部分代码省略.........
}
}
// swap all the tags
tag = (md3Tag_t *) ( (byte *)mod->md3[lod] + mod->md3[lod]->ofsTags );
for ( i = 0 ; i < mod->md3[lod]->numTags * mod->md3[lod]->numFrames ; i++, tag++) {
for ( j = 0 ; j < 3 ; j++ ) {
LF(tag->origin[j]);
LF(tag->axis[0][j]);
LF(tag->axis[1][j]);
LF(tag->axis[2][j]);
}
}
#endif
// swap all the surfaces
surf = (md3Surface_t *) ( (byte *)mod->md3[lod] + mod->md3[lod]->ofsSurfaces );
for ( i = 0 ; i < mod->md3[lod]->numSurfaces ; i++) {
LL(surf->flags);
LL(surf->numFrames);
LL(surf->numShaders);
LL(surf->numTriangles);
LL(surf->ofsTriangles);
LL(surf->numVerts);
LL(surf->ofsShaders);
LL(surf->ofsSt);
LL(surf->ofsXyzNormals);
LL(surf->ofsEnd);
if ( surf->numVerts > SHADER_MAX_VERTEXES ) {
Com_Error (ERR_DROP, "R_LoadMD3: %s has more than %i verts on a surface (%i)",
mod_name, SHADER_MAX_VERTEXES, surf->numVerts );
}
if ( surf->numTriangles*3 > SHADER_MAX_INDEXES ) {
Com_Error (ERR_DROP, "R_LoadMD3: %s has more than %i triangles on a surface (%i)",
mod_name, SHADER_MAX_INDEXES / 3, surf->numTriangles );
}
// change to surface identifier
surf->ident = SF_MD3;
// lowercase the surface name so skin compares are faster
Q_strlwr( surf->name );
// strip off a trailing _1 or _2
// this is a crutch for q3data being a mess
j = strlen( surf->name );
if ( j > 2 && surf->name[j-2] == '_' ) {
surf->name[j-2] = 0;
}
// register the shaders
shader = (md3Shader_t *) ( (byte *)surf + surf->ofsShaders );
for ( j = 0 ; j < surf->numShaders ; j++, shader++ ) {
shader_t *sh;
sh = R_FindShader( shader->name, lightmapsNone, stylesDefault, qtrue );
if ( sh->defaultShader ) {
shader->shaderIndex = 0;
} else {
shader->shaderIndex = sh->index;
}
RE_RegisterModels_StoreShaderRequest(mod_name, &shader->name[0], &shader->shaderIndex);
}
#ifdef Q3_BIG_ENDIAN
// swap all the triangles
tri = (md3Triangle_t *) ( (byte *)surf + surf->ofsTriangles );
for ( j = 0 ; j < surf->numTriangles ; j++, tri++ ) {
LL(tri->indexes[0]);
LL(tri->indexes[1]);
LL(tri->indexes[2]);
}
// swap all the ST
st = (md3St_t *) ( (byte *)surf + surf->ofsSt );
for ( j = 0 ; j < surf->numVerts ; j++, st++ ) {
LF(st->st[0]);
LF(st->st[1]);
}
// swap all the XyzNormals
xyz = (md3XyzNormal_t *) ( (byte *)surf + surf->ofsXyzNormals );
for ( j = 0 ; j < surf->numVerts * surf->numFrames ; j++, xyz++ )
{
LS(xyz->xyz[0]);
LS(xyz->xyz[1]);
LS(xyz->xyz[2]);
LS(xyz->normal);
}
#endif
// find the next surface
surf = (md3Surface_t *)( (byte *)surf + surf->ofsEnd );
}
return qtrue;
}
示例14: models
/*
==============
RE_GetShaderFromModel
return a shader index for a given model's surface
'withlightmap' set to '0' will create a new shader that is a copy of the one found
on the model, without the lighmap stage, if the shader has a lightmap stage
NOTE: only works for bmodels right now. Could modify for other models (md3's etc.)
==============
*/
qhandle_t RE_GetShaderFromModel( qhandle_t modelid, int surfnum, int withlightmap )
{
model_t *model;
bmodel_t *bmodel;
msurface_t *surf;
shader_t *shd;
if ( surfnum < 0 )
{
surfnum = 0;
}
model = R_GetModelByHandle( modelid ); // (SA) should be correct now
if ( model )
{
bmodel = model->model.bmodel;
if ( bmodel && bmodel->firstSurface )
{
if ( surfnum >= bmodel->numSurfaces )
{
// if it's out of range, return the first surface
surfnum = 0;
}
surf = bmodel->firstSurface + surfnum;
// RF, check for null shader (can happen on func_explosive entities with botclips attached)
if ( !surf->shader )
{
return 0;
}
// if(surf->shader->lightmapIndex != LIGHTMAP_NONE) {
if ( surf->shader->lightmapIndex > LIGHTMAP_NONE )
{
image_t *image;
long hash;
qboolean mip = qtrue; // mip generation on by default
// get mipmap info for original texture
hash = GenerateImageHashValue( surf->shader->name );
for ( image = r_imageHashTable[ hash ]; image; image = image->next )
{
if ( !strcmp( surf->shader->name, image->imgName ) )
{
mip = image->mipmap;
break;
}
}
shd = R_FindShader( surf->shader->name, LIGHTMAP_NONE, mip );
shd->stages[ 0 ]->rgbGen = CGEN_LIGHTING_DIFFUSE; // (SA) new
}
else
{
shd = surf->shader;
}
return shd->index;
}
}
return 0;
}
示例15: R_LoadMD5
//.........这里部分代码省略.........
if (Q_stricmp(token, "{"))
{
Ren_Warning("R_LoadMD5: expected '{' found '%s' in model '%s'\n", token, modName);
return qfalse;
}
// change to surface identifier
surf->surfaceType = SF_MD5;
// give pointer to model for Tess_SurfaceMD5
surf->model = md5;
// parse shader <name>
token = COM_ParseExt2(&buf_p, qtrue);
if (Q_stricmp(token, "shader"))
{
Ren_Warning("R_LoadMD5: expected 'shader' found '%s' in model '%s'\n", token, modName);
return qfalse;
}
token = COM_ParseExt2(&buf_p, qfalse);
Q_strncpyz(surf->shader, token, sizeof(surf->shader));
//Ren_Print("R_LoadMD5: '%s' uses shader '%s'\n", modName, surf->shader);
// FIXME .md5mesh meshes don't have surface names
// lowercase the surface name so skin compares are faster
//Q_strlwr(surf->name);
//Ren_Print("R_LoadMD5: '%s' has surface '%s'\n", modName, surf->name);
// register the shaders
sh = R_FindShader(surf->shader, SHADER_3D_DYNAMIC, qtrue);
if (sh->defaultShader)
{
surf->shaderIndex = 0;
}
else
{
surf->shaderIndex = sh->index;
}
// parse numVerts <number>
token = COM_ParseExt2(&buf_p, qtrue);
if (Q_stricmp(token, "numVerts"))
{
Ren_Warning("R_LoadMD5: expected 'numVerts' found '%s' in model '%s'\n", token, modName);
return qfalse;
}
token = COM_ParseExt2(&buf_p, qfalse);
surf->numVerts = atoi(token);
if (surf->numVerts > SHADER_MAX_VERTEXES)
{
Ren_Drop("R_LoadMD5: '%s' has more than %i verts on a surface (%i)",
modName, SHADER_MAX_VERTEXES, surf->numVerts);
}
surf->verts = ri.Hunk_Alloc(sizeof(*v) * surf->numVerts, h_low);
for (j = 0, v = surf->verts; j < surf->numVerts; j++, v++)
{