Example #1
0
    /**
    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 = convertPositionToMangosRep(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;
    }
    /**
    get the hit position and return true if we hit something
    otherwise the result pos will be the dest pos
    */
    bool VMapManager2::getObjectHitPos(unsigned int mapId, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float &ry, float& rz, float modifyDist)
    {
        if (isLineOfSightCalcEnabled() && !sDisableMgr->IsDisabledFor(DISABLE_TYPE_VMAP, mapId, NULL, VMAP_DISABLE_LOS))
        {
            InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(mapId);
            if (instanceTree != iInstanceMapTrees.end())
            {
                Vector3 pos1 = convertPositionToInternalRep(x1, y1, z1);
                Vector3 pos2 = convertPositionToInternalRep(x2, y2, z2);
                Vector3 resultPos;
                bool result = instanceTree->second->getObjectHitPos(pos1, pos2, resultPos, modifyDist);
                resultPos = convertPositionToMangosRep(resultPos.x, resultPos.y, resultPos.z);
                rx = resultPos.x;
                ry = resultPos.y;
                rz = resultPos.z;
                return result;
            }
        }

        rx = x2;
        ry = y2;
        rz = z2;

        return false;
    }
Example #3
0
	bool VMapManager::getObjectHitPos(unsigned int pMapId, LocationVector & v1, LocationVector & v2, LocationVector & vout, float pModifyDist)
	{
		bool result = false;
		vout = v2;
		if( m_maps[pMapId] != NULL )
		{
			Vector3 pos1 = convertPositionToInternalRepMod(v1);
			Vector3 pos2 = convertPositionToInternalRepMod(v2);
			Vector3 resultPos;
			MapTree* mapTree = m_maps[pMapId];
			result = mapTree->getObjectHitPos(pos1, pos2, resultPos, pModifyDist);
			vout = convertPositionToMangosRep(resultPos);
		}
		return result;
	}
Example #4
0
    /**
    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( m_maps[pMapId] != NULL )
		{
                Vector3 pos1 = convertPositionToInternalRep(x1,y1,z1);
                Vector3 pos2 = convertPositionToInternalRep(x2,y2,z2);
                Vector3 resultPos;
                MapTree* mapTree = m_maps[pMapId];
                result = mapTree->getObjectHitPos(pos1, pos2, resultPos, pModifyDist);
                resultPos = convertPositionToMangosRep(resultPos.x,resultPos.y,resultPos.z);
                rx = resultPos.x;
                ry = resultPos.y;
                rz = resultPos.z;
        }
        return result;
    }
Example #5
0
 /**
 get the hit position and return true if we hit something
 otherwise the result pos will be the dest pos
 */
 bool VMapManager2::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())
     {
         InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(pMapId);
         if (instanceTree != iInstanceMapTrees.end())
         {
             Vector3 pos1 = convertPositionToInternalRep(x1,y1,z1);
             Vector3 pos2 = convertPositionToInternalRep(x2,y2,z2);
             Vector3 resultPos;
             result = instanceTree->second->getObjectHitPos(pos1, pos2, resultPos, pModifyDist);
             resultPos = convertPositionToMangosRep(resultPos.x,resultPos.y,resultPos.z);
             rx = resultPos.x;
             ry = resultPos.y;
             rz = resultPos.z;
         }
     }
     return result;
 }
Example #6
0
    void ModelContainerView::onUserInput(UserInput* ui) {

        if (ui->keyPressed(SDLK_ESCAPE)) {
            // Even when we aren't in debug mode, quit on escape.
            endApplet = true;
            i_App->endProgram = true;
        }

        if(ui->keyPressed(SDLK_l)) { //load
            iCmdArray = Array<Command>();
            iCommandFileRW.getNewCommands(iCmdArray);
            iCurrCmdIndex = 0;
            processCommand();
        }

        if(ui->keyPressed(SDLK_r)) { //restart
            iCurrCmdIndex = 0;
        }

        if(ui->keyPressed(SDLK_1)) { //inc count1
            gCount1++;
        }

        if(ui->keyPressed(SDLK_h)) { //inc count1
            i_App->debugController.getPosition();
            Vector3 pos = i_App->debugController.getPosition();
            Vector3 pos2 = convertPositionToMangosRep(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);
        }


        if(ui->keyPressed(SDLK_2)) { //dec count1
            gCount1--;
            if(gCount1 < 0) 
                gCount1 = 0;
        }

        if(ui->keyPressed(SDLK_z)) { //zero pos
            i_App->debugController.setPosition(Vector3(0,0,0));
            printf("set pos to 0, 0, 0\n");
        }


        if(ui->keyPressed(SDLK_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(SDL_LEFT_MOUSE_KEY)) {
            if(		iCurrCmdIndex>0) {
                --iCurrCmdIndex;
                printf("restart last command\n");
                processCommand();
            }
        }

        GApplet::onUserInput(ui);

        if(ui->keyPressed(SDL_RIGHT_MOUSE_KEY)) {
            processCommand();
        }
    }