/* ================= R_AddMD3Surfaces ================= */ void R_AddMD3Surfaces(trRefEntity_t * ent) { int i; md3Header_t *header = 0; md3Surface_t *surface = 0; md3Shader_t *md3Shader = 0; shader_t *shader = 0; int cull; int lod; int fogNum; bool personalModel; // don't add third_person objects if not in a portal personalModel = (ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal; if(ent->e.renderfx & RF_WRAP_FRAMES) { ent->e.frame %= tr.currentModel->model.md3[0]->numFrames; ent->e.oldframe %= tr.currentModel->model.md3[0]->numFrames; } // // compute LOD // if(ent->e.renderfx & RF_FORCENOLOD) { lod = 0; } else { lod = R_ComputeLOD(ent); } // // Validate the frames so there is no chance of a crash. // This will write directly into the entity structure, so // when the surfaces are rendered, they don't need to be // range checked again. // if((ent->e.frame >= tr.currentModel->model.md3[lod]->numFrames) || (ent->e.frame < 0) || (ent->e.oldframe >= tr.currentModel->model.md3[lod]->numFrames) || (ent->e.oldframe < 0)) { ri.Printf(PRINT_DEVELOPER, "R_AddMD3Surfaces: no such frame %d to %d for '%s' (%d)\n", ent->e.oldframe, ent->e.frame, tr.currentModel->name, tr.currentModel->model.md3[lod]->numFrames); ent->e.frame = 0; ent->e.oldframe = 0; } header = tr.currentModel->model.md3[lod]; // // cull the entire model if merged bounding box of both frames // is outside the view frustum. // cull = R_CullModel(header, ent); if(cull == CULL_OUT) { return; } // // set up lighting now that we know we aren't culled // if(!personalModel || r_shadows->integer > 1) { R_SetupEntityLighting(&tr.refdef, ent); } // // see if we are in a fog volume // fogNum = R_ComputeFogNum(header, ent); // // draw all surfaces // surface = (md3Surface_t *) ((byte *) header + header->ofsSurfaces); for(i = 0; i < header->numSurfaces; i++) { if(ent->e.customShader) { shader = R_GetShaderByHandle(ent->e.customShader); } else if(ent->e.customSkin > 0 && ent->e.customSkin < tr.numSkins) { skin_t *skin; int hash; int j; skin = R_GetSkinByHandle(ent->e.customSkin); // match the surface name to something in the skin file shader = tr.defaultShader; //----(SA) added blink if(ent->e.renderfx & RF_BLINK) { char *s = va("%s_b", surface->name); // append '_b' for 'blink' hash = Com_HashKey(s, strlen(s)); for(j = 0; j < skin->numSurfaces; j++) { if(hash != skin->surfaces[j]->hash) { continue; } if(!strcmp(skin->surfaces[j]->name, s)) { shader = skin->surfaces[j]->shader; break; } } } if(shader == tr.defaultShader) { // blink reference in skin was not found hash = Com_HashKey(surface->name, sizeof(surface->name)); for(j = 0; j < skin->numSurfaces; j++) { // the names have both been lowercased if(hash != skin->surfaces[j]->hash) { continue; } if(!strcmp(skin->surfaces[j]->name, surface->name)) { shader = skin->surfaces[j]->shader; break; } } } //----(SA) end if(shader == tr.defaultShader) { ri.Printf(PRINT_DEVELOPER, "WARNING: no shader for surface %s in skin %s\n", surface->name, skin->name); } else if(shader->defaultShader) { ri.Printf(PRINT_DEVELOPER, "WARNING: shader %s in skin %s not found\n", shader->name, skin->name); } } else if(surface->numShaders <= 0) { shader = tr.defaultShader; } else { md3Shader = (md3Shader_t *) ((byte *) surface + surface->ofsShaders); md3Shader += ent->e.skinNum % surface->numShaders; shader = tr.shaders[md3Shader->shaderIndex]; } // we will add shadows even if the main object isn't visible in the view // stencil shadows can't do personal models unless I polyhedron clip if(!personalModel && r_shadows->integer == 2 && fogNum == 0 && !(ent->e.renderfx & (RF_NOSHADOW | RF_DEPTHHACK)) && shader->sort == SS_OPAQUE) { R_AddDrawSurf((surfaceType_t *)surface, tr.shadowShader, 0, 0, 0); } // projection shadows work fine with personal models if(r_shadows->integer == 3 && fogNum == 0 && (ent->e.renderfx & RF_SHADOW_PLANE) && shader->sort == SS_OPAQUE) { R_AddDrawSurf((surfaceType_t *)surface, tr.projectionShadowShader, 0, 0, 0); } // for testing polygon shadows (on /all/ models) if(r_shadows->integer == 4) { R_AddDrawSurf((surfaceType_t *)surface, tr.projectionShadowShader, 0, 0, 0); } // don't add third_person objects if not viewing through a portal if(!personalModel) { R_AddDrawSurf((surfaceType_t *)surface, shader, fogNum, 0, 0); } surface = (md3Surface_t *) ((byte *) surface + surface->ofsEnd); } }
/* ============== R_AddAnimSurfaces ============== */ void R_AddAnimSurfaces(trRefEntity_t *ent) { mdsHeader_t *header = tr.currentModel->model.mds; mdsSurface_t *surface; shader_t *shader = 0; int i, fogNum, cull; qboolean personalModel = (ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal; // don't add third_person objects if not in a portal // cull the entire model if merged bounding box of both frames // is outside the view frustum. cull = R_CullModel(header, ent); if (cull == CULL_OUT) { return; } // set up lighting now that we know we aren't culled if (!personalModel || r_shadows->integer > 1) { R_SetupEntityLighting(&tr.refdef, ent); } // see if we are in a fog volume fogNum = R_ComputeFogNum(header, ent); surface = ( mdsSurface_t * )((byte *)header + header->ofsSurfaces); for (i = 0 ; i < header->numSurfaces ; i++) { if (ent->e.customShader) { shader = R_GetShaderByHandle(ent->e.customShader); } else if (ent->e.customSkin > 0 && ent->e.customSkin < tr.numSkins) { skin_t *skin; int hash; int j; skin = R_GetSkinByHandle(ent->e.customSkin); // match the surface name to something in the skin file shader = tr.defaultShader; if (ent->e.renderfx & RF_BLINK) { char *s = va("%s_b", surface->name); // append '_b' for 'blink' hash = Com_HashKey(s, strlen(s)); for (j = 0 ; j < skin->numSurfaces ; j++) { if (hash != skin->surfaces[j]->hash) { continue; } if (!strcmp(skin->surfaces[j]->name, s)) { shader = skin->surfaces[j]->shader; break; } } } if (shader == tr.defaultShader) // blink reference in skin was not found { hash = Com_HashKey(surface->name, sizeof(surface->name)); for (j = 0 ; j < skin->numSurfaces ; j++) { // the names have both been lowercased if (hash != skin->surfaces[j]->hash) { continue; } if (!strcmp(skin->surfaces[j]->name, surface->name)) { shader = skin->surfaces[j]->shader; break; } } } if (shader == tr.defaultShader) { Ren_Developer("WARNING: no shader for surface %s in skin %s\n", surface->name, skin->name); } else if (shader->defaultShader) { Ren_Developer("WARNING: shader %s in skin %s not found\n", shader->name, skin->name); } } else { shader = R_GetShaderByHandle(surface->shaderIndex); } // don't add third_person objects if not viewing through a portal if (!personalModel) { R_AddDrawSurf((void *)surface, shader, fogNum, 0, 0); } surface = ( mdsSurface_t * )((byte *)surface + surface->ofsEnd); } }
/* ================= R_AddMDCSurfaces ================= */ void R_AddMDCSurfaces( trRefEntity_t *ent ) { int i; mdcHeader_t *header = 0; mdcSurface_t *surface = 0; md3Shader_t *md3Shader = 0; shader_t *shader = 0; int cull; int lod; int fogNum; qboolean personalModel; // don't add third_person objects if not in a portal personalModel = ( ent->e.renderfx & RF_THIRD_PERSON ) && !tr.viewParms.isPortal; if ( ent->e.renderfx & RF_WRAP_FRAMES ) { ent->e.frame %= tr.currentModel->mdc[0]->numFrames; ent->e.oldframe %= tr.currentModel->mdc[0]->numFrames; } // // Validate the frames so there is no chance of a crash. // This will write directly into the entity structure, so // when the surfaces are rendered, they don't need to be // range checked again. // if ( ( ent->e.frame >= tr.currentModel->mdc[0]->numFrames ) || ( ent->e.frame < 0 ) || ( ent->e.oldframe >= tr.currentModel->mdc[0]->numFrames ) || ( ent->e.oldframe < 0 ) ) { ri.Printf( PRINT_DEVELOPER, "R_AddMDCSurfaces: no such frame %d to %d for '%s'\n", ent->e.oldframe, ent->e.frame, tr.currentModel->name ); ent->e.frame = 0; ent->e.oldframe = 0; } // // compute LOD // lod = R_ComputeLOD( ent ); header = tr.currentModel->mdc[lod]; // // cull the entire model if merged bounding box of both frames // is outside the view frustum. // cull = R_CullModel( header, ent ); if ( cull == CULL_OUT ) { return; } // // set up lighting now that we know we aren't culled // if ( !personalModel || r_shadows->integer > 1 ) { R_SetupEntityLighting( &tr.refdef, ent ); } // // see if we are in a fog volume // fogNum = R_ComputeFogNum( header, ent ); // // draw all surfaces // surface = ( mdcSurface_t * )( (byte *)header + header->ofsSurfaces ); for ( i = 0 ; i < header->numSurfaces ; i++ ) { int j; //----(SA) blink will change to be an overlay rather than replacing the head texture. // think of it like batman's mask. the polygons that have eye texture are duplicated // and the 'lids' rendered with polygonoffset over the top of the open eyes. this gives // minimal overdraw/alpha blending/texture use without breaking the model and causing seams if ( !Q_stricmp( surface->name, "h_blink" ) ) { if ( !( ent->e.renderfx & RF_BLINK ) ) { surface = ( mdcSurface_t * )( (byte *)surface + surface->ofsEnd ); continue; } } //----(SA) end if ( ent->e.customShader ) { shader = R_GetShaderByHandle( ent->e.customShader ); } else if ( ent->e.customSkin > 0 && ent->e.customSkin < tr.numSkins ) { skin_t *skin; skin = R_GetSkinByHandle( ent->e.customSkin ); // match the surface name to something in the skin file shader = tr.defaultShader; for ( j = 0 ; j < skin->numSurfaces ; j++ ) { // the names have both been lowercased if ( !strcmp( skin->surfaces[j]->name, surface->name ) ) { shader = skin->surfaces[j]->shader; break; } } } else if ( surface->numShaders <= 0 ) { shader = tr.defaultShader; } else { md3Shader = ( md3Shader_t * )( (byte *)surface + surface->ofsShaders ); md3Shader += ent->e.skinNum % surface->numShaders; shader = tr.shaders[ md3Shader->shaderIndex ]; } // we will add shadows even if the main object isn't visible in the view // stencil shadows can't do personal models unless I polyhedron clip if ( !personalModel && r_shadows->integer == 2 && fogNum == 0 && !( ent->e.renderfx & ( RF_NOSHADOW | RF_DEPTHHACK ) ) && shader->sort == SS_OPAQUE ) { // GR - tessellate according to model capabilities R_AddDrawSurf( (void *)surface, tr.shadowShader, 0, qfalse, tr.currentModel->ATI_tess ); } //----(SA) // projection shadows work fine with personal models // if ( r_shadows->integer == 3 // && fogNum == 0 // && (ent->e.renderfx & RF_SHADOW_PLANE ) // && shader->sort == SS_OPAQUE ) { // R_AddDrawSurf( (void *)surface, tr.projectionShadowShader, 0, qfalse ); // } //----(SA) for testing polygon shadows (on /all/ models) // if ( r_shadows->integer == 4) // R_AddDrawSurf( (void *)surface, tr.projectionShadowShader, 0, qfalse ); //----(SA) done testing // don't add third_person objects if not viewing through a portal if ( !personalModel ) { // GR - tessellate according to model capabilities R_AddDrawSurf( (void *)surface, shader, fogNum, qfalse, tr.currentModel->ATI_tess ); } surface = ( mdcSurface_t * )( (byte *)surface + surface->ofsEnd ); } }
/* ================= R_AddMD3Surfaces ================= */ void R_AddMD3Surfaces( trRefEntity_t *ent ) { int i; md3Header_t *header = 0; md3Surface_t *surface = 0; md3Shader_t *md3Shader = 0; shader_t *shader = 0; shader_t *main_shader = 0; int cull; int lod; int fogNum; qboolean personalModel; // don't add third_person objects if not in a portal personalModel = (ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal; if ( ent->e.renderfx & RF_CAP_FRAMES) { if (ent->e.frame > tr.currentModel->md3[0]->numFrames-1) ent->e.frame = tr.currentModel->md3[0]->numFrames-1; if (ent->e.oldframe > tr.currentModel->md3[0]->numFrames-1) ent->e.oldframe = tr.currentModel->md3[0]->numFrames-1; } else if ( ent->e.renderfx & RF_WRAP_FRAMES ) { ent->e.frame %= tr.currentModel->md3[0]->numFrames; ent->e.oldframe %= tr.currentModel->md3[0]->numFrames; } // // Validate the frames so there is no chance of a crash. // This will write directly into the entity structure, so // when the surfaces are rendered, they don't need to be // range checked again. // if ( (ent->e.frame >= tr.currentModel->md3[0]->numFrames) || (ent->e.frame < 0) || (ent->e.oldframe >= tr.currentModel->md3[0]->numFrames) || (ent->e.oldframe < 0) ) { VID_Printf (PRINT_ALL, "R_AddMD3Surfaces: no such frame %d to %d for '%s'\n", ent->e.oldframe, ent->e.frame, tr.currentModel->name ); ent->e.frame = 0; ent->e.oldframe = 0; } // // compute LOD // lod = R_ComputeLOD( ent ); header = tr.currentModel->md3[lod]; // // cull the entire model if merged bounding box of both frames // is outside the view frustum. // cull = R_CullModel ( header, ent ); if ( cull == CULL_OUT ) { return; } // // set up lighting now that we know we aren't culled // #ifdef VV_LIGHTING if ( !personalModel ) { VVLightMan.R_SetupEntityLighting( &tr.refdef, ent ); #else if ( !personalModel || r_shadows->integer > 1 ) { R_SetupEntityLighting( &tr.refdef, ent ); #endif } // // see if we are in a fog volume // fogNum = R_ComputeFogNum( header, ent ); // // draw all surfaces // main_shader = R_GetShaderByHandle( ent->e.customShader ); surface = (md3Surface_t *)( (byte *)header + header->ofsSurfaces ); for ( i = 0 ; i < header->numSurfaces ; i++ ) { if ( ent->e.customShader ) {// a little more efficient shader = main_shader; } else if ( ent->e.customSkin > 0 && ent->e.customSkin < tr.numSkins ) { skin_t *skin; int j; skin = R_GetSkinByHandle( ent->e.customSkin ); // match the surface name to something in the skin file shader = tr.defaultShader; for ( j = 0 ; j < skin->numSurfaces ; j++ ) { // the names have both been lowercased if ( !strcmp( skin->surfaces[j]->name, surface->name ) ) { shader = skin->surfaces[j]->shader; break; } } } else if ( surface->numShaders <= 0 ) { shader = tr.defaultShader; } else { md3Shader = (md3Shader_t *) ( (byte *)surface + surface->ofsShaders ); md3Shader += ent->e.skinNum % surface->numShaders; shader = tr.shaders[ md3Shader->shaderIndex ]; } // we will add shadows even if the main object isn't visible in the view // stencil shadows can't do personal models unless I polyhedron clip if ( !personalModel && r_shadows->integer == 2 #ifndef VV_LIGHTING && fogNum == 0 #endif && (ent->e.renderfx & RF_SHADOW_PLANE ) && !(ent->e.renderfx & ( RF_NOSHADOW | RF_DEPTHHACK ) ) && shader->sort == SS_OPAQUE ) { R_AddDrawSurf( (surfaceType_t *)surface, tr.shadowShader, 0, qfalse ); } // projection shadows work fine with personal models if ( r_shadows->integer == 3 && fogNum == 0 && (ent->e.renderfx & RF_SHADOW_PLANE ) && shader->sort == SS_OPAQUE ) { R_AddDrawSurf( (surfaceType_t *)surface, tr.projectionShadowShader, 0, qfalse ); } // don't add third_person objects if not viewing through a portal if ( !personalModel ) { #ifdef VV_LIGHTING int dlightBits = ( ent->dlightBits != 0 ); R_AddDrawSurf( (surfaceType_t *)surface, shader, fogNum, dlightBits ); #else R_AddDrawSurf( (surfaceType_t *)surface, shader, fogNum, qfalse ); #endif } surface = (md3Surface_t *)( (byte *)surface + surface->ofsEnd ); } }
/* ================= R_AddMD3Surfaces ================= */ void R_AddMD3Surfaces(trRefEntity_t *ent) { int i; mdvModel_t *model = NULL; mdvSurface_t *surface = NULL; shader_t *shader = NULL; int cull; int lod; int fogNum; int cubemapIndex; qboolean personalModel; // don't add third_person objects if not in a portal personalModel = (ent->e.renderfx & RF_THIRD_PERSON) && !(tr.viewParms.isPortal || (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW))); if (ent->e.renderfx & RF_WRAP_FRAMES) { ent->e.frame %= tr.currentModel->mdv[0]->numFrames; ent->e.oldframe %= tr.currentModel->mdv[0]->numFrames; } // // Validate the frames so there is no chance of a crash. // This will write directly into the entity structure, so // when the surfaces are rendered, they don't need to be // range checked again. // if ((ent->e.frame >= tr.currentModel->mdv[0]->numFrames) || (ent->e.frame < 0) || (ent->e.oldframe >= tr.currentModel->mdv[0]->numFrames) || (ent->e.oldframe < 0)) { ri.Printf(PRINT_DEVELOPER, "R_AddMD3Surfaces: no such frame %d to %d for '%s'\n", ent->e.oldframe, ent->e.frame, tr.currentModel->name); ent->e.frame = 0; ent->e.oldframe = 0; } // // compute LOD // lod = R_ComputeLOD(ent); model = tr.currentModel->mdv[lod]; // // cull the entire model if merged bounding box of both frames // is outside the view frustum. // cull = R_CullModel (model, ent); if (cull == CULL_OUT) { return; } // // set up lighting now that we know we aren't culled // if (!personalModel || r_shadows->integer > 1) { R_SetupEntityLighting(&tr.refdef, ent); } // // see if we are in a fog volume // fogNum = R_ComputeFogNum(model, ent); cubemapIndex = R_CubemapForPoint(ent->e.origin); // // draw all surfaces // surface = model->surfaces; for (i = 0 ; i < model->numSurfaces ; i++) { if (ent->e.customShader) { shader = R_GetShaderByHandle(ent->e.customShader); } else if (ent->e.customSkin > 0 && ent->e.customSkin < tr.numSkins) { skin_t *skin; int j; skin = R_GetSkinByHandle(ent->e.customSkin); // match the surface name to something in the skin file shader = tr.defaultShader; //----(SA) added blink if (ent->e.renderfx & RF_BLINK) { const char *s = va("%s_b", surface->name); // append '_b' for 'blink' for (j = 0 ; j < skin->numSurfaces ; j++) { if (!strcmp(skin->surfaces[j]->name, s)) { shader = skin->surfaces[j]->shader; break; } } } if (shader == tr.defaultShader) { // blink reference in skin was not found for (j = 0 ; j < skin->numSurfaces ; j++) { // the names have both been lowercased if (!strcmp(skin->surfaces[j]->name, surface->name)) { shader = skin->surfaces[j]->shader; break; } } } //----(SA) end if (shader == tr.defaultShader) { ri.Printf(PRINT_DEVELOPER, "WARNING: no shader for surface %s in skin %s\n", surface->name, skin->name); } else if (shader->defaultShader) { ri.Printf(PRINT_DEVELOPER, "WARNING: shader %s in skin %s not found\n", shader->name, skin->name); } //} else if (surface->numShaders <= 0) { //shader = tr.defaultShader; } else { //md3Shader = (md3Shader_t *) ((byte *)surface + surface->ofsShaders); //md3Shader += ent->e.skinNum % surface->numShaders; //shader = tr.shaders[ md3Shader->shaderIndex ]; shader = tr.shaders[ surface->shaderIndexes[ ent->e.skinNum % surface->numShaderIndexes ] ]; } // for testing polygon shadows (on /all/ models) if (r_shadows->integer == 4) { R_AddDrawSurf((void *)surface, tr.projectionShadowShader, 0, qfalse, qfalse, 0); } // don't add third_person objects if not viewing through a portal if(!personalModel) { srfVaoMdvMesh_t *vaoSurface = &model->vaoSurfaces[i]; R_AddDrawSurf((void *)vaoSurface, shader, fogNum, qfalse, qfalse, cubemapIndex); } surface++; } }
/* ================= R_AddMD3Surfaces ================= */ void R_AddMD3Surfaces( trRefEntity_t *ent ) { int i; mdvModel_t *model = NULL; mdvSurface_t *surface = NULL; shader_t *shader = NULL; int cull; int lod; int fogNum; int cubemapIndex; qboolean personalModel; // don't add mirror only objects if not in a mirror/portal personalModel = (ent->e.renderfx & RF_ONLY_MIRROR) && !(tr.viewParms.isPortal || (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW))); if ( ent->e.renderfx & RF_WRAP_FRAMES ) { ent->e.frame %= tr.currentModel->mdv[0]->numFrames; ent->e.oldframe %= tr.currentModel->mdv[0]->numFrames; } // // Validate the frames so there is no chance of a crash. // This will write directly into the entity structure, so // when the surfaces are rendered, they don't need to be // range checked again. // if ( (ent->e.frame >= tr.currentModel->mdv[0]->numFrames) || (ent->e.frame < 0) || (ent->e.oldframe >= tr.currentModel->mdv[0]->numFrames) || (ent->e.oldframe < 0) ) { ri.Printf( PRINT_DEVELOPER, "R_AddMD3Surfaces: no such frame %d to %d for '%s'\n", ent->e.oldframe, ent->e.frame, tr.currentModel->name ); ent->e.frame = 0; ent->e.oldframe = 0; } // // compute LOD // lod = R_ComputeLOD( ent ); model = tr.currentModel->mdv[lod]; // // cull the entire model if merged bounding box of both frames // is outside the view frustum. // cull = R_CullModel ( model, ent ); if ( cull == CULL_OUT ) { return; } // // set up lighting now that we know we aren't culled // if ( !personalModel || r_shadows->integer > 1 ) { R_SetupEntityLighting( &tr.refdef, ent ); } // // see if we are in a fog volume // fogNum = R_ComputeFogNum( model, ent ); cubemapIndex = R_CubemapForPoint(ent->e.origin); // // draw all surfaces // surface = model->surfaces; for ( i = 0 ; i < model->numSurfaces ; i++ ) { if ( ent->e.customShader || ent->e.customSkin ) { shader = R_CustomSurfaceShader( surface->name, ent->e.customShader, ent->e.customSkin ); if ( shader == tr.nodrawShader ) { surface++; continue; } //} else if ( surface->numShaders <= 0 ) { //shader = tr.defaultShader; } else { //md3Shader = (md3Shader_t *) ( (byte *)surface + surface->ofsShaders ); //md3Shader += ent->e.skinNum % surface->numShaders; //shader = tr.shaders[ md3Shader->shaderIndex ]; shader = tr.shaders[ surface->shaderIndexes[ ent->e.skinNum % surface->numShaderIndexes ] ]; } // don't add third_person objects if not viewing through a portal if(!personalModel) { srfVaoMdvMesh_t *vaoSurface = &model->vaoSurfaces[i]; R_AddEntDrawSurf( ent, (void *)vaoSurface, shader, fogNum, qfalse, 0, qfalse, cubemapIndex ); } surface++; } }
/* ================= R_AddMD3Surfaces ================= */ void R_AddMD3Surfaces( trRefEntity_t *ent ) { int i; mdvModel_t *model = NULL; mdvSurface_t *surface = NULL; shader_t *shader = NULL; int cull; int lod; int fogNum; int cubemapIndex; qboolean personalModel; // don't add third_person objects if not in a portal personalModel = (ent->e.renderfx & RF_THIRD_PERSON) && !(tr.viewParms.isPortal || (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW))); if ( ent->e.renderfx & RF_WRAP_FRAMES ) { ent->e.frame %= tr.currentModel->mdv[0]->numFrames; ent->e.oldframe %= tr.currentModel->mdv[0]->numFrames; } // // Validate the frames so there is no chance of a crash. // This will write directly into the entity structure, so // when the surfaces are rendered, they don't need to be // range checked again. // if ( (ent->e.frame >= tr.currentModel->mdv[0]->numFrames) || ( ent->e.frame < 0 ) || (ent->e.oldframe >= tr.currentModel->mdv[0]->numFrames) || ( ent->e.oldframe < 0 ) ) { ri.Printf( PRINT_DEVELOPER, "R_AddMD3Surfaces: no such frame %d to %d for '%s'\n", ent->e.oldframe, ent->e.frame, tr.currentModel->name ); ent->e.frame = 0; ent->e.oldframe = 0; } // // compute LOD // lod = R_ComputeLOD( ent ); model = tr.currentModel->mdv[lod]; // // cull the entire model if merged bounding box of both frames // is outside the view frustum. // cull = R_CullModel ( model, ent ); if ( cull == CULL_OUT ) { return; } // // set up lighting now that we know we aren't culled // if ( !personalModel || r_shadows->integer > 1 ) { R_SetupEntityLighting( &tr.refdef, ent ); } // // see if we are in a fog volume // fogNum = R_ComputeFogNum( model, ent ); cubemapIndex = R_CubemapForPoint(ent->e.origin); // // draw all surfaces // surface = model->surfaces; for ( i = 0 ; i < model->numSurfaces ; i++ ) { int j; //----(SA) blink will change to be an overlay rather than replacing the head texture. // think of it like batman's mask. the polygons that have eye texture are duplicated // and the 'lids' rendered with polygonoffset shader parm over the top of the open eyes. this gives // minimal overdraw/alpha blending/texture use without breaking the model and causing seams if ( !Q_stricmp( surface->name, "h_blink" ) ) { if ( !( ent->e.renderfx & RF_BLINK ) ) { //surface = ( md3Surface_t * )( (byte *)surface + surface->ofsEnd ); //surface++; continue; } } //----(SA) end if ( ent->e.customShader ) { shader = R_GetShaderByHandle( ent->e.customShader ); } else if ( ent->e.customSkin > 0 && ent->e.customSkin < tr.numSkins ) { skin_t *skin; skin = R_GetSkinByHandle( ent->e.customSkin ); // match the surface name to something in the skin file shader = tr.defaultShader; for ( j = 0 ; j < skin->numSurfaces ; j++ ) { // the names have both been lowercased if ( !strcmp( skin->surfaces[j]->name, surface->name ) ) { shader = skin->surfaces[j]->shader; break; } } if ( shader == tr.defaultShader ) { ri.Printf( PRINT_DEVELOPER, "WARNING: no shader for surface %s in skin %s\n", surface->name, skin->name ); } else if ( shader->defaultShader ) { ri.Printf( PRINT_DEVELOPER, "WARNING: shader %s in skin %s not found\n", shader->name, skin->name ); } //} else if ( surface->numShaders <= 0 ) { //shader = tr.defaultShader; } else { //md3Shader = ( md3Shader_t * )( (byte *)surface + surface->ofsShaders ); //md3Shader += ent->e.skinNum % surface->numShaders; shader = tr.shaders[ surface->shaderIndexes[ ent->e.skinNum % surface->numShaderIndexes ] ]; } // don't add third_person objects if not viewing through a portal if ( !personalModel ) { // GR - tessellate according to model capabilities srfVaoMdvMesh_t *vaoSurface = &model->vaoSurfaces[i]; R_AddDrawSurf( (void *)vaoSurface, shader, fogNum, qfalse, qfalse, cubemapIndex, tr.currentModel->ATI_tess ); } surface++; } }
/* ============== R_AddAnimSurfaces ============== */ void R_AddAnimSurfaces( trRefEntity_t *ent ) { mdsHeader_t *header; mdsSurface_t *surface; shader_t *shader = 0; int i, fogNum, cull; qboolean personalModel; // don't add third_person objects if not in a portal personalModel = ( ent->e.renderfx & RF_THIRD_PERSON ) && !tr.viewParms.isPortal; header = tr.currentModel->mds; // // cull the entire model if merged bounding box of both frames // is outside the view frustum. // cull = R_CullModel( header, ent ); if ( cull == CULL_OUT ) { return; } // // set up lighting now that we know we aren't culled // if ( !personalModel || r_shadows->integer > 1 ) { R_SetupEntityLighting( &tr.refdef, ent ); } // // see if we are in a fog volume // fogNum = R_ComputeFogNum( header, ent ); surface = ( mdsSurface_t * )( (byte *)header + header->ofsSurfaces ); for ( i = 0 ; i < header->numSurfaces ; i++ ) { int j; //----(SA) blink will change to be an overlay rather than replacing the head texture. // think of it like batman's mask. the polygons that have eye texture are duplicated // and the 'lids' rendered with polygonoffset over the top of the open eyes. this gives // minimal overdraw/alpha blending/texture use without breaking the model and causing seams if ( !Q_stricmp( surface->name, "h_blink" ) ) { if ( !( ent->e.renderfx & RF_BLINK ) ) { surface = ( mdsSurface_t * )( (byte *)surface + surface->ofsEnd ); continue; } } //----(SA) end if ( ent->e.customShader ) { shader = R_GetShaderByHandle( ent->e.customShader ); } else if ( ent->e.customSkin > 0 && ent->e.customSkin < tr.numSkins ) { skin_t *skin; skin = R_GetSkinByHandle( ent->e.customSkin ); // match the surface name to something in the skin file shader = tr.defaultShader; for ( j = 0 ; j < skin->numSurfaces ; j++ ) { // the names have both been lowercased if ( !strcmp( skin->surfaces[j]->name, surface->name ) ) { shader = skin->surfaces[j]->shader; break; } } if ( shader == tr.defaultShader ) { ri.Printf( PRINT_DEVELOPER, "WARNING: no shader for surface %s in skin %s\n", surface->name, skin->name ); } else if ( shader->defaultShader ) { ri.Printf( PRINT_DEVELOPER, "WARNING: shader %s in skin %s not found\n", shader->name, skin->name ); } } else { shader = R_GetShaderByHandle( surface->shaderIndex ); } // don't add third_person objects if not viewing through a portal if ( !personalModel ) { // GR - always tessellate these objects R_AddDrawSurf( (void *)surface, shader, fogNum, qfalse, ATI_TESS_TRUFORM ); } surface = ( mdsSurface_t * )( (byte *)surface + surface->ofsEnd ); } }