本文整理汇总了C++中CStaticArray类的典型用法代码示例。如果您正苦于以下问题:C++ CStaticArray类的具体用法?C++ CStaticArray怎么用?C++ CStaticArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CStaticArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RemoveColisionBox
// remove colision box from model instance
void CModelInstance::RemoveColisionBox(INDEX iIndex)
{
INDEX ctcb = mi_cbAABox.Count();
INDEX icbNew = 0;
CStaticArray<struct ColisionBox> aColisionBoxesTemp;
aColisionBoxesTemp.New(ctcb-1);
for(INDEX icb=0;icb<ctcb;icb++) {
if(iIndex != icb) {
aColisionBoxesTemp[icbNew] = mi_cbAABox[icb];
icbNew++;
}
}
mi_cbAABox = aColisionBoxesTemp;
}
示例2: InitList
void InitList( CStaticArray<int>& ilistIndex, int iValue)
{
for(int i=0; i<ilistIndex.Count() ; i++)
{
ilistIndex[i]= iValue;
};
}
示例3: ASSERT
// 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();
}
示例4: ASSERT
void CStaticArray<Type>::MoveArray(CStaticArray<Type> &arOther)
{
ASSERT(this!=NULL);
ASSERT(&arOther!=NULL);
ASSERT(this!=&arOther);
// clear previous contents
Clear();
// if the other array has no elements
if (arOther.Count()==0) {
// no assignment
return;
}
// move data from the other array into this one and clear the other one
sa_Count = arOther.sa_Count;
sa_Array = arOther.sa_Array;
arOther.sa_Count = 0;
arOther.sa_Array = NULL;
}
示例5: OglCacheLevelTextures
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++)
//.........这里部分代码省略.........
示例6: LoadSkillDataFromFile
//안태훈 수정 끝 //(Open beta)(2004-11-29)
//-----------------------------------------------------------------------------
// Purpose:
// Input : &apSkillData -
// FileName -
// Output : int
//-----------------------------------------------------------------------------
int CSkill::LoadSkillDataFromFile(CStaticArray<CSkill> &apSkillData, const char* FileName)
{
FILE *fp = NULL;
if ((fp = fopen(FileName, "rb")) == NULL)
{
MessageBox(NULL, "File is not Exist.", "error!", MB_OK);
return -1;
}
// [2012/07/18 : Sora] 파일 보안코드 추가
CFileSecure fs;
if( !fs.DecodeFile( fp ) )
{
return -1;
}
fflush(fp);
int i, j, k, iWeapon;
int iLastSkillIndex = 0; //스킬 갯수.
int iLength = -1;
int iReadBytes = 0;
iReadBytes = fread(&iLastSkillIndex, sizeof(int), 1, fp);
apSkillData.New(iLastSkillIndex);
ASSERT(apSkillData.Count() >= iLastSkillIndex && "Invalid Array Count");//여기서 걸리면 고정된 개수의 스킬수 초과한것임. 더 늘릴것.(스킬은 고정배열 사용)
ASSERT(iLastSkillIndex > 0 && "Invalid Skill Data");
//////////////////////////////////////////////////////////////////////////
// MACRO DEFINITION
//////////////////////////////////////////////////////////////////////////
#define LOADINT(d) iReadBytes = fread(&d, sizeof(int), 1, fp);
#define LOADSHORT(d) iReadBytes = fread(&d, sizeof(short), 1, fp);
#define LOADCHAR(d) iReadBytes = fread(&d, sizeof(char), 1, fp);
#define LOADFLOAT(d) iReadBytes = fread(&d, sizeof(float), 1, fp);
#define LOADSTR(d) { int iLen; LOADINT(iLen); iReadBytes = fread(&d, iLen, 1, fp); }
//////////////////////////////////////////////////////////////////////////
CUIManager* pUIManager = CUIManager::getSingleton();
for( i = 0; i < iLastSkillIndex; i++) //스킬 갯수만큼.
{
int iIndex = 1; //스킬번호.
LOADINT(iIndex);
if( fs.IsEndCode( iIndex ) ) // [2012/07/18 : Sora] 파일 end
break;
if(iReadBytes <= 0) break; // EOF
ASSERT(iIndex != -1 && "Invalid Skill Index");
CSkill& SkillData = apSkillData[iIndex];
_SkillData& SD = SkillData.Skill_Data;
SD.index = iIndex;
// 일반
LOADINT(SD.job);
LOADINT(SD.job2);
LOADINT(SD.petindex);
LOADCHAR(SD.type);
LOADINT(SD.flag);
LOADINT(SD.sorcerer);
LOADCHAR(SD.maxLevel);
// 거리
LOADFLOAT(SD.appRange);
LOADFLOAT(SD.fireRange);
LOADFLOAT(SD.fireRange2);
// 타겟
LOADCHAR(SD.targetType);
if( SD.targetType == STT_TARGET_ONE ||
SD.targetType == STT_TARGET_RANGE ||
SD.targetType == STT_PARTY_ONE ||
SD.targetType == STT_TARGET_D120 ||
SD.targetType == STT_TARGET_RECT ||
SD.targetType == STT_GUILD_ONE)
{
SkillData.bNeedTarget = TRUE;
}
// LOADCHAR(SD.targetNum);
// 사용조건
LOADINT(SD.useState);
LOADINT(SD.useWeaponType0);
LOADINT(SD.useWeaponType1);
LOADINT(SD.useMagicIndex1);
LOADCHAR(SD.useMagicLevel1);
LOADINT(SD.useMagicIndex2);
LOADCHAR(SD.useMagicLevel2);
LOADINT(SD.useMagicIndex3);
LOADCHAR(SD.useMagicLevel3);
//.........这里部分代码省略.........
示例7: LoadShopDataFromFile
//-----------------------------------------------------------------------------
// Purpose:
// Input : &apShopData -
// FileName -
// Output : int
//-----------------------------------------------------------------------------
int CShopData::LoadShopDataFromFile(CStaticArray<CShopData> &apShopData, const char* FileName)
{
FILE *fp = NULL;
if ((fp = fopen(FileName, "rb")) == NULL)
{
MessageBox(NULL, "File is not Exist.", "error!", MB_OK);
return -1;
}
int iNumOfShop = 0;
int iLength = 0;
int iReadBytes = 0;
int iLastIndex = 0;
//iReadBytes = fread(&iNumOfShop, sizeof(int), 1, fp); // SHOP 데이터의 갯수.
iReadBytes = fread(&iLastIndex, sizeof(int), 1, fp); // SHOP의 마지막 인덱스.
apShopData.New(iLastIndex);
ASSERT(apShopData.Count() > 0 && "Invalid SHOP Data");
ASSERT(iLastIndex > 0 && "Invalid SHOP Data");
//////////////////////////////////////////////////////////////////////////
// MACRO DEFINITION
//////////////////////////////////////////////////////////////////////////
#define LOADINT(d) iReadBytes = fread(&d, sizeof(int), 1, fp);
#define LOADSHORT(d) iReadBytes = fread(&d, sizeof(short), 1, fp);
#define LOADCHAR(d) iReadBytes = fread(&d, sizeof(char), 1, fp);
#define LOADFLOAT(d) iReadBytes = fread(&d, sizeof(float), 1, fp);
#define LOADSTR(d) { int iLen; LOADINT(iLen); iReadBytes = fread(&d, iLen, 1, fp); }
//////////////////////////////////////////////////////////////////////////
for(int i = 0; i < iLastIndex; ++i)
{
int iIndex = -1;
LOADINT(iIndex);
if(iReadBytes <= 0) break;
CShopData& SD = apShopData[iIndex];
TShopData& ShopData = SD.m_ShopData;
ShopData.iIndex = iIndex;
int iItemCount = 0;
LOADSTR(ShopData.szShopName);
LOADINT(ShopData.iSellRate);
LOADINT(ShopData.iBuyRate);
LOADINT(iItemCount);
SD.m_iNumOfItem = iItemCount;
ASSERT(iItemCount > 0 && "Invalid Item Count!!!");
SD.m_vectorSellItems.resize(iItemCount);
iReadBytes = fread(&SD.m_vectorSellItems[0], sizeof(int), iItemCount, fp); // SHOP이 판매하는 아이템의 갯수.
if(iReadBytes < 0)
{
MessageBox(NULL, "SHOP 데이터 화일이 올바르지 않습니다.", "Error!", MB_OK);
fclose(fp);
return -1;
}
}
fclose(fp);
//////////////////////////////////////////////////////////////////////////
#undef LOADINT
#undef LOADCHAR
#undef LOADFLOAT
#undef LOADSTR
return iLastIndex;
}
示例8:
*/
struct ConversionTriangle {
INDEX ct_iVtx[3]; // indices of vertices
INDEX ct_iTVtx[3]; // indices of texture vertices
INDEX ct_iMaterial; // index of material
};
struct ConversionMaterial {
ULONG cm_ulTag; // for recognition of material
CTString cm_strName; // material's name
COLOR cm_colColor; // material's color
CDynamicContainer<INDEX> ms_Polygons; // indices of polygons in this material
};
// conversion arrays
CDynamicContainer<ConversionMaterial> acmMaterials;
CStaticArray<ConversionTriangle> actTriangles;
CStaticArray<FLOAT3D> avVertices;
CStaticStackArray<FLOAT3D> avDst;
CStaticArray<FLOAT2D> avTextureVertices;
CStaticArray<INDEX> aiRemap;
/////////////////////////////////////////////////////////////////////////////
// Helper functions
//--------------------------------------------------------------------------------------------
class CObjectSectorLock {
private:
CObjectSector *oscl_posc; // ptr to object sector that will do lock/unlock
public:
CObjectSectorLock( CObjectSector *posc); // lock all object sector arrays
~CObjectSectorLock(); // unlock all object sector arrays
示例9: ClearConversionArrays
void ClearConversionArrays( void)
{
acmMaterials.Clear();
actTriangles.Clear();
avVertices.Clear();
avTextureVertices.Clear();
aiRemap.Clear();
}
示例10: CopyEntities
/* 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++;
}}
示例11: ObtainTextSize
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);
}
示例12: Init
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
}
示例13: RemapVertices
void RemapVertices(BOOL bAsOpened)
{
{INDEX ctSurf = 0;
// fill remap array with indices of vertices in order how they appear per polygons
{FOREACHINDYNAMICCONTAINER(acmMaterials, ConversionMaterial, itcm)
{
_RPT1(_CRT_WARN, "Indices of polygons in surface %d:", ctSurf);
// for each polygon in surface
{FOREACHINDYNAMICCONTAINER(itcm->ms_Polygons, INDEX, itipol)
{
_RPT1(_CRT_WARN, " %d,", *itipol);
}}
_RPT0(_CRT_WARN, "\n");
ctSurf++;
}}
_RPT0(_CRT_WARN, "Polygons and their vertex indices:\n");
for( INDEX ipol=0; ipol<actTriangles.Count(); ipol++)
{
INDEX idxVtx0 = actTriangles[ipol].ct_iVtx[0];
INDEX idxVtx1 = actTriangles[ipol].ct_iVtx[1];
INDEX idxVtx2 = actTriangles[ipol].ct_iVtx[2];
_RPT4(_CRT_WARN, "Indices of vertices in polygon %d : (%d, %d, %d)\n", ipol, idxVtx0, idxVtx1, idxVtx2);
}}
示例14:
CToolTipWnd::~CToolTipWnd()
{
_saPixLineHeights.Clear();
}
示例15: wsprintf
void CObject3D::LoadAny3DFormat_t(
const CTFileName &fnmFileName,
const FLOATmatrix3D &mTransform,
enum LoadType ltLoadType/*= LT_NORMAL*/)
{
#if USE_E3D
BOOL bWasOn = _bBatchLoading;
try {
if (!_bBatchLoading) {
BatchLoading_t(TRUE);
}
// call file load with file's full path name
CTString strFile = _fnmApplicationPath+fnmFileName;
char acFile[MAX_PATH];
wsprintf(acFile,"%s",strFile);
e3_LoadFile(_hwnd, acFile);
_pe3Scene=e3_GetScene(_hwnd);
// if scene is successefuly loaded
if(_pe3Scene != NULL)
{
_pe3Object = _pe3Scene->GetObject3d( 0);
// use different methods to convert into Object3D
switch( ltLoadType)
{
case LT_NORMAL:
FillConversionArrays_t(mTransform);
ConvertArraysToO3D();
break;
case LT_OPENED:
FillConversionArrays_t(mTransform);
RemapVertices(TRUE);
ConvertArraysToO3D();
break;
case LT_UNWRAPPED:
FLOATmatrix3D mOne;
mOne.Diagonal(1.0f);
FillConversionArrays_t(mOne);
if( avTextureVertices.Count() == 0)
{
ThrowF_t("Unable to import mapping from 3D object because it doesn't contain mapping coordinates.");
}
RemapVertices(FALSE);
ConvertArraysToO3D();
break;
}
ClearConversionArrays();
}
else
{
ThrowF_t("Unable to load 3D object: %s", (const char *)fnmFileName);
}
if (!bWasOn) {
BatchLoading_t(FALSE);
}
} catch (char *) {
if (!bWasOn) {
BatchLoading_t(FALSE);
}
throw;
}
#endif
}