void OglCachePolyModelTextures (int nModel)
{
	CPolyModel* modelP = GetPolyModel (NULL, NULL, nModel, 0);

if (modelP)
	modelP->LoadTextures (NULL);
}
Esempio n. 2
0
//draw a polygon model
int DrawPolyModel (
	CObject*			objP,
	CFixVector*		pos,
	CFixMatrix*		orient,
	CAngleVector*	animAngles,
	int				nModel,
	int				flags,
	fix				light,
	fix*				glowValues,
	tBitmapIndex	altTextures [],
	tRgbaColorf*	colorP)
{
	CPolyModel*	modelP;
	int			nTextures, bHires = 0;

if ((gameStates.render.nShadowPass == 2) && !ObjectHasShadow (objP))
	return 1;
if (!(modelP = GetPolyModel (objP, pos, nModel, flags))) {
	if (!flags && (gameStates.render.nShadowPass != 2) && HaveHiresModel (nModel))
		bHires = 1;
	else
		return gameStates.render.nShadowPass == 2;
	}
if (gameStates.render.nShadowPass == 2) {
	if (!bHires) {
		G3SetModelPoints (gameData.models.polyModelPoints.Buffer ());
		G3DrawPolyModelShadow (objP, modelP->Data (), animAngles, nModel);
		}
	return 1;
	}
#if 1//def _DEBUG
if (nModel == nDbgModel)
	nDbgModel = nDbgModel;
#endif
nTextures = bHires ? 0 : modelP->LoadTextures (altTextures);
gameStates.ogl.bUseTransform = 1;
G3SetModelPoints (gameData.models.polyModelPoints.Buffer ());
gameData.render.vertP = gameData.models.fPolyModelVerts.Buffer ();
if (!flags) {	//draw entire CObject
	if (gameStates.app.bNostalgia || !G3RenderModel (objP, nModel, -1, modelP, gameData.models.textures, animAngles, NULL, light, glowValues, colorP)) {
		if (bHires) {
			gameStates.ogl.bUseTransform = 0;
			return 0;
			}
		if (objP && (objP->info.nType == OBJ_POWERUP)) {
			if ((objP->info.nId == POW_SMARTMINE) || (objP->info.nId == POW_PROXMINE))
				gameData.models.vScale.Set (I2X (2), I2X (2), I2X (2));
			else
				gameData.models.vScale.Set (I2X (3) / 2, I2X (3) / 2, I2X (3) / 2);
			}
		gameStates.ogl.bUseTransform = 
			(gameStates.app.bEndLevelSequence < EL_OUTSIDE) && 
			!(SHOW_DYN_LIGHT && (gameOpts->ogl.bObjLighting || gameOpts->ogl.bLightObjects));
		transformation.Begin (*pos, *orient);
		G3DrawPolyModel (objP, modelP->Data (), gameData.models.textures, animAngles, NULL, light, glowValues, colorP, NULL, nModel);
		transformation.End ();
		}
	}
else {	
	CFixVector vOffset;

	for (int i = 0; flags > 0; flags >>= 1, i++) {
		if ((flags & 1) && (i < modelP->ModelCount ())) {
			//if submodel, rotate around its center point, not pivot point
			vOffset = CFixVector::Avg (modelP->SubModels ().mins [i], modelP->SubModels ().maxs [i]);
			vOffset.Neg ();
			if (!G3RenderModel (objP, nModel, i, modelP, gameData.models.textures, animAngles, &vOffset, light, glowValues, colorP)) {
				if (bHires) {
					gameStates.ogl.bUseTransform = 0;
					return 0;
					}
#if DBG
				G3RenderModel (objP, nModel, i, modelP, gameData.models.textures, animAngles, &vOffset, light, glowValues, colorP);
#endif
				transformation.Begin (vOffset);
				G3DrawPolyModel (objP, modelP->Data () + modelP->SubModels ().ptrs [i], gameData.models.textures,
									  animAngles, NULL, light, glowValues, colorP, NULL, nModel);
				transformation.End ();
				}
			}
		}
	}
gameStates.ogl.bUseTransform = 0;
gameData.render.vertP = NULL;
#if 0
{
	g3sPoint p0, p1;

transformation.Transform (&p0.p3_vec, &objP->info.position.vPos);
VmVecSub (&p1.p3_vec, &objP->info.position.vPos, &objP->mType.physInfo.velocity);
transformation.Transform (&p1.p3_vec, &p1.p3_vec);
glLineWidth (20);
glDisable (GL_TEXTURE_2D);
glBegin (GL_LINES);
glColor4d (1.0, 0.5, 0.0, 0.3);
OglVertex3x (p0.p3_vec [X], p0.p3_vec [Y], p0.p3_vec [Z]);
glColor4d (1.0, 0.5, 0.0, 0.1);
OglVertex3x (p1.p3_vec [X], p1.p3_vec [Y], p1.p3_vec [Z]);
glEnd ();
glLineWidth (1);
}
#endif
return 1;
}