Пример #1
0
	// 改变当前编辑的点的位置
	void CPathFindAction::ChangeCurEditPointPos(const Point& pt)
	{
		CUnreachRegion* pRegion = NULL;
		CPointInfo*     pPoint  = NULL;

		// 得到当前正在编辑的区域的信息.
		pRegion = GetRegionById(m_ulCurEditRegionId);
		if(pRegion)
		{
			pPoint = pRegion->GetPointInfoById1(m_ulCurEditPointId);
			if(pPoint)
			{	

				// 查找这个点的下标值.
				int iIndex = -1;
				POINT_MAP::iterator it;
				POINT_MAP::iterator itEnd;
				itEnd = pRegion->m_pointMap.end();
				for(it = pRegion->m_pointMap.begin(); it != itEnd; it++)
				{
					iIndex++;
					if(m_ulCurEditPointId == it->first)
					{
						break;
					}
				}


				// 得到修改后的位置.
				Ogre::Vector3 position;
				bool hit = getSceneManipulator()->getTerrainIntersects(pt.x, pt.y, position);
				if(hit)
				{

					//暂时把判断能否添加一个点去掉.
					//if(pRegion->CanChangePointPos(iIndex, position))
					{
						// 修改新的点的位置.
						pPoint->SetPos(position);

						// 当前编辑的点的位置.
						m_curPointPos = position;

						if(it != itEnd)
						{
							// 如果下标存在
							if((-1 != iIndex)&&(iIndex < (int)pRegion->m_pLineShape->m_pointArray.size()))
							{
								pRegion->m_pLineShape->m_pointArray[iIndex] = position;
								pRegion->m_pLineShape->FillPointData1();
								//pRegion->ReShapeArea1();
							}
						}

					}
				}
			}
		}
	}
Пример #2
0
// 选中点的操作
void CPathFindEditDlg::DoSelPoint()
{
	if(NULL == m_pListboxPointInRegion)
	{
		return;
	}

	// 得到选中的索引
	int iIndex = m_pListboxPointInRegion->GetSelection();

	unsigned long ulPointId = 0;
	if(-1 != iIndex)
	{
		// 得到点id
		ulPointId = (unsigned long)m_pListboxPointInRegion->GetClientData(iIndex);
		if(m_pAction)
		{
			DWORD dwOldID = m_ulCurPointId;
			DWORD dwMax, dwMin;
			FLOAT fDistance = 0.0f;
			Ogre::Vector3 p1, p2;

			//设置选中点
			m_ulCurPointId = ulPointId;
			m_pAction->SelPoint(ulPointId);

			//求原先的选中点和新的选中点的折线距离
			CUnreachRegion* pRegion = m_pAction->GetRegionById( m_ulCurRegionId );
			if( dwOldID != m_ulCurPointId && pRegion )
			{
				//试图得到原先点和选中点间的每一个点
				dwMax = dwOldID > m_ulCurPointId ? dwOldID : m_ulCurPointId;
				dwMin = dwOldID > m_ulCurPointId ? m_ulCurPointId : dwOldID;
				for( DWORD dw = dwMin; dw <= dwMax; dw ++ )
				{
					CPointInfo* pPoint = pRegion->GetPointInfoById1(dw);
					if( !pPoint ) continue;
					if( dw == dwMin )
					{
						p1 = pPoint->GetPosition();
					}
					else
					{
						p2 = pPoint->GetPosition();
						fDistance += sqrtf( ( p1.x - p2.x ) * ( p1.x - p2.x ) + ( p1.y - p2.y ) * ( p1.y - p2.y ) + ( p1.z - p2.z ) * ( p1.z - p2.z ) );
						p1 = p2;
					}
				}
			}
		}
	}
}
Пример #3
0
	// 记录当前操作前一次点的位置.
	void CPathFindAction::RecordPreDoPointPos()
	{

		CUnreachRegion* pRegion = NULL;
		CPointInfo*     pPoint  = NULL;

		// 得到当前正在编辑的区域的信息.
		pRegion = GetRegionById(m_ulCurEditRegionId);
		if(pRegion)
		{
			pPoint = pRegion->GetPointInfoById1(m_ulCurEditPointId);
			if(pPoint)
			{	
				m_preDoPointPos = pPoint->m_Position;		
			}
		}
	}
Пример #4
0
	// 选择一个点.
	void CPathFindAction::SelPoint(unsigned long ulPointId)
	{
		m_ulCurEditPointId = ulPointId;

		CUnreachRegion* pRegion = NULL;
		CPointInfo*     pPoint  = NULL;

		// 得到当前正在编辑的区域的信息.
		pRegion = GetRegionById(m_ulCurEditRegionId);
		if(pRegion)
		{
			pRegion->SetPrePointMaterial();
			pRegion->m_ulCurEditPointId = m_ulCurEditPointId;
			pPoint = pRegion->GetPointInfoById1(ulPointId);
			if(pPoint)
			{
				pPoint->SetSelMaterial();
			}
		}
	}
Пример #5
0
	void CPathFindAction::ChangeCurEditPointPos(unsigned long ulPointId, Ogre::Vector3 position)
	{
		CUnreachRegion* pRegion = NULL;
		CPointInfo*     pPoint  = NULL;

		// 得到当前正在编辑的区域的信息.
		pRegion = GetRegionById(m_ulCurEditRegionId);
		if(pRegion)
		{
			pPoint = pRegion->GetPointInfoById1(ulPointId);
			if(pPoint)
			{	

				// 查找这个点的下标值.
				int iIndex = -1;
				POINT_MAP::iterator it;
				POINT_MAP::iterator itEnd;
				itEnd = pRegion->m_pointMap.end();
				for(it = pRegion->m_pointMap.begin(); it != itEnd; it++)
				{
					iIndex++;
					if(ulPointId == it->first)
					{
						break;
					}
				}

				pPoint->SetPos(position);

				// 如果下标存在
				if((-1 != iIndex)&&(iIndex < (int)pRegion->m_pLineShape->m_pointArray.size()))
				{
					pRegion->m_pLineShape->m_pointArray[iIndex] = position;
					pRegion->m_pLineShape->FillPointData1();
				}

			}

		}

	}