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


C++ CGrid类代码示例

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


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

示例1: FindMonsterGroupInRange

WORD CGrid::FindMonsterGroupInRange(DWORD* pFriendsList, CObject* pFinder,VECTOR3* pPos)
{
	POS pos = m_NeighborGrid.GetFirstPos();
	CGrid* pGrid;
	WORD wStartEmptyNum = 0;
	DWORD objectList[MAX_FIND_MONSTERNUM] = {0,};
	WORD wFindNum = FindMonsterGroupInRange(pFinder, pPos, &objectList[0]);

	for(WORD i=0; i<wFindNum; ++i)
	{
		pFriendsList[wStartEmptyNum] = objectList[i];
		wStartEmptyNum++;
	}

	while( (pGrid = m_NeighborGrid.GetNextPos(pos) ) != NULL)
	{
		if(wStartEmptyNum >= MAX_FIND_MONSTERNUM)
			return wStartEmptyNum;

		ZeroMemory(objectList, sizeof(objectList));

		wFindNum = pGrid->FindMonsterGroupInRange(pFinder, pPos, &objectList[0]);

		for(WORD i=0; i<wFindNum; i++)
		{
			if(wStartEmptyNum >= MAX_FIND_MONSTERNUM)
				return wStartEmptyNum;

			pFriendsList[wStartEmptyNum] = objectList[i];
			wStartEmptyNum++;
		}
	}

	return wStartEmptyNum;
}
开发者ID:xianyinchen,项目名称:LUNAPlus,代码行数:35,代码来源:Grid.cpp

示例2:

void	CMap::Draw( void )
{
	CGrid* pEnd = m_pGrid + m_uWidth*m_uHeight;
	for ( CGrid* pCur = m_pGrid; pCur!=pEnd; pCur++ )
	{
		pCur->Draw();
	}
}
开发者ID:roosen5,项目名称:media-design-school,代码行数:8,代码来源:Map.cpp

示例3: GetGridByPos

BOOL CGridManager::RemoveObjectFromGrid( CWorldObject *pWorldObject, FLOAT x, FLOAT z )
{
	CGrid *pGrid = GetGridByPos(x, z);
	if(pGrid == NULL)
	{
		return FALSE;
	}

	return pGrid->RemoveObject(pWorldObject);;
}
开发者ID:lweijin,项目名称:GameProject,代码行数:10,代码来源:GridManager.cpp

示例4: GetGridByIndex

//将对象从网格中删除
BOOL CGridManager::RemoveObjectFromGrid(CWorldObject *pWorldObject, INT32 nIndex)
{
	CGrid *pGrid = GetGridByIndex(nIndex);
	if(pGrid == NULL)
	{
		return FALSE;
	}

	return pGrid->RemoveObject(pWorldObject);;
}
开发者ID:lweijin,项目名称:GameProject,代码行数:11,代码来源:GridManager.cpp

示例5: AddGridToPackedDataWithoutOne

void CGrid::AddGridToPackedDataWithoutOne(DWORD dwID,CPackedData* pPackedData)
{
	POS pos = m_NeighborGrid.GetFirstPos();
	CGrid* pGrid;
	
	AddObjectToPacket(dwID,pPackedData);
	while( (pGrid = m_NeighborGrid.GetNextPos(pos)) != NULL)
	{
		pGrid->AddObjectToPacket(dwID,pPackedData);
	}
}
开发者ID:xianyinchen,项目名称:LUNAPlus,代码行数:11,代码来源:Grid.cpp

示例6: AddGridToPackedData

void CGrid::AddGridToPackedData(CPackedData* pPackedData)
{
	POS pos = m_NeighborGrid.GetFirstPos();
	CGrid* pGrid;
	
	AddObjectToPacket(0,pPackedData);
	while( (pGrid = m_NeighborGrid.GetNextPos(pos)) != NULL)
	{
		pGrid->AddObjectToPacket(0,pPackedData);
	}
}
开发者ID:xianyinchen,项目名称:LUNAPlus,代码行数:11,代码来源:Grid.cpp

