/* ================= R_AddIQMSurfaces Add all surfaces of this model ================= */ void R_AddIQMSurfaces( trRefEntity_t *ent ) { iqmData_t *data; iqmData_t *skeleton; iqmData_t *oldSkeleton; srfIQModel_t *surface; int i, j; qboolean personalModel; int cull; int fogNum; int cubemapIndex; shader_t *shader; skin_t *skin; skinSurface_t *skinSurf; data = tr.currentModel->modelData; surface = data->surfaces; if ( !data->num_surfaces || !data->num_triangles || !data->num_vertexes ) { ri.Printf( PRINT_WARNING, "WARNING: Tried to render IQM '%s' with no surfaces\n", tr.currentModel->name ); return; } skeleton = R_GetIQMModelDataByHandle( ent->e.frameModel, data ); oldSkeleton = R_GetIQMModelDataByHandle( ent->e.oldframeModel, data ); // don't add mirror only objects if not in a mirror/portal personalModel = (ent->e.renderfx & RF_ONLY_MIRROR) && !tr.viewParms.isPortal; if ( ent->e.renderfx & RF_WRAP_FRAMES ) { ent->e.frame %= skeleton->num_frames; ent->e.oldframe %= oldSkeleton->num_frames; } // // 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 >= skeleton->num_frames) || (ent->e.frame < 0) || (ent->e.oldframe >= oldSkeleton->num_frames) || (ent->e.oldframe < 0) ) { ri.Printf( PRINT_DEVELOPER, "R_AddIQMSurfaces: 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; } // // cull the entire model if merged bounding box of both frames // is outside the view frustum. // cull = R_CullIQM ( skeleton, oldSkeleton, 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_ComputeIQMFogNum( skeleton, ent ); cubemapIndex = R_CubemapForPoint(ent->e.origin); for ( i = 0 ; i < data->num_surfaces ; i++ ) { if(ent->e.customShader) shader = R_GetShaderByHandle( ent->e.customShader ); else if(ent->e.customSkin > 0 && ent->e.customSkin <= tr.refdef.numSkins) { skin = &tr.refdef.skins[ent->e.customSkin - 1]; shader = tr.defaultShader; for(j = 0 ; j < skin->numSurfaces ; j++) { skinSurf = &tr.skinSurfaces[ skin->surfaces[ j ] ]; if (!strcmp(skinSurf->name, surface->name)) { shader = skinSurf->shader; break; } } if (shader == tr.nodrawShader) { surface++; continue; } } else { shader = surface->shader; } // 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( (void *)surface, tr.shadowShader, 0, 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( (void *)surface, tr.projectionShadowShader, 0, 0, 0, 0 ); } if( !personalModel ) { R_AddEntDrawSurf( ent, (void *)surface, shader, fogNum, 0, 0, cubemapIndex ); } surface++; } }
/* ================= R_AddIQMSurfaces Add all surfaces of this model ================= */ void R_AddIQMSurfaces(trRefEntity_t* ent) { iqmData_t* data; srfIQModel_t* surface; int i, j; qboolean personalModel; int cull; int fogNum; shader_t* shader; skin_t* skin; data = tr.currentModel->modelData; surface = data->surfaces; // 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 %= data->num_frames; ent->e.oldframe %= data->num_frames; } // // 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 >= data->num_frames) || (ent->e.frame < 0) || (ent->e.oldframe >= data->num_frames) || (ent->e.oldframe < 0)) { ri.Printf(PRINT_DEVELOPER, "R_AddIQMSurfaces: 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; } // // cull the entire model if merged bounding box of both frames // is outside the view frustum. // cull = R_CullIQM(data, 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_ComputeIQMFogNum(data, ent); for (i = 0 ; i < data->num_surfaces ; i++) { if (ent->e.customShader) shader = R_GetShaderByHandle(ent->e.customShader); else if (ent->e.customSkin > 0 && ent->e.customSkin < tr.numSkins) { skin = R_GetSkinByHandle(ent->e.customSkin); shader = tr.defaultShader; for (j = 0; j < skin->numSurfaces; j++) { if (!strcmp(skin->surfaces[j]->name, surface->name)) { shader = skin->surfaces[j]->shader; break; } } } else { shader = surface->shader; } // 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((void*)surface, tr.shadowShader, 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((void*)surface, tr.projectionShadowShader, 0, 0); } if (!personalModel) { R_AddDrawSurf((void*)surface, shader, fogNum, 0); } surface++; } }
/* ================= R_AddIQMSurfaces Add all surfaces of this model ================= */ void R_AddIQMSurfaces( trRefEntity_t *ent ) { IQModel_t *IQModel; srfIQModel_t *surface; int i, j; qboolean personalModel; int cull; int fogNum; shader_t *shader; skin_t *skin; IQModel = tr.currentModel->iqm; surface = IQModel->surfaces; // don't add third_person objects if not in a portal personalModel = (ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal; // // cull the entire model if merged bounding box of both frames // is outside the view frustum. // cull = R_CullIQM ( ent ); if ( cull == CULL_OUT ) { return; } // // set up lighting now that we know we aren't culled // if ( !personalModel || r_shadows->integer > SHADOWING_BLOB ) { R_SetupEntityLighting( &tr.refdef, ent, NULL ); } // // see if we are in a fog volume // fogNum = R_ComputeIQMFogNum( ent ); for ( i = 0 ; i < IQModel->num_surfaces ; i++ ) { if(ent->e.customShader) shader = R_GetShaderByHandle( ent->e.customShader ); else if(ent->e.customSkin > 0 && ent->e.customSkin < tr.numSkins) { skin = R_GetSkinByHandle(ent->e.customSkin); shader = tr.defaultShader; if (surface->name && *surface->name) { for(j = 0; j < skin->numSurfaces; j++) { if (!strcmp(skin->surfaces[j]->name, surface->name)) { shader = skin->surfaces[j]->shader; break; } } } if ( shader == tr.defaultShader && i >= 0 && i < skin->numSurfaces && skin->surfaces[ i ] ) { shader = skin->surfaces[ i ]->shader; } } else { shader = surface->shader; if ( ent->e.altShaderIndex > 0 && ent->e.altShaderIndex < MAX_ALTSHADERS && shader->altShader[ ent->e.altShaderIndex ].index ) { shader = R_GetShaderByHandle( shader->altShader[ ent->e.altShaderIndex ].index ); } } // we will add shadows even if the main object isn't visible in the view if( !personalModel ) { R_AddDrawSurf( ( surfaceType_t *)surface, shader, -1, fogNum ); } surface++; } }