本文整理汇总了C++中COperator::SetHitPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ COperator::SetHitPoint方法的具体用法?C++ COperator::SetHitPoint怎么用?C++ COperator::SetHitPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类COperator
的用法示例。
在下文中一共展示了COperator::SetHitPoint方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _Execute
void CCmdMoveObject::_Execute()
{
COpearationLog::GetInst()->WriteOperationLog("DO LShift Or C move object");
CTerrainMesh * pTerrainMesh = CMapEditApp::GetInst()->GetEditingMesh();
COperator * pOperator = CMapEditApp::GetInst()->GetOperator();
CMapEditObject * pModel = m_diff.pObject->GetModelGroup()->GetSelfPresentation(0);
pModel->SetGroupOffset(m_diff.vGroupOffset);
// erase center image info
int nCenterGridIndex = pModel->GetUserOffsetAdjustedGridIndex(m_diff.nCenterGridIndex);
SGrid & gridCenter = pTerrainMesh->GetGrid(nCenterGridIndex);
gridCenter.vecCenterObjects.erase(
remove(gridCenter.vecCenterObjects.begin(), gridCenter.vecCenterObjects.end(), m_diff.pObject), gridCenter.vecCenterObjects.end() );
CToolSetModel::GetInst()->AddActiveObject(m_diff.pObject);
m_diff.pObject->SetCenterGridIndex(INVALID);
m_diff.pObject->GetModelGroup()->SetEditState(sqr::EES_MOVING);
// update hot
CTObject * p = NULL;
CVector3f v;
DWORD dwGridIndexHot = CPicker::GetInst()->GetPickPos(&p,&v);
pOperator->SetGridIndexHot(dwGridIndexHot);
pOperator->SetHitPoint(*((CVector3f*)&v));
pOperator->SetObjectHot(p);
}
示例2: OnEvent
void CAnimCamera::OnEvent(InputEvent & event)
{
COperator *pOperator = NULL;
pOperator = CMapEditApp::GetInst()->GetOperator();
if ( pOperator == NULL || !m_bActive )
{
return;
}
CVector3f vecVector;
CVector3f hitpoint = pOperator->GetHitPoint();
switch ( event.eType )
{
case EIET_KB_KEYDOWN :
{
// handle keyboard
if ( m_bMovable )
{
// left
if ( event.dwData == DIK_A )
{
vecVector = -m_pCamEx->getRIGHT();
vecVector.y = 0;
vecVector.normalize();
vecVector *= MOVE_SPEED_RATIO;
MoveRTS(vecVector) ;
hitpoint.x += vecVector.x;
hitpoint.z += vecVector.z;
pOperator->SetHitPoint(hitpoint);
m_bResetVS = true;
}
// right
if ( event.dwData == DIK_D )
{
vecVector = m_pCamEx->getRIGHT();
vecVector.y = 0;
vecVector.normalize();
vecVector *= MOVE_SPEED_RATIO;
MoveRTS(vecVector) ;
hitpoint.x += vecVector.x;
hitpoint.z += vecVector.z;
pOperator->SetHitPoint(hitpoint);
m_bResetVS = true;
}
// up
if ( event.dwData == DIK_W )
{
vecVector = m_pCamEx->getDIRECTION();
vecVector.y = 0;
vecVector.normalize();
vecVector *= MOVE_SPEED_RATIO;
MoveRTS(vecVector);
hitpoint.x += vecVector.x;
hitpoint.z += vecVector.z;
pOperator->SetHitPoint(hitpoint);
m_bResetVS = true;
}
// down
if ( event.dwData == DIK_S )
{
vecVector = -m_pCamEx->getDIRECTION();
vecVector.y = 0;
vecVector.normalize();
vecVector *= MOVE_SPEED_RATIO;
MoveRTS(vecVector);
hitpoint.x += vecVector.x;
hitpoint.z += vecVector.z;
pOperator->SetHitPoint(hitpoint);
m_bResetVS = true;
}
// up another type
if ( event.dwData == DIK_Q )
{
vecVector = m_pCamEx->getDIRECTION();
vecVector *= MOVE_SPEED_RATIO;
MoveRTS(vecVector);
hitpoint.x += m_pCamEx->getDIRECTION().x;
hitpoint.y += m_pCamEx->getDIRECTION().y;
pOperator->SetHitPoint(hitpoint);
m_bResetVS = true;
CMapEditApp::GetInst()->GetOperator()->SetGPushed(false);
}
// down another type
if ( event.dwData == DIK_E )
{
vecVector = -m_pCamEx->getDIRECTION();
vecVector *= MOVE_SPEED_RATIO;
MoveRTS(vecVector);
hitpoint.x -= m_pCamEx->getDIRECTION().x;
hitpoint.y -= m_pCamEx->getDIRECTION().y;
pOperator->SetHitPoint(hitpoint);
m_bResetVS = true;
CMapEditApp::GetInst()->GetOperator()->SetGPushed(false);
}
//.........这里部分代码省略.........
示例3: _UnExecute
void CCmdPlaceObject::_UnExecute()
{
CTerrainMesh * pTerrainMesh = CMapEditApp::GetInst()->GetEditingMesh();
COperator * pOperator = CMapEditApp::GetInst()->GetOperator();
CMapEditObject * pModel = m_diff.pObject->GetModelGroup()->GetSelfPresentation(0);
pModel->SetGroupOffset(m_diff.vGroupOffset);
pModel->SetVisible(false);
int nHotGridIndex = pModel->GetUserOffsetAdjustedGridIndex(m_diff.nHotGridIndex);
if ( m_diff.pObject->GetModelGroup()->m_SL.m_bIAmbScenePointLight || m_diff.pObject->GetModelGroup()->m_SpotLight.m_bIAmbSceneSpotLight )
{
if ( pTerrainMesh->m_DynamicLightGrids.find(nHotGridIndex) != pTerrainMesh->m_DynamicLightGrids.end() )
pTerrainMesh->m_DynamicLightGrids.erase(pTerrainMesh->m_DynamicLightGrids.find(nHotGridIndex));
if ( pTerrainMesh->m_VisibleDynamicLightGrids.find(nHotGridIndex) != pTerrainMesh->m_VisibleDynamicLightGrids.end() )
pTerrainMesh->m_VisibleDynamicLightGrids.erase(pTerrainMesh->m_VisibleDynamicLightGrids.find(nHotGridIndex));
m_diff.pObject->GetModelGroup()->SetIsLightEffect(false);
}
// erase center image info
SGrid & gridCenter = pTerrainMesh->GetGrid(nHotGridIndex);
int nDeleteGridIndex = 0;
size_t nModelGroupCnt = gridCenter.vecCenterObjects.size();
for ( size_t m = 0; m < nModelGroupCnt; ++m )
{
if( gridCenter.vecCenterObjects[m] == m_diff.pObject )
{
nDeleteGridIndex = m;
m = nModelGroupCnt;
}
}
gridCenter.vecCenterObjects.erase(
remove(gridCenter.vecCenterObjects.begin(), gridCenter.vecCenterObjects.end(), m_diff.pObject), gridCenter.vecCenterObjects.end() );
OfflineRender::GetInst()->UpdateGridLights(nHotGridIndex);
//////////////////////////////////////////////////////////////////////////
pModel = m_diff.pObject->GetModelGroup()->GetSelfPresentation(0);
//////////////////////////////////////////////////////////////////////////
CToolSetModel::GetInst()->AddActiveObject(m_diff.pObject);
m_diff.pObject->GetModelGroup()->SetEditState(sqr::EES_MOVING);
m_diff.pObject->SetCenterGridIndex(INVALID);
//////////////////////////////////////////////////////////////////////////
// update hot
CTObject * p = NULL;
CVector3f v;
nHotGridIndex = CPicker::GetInst()->GetPickPos(&p,&v);
pOperator->SetGridIndexHot(nHotGridIndex);
pOperator->SetHitPoint(*((CVector3f*)&v));
pOperator->SetObjectHot(p);
///删除模型名记录
string modelname = "";
modelname = pModel->GetName();
set<string>::iterator iter = pTerrainMesh->m_SceneModelList.find(modelname);
if ( iter != pTerrainMesh->m_SceneModelList.end() )
pTerrainMesh->m_SceneModelList.erase(iter);
size_t npos = modelname.rfind("\\");
modelname = modelname.substr(npos+1, modelname.length());
char szObjectBuf[1024];
sprintf(szObjectBuf, "UNDO 放置 %s", modelname.c_str());
COpearationLog::GetInst()->WriteOperationLog(szObjectBuf);
}