示例7: ImportGrid

BOOL CDlgImportField::ImportGrid(int nGrid)
{
	CGrid		*pGrd = &(m_fldGrd[nGrid]);
	CGrid		grd;
	GridInfo	gi;

	if(pGrd->IsEmpty()) {
		gi = grd.GetInfoBrowse();
		if( CheckGrid(gi) ) {
			pGrd->Open( gi.strFilePath, gi.nType );
			return TRUE;
		}
	}
	else {
		int ret = AfxMessageBox("Grid is not empty. Replace?", MB_ICONQUESTION | MB_YESNO);
		if( ret == IDYES) {
			gi = grd.GetInfoBrowse();
			if( CheckGrid( gi) ) {
				pGrd->Close();
				pGrd->Open( gi.strFilePath, gi.nType );
				return TRUE;
			}
		}
	}

	return FALSE;

}
开发者ID:igorcerovsky,项目名称:Mod3D,代码行数:28,代码来源:DlgImportField.cpp

示例8: SendRemoveObjectInfo

void CGrid::SendRemoveObjectInfo(CObject* pLeavedObject,CGrid* pCurGrid)
{
	
	/////////////////////////////////////////////////////////////////////////
	// 06. 04. 그리드 수정
	// 이 함수는 삭제된 오브젝트가 소속된 그리드의 오브젝트들이
	// 삭제된 오브젝트에게 연결된 Agent에 메세지를 보내는 부분인데
	// 플레이어 이외의 오브젝트는 연결된 Agent가 없으므로 들어올 필요가 없다.
	if(pLeavedObject->GetObjectKind() != eObjectKind_Player )
		return;
	/////////////////////////////////////////////////////////////////////////

	POS pos = m_NeighborGrid.GetFirstPos();
	CGrid* pGrid;
	
	if(pCurGrid == NULL)
	{
		SendRemoveCharacterMsg(pLeavedObject);
	//	SendRemoveItemMsg(pLeavedObject);
		while( (pGrid = m_NeighborGrid.GetNextPos(pos)) != NULL)
		{
			pGrid->SendRemoveCharacterMsg(pLeavedObject);
	//		pGrid->SendRemoveItemMsg(pLeavedObject);
		}
	}
	else
	{
		if(!pCurGrid->IsNeighborGrid(this))
		{
			SendRemoveCharacterMsg(pLeavedObject);
	//		SendRemoveItemMsg(pLeavedObject);
		}
		
		while( (pGrid = m_NeighborGrid.GetNextPos(pos)) != NULL)
		{
			if(!pCurGrid->IsNeighborGrid(pGrid))
			{
				pGrid->SendRemoveCharacterMsg(pLeavedObject);
	//			pGrid->SendRemoveItemMsg(pLeavedObject);
			}
		}
	}
}
开发者ID:xianyinchen,项目名称:LUNAPlus,代码行数:43,代码来源:Grid.cpp

