示例#1
0
void ClearConversionArrays( void)
{
  acmMaterials.Clear();
  actTriangles.Clear();
  avVertices.Clear();
  avTextureVertices.Clear();
  aiRemap.Clear();
}
示例#2
0
/* Copy container of entities from another world to this one and select them. */
void CWorld::CopyEntities(CWorld &woOther, CDynamicContainer<CEntity> &cenToCopy,
  CEntitySelection &senCopied, const CPlacement3D &plOtherSystem)
{
  INDEX ctEntities = cenToCopy.Count();
  if (ctEntities<=0) {
    return;
  }


  ULONG ulCopyFlags = COPY_REMAP;
  if(_bReinitEntitiesWhileCopying) {
    ulCopyFlags|=COPY_REINIT;
  };

  // create array of pointer remaps
  _aprRemaps.Clear();
  _aprRemaps.New(ctEntities);


  // PASS 1: create entities

  // for each entity to copy
  INDEX iRemap = 0;
  {FOREACHINDYNAMICCONTAINER(cenToCopy, CEntity, itenToCopy) {
    CEntity &enToCopy = *itenToCopy;

    CEntity *penNew;
    CPlacement3D plEntity;
    // thansform the entity placement from the system of other world
    plEntity = enToCopy.en_plPlacement;
    plEntity.RelativeToAbsolute(plOtherSystem);

    // mirror and stretch placement if needed
    if (_bMirrorAndStretch) {
      MirrorAndStretchPlacement(plEntity);
    }

    /*
     * NOTE: We must use CreateEntity_t() overload with class name instead with class pointer
     * because the entity class must be obtained by the target world too!
     */
    // try to
    try {
      // create an entity of same class as the one to copy
      penNew = CreateEntity_t(plEntity, enToCopy.en_pecClass->GetName());
    // if not successfull
    } catch (char *strError) {
      (void)strError;
      ASSERT(FALSE);    // this should not happen
      FatalError(TRANS("Cannot CopyEntity():\n%s"), strError);
    }

    // remember its remap pointer
    _aprRemaps[iRemap].pr_penOriginal = &enToCopy;
    _aprRemaps[iRemap].pr_penCopy = penNew;
    iRemap++;
  }}
void CTextureManager::Init (void)
{
#if 1
m_textures = NULL;
m_nTextures = 0;
#else
m_textures.Create (TEXTURE_LIST_SIZE);
for (int i = 0; i < TEXTURE_LIST_SIZE; i++)
	m_textures [i].SetIndex (i);
#endif
#if DBG
usedHandles.Clear ();
#endif
}
void CToolTipWnd::ObtainTextSize(PIX &pixMaxWidth, PIX &pixMaxHeight) 
{
  CDC *pDC = GetDC();
  if( pDC == NULL) return;

  pixMaxWidth = 0;
  _saPixLineHeights.Clear();
  PIX pixStartY = 0;
  INDEX ctLines = GetLinesCount();
  _saPixLineHeights.New( ctLines);
  for(INDEX iLine = 0; iLine<ctLines; iLine++)
  {
    CTString strLine = GetLine(iLine);
    CSize size = pDC->GetOutputTextExtent( CString(strLine));
    if( size.cx>pixMaxWidth)  pixMaxWidth = size.cx;
    _saPixLineHeights[iLine] = pixStartY;
    pixStartY += size.cy;
  }
  pixMaxHeight = pixStartY;
  ReleaseDC( pDC);
}
// Remove one texture from model instance
void CModelInstance::RemoveTexture(TextureInstance *ptiRemove,MeshInstance *pmshi)
{
  ASSERT(pmshi!=NULL);
  CStaticArray<struct TextureInstance> atiTextures;
  INDEX ctti=pmshi->mi_tiTextures.Count();
  atiTextures.New(ctti-1);
  // for each texture instance in mesh instance
  INDEX iIndexSrc=0;
  for(INDEX iti=0;iti<ctti;iti++)
  {
    TextureInstance *pti = &pmshi->mi_tiTextures[iti];
    // if texture instance is different from selected one 
    if(pti != ptiRemove) {
      // copy it to new array of texture isntances
      atiTextures[iIndexSrc] = pmshi->mi_tiTextures[iti];
      iIndexSrc++;
    }
  }
  // copy new texture instances array in mesh instance
  pmshi->mi_tiTextures.CopyArray(atiTextures);
  // clear temp texture isntances array
  atiTextures.Clear();
}
int OglCacheLevelTextures (void)
{
	int				i, j, bD1;
	tEffectClip*	ecP;
	int				max_efx = 0, ef;
	int				nSegment, nSide;
	short				nBaseTex, nOvlTex;
	CBitmap*			bmBot,* bmTop, * bmm;
	CSegment*		segP;
	CSide*			sideP;
	CObject*			objP;
	CStaticArray< bool, MAX_POLYGON_MODELS >	bModelLoaded;

if (gameStates.render.bBriefing)
	return 0;
PrintLog ("caching level textures\n");
TexMergeClose ();
TexMergeInit (-1);
PrintLog ("   caching effect textures\n");
for (bD1 = 0; bD1 <= gameStates.app.bD1Data; bD1++) {
	for (i = 0, ecP = gameData.eff.effects [bD1].Buffer (); i < gameData.eff.nEffects [bD1]; i++, ecP++) {
		if ((ecP->changingWallTexture == -1) && (ecP->changingObjectTexture == -1))
			continue;
		if (ecP->vClipInfo.nFrameCount > max_efx)
			max_efx = ecP->vClipInfo.nFrameCount;
		}
	for (ef = 0; ef < max_efx; ef++)
		for (i = 0, ecP = gameData.eff.effects [bD1].Buffer (); i < gameData.eff.nEffects [bD1]; i++, ecP++) {
			if ((ecP->changingWallTexture == -1) && (ecP->changingObjectTexture == -1))
				continue;
			ecP->xTimeLeft = -1;
			}
	}

PrintLog ("   caching geometry textures\n");
bLoadTextures = (ogl.m_states.nPreloadTextures > 0);
for (segP = SEGMENTS.Buffer (), nSegment = 0; nSegment < gameData.segs.nSegments; nSegment++, segP++) {
	for (nSide = 0, sideP = segP->m_sides; nSide < MAX_SIDES_PER_SEGMENT; nSide++, sideP++) {
		nBaseTex = sideP->m_nBaseTex;
		if ((nBaseTex < 0) || (nBaseTex >= gameData.pig.tex.nTextures [gameStates.app.bD1Data]))
			continue;
#if DBG
		if ((nSegment == nDbgSeg) && ((nDbgSide < 0) || (nSide == nDbgSide)))
			nDbgSeg = nDbgSeg;
#endif
		bmBot = LoadFaceBitmap (nBaseTex, sideP->m_nFrame, bLoadTextures);
		if ((nOvlTex = sideP->m_nOvlTex)) {
			bmTop = LoadFaceBitmap (nOvlTex, sideP->m_nFrame, bLoadTextures);
			bmTop->SetTranspType (3);
			if (gameOpts->ogl.bGlTexMerge) // || !(bmTop->Flags () & BM_FLAG_SUPER_TRANSPARENT))
				bmTop->SetupTexture (1, bLoadTextures);
			else if ((bmm = TexMergeGetCachedBitmap (nBaseTex, nOvlTex, sideP->m_nOvlOrient)))
				bmBot = bmm;
			else
				bmTop->SetupTexture (1, bLoadTextures);
			}
		bmBot->SetTranspType (3);
		bmBot->SetupTexture (1, bLoadTextures);
		}
	}

PrintLog ("   caching addon textures\n");
CacheAddonTextures ();

PrintLog ("   caching model textures\n");
bLoadTextures = (ogl.m_states.nPreloadTextures > 1);
bModelLoaded.Clear ();
bVClipLoaded.Clear ();
FORALL_OBJS (objP, i) {
	if (objP->info.renderType != RT_POLYOBJ)
		continue;
	if (bModelLoaded [objP->rType.polyObjInfo.nModel])
		continue;
	bModelLoaded [objP->rType.polyObjInfo.nModel] = true;
	OglCachePolyModelTextures (objP->rType.polyObjInfo.nModel);
	}

PrintLog ("   caching hostage sprites\n");
bLoadTextures = (ogl.m_states.nPreloadTextures > 3);
OglCacheVClipTextures (33, 3);    

PrintLog ("   caching weapon sprites\n");
bLoadTextures = (ogl.m_states.nPreloadTextures > 5);
for (i = 0; i < EXTRA_OBJ_IDS; i++)
	OglCacheWeaponTextures (gameData.weapons.info + i);

PrintLog ("   caching powerup sprites\n");
bLoadTextures = (ogl.m_states.nPreloadTextures > 4);
for (i = 0; i < MAX_POWERUP_TYPES; i++)
	if (i != 9)
		OglCacheVClipTextures (gameData.objs.pwrUp.info [i].nClipIndex, 3);

PrintLog ("   caching effect textures\n");
CacheObjectEffects ();
bLoadTextures = (ogl.m_states.nPreloadTextures > 2);
for (i = 0; i < gameData.eff.nClips [0]; i++)
	OglCacheVClipTextures (i, 1);

PrintLog ("   caching cockpit textures\n");
for (i = 0; i < 2; i++)
	for (j = 0; j < MAX_GAUGE_BMS; j++)
		if (gameData.cockpit.gauges [i][j].index != 0xffff)
			LoadBitmap (gameData.cockpit.gauges [i][j].index, 0);

ResetSpecialEffects ();
InitSpecialEffects ();
DoSpecialEffects (true);
return 0;
}
CToolTipWnd::~CToolTipWnd()
{
  _saPixLineHeights.Clear();
}