/** get the hit position and return true if we hit something otherwise the result pos will be the dest pos */ bool VMapManager::getObjectHitPos(unsigned int pMapId, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float &ry, float& rz, float pModifyDist) { bool result = false; rx=x2; ry=y2; rz=z2; if(isLineOfSightCalcEnabled()) { if(iInstanceMapTrees.containsKey(pMapId)) { Vector3 pos1 = convertPositionToInternalRep(x1,y1,z1); Vector3 pos2 = convertPositionToInternalRep(x2,y2,z2); Vector3 resultPos; MapTree* mapTree = iInstanceMapTrees.get(pMapId); result = mapTree->getObjectHitPos(pos1, pos2, resultPos, pModifyDist); resultPos = convertPositionToTrinityRep(resultPos.x,resultPos.y,resultPos.z); rx = resultPos.x; ry = resultPos.y; rz = resultPos.z; #ifdef _VMAP_LOG_DEBUG Command c = Command(); c.fillTestObjectHitCmd(pMapId, pos1, pos2, resultPos, result); iCommandLogger.appendCmd(c); #endif } } return result; }
void ModelContainerView::onUserInput(UserInput* ui) { GApp::onUserInput(ui); if(ui->keyPressed(GKey::fromString("l"))) { //load iCmdArray = Array<Command>(); iCommandFileRW.getNewCommands(iCmdArray); iCurrCmdIndex = 0; processCommand(); } if(ui->keyPressed(GKey::fromString("r"))) { //restart iCurrCmdIndex = 0; } if(ui->keyPressed(GKey::fromString("1"))) { //inc count1 gCount1++; } if(ui->keyPressed(GKey::fromString("h"))) { //inc count1 #if 0 i_App->defaultController.getPosition(); Vector3 pos = i_App->defaultController.getPosition(); Vector3 pos2 = convertPositionToTrinityRep(pos.x, pos.y, pos.z); //Vector3 pos3 = iVMapManager->convertPositionToInternalRep(pos2.x, pos2.y, pos2.z); //pos3 = iVMapManager->convertPositionToInternalRep(pos2.x, pos2.y, pos2.z); float hight = iVMapManager->getHeight(iInstanceId, pos2.x, pos2.y, pos2.z); printf("Hight = %f\n",hight); #endif } if(ui->keyPressed(GKey::fromString("2"))) { //dec count1 gCount1--; if(gCount1 < 0) gCount1 = 0; } if(ui->keyPressed(GKey::fromString("z"))) { //zero pos i_App->defaultCamera.setPosition(Vector3(0,0,0)); printf("set pos to 0, 0, 0\n"); } if(ui->keyPressed(GKey::fromString("c"))) { //restart if(iCurrCmdIndex > 0) { if(iCmdArray[iCurrCmdIndex-1].getType() == TEST_VIS) { Vector3 p1 = iCmdArray[iCurrCmdIndex-1].getVector(0); Vector3 p2 = iCmdArray[iCurrCmdIndex-1].getVector(1); bool result; int mapId = iCmdArray[iCurrCmdIndex-1].getInt(1); gCount3 = gCount2 = 0;// debug counter gBoxArray = Array<AABox>(); result = iVMapManager->isInLineOfSight(mapId, p1.x,p1.y,p1.z,p2.x,p2.y,p2.z); printf("recalc last line of light: result = %d\n", result); } } } if(ui->keyPressed(GKey::LEFT_MOUSE)) { if( iCurrCmdIndex>0) { --iCurrCmdIndex; printf("restart last command\n"); processCommand(); } } if(ui->keyPressed(GKey::MIDDLE_MOUSE)) { processCommand(); } }