示例9: GetNodeAttributeOrDefault

 void CRABMedium::Init(TConfigurationNode& t_tree) {
    try {
       CMedium::Init(t_tree);
       /* Check occlusions? */
       GetNodeAttributeOrDefault(t_tree, "check_occlusions", m_bCheckOcclusions, m_bCheckOcclusions);
       /* Get the positional index method */
       std::string strPosIndexMethod("grid");
       GetNodeAttributeOrDefault(t_tree, "index", strPosIndexMethod, strPosIndexMethod);
       /* Get the arena center and size */
       CVector3 cArenaCenter;
       CVector3 cArenaSize;
       TConfigurationNode& tArena = GetNode(CSimulator::GetInstance().GetConfigurationRoot(), "arena");
       GetNodeAttribute(tArena, "size", cArenaSize);
       GetNodeAttributeOrDefault(tArena, "center", cArenaCenter, cArenaCenter);
       /* Create the positional index for embodied entities */
       if(strPosIndexMethod == "grid") {
          size_t punGridSize[3];
          if(!NodeAttributeExists(t_tree, "grid_size")) {
             punGridSize[0] = cArenaSize.GetX();
             punGridSize[1] = cArenaSize.GetY();
             punGridSize[2] = cArenaSize.GetZ();
          }
          else {
             std::string strPosGridSize;
             GetNodeAttribute(t_tree, "grid_size", strPosGridSize);
             ParseValues<size_t>(strPosGridSize, 3, punGridSize, ',');
          }
          CGrid<CRABEquippedEntity>* pcGrid = new CGrid<CRABEquippedEntity>(
             cArenaCenter - cArenaSize * 0.5f, cArenaCenter + cArenaSize * 0.5f,
             punGridSize[0], punGridSize[1], punGridSize[2]);
          m_pcRABEquippedEntityGridUpdateOperation = new CRABEquippedEntityGridEntityUpdater(*pcGrid);
          pcGrid->SetUpdateEntityOperation(m_pcRABEquippedEntityGridUpdateOperation);
          m_pcRABEquippedEntityIndex = pcGrid;
       }
       else {
          THROW_ARGOSEXCEPTION("Unknown method \"" << strPosIndexMethod << "\" for the positional index.");
       }
    }
    catch(CARGoSException& ex) {
       THROW_ARGOSEXCEPTION_NESTED("Error in initialization of the range-and-bearing medium", ex);
    }
 }
开发者ID:daneshtarapore,项目名称:argos3,代码行数:42,代码来源:rab_medium.cpp

示例10: OnBnClickedBrowseModel

void CDlgDefineModel::OnBnClickedBrowseModel()
{
	CGrid grd;
	grd.Open();
	m_nX = grd.GetCols();
	m_nY = grd.GetRows();
	m_x0 = grd.GetX0();
	m_y0 = grd.GetY0();
	m_xCs = grd.GetXSize();
	m_yCs = grd.GetYSize();

	UpdateData(FALSE);
}
开发者ID:igorcerovsky,项目名称:Inv3D,代码行数:13,代码来源:DlgDefineModel.cpp

示例11: FindFirstMonsterInRange

CObject* CGrid::FindFirstMonsterInRange(CObject* pFinder,VECTOR3* pPos,float Range)
{
	POS pos = m_NeighborGrid.GetFirstPos();
	CGrid* pGrid;
	CObject* pObject;
	
	FindFirstMonsterInRange(pFinder,pPos,Range,&pObject);
	if(pObject)
		return pObject;

	while( (pGrid = m_NeighborGrid.GetNextPos(pos) ) != NULL)
	{
		pGrid->FindFirstMonsterInRange(pFinder,pPos,Range,&pObject);
		if(pObject)
			return pObject;
	}
	
	return NULL;

}
开发者ID:xianyinchen,项目名称:LUNAPlus,代码行数:20,代码来源:Grid.cpp

示例12: FindPlayerRandom

CObject* CGrid::FindPlayerRandom()
{
	POS pos = m_NeighborGrid.GetFirstPos();
	CGrid* pGrid;
	CObject* pObject[9];
	CObject* temp;
	WORD count = 0;

	/// 우선 자기 그리드 내에서 플레이어를 고른다.
	FindPlayerRandom( &temp );
	if( temp )
	{
		pObject[count++] = temp;
	}

	/// 각 그리드에서 플레이어를 골라온다.
	while( ( pGrid = m_NeighborGrid.GetNextPos( pos ) ) != NULL)
	{
		temp = NULL;
		pGrid->FindPlayerRandom( &temp );
		if( temp )
		{
			pObject[count++] = temp;

			if(count == 9)
				break;
		}
	}
	
	/// 선택된 플레이어가 1인 이상일때
	if(count > 0)
	{
		/// 리턴할 플레이어를 고른다
		WORD select = WORD( rand() % count);

		return pObject[select];
	}

	/// 선택된 플레이어가 없으면 NULL 리턴
	return NULL;
}
开发者ID:xianyinchen,项目名称:LUNAPlus,代码行数:41,代码来源:Grid.cpp

示例13: sample

