当前位置: 首页>>代码示例>>C++>>正文


C++ CStaticArray::New方法代码示例

本文整理汇总了C++中CStaticArray::New方法的典型用法代码示例。如果您正苦于以下问题:C++ CStaticArray::New方法的具体用法?C++ CStaticArray::New怎么用?C++ CStaticArray::New使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CStaticArray的用法示例。


在下文中一共展示了CStaticArray::New方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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++;
  }}
开发者ID:RocketersAlex,项目名称:LCSource,代码行数:58,代码来源:EntityCopying.cpp

示例2: 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;
}
开发者ID:ArcticPheenix,项目名称:Serious-Engine,代码行数:15,代码来源:ModelInstance.cpp

示例3: 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);
}
开发者ID:EgoIncarnate,项目名称:Serious-Engine,代码行数:21,代码来源:ToolTipWnd.cpp

示例4: RemoveTexture

// 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();
}
开发者ID:ArcticPheenix,项目名称:Serious-Engine,代码行数:24,代码来源:ModelInstance.cpp

示例5: 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);
//.........这里部分代码省略.........
开发者ID:RocketersAlex,项目名称:LCSource,代码行数:101,代码来源:Skill.cpp

示例6: 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;
}
开发者ID:RocketersAlex,项目名称:LCSource,代码行数:74,代码来源:ShopData.cpp

示例7: FillConversionArrays_t

/*
 * Converts data from Exploration3D format into arrays used for conversion to O3D
 */
void FillConversionArrays_t(const FLOATmatrix3D &mTransform)
{
#if USE_E3D
  // all polygons must be triangles
  if(_pe3Object->_facecount != 0)
  {
    throw("Error: Not all polygons are triangles!");
  }

  // check if we need flipping (if matrix is flipping, polygons need to be flipped)
  const FLOATmatrix3D &m = mTransform;
  FLOAT fDet = 
    m(1,1)*(m(2,2)*m(3,3)-m(2,3)*m(3,2))+
    m(1,2)*(m(2,3)*m(3,1)-m(2,1)*m(3,3))+
    m(1,3)*(m(2,1)*m(3,2)-m(2,2)*m(3,1));
  FLOAT bFlipped = fDet<0;

  // ------------  Convert object vertices (coordinates)
  INDEX ctVertices = _pe3Object->pointcount;
  avVertices.New(ctVertices);
  // copy vertices
  for( INDEX iVtx=0; iVtx<ctVertices; iVtx++)
  {
    avVertices[iVtx] = ((FLOAT3D &)_pe3Object->points[iVtx])*mTransform;
    avVertices[iVtx](1) = -avVertices[iVtx](1);
    avVertices[iVtx](3) = -avVertices[iVtx](3);
  }

  // ------------ Convert object's mapping vertices (texture vertices)
  INDEX ctTextureVertices = _pe3Object->txtcount;
  avTextureVertices.New(ctTextureVertices);
  // copy texture vertices
  for( INDEX iTVtx=0; iTVtx<ctTextureVertices; iTVtx++)
  {
    avTextureVertices[iTVtx] = (FLOAT2D &)_pe3Object->txtpoints[iTVtx];
  }
  
  // ------------ Organize triangles as list of surfaces
  // allocate triangles
  INDEX ctTriangles = _pe3Object->facecount;
  actTriangles.New(ctTriangles);

  acmMaterials.Lock();
  
  // sort triangles per surfaces
  for( INDEX iTriangle=0; iTriangle<ctTriangles; iTriangle++)
  {
    ConversionTriangle &ctTriangle = actTriangles[iTriangle];
    e3_TFACE *pe3Triangle = _pe3Object->GetFace( iTriangle);
    // copy vertex indices
    if (bFlipped) {
      ctTriangle.ct_iVtx[0] = pe3Triangle->v[2];
      ctTriangle.ct_iVtx[1] = pe3Triangle->v[1];
      ctTriangle.ct_iVtx[2] = pe3Triangle->v[0];
    } else {
      ctTriangle.ct_iVtx[0] = pe3Triangle->v[0];
      ctTriangle.ct_iVtx[1] = pe3Triangle->v[1];
      ctTriangle.ct_iVtx[2] = pe3Triangle->v[2];
    }
    // copy texture vertex indices
    if (bFlipped) {
      ctTriangle.ct_iTVtx[0] = pe3Triangle->t[2];
      ctTriangle.ct_iTVtx[1] = pe3Triangle->t[1];
      ctTriangle.ct_iTVtx[2] = pe3Triangle->t[0];
    } else {
      ctTriangle.ct_iTVtx[0] = pe3Triangle->t[0];
      ctTriangle.ct_iTVtx[1] = pe3Triangle->t[1];
      ctTriangle.ct_iTVtx[2] = pe3Triangle->t[2];
    }

    // obtain material
    e3_MATERIAL *pe3Mat = pe3Triangle->material;
    BOOL bNewMaterial = TRUE;
    // attach triangle into one material
    for( INDEX iMat=0; iMat<acmMaterials.Count(); iMat++)
    {
      // if this material already exist in array of materu
      if( acmMaterials[ iMat].cm_ulTag == (ULONG) pe3Mat)
      {
        // set index of surface
        ctTriangle.ct_iMaterial = iMat;
        // add triangle into surface list of triangles
        INDEX *piNewTriangle = new INDEX(1);
        *piNewTriangle = iTriangle;
        acmMaterials[ iMat].ms_Polygons.Add( piNewTriangle);
        bNewMaterial = FALSE;
        continue;
      }
    }
    // if material hasn't been added yet
    if( bNewMaterial)
    {
      // add new material
      ConversionMaterial *pcmNew = new ConversionMaterial;
      acmMaterials.Unlock();
      acmMaterials.Add( pcmNew);
      acmMaterials.Lock();
//.........这里部分代码省略.........
开发者ID:0-T-0,项目名称:Serious-Engine,代码行数:101,代码来源:Object3D_IO.cpp


注:本文中的CStaticArray::New方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。