void LoadModelTextures (int nModel) { CPolyModel* modelP = gameData.models.polyModels [0] + nModel; ushort* pi = gameData.pig.tex.objBmIndexP + modelP->FirstTexture (); int j; for (int i = modelP->TextureCount (); i; i--, pi++) { j = *pi; LoadBitmap (gameData.pig.tex.objBmIndex [j].index, 0); LoadObjectEffectTextures (j); } }
int DrawPolygonObject (CObject *objP, int bDepthSort, int bForce) { fix xLight; int imSave = 0; fix xEngineGlow [2]; //element 0 is for engine glow, 1 for headlight int bBlendPolys = 0; int bBrightPolys = 0; int bGatling = 0; int bCloaked = ObjectIsCloaked (objP); int bEnergyWeapon; int i, id, bOk = 0; if (objP->info.nType == 255) return 0; id = (int) objP->info.nId; if ((id < 0) || (id == 255)) bEnergyWeapon = id = 0; else { #if 0 bGatling = ((objP->info.nType == OBJ_WEAPON) && ((id == VULCAN_ID) || (id == GAUSS_ID))); #endif bEnergyWeapon = (objP->info.nType == OBJ_WEAPON) && gameData.objs.bIsWeapon [id] && !gameData.objs.bIsMissile [id]; } #if SHADOWS if (!bForce && FAST_SHADOWS && !gameOpts->render.shadows.bSoft && (gameStates.render.nShadowPass == 3)) return 1; #endif if (gameStates.render.bBuildModels) xLight = I2X (1); else { xLight = CalcObjectLight (objP, xEngineGlow); if ((bCloaked || bEnergyWeapon) && bDepthSort && (gameStates.render.nShadowPass != 2)) { transparencyRenderer.AddObject (objP); return 1; } if (DrawHiresObject (objP, xLight, xEngineGlow)) return 1; gameStates.render.bBrightObject = bEnergyWeapon; gameOpts->render.bDepthSort = -gameOpts->render.bDepthSort; imSave = gameStates.render.nInterpolationMethod; if (bLinearTMapPolyObjs) gameStates.render.nInterpolationMethod = 1; } if (objP->rType.polyObjInfo.nTexOverride != -1) { #if DBG CPolyModel* pm = gameData.models.polyModels [0] + objP->rType.polyObjInfo.nModel; #endif tBitmapIndex bm = gameData.pig.tex.bmIndex [0][objP->rType.polyObjInfo.nTexOverride], bmiP [MAX_MODEL_TEXTURES]; #if DBG Assert (pm->TextureCount () <= 12); #endif for (i = 0; i < MAX_MODEL_TEXTURES; i++) //fill whole array, in case simple model needs more bmiP [i] = bm; bOk = DrawPolyModel (objP, &objP->info.position.vPos, &objP->info.position.mOrient, reinterpret_cast<CAngleVector*> ( &objP->rType.polyObjInfo.animAngles), objP->rType.polyObjInfo.nModel, objP->rType.polyObjInfo.nSubObjFlags, xLight, xEngineGlow, bmiP, NULL); } else { if (bCloaked) { if (objP->info.nType == OBJ_PLAYER) bOk = DrawCloakedObject (objP, xLight, xEngineGlow, gameData.multiplayer.players [id].cloakTime, gameData.multiplayer.players [id].cloakTime + CLOAK_TIME_MAX); else if (objP->info.nType == OBJ_ROBOT) { if (!ROBOTINFO (id).bossFlag) bOk = DrawCloakedObject (objP, xLight, xEngineGlow, gameData.time.xGame - I2X (10), gameData.time.xGame + I2X (10)); else if (0 <= (i = gameData.bosses.Find (objP->Index ()))) bOk = DrawCloakedObject (objP, xLight, xEngineGlow, gameData.bosses [i].m_nCloakStartTime, gameData.bosses [i].m_nCloakEndTime); } } else { tBitmapIndex *bmiAltTex = (objP->rType.polyObjInfo.nAltTextures > 0) ? mpTextureIndex [objP->rType.polyObjInfo.nAltTextures - 1] : NULL; // Snipers get bright when they fire. if (!gameStates.render.bBuildModels) { if ((objP->info.nType == OBJ_ROBOT) && (gameData.ai.localInfo [objP->Index ()].nextPrimaryFire < I2X (1) / 8) && (objP->cType.aiInfo.behavior == AIB_SNIPE)) xLight = 2 * xLight + I2X (1); bBlendPolys = bEnergyWeapon && (gameData.weapons.info [id].nInnerModel > -1); bBrightPolys = bGatling || (bBlendPolys && WI_energy_usage (id)); if (bEnergyWeapon) { if (gameOpts->legacy.bRender) gameStates.render.grAlpha = GrAlpha (FADE_LEVELS - 2); else ogl.BlendFunc (GL_ONE, GL_ONE); } if (bBlendPolys) { #if 0 fix xDistToEye = CFixVector::Dist(gameData.objs.viewerP->info.position.vPos, objP->info.position.vPos); if (xDistToEye < gameData.models.nSimpleModelThresholdScale * I2X (2)) #endif bOk = DrawPolyModel (objP, &objP->info.position.vPos, &objP->info.position.mOrient, objP->rType.polyObjInfo.animAngles, gameData.weapons.info [id].nInnerModel, objP->rType.polyObjInfo.nSubObjFlags, bBrightPolys ? I2X (1) : xLight, xEngineGlow, bmiAltTex, NULL); } if (bEnergyWeapon) gameStates.render.grAlpha = GrAlpha (4 * FADE_LEVELS / 5); else if (!bBlendPolys) gameStates.render.grAlpha = 1.0f; } bOk = DrawPolyModel (objP, &objP->info.position.vPos, &objP->info.position.mOrient, objP->rType.polyObjInfo.animAngles, objP->rType.polyObjInfo.nModel, objP->rType.polyObjInfo.nSubObjFlags, (bGatling || bBrightPolys) ? I2X (1) : xLight, xEngineGlow, bmiAltTex, (bGatling || bEnergyWeapon) ? gameData.weapons.color + id : NULL); if (!gameStates.render.bBuildModels) { if (!gameOpts->legacy.bRender) ogl.BlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gameStates.render.grAlpha = 1.0f; } } } if (!gameStates.render.bBuildModels) { gameStates.render.nInterpolationMethod = imSave; gameStates.render.bBrightObject = 0; gameOpts->render.bDepthSort = -gameOpts->render.bDepthSort; } return bOk; }