void CGrid::sample(CGrid &points, 
                void (*sample)(iterator starta, iterator enda, 
                               iterator startb, iterator endb, double radius)) {

   static int corner[8*3] = { 0, 0, 0,  1, 0, 0,  0, 1, 0,  0, 0, 1,
                              0, 1, 1,  1, 0, 1,  1, 1, 0,  1, 1, 1 };

   static int diagonals[14*2] = { 0, 0, //remove this line to avoid self intesextion
                                  0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7,
                                  2, 3, 1, 3, 1, 2,                       
                                  1, 4, 2, 5, 3, 6 };

  for(int z = 0; z < zside; z++) {
    for(int y = 0; y < yside; y++) {
      for(int x = 0; x < xside; x++) {     
        int origin = cell(x, y, z);  

         
        if(!isEmpty(origin) && !points.isEmpty(origin)) 
          sample(startV(origin), endV(origin), 
                 points.startV(origin),   points.endV(origin), radius);  
                        

        for(int d = 2; d < 28; d += 2) { //skipping self
          int *cs = corner + 3*diagonals[d];
          int *ce = corner + 3*diagonals[d+1];
          if((x+cs[0] < xside) && (y+cs[1] < yside) && (z+cs[2] < zside) &&
             (x+ce[0] < xside) && (y+ce[1] < yside) && (z+ce[2] < zside)) {

             origin   = cell(x+cs[0], y+cs[1], z+cs[2]);

             int dest = cell(x+ce[0], y+ce[1], z+ce[2]);

             if(!isEmpty(origin) && !points.isEmpty(dest))           // Locally 
               sample(startV(origin), endV(origin), 
                      points.startV(dest),   points.endV(dest), radius); 

             if(!isEmpty(dest) && !points.isEmpty(origin))  
               sample(startV(dest), endV(dest), 
                      points.startV(origin),   points.endV(origin), radius);        
          }
        }      
      }
    }
  }
}
开发者ID:debowin,项目名称:Symmetry-Detection,代码行数:46,代码来源:grid.cpp

示例14: PrintGridCells

void PrintGridCells(CGrid<CLEDEntity>& g) {
   for(SInt32 k = g.GetSizeK()-1; k >= 0; --k) {
      for(SInt32 j = g.GetSizeJ()-1; j >= 0; --j) {
         for(SInt32 i = 0; i < g.GetSizeI(); ++i) {
            CGrid<CLEDEntity>::SCell& c = g.GetCellAt(i, j, k);
            fprintf(stdout, "[ %d, %d, %d ] %u entities, timestamp = %u\n", i, j, k, c.Entities.size(), c.Timestamp);
            if(!c.Entities.empty()) {
               for(CSet<CLEDEntity*>::iterator it = c.Entities.begin();
                   it != c.Entities.end();
                   ++it) {
                  fprintf(stdout, "   %s\t%.3f\t%.3f\t%.3f\n",
                          (**it).GetId().c_str(),
                          (**it).GetPosition().GetX(),
                          (**it).GetPosition().GetY(),
                          (**it).GetPosition().GetZ());
               }
            }
         }
      }
   }
   fprintf(stdout, "\n");
}
开发者ID:NavQ,项目名称:argos3,代码行数:22,代码来源:test-grid.cpp

示例15: FindMonsterInRange

CObject* CGrid::FindMonsterInRange(CObject* pFinder,VECTOR3* pPos,float Range)
{
	POS pos = m_NeighborGrid.GetFirstPos();
	CGrid* pGrid;
	CObject* pObject;
	CObject* pClosestObject;
	float dist;
	float mindist;
	
	FindMonsterInRange(pFinder,pPos,Range,mindist,&pClosestObject);
	while( (pGrid = m_NeighborGrid.GetNextPos(pos)) != NULL)
	{
		pGrid->FindMonsterInRange(pFinder,pPos,Range,dist,&pObject);
		if(dist < mindist)
		{
			mindist = dist;
			pClosestObject = pObject;
		}
	}
	
	return pClosestObject;
}
开发者ID:xianyinchen,项目名称:LUNAPlus,代码行数:22,代码来源:Grid.cpp


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