示例#1
0
Ogre::Vector3 CCS::FreeCameraMode::getFirstRealHit(Ogre::Vector3 origin, Ogre::Vector3 direction)
{
    Ogre::Vector3 hit = origin;
    Ogre::Real minDistance = std::numeric_limits<Ogre::Real>::max();

    Ogre::RaySceneQuery *raySceneQuery = mCameraCS2->getSceneManager()->createRayQuery(Ogre::Ray(origin, direction));

	Ogre::RaySceneQueryResult &result = raySceneQuery->execute();
	Ogre::RaySceneQueryResult::iterator itr = result.begin();

	bool intersect = false;
	while (itr != result.end() /*&& !intersect*/) // ToDo: are the results ordered ??
	{
		if( itr->distance < minDistance // take the shorter
            && itr->movable->getParentSceneNode() != mCameraCS2->getCameraSceneNode()
			&& itr->movable->getParentSceneNode() != mCameraCS2->getTargetSceneNode())
		{
            minDistance = itr->distance;
			intersect = true;
			if(itr->worldFragment)
			{
				hit = itr->worldFragment->singleIntersection;
			}
			else //if(itr->movable)
			{					
				hit = origin + (direction * itr->distance);
			}
		}
		itr++;
	}

	mCameraCS2->getSceneManager()->destroyQuery(raySceneQuery);

    return hit;
}
示例#2
0
bool BaselinePattern::mousePressed(const OIS::MouseEvent &evt, OIS::MouseButtonID id)
{
    Ogre::Ray ray = OgreFramework::getSingletonPtr()->getCursorRay();
    Ogre::RaySceneQuery* query = OgreFramework::getSingletonPtr()->m_pSceneMgr->createRayQuery(ray);
    
    query->setSortByDistance(true);
    Ogre::RaySceneQueryResult result = query->execute();
    
    //Handle Selection
    if (stage->selected == NULL) {
        if (result.size() > 0 && result[0].movable != NULL) {
            for (int i = 0; i < stage->poppies.size(); ++i)
                if ( stage->poppies[i]->hasEntity( (Ogre::Entity*)result[0].movable ) ) {
                    stage->poppies[i]->setColor(getRandomPotColor());
                    stage->selected = stage->poppies[i];
                    stage->poppies[i]->deactivateJump();
                    //soundPickUp->play();
                }
            
            for (int i = 0; i < stage->pots.size(); ++i)
                if (stage->pots[i]->hasEntity( (Ogre::Entity*)result[0].movable) )
                    stage->pots[i]->setColor(getRandomPotColor());
        }
    }
    
    return true;
}
示例#3
0
文件: Camera.cpp 项目: Pured/CSCI356
bool DemoApp::quickSelect()
{
	// Create RaySceneQuery
	Ogre::Ray mouseRay = mCamera->getCameraToViewportRay(static_cast<float>(mMouse->getMouseState().X.abs)/mMouse->getMouseState().width, static_cast<float>(mMouse->getMouseState().Y.abs)/mMouse->getMouseState().height);

	Ogre::RaySceneQuery * mRaySceneQuery = mSceneMgr->createRayQuery(Ogre::Ray());

	// Set ray
	mRaySceneQuery->setRay(mouseRay);

	mRaySceneQuery->setQueryTypeMask(Ogre::SceneManager::ENTITY_TYPE_MASK);
			
	mRaySceneQuery->setSortByDistance(true);

	// Ray-cast and get first hit
	Ogre::RaySceneQueryResult &result = mRaySceneQuery->execute();
	Ogre::RaySceneQueryResult::iterator itr = result.begin();

	if((itr != result.end() && itr->movable))
	{
		
		//Get hit location
		Ogre::String name = itr->movable->getName();
		bool found=false;
		if(name=="Box")
		{
			itr++;
			name = itr->movable->getName();
		}

		for(int i=0;i<TANK_LIMIT;i++)
		{
			if(name=="Tank"+std::to_string(i))
			{
				tanks.at(i).selected=true;
				if(tanks.at(i).mSelectionCircle->getParentSceneNode()!=tanks.at(i).tankNode)
					tanks.at(i).tankNode->attachObject(tanks.at(i).mSelectionCircle);
				if(tanks.at(i).mHealthBar->getParentSceneNode()!=tanks.at(i).tankNode)
					tanks.at(i).tankNode->attachObject(tanks.at(i).mHealthBar);
				found=true;	
				tanks.at(i).path2->setVisible(true);
			}
			else if(controlPressed==false)
			{
				tanks.at(i).selected=false;
				if(tanks.at(i).mSelectionCircle->getParentSceneNode()==tanks.at(i).tankNode)
					tanks.at(i).tankNode->detachObject(tanks.at(i).mSelectionCircle);
				if(tanks.at(i).mHealthBar->getParentSceneNode()==tanks.at(i).tankNode)
					tanks.at(i).tankNode->detachObject(tanks.at(i).mHealthBar);
				tanks.at(i).path2->setVisible(false);
			}
		}
		if(found==false)
			return false;
		else return true;
	}
	return false;
}
示例#4
0
//-------------------------------------------------------------------------------------
///controls collision in given direction (true-front false-back)
bool Player::collision(bool goAhead){
	Ogre::Ray ray = Ogre::Ray(sceneNode->getPosition(), getDirection(sceneNode->getOrientation(),goAhead));
	Ogre::RaySceneQuery* mRaySceneQuery = manager->createRayQuery(ray);
	Ogre::RaySceneQueryResult result = mRaySceneQuery->execute();
	
	for(Ogre::RaySceneQueryResult::iterator it = result.begin(); it != result.end() ; ++it){
		if((it->distance < farFarAway)&& (it->distance > 0)){
			return true;
		}
	}
	return false;
}
std::pair<DetectionResult, DetectionIterator&> ViewDetection::detectObjects() {
	//Ogre::ResourceGroupManager::getSingletonPtr();
	//Ogre::OverlayManager* mg = Ogre::OverlayManager::getSingletonPtr();
	//Ogre::Overlay* ov = mg->getByName("TestScriptOverlay");

	Ogre::RaySceneQuery* rayQuery = viewManager->createRayQuery(*detection);
	rayQuery->setSortByDistance(true);

	DetectionResult result = rayQuery->execute();
	DetectionIterator& endOfResult = filterObjects(result);

	return std::make_pair(result, endOfResult);
}
    const ActorVector& OgreRaySceneQuery::execute()
    {
        // Clear last results
        mResult.clear();

		Ray ray(getRayStart(), (getRayEnd() - getRayStart()).normalisedCopy());

		Ogre::RaySceneQuery* query = CoreSubsystem::getSingleton().getWorld()->getSceneManager()
			->createRayQuery(ray, getQueryMask());

		query->execute(this);

        return mResult;
    }
示例#7
0
void Game::CheckAndRespawnPlayers()
{
	// When A Player is dead, he is simply invisible
	for (std::vector<RenderableChar*>::iterator ite = local_players.begin(); ite != local_players.end(); ++ite) {
		if ( (*ite)->getCharState() == RenderableChar::SPAWNING ) {
			std::cout << "I should respawn!" << std::endl;
			(*ite)->resetVelX();
			(*ite)->resetVelY();
			(*ite)->setCharState(RenderableChar::IDLE);
			
			bool free = false;
			Ogre::RaySceneQuery* msq;
			float x;
			float y;
			int c = 0;
			
			// Here, we look for a position in the level which is collision free
			// TODO: IN NARROW LEVELS, THIS CAN LEAD TO INFINITE LOOPS!
			do {
				if (c > 20) {
					x = 10.0f;
					y = 10.0f;
					free = true;
				}
				x = Ogre::Math::RangeRandom(myLevel->getObjectSide(), myLevel->getObjectSide() * (myLevel->getWidth() -1));
				y = Ogre::Math::RangeRandom(myLevel->getObjectSide(), myLevel->getObjectSide() * (myLevel->getHeight()));	
				
				std::cout << "GENX: " << x << " --- GENY: " << y << std::endl;

				msq = OgreFW::getSingletonPtr()->m_pSceneMgr->createRayQuery(Ogre::Ray(Ogre::Vector3(x, y, 0.0f), Ogre::Vector3::UNIT_Y));
				msq->setSortByDistance(true, 3);
				//Ogre::RaySceneQuery	msq->setRay(Ogre::Ray( ( (*ite)->getWorldPosition() + Ogre::Vector3(0.0f, (*ite)->getAABB().getHalfSize().y, 0.0f) ), Ogre::Vector3::UNIT_Y ));
				Ogre::RaySceneQueryResult& result = msq->execute();
			
				for (Ogre::RaySceneQueryResult::iterator itr = result.begin(); itr != result.end(); ++itr) {
					if ( itr->distance >= (*ite)->getAABB().getSize().x ){
						free = true;
						break;
					}
				}
				c++;
			} while (free != true);
			(*ite)->SetPosition(Ogre::Vector3(x, y + 0.1, 0.0f));
			(*ite)->setVisible(true);
			msq->clearResults();
		}
	}
}
示例#8
0
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
void
RenderingCanvas::querySceneNodes(Math::Real _x, Math::Real _y, I_SceneNodeVisitor& _visitor)
{
    Ogre::Camera& camera = m_pCurrentCamera->getOgreCamera();
    Ogre::Vector3 position;
    if( camera.getParentSceneNode() )
    {
        position = camera.getParentSceneNode()->_getDerivedPosition();
    }
    else
    {
        position = camera.getDerivedPosition();
    }

    Ogre::RaySceneQuery* pSceneQuery =
        m_pSceneManager->createRayQuery(camera.getCameraToViewportRay(_x, _y));
    pSceneQuery->setSortByDistance(true);

    Ogre::RaySceneQueryResult::const_iterator iter;
    const Ogre::RaySceneQueryResult& queryResult = pSceneQuery->execute();

    _visitor.begin();
    for(iter = queryResult.begin(); iter != queryResult.end(); iter++)
    {
        const Ogre::RaySceneQueryResultEntry& result = *iter;

        // Check to see if this is a scene node.
        if (result.movable != NULL)
        {
            Ogre::SceneNode *pNode = dynamic_cast<Ogre::SceneNode*>(result.movable->getParentSceneNode());
            if (pNode)
            {
                if (!pNode->getUserAny().isEmpty())
                {
                    SceneNode* pRawSceneNode = Ogre::any_cast<SceneNode*>(pNode->getUserAny());

                    I_SceneNodeVisitor::pSceneNode_type pSceneNode(pRawSceneNode->getSelfReference().lock());

                    _visitor.visit(pSceneNode);
                }
            }
        }
    }
    _visitor.end();

    delete pSceneQuery;
}
示例#9
0
void createPalms(Ogre::SceneManager *mSceneMgr)
{
	const int NumberOfPalms = 12;

	Ogre::SceneNode* mPalmsSceneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
		
	for (int k = 0; k < NumberOfPalms; k++)
	{
		Ogre::Vector3 RandomPos = Ogre::Vector3(rnd_(500,2500),
			0,
			rnd_(500,2500));

		Ogre::RaySceneQuery * raySceneQuery = mSceneMgr->
			createRayQuery(Ogre::Ray(RandomPos + Ogre::Vector3(0,1000000,0), 
			Ogre::Vector3::NEGATIVE_UNIT_Y));

		Ogre::RaySceneQueryResult& qryResult = raySceneQuery->execute();
		Ogre::RaySceneQueryResult::iterator i = qryResult.begin();

		if (i != qryResult.end() && i->worldFragment)
		{
			if (i->worldFragment->singleIntersection.y>105 || i->worldFragment->singleIntersection.y<20)
			{
				k--;
				continue;
			}

			RandomPos.y = i->worldFragment->singleIntersection.y;
		}
		else
		{
			k--;
			continue;
		}

		Ogre::Entity *mPalmEnt = mSceneMgr->createEntity("Palm"+Ogre::StringConverter::toString(k), "Palm.mesh");
		Ogre::SceneNode *mPalmSN = mPalmsSceneNode->createChildSceneNode();

		mPalmSN->rotate(Ogre::Vector3(-1,0,rnd_(-0.3,0.3)), Ogre::Degree(90));
		mPalmSN->attachObject(mPalmEnt);
		Ogre::Real Scale = rnd_(50,75);
		mPalmSN->scale(Scale,Scale,Scale);
		mPalmSN->setPosition(RandomPos);
	}
}
示例#10
0
bool BaselinePattern::mouseMoved(const OIS::MouseEvent &evt)
{
    Ogre::Ray ray = OgreFramework::getSingletonPtr()->getCursorRay();
    Ogre::RaySceneQuery* query = OgreFramework::getSingletonPtr()->m_pSceneMgr->createRayQuery(ray);
    
    query->setSortByDistance(true);
    Ogre::RaySceneQueryResult result = query->execute();
    
    if (stage->selected && stage->selected->getType() == Selectable::TYPE_POPPY)
        for (int i = 0; i < result.size(); ++i)
            if (stage->ground->hasEntity( (Entity*)result[i].movable )) {
                Poppy* toMove = (Poppy*)stage->selected;
                Vector3 hoverPos = ray * result[i].distance;
                hoverPos.y = poppyRadius;
                toMove->setPosition(hoverPos);
            }
    return true;
}
示例#11
0
	void checkCameraHeight()
	{
		Ogre::RaySceneQuery *raySceneQuery = 
			m_sceneManager->
			createRayQuery(Ogre::Ray(m_camera->getPosition() + Ogre::Vector3(0,10000,0), 
			Ogre::Vector3::NEGATIVE_UNIT_Y));
		Ogre::RaySceneQueryResult& qryResult = raySceneQuery->execute();
		Ogre::RaySceneQueryResult::iterator i = qryResult.begin();
		if (i != qryResult.end() && i->worldFragment)
		{
			if (m_camera->getPosition().y < i->worldFragment->singleIntersection.y + 30)
			{
				m_camera->setPosition(m_camera->getPosition().x, i->worldFragment->singleIntersection.y + 30, m_camera->getPosition().z);
			}
		}

		delete raySceneQuery;
	}
示例#12
0
bool BaselinePattern::mouseReleased(const OIS::MouseEvent &evt, OIS::MouseButtonID id)
{
    Ogre::Ray ray = OgreFramework::getSingletonPtr()->getCursorRay();
    Ogre::RaySceneQuery* query = OgreFramework::getSingletonPtr()->m_pSceneMgr->createRayQuery(ray);
    
    query->setSortByDistance(true);
    Ogre::RaySceneQueryResult result = query->execute();
    
    if (stage->selected != NULL && stage->selected->getType() == Selectable::TYPE_POPPY && result.size() > 0) {
        Poppy* old = (Poppy*)stage->selected;
        stage->selected = NULL;
        Vector3 placeDest = ray * result[0].distance;
        placeDest.y = poppyRadius;
        old->setPosition(placeDest);
        old->activateJump();
    }
    
    return true;
}
Ogre::Vector3 CCS::CollidableOrbitalCameraMode::DefaultCollisionDetectionFunction(Ogre::Vector3 cameraTargetPosition, Ogre::Vector3 cameraPosition)
{
	Ogre::Vector3 finalCameraPosition (cameraPosition.x, cameraPosition.y, cameraPosition.z);

	Ogre::RaySceneQuery *raySceneQuery = mCameraCS->getSceneManager()->createRayQuery(Ogre::Ray(cameraTargetPosition, cameraPosition));

	// Perform the scene query
	Ogre::RaySceneQueryResult &result = raySceneQuery->execute();
	Ogre::RaySceneQueryResult::iterator itr = result.begin();

	// Get the results, set the camera height
	if (itr != result.end() && itr->worldFragment)
	{
		finalCameraPosition = itr->worldFragment->singleIntersection;				
	}

	mCameraCS->getSceneManager()->destroyQuery(raySceneQuery);

	return finalCameraPosition;
}
示例#14
0
WorldObject *RTSState::getObjectUnderRay(const Ogre::Ray &ray) const
{
    EngineManager *mng = m_gameEngine->getManager();
    Ogre::RaySceneQuery *query = mng->getGraphic()->getSceneManager()->createRayQuery(ray);
    Ogre::RaySceneQueryResult &queryResult = query->execute();

    for (Ogre::RaySceneQueryResultEntry & entry : queryResult)
    {
        if (entry.movable)
        {
            WorldObject *worldObject;
            try
            {
                worldObject = Ogre::any_cast<WorldObject *>(entry.movable->getUserObjectBindings().getUserAny());
                if (worldObject)
                    return worldObject;
            }
            catch (...) {}
        }
    }
    mng->getGraphic()->getSceneManager()->destroyQuery(query);

    return nullptr;
}
示例#15
0
void QOgreWindow::mouseReleaseEvent(QMouseEvent *e)
{
    if (camMan) camMan->injectMouseUp(*e);

    QPoint pos = e->pos();
    Ogre::Ray mouseRay = oCam->getCameraToViewportRay(
                (Ogre::Real)pos.x() / oWin->getWidth(),
                (Ogre::Real)pos.y() / oWin->getHeight());
    Ogre::RaySceneQuery* sceneQuery = oSceneMgr->createRayQuery(mouseRay);
    sceneQuery->setSortByDistance(true);
    Ogre::RaySceneQueryResult vResult = sceneQuery->execute();

    for (size_t ui = 0; ui < vResult.size(); ui++)
    {
        if (vResult[ui].movable)
        {
            if (vResult[ui].movable->getMovableType().compare("Entity") == 0)
            {
                emit entitySelected((Ogre::Entity*)vResult[ui].movable);
            }
        }
    }
    oSceneMgr->destroyQuery(sceneQuery);
}
//-------------------------------------------------------------------------------------
bool RollerCoaster::Querytest()
{
	Ogre::RaySceneQuery *mQuery = mSceneMgr->createRayQuery(Ogre::Ray());
	Ogre::Vector3 direction =trainNode->getPosition()+
		trainNode->_getDerivedOrientation()*Ogre::Vector3::UNIT_Z;
	
	Ogre::Ray objRay( trainNode->getPosition(),direction);

	mQuery->setRay(objRay);

	Ogre::RaySceneQueryResult &result = mQuery->execute();
	Ogre::RaySceneQueryResult::iterator iter = result.begin();

	for (iter; iter!=result.end(); iter++)
	{
		if((*iter).movable->getName()== "mTarget")
		{
			return true;
		}
	}

	mQuery->clearResults();
	return false;
}
void OgreWidget::mouseDoubleClickEvent(QMouseEvent *e)
{
    if(e->buttons().testFlag(Qt::LeftButton))
    {
        Ogre::Real x = e->pos().x() / (float)width();
        Ogre::Real y = e->pos().y() / (float)height();

        Ogre::Ray ray = ogreCamera->getCameraToViewportRay(x, y);
        Ogre::RaySceneQuery *query = ogreSceneManager->createRayQuery(ray);
        Ogre::RaySceneQueryResult &queryResult = query->execute();
        Ogre::RaySceneQueryResult::iterator queryResultIterator = queryResult.begin();

        if(queryResultIterator != queryResult.end())
        {
            if(queryResultIterator->movable)
            {
                selectedNode = queryResultIterator->movable->getParentSceneNode();
                selectedNode->showBoundingBox(true);
            }
        }
        else
        {
            selectedNode->showBoundingBox(false);
            selectedNode = 0;
        }

        ogreSceneManager->destroyQuery(query);

        update();
        e->accept();
    }
    else
    {
        e->ignore();
    }
}
示例#18
0
void Tank::update(const float& deltaTime, std::vector<PowerUpSpawn*> mPowerUpSpawns){
	
	//this check must be first
	if (!isAlive())
	{
		deathTimer -= deltaTime;

		if (deathTimer <= 0.f)
		{
			deathTimer = 0.f;
			resetAll();
			
			std::random_device rd;
			std::mt19937 random(rd());

			if (tankSide == 1)
			{
				std::uniform_real_distribution<double> randomGen1(1, 5);
				int tempNumber = randomGen1(random);
				std::uniform_real_distribution<double> randomGen2(0, 36);
				int tempNumber2 = (36 * (int)randomGen2(random)) + (int)tempNumber;

				Ogre::Vector3 position = pathFindingGraph->getPosition(tempNumber2);

				mTankBodyNode->setPosition(position);
			} else if(tankSide == 2){
				std::uniform_real_distribution<double> randomGen1(31, 35);
				int tempNumber = randomGen1(random);
				std::uniform_real_distribution<double> randomGen2(0, 36);
				int tempNumber2 = (36 * (int)randomGen2(random)) + (int)tempNumber;
				
				Ogre::Vector3 position = pathFindingGraph->getPosition(tempNumber2);

				mTankBodyNode->setPosition(position);
			}
			mTankBodyNode->setVisible(true);
			setSelected(false);
		}
	}

	//Check for tank powerups
	sphereSceneTime += deltaTime;
	if(sphereSceneTime > 0.2)
	{
		sphereSceneTime = 0;

		Ogre::Vector3 tankCenter = mTankBodyNode->getPosition();
		int location;
		bool found = false;

		for(int i = 0; i < mPowerUpSpawns.size(); i++)
		{
			Ogre::Vector3 powerUpLocation = mPowerUpSpawns[i]->spawnNode->getPosition();
			if(tankCenter.squaredDistance(powerUpLocation) < 5625) //squaredDistance is better
			{
				found = true;
				location = i;
			}
		}
		if (found)
		{
			if(mPowerUpSpawns[location]->getIsPowerUp())
			{
				char tempType = mPowerUpSpawns[location]->pickupPowerUp(mSceneMgr);

				printf("Got Powerup %c\n", tempType);

				switch(tempType)
				{
					case ('H'): //health
					{
						hp += 0.1f;
						if (hp > 1.0f)
						{
							hp = 1.0f;
						}
						printf("Got Health\n");

						//update healthbar
						float healthBarAdjuster = (1.0 - hp) / 2;
						mHealthBarBB->setTexcoordRect(0.0 + healthBarAdjuster, 0.0, 0.5 + healthBarAdjuster, 1.0);
					}
					break;
					case ('R'): //fire rate
					{
						fireRate = 1.f;
						powerUpDurationR = 6.f;
					}
					break;
					case ('S'): //speed
					{
						mRotSpd = 75.0f;
						ms = 100.f;
						mMoveSpd = 100.f;
						powerUpDurationS = 6.f;
					}
					break;
					case ('P'): //damage
					{
						dmg = 30.f;
						powerUpDurationP = 6.f;
					}
					break;
					default:
						printf("Unknown Powerup\n");
					break;
				}
			}
			currentState = WANDER;
			resetWander();
			wanderAStar();
		}
	}

	decrementPowerups(deltaTime);

	//weapontimer
	weaponTimer += deltaTime;

	//seek powerups
	/*
	Ogre::Real distancePowerUp = 0;
	int powerUpNo = 0;
	bool firstTimeDistanceCheck = true;
	for(int i = 0; i < mPowerUpSpawns.size(); i++)
	{
		if(mPowerUpSpawns[i]->getIsPowerUp())
		{
			Ogre::Real tempDistancePowerUp = mTankBodyNode->getPosition().distance(mPowerUpSpawns[i]->getPowerLocation());

			if(firstTimeDistanceCheck)
			{
				firstTimeDistanceCheck = false;
				distancePowerUp = tempDistancePowerUp;
			}
			if(tempDistancePowerUp < distancePowerUp)
			{
				distancePowerUp = tempDistancePowerUp;
				powerUpNo = i;
			}
		}
	}*/
	/*
	if(distancePowerUp < 500 && distancePowerUp > 0 && currentState != POSSESSED)
	{
		if(mPowerUpSpawns[powerUpNo]->getIsPowerUp())
		{
			if(currentState != SEEK)
			{
				currentState = SEEK;
				seekTarget = mPowerUpSpawns[powerUpNo]->getPowerLocation();
				seekAStar();
			}
			
		}
		else 
			currentState = WANDER;
		
	}*/
	
	//check if the user is like somewhere and stopped ocassionally 
	if (currentState != POSSESSED)
	{
		checkPosition += deltaTime;
		if(checkPosition > 3)
		{
			if(mTankBodyNode->getPosition().x == previousLocation.x)
			{
				if(mTankBodyNode->getPosition().z == previousLocation.z)
				{
					checkWhereAt();
				}
			}
			checkPosition = 0;
			previousLocation = mTankBodyNode->getPosition();
		}
	
		checkOrientation += deltaTime;
		if(checkOrientation > 15)
		{
			if(currentState != A_STAR)
			{
				if(!orientationEquals(initBodyOrientation, mTankBodyNode->getOrientation()))
				{
					mTankBodyNode->setOrientation(initBodyOrientation);
				}
				if(!orientationEquals(initBarrelOrientation, mTankBarrelNode->getOrientation()))
				{
					mTankBarrelNode->setOrientation(initBarrelOrientation);
				}
				if(!orientationEquals(initTurretOrientation, mTankTurretNode->getOrientation()))
				{
					mTankTurretNode->setOrientation(initTurretOrientation);
				}
			}
			checkOrientation = 0;
		}
	}

	//no movement for body yet

	//A_STAR, SEEK, WANDER, ESCAPE, STOP
	switch(currentState)
	{
		case A_STAR:
			//initiate astar
			if(tankStarted == false)
			{
				tankStarted = true;
				aStar(tankSide); //creates the path to get out of there
			}
			else
			{
				aStarMovement(deltaTime);
			}
		break;
		case FIRE:
		{
			Ogre::Vector3 targetPosition = getPredictPos(target);
			targetPosition.y = 16.f;

			Ogre::Degree angle = getShootingAngle(targetPosition);

			mTankTurretNode->lookAt(targetPosition, Ogre::Node::TransformSpace::TS_WORLD, Ogre::Vector3::NEGATIVE_UNIT_X);
			//barrelDegree = angle;
			if (weaponTimer > 4)
			{
				tnkMgr->createProjectile(mTankBodyNode->getPosition(), mTankTurretNode->_getDerivedOrientation(), angle, shootingVelocity, dmg);
				weaponTimer = 0;
			}
			if (target->hp <= 0 || mTankBodyNode->getPosition().distance(target->getPosition()) > 600 )
				currentState = WANDER;
		}
		case WANDER:
			//wander(deltaTime);
			wanderMovement(deltaTime);
			break;
	
		case SEEK:
			//seek(mPowerUpSpawns[powerUpNo]->getPowerLocation(), deltaTime);

			//seek(Ogre::Vector3::ZERO, deltaTime);
			//seekMovement(deltaTime);
		break;
		case ESCAPE:
			
		break;
		case STOP:
		
		break;

		case POSSESSED: {
			Ogre::Vector3 rayDest;

			if (mMove < 0)
				rayDest = mTankBodyNode->getOrientation() * Ogre::Vector3(-1,0,0);
			else if (mMove > 0)
				rayDest = mTankBodyNode->getOrientation() * Ogre::Vector3(1,0,0);


			//THIS IS WHERE THE TANK IS MOVED WHEN PROCESSING

			//if (rayDest != NULL)
			{
				Ogre::Ray shootToCheckWall = Ogre::Ray(mTankBodyNode->getPosition(), rayDest);

				Ogre::RaySceneQuery* mRaySceneQuery = mSceneMgr->createRayQuery(shootToCheckWall, Ogre::SceneManager::ENTITY_TYPE_MASK);
				mRaySceneQuery->setSortByDistance(true);

				// Ray-cast and get first hit
				Ogre::RaySceneQueryResult &result = mRaySceneQuery->execute();
				Ogre::RaySceneQueryResult::iterator itr = result.begin();

				bool hit = false;
				for (itr = result.begin(); itr != result.end(); itr++) 
				{
					
					std::string x = itr->movable->getName();
					printf("Check %s \n", x.c_str());

					if (x[0] == 'C' && itr->distance < 10)
					{
						printf("Too close to %s: %f \n", x.c_str(), (float)itr->distance);
						hit = true;
					}
				}

				if(hit == false)
				{
				
					mTankBodyNode->translate(mMove * deltaTime * mMoveSpd, 0, 0, Ogre::Node::TransformSpace::TS_LOCAL);
				}
			}		

			mTankBodyNode->yaw(Ogre::Degree(bodyRotate * deltaTime * mRotSpd));

			// Rotate the tank turret
			mTankTurretNode->yaw(Ogre::Degree(turretRotation * deltaTime * mRotSpd * 1.5));

			turretDegree += turretRotation;

			//to move barrel change barrelRotation
			float barrelChange = barrelRotation * deltaTime * mRotSpd;
			barrelDegree += barrelChange;

			if(barrelDegree > 30)
				barrelDegree = 30;
			else if(barrelDegree < 0)
				barrelDegree = 0;
			else
				mTankBarrelNode->roll(Ogre::Degree(-barrelChange));				
		}

		break;
	}

	Ogre::Vector3 setpos = mTankBodyNode->getPosition();
	setpos.y = 13.f;
	mTankBodyNode->setPosition(setpos);

}
示例#19
0
bool Player::Update(InputManager* input,
					PhysicsManager* physics,
					EWSManager* ews,
					const OgreTransform& transform)
{
	if(input->isCFGKeyPressed(InputManager::ENVWARNSYS))
	{
		placeEWS(ews,physics,transform);
	}

	cGunData* gun = nullptr;

	if(_equippables[_curEquippable].equip->getIsWeapon())
	{
		gun = static_cast<cGunData*>(_equippables[_curEquippable].equip);
	}

	if(gun != nullptr)
	{	
		bool movkey = false;
		movkey = (input->isCFGKeyPressed(InputManager::FORWARD) || 
			      input->isCFGKeyPressed(InputManager::BACKWARD)||
				  input->isCFGKeyPressed(InputManager::RIGHT) ||
				  input->isCFGKeyPressed(InputManager::LEFT));

		if(input->isMBPressed(OIS::MB_Left))
		{
			//shoot gun
			//std::cout << "MB_Left pressed..." << std::endl;
			gun->fire();
			//check for collisions with enemies if first time through
			if(gun->shouldDamage())
			{
				Ogre::SceneManager* scene = _equipNode->getCreator();
				Ogre::Vector3 dir = transform.direction;
				Ogre::Ray ray(transform.position,dir);

				Ogre::RaySceneQuery* rayQuery = scene->createRayQuery(ray);
				rayQuery->setSortByDistance(true);

				Ogre::RaySceneQueryResult results = rayQuery->execute();

				auto shot =  [this,gun] (Ogre::RaySceneQueryResultEntry& entry) 
				{
					if(entry.movable != nullptr)
					{
						std::string name = entry.movable->getName().substr(3,std::string::npos);
						LevelData::BaseEntity* ent = LuaManager::getSingleton().getEntity(name);
						if(ent != nullptr && (ent->getType() == LevelData::NPC || ent->getType() == LevelData::ENEMY))
						{
							_damageInterface->registerShotAtEnemy(gun->getGunshotData(),name);
						}
					}
				};
				std::for_each(results.begin(),results.end(),shot);

				scene->destroyQuery(rayQuery);
			}
		}
		else
		{
			gun->setFiring(false);
		}

		if(input->isCFGKeyPressed(InputManager::RELOAD))
		{
			gun->reload();
		}

		if(movkey)
		{
			gun->setMoving(true);
		}
		else
		{
			if(gun->isMoving())
			{
				gun->setMoving(false);
			}
		}
	}

	if(_damageInterface != nullptr)
	{
		//this clears out the added-up damage in the interface.
		_health -= static_cast<int>(_damageInterface->getTotalDamagePlayer());
	}

	return true;
}
示例#20
0
    bool frameStarted(const FrameEvent &e)
    {
		mKeyboard->capture();

		// Check camera height
		Ogre::RaySceneQuery *raySceneQuery = 
			mSceneMgr->
			     createRayQuery(Ogre::Ray(mCamera->getPosition() + Ogre::Vector3(0,1000000,0), 
				                Vector3::NEGATIVE_UNIT_Y));
		Ogre::RaySceneQueryResult& qryResult = raySceneQuery->execute();
        Ogre::RaySceneQueryResult::iterator i = qryResult.begin();
        if (i != qryResult.end() && i->worldFragment)
        {
			if (mCamera->getPosition().y < i->worldFragment->singleIntersection.y + 30)
			{
                mCamera->
				     setPosition(mCamera->getPosition().x, 
                                 i->worldFragment->singleIntersection.y + 30, 
                                 mCamera->getPosition().z);
			}
        }

		delete raySceneQuery;

		// Change SkyX atmosphere options if needed
		SkyX::AtmosphereManager::Options SkyXOptions = mSkyX->getAtmosphereManager()->getOptions();

		// Time
		if (!mShowInformation)
		{
			mSkyX->setTimeMultiplier(mTimeMultiplier);
		}
		else
		{
			mSkyX->setTimeMultiplier(0.0f);
		}

		if (mKeyboard->isKeyDown(OIS::KC_1) && !(mKeyboard->isKeyDown(OIS::KC_LSHIFT) || mKeyboard->isKeyDown(OIS::KC_RSHIFT)))
			mSkyX->setTimeMultiplier(1.0f);
		if (mKeyboard->isKeyDown(OIS::KC_1) &&  (mKeyboard->isKeyDown(OIS::KC_LSHIFT) || mKeyboard->isKeyDown(OIS::KC_RSHIFT)))
			mSkyX->setTimeMultiplier(-1.0f);

		// Rayleigh multiplier
		if (mKeyboard->isKeyDown(OIS::KC_2) && !(mKeyboard->isKeyDown(OIS::KC_LSHIFT) || mKeyboard->isKeyDown(OIS::KC_RSHIFT)))
			SkyXOptions.RayleighMultiplier += e.timeSinceLastFrame*0.025f;
		if (mKeyboard->isKeyDown(OIS::KC_2) &&  (mKeyboard->isKeyDown(OIS::KC_LSHIFT) || mKeyboard->isKeyDown(OIS::KC_RSHIFT)))
			SkyXOptions.RayleighMultiplier -= e.timeSinceLastFrame*0.025f;

		// Mie multiplier
		if (mKeyboard->isKeyDown(OIS::KC_3) && !(mKeyboard->isKeyDown(OIS::KC_LSHIFT) || mKeyboard->isKeyDown(OIS::KC_RSHIFT)))
			SkyXOptions.MieMultiplier += e.timeSinceLastFrame*0.025f;
		if (mKeyboard->isKeyDown(OIS::KC_3) &&  (mKeyboard->isKeyDown(OIS::KC_LSHIFT) || mKeyboard->isKeyDown(OIS::KC_RSHIFT)))
			SkyXOptions.MieMultiplier -= e.timeSinceLastFrame*0.025f;

		// Exposure
		if (mKeyboard->isKeyDown(OIS::KC_4) && !(mKeyboard->isKeyDown(OIS::KC_LSHIFT) || mKeyboard->isKeyDown(OIS::KC_RSHIFT)))
			SkyXOptions.Exposure += e.timeSinceLastFrame*0.5f;
		if (mKeyboard->isKeyDown(OIS::KC_4) &&  (mKeyboard->isKeyDown(OIS::KC_LSHIFT) || mKeyboard->isKeyDown(OIS::KC_RSHIFT)))
			SkyXOptions.Exposure -= e.timeSinceLastFrame*0.5f;

		// Inner radius
		if (mKeyboard->isKeyDown(OIS::KC_5) && !(mKeyboard->isKeyDown(OIS::KC_LSHIFT) || mKeyboard->isKeyDown(OIS::KC_RSHIFT)))
			SkyXOptions.InnerRadius += e.timeSinceLastFrame*0.25f;
		if (mKeyboard->isKeyDown(OIS::KC_5) &&  (mKeyboard->isKeyDown(OIS::KC_LSHIFT) || mKeyboard->isKeyDown(OIS::KC_RSHIFT)))
			SkyXOptions.InnerRadius -= e.timeSinceLastFrame*0.25f;

		// Outer radius
		if (mKeyboard->isKeyDown(OIS::KC_6) && !(mKeyboard->isKeyDown(OIS::KC_LSHIFT) || mKeyboard->isKeyDown(OIS::KC_RSHIFT)))
			SkyXOptions.OuterRadius += e.timeSinceLastFrame*0.25f;
		if (mKeyboard->isKeyDown(OIS::KC_6) &&  (mKeyboard->isKeyDown(OIS::KC_LSHIFT) || mKeyboard->isKeyDown(OIS::KC_RSHIFT)))
			SkyXOptions.OuterRadius -= e.timeSinceLastFrame*0.25f;

		// Number of samples
		if (mKeyboard->isKeyDown(OIS::KC_7) && mKeyBuffer < 0 &&!(mKeyboard->isKeyDown(OIS::KC_LSHIFT) || mKeyboard->isKeyDown(OIS::KC_RSHIFT)))
		{
			SkyXOptions.NumberOfSamples ++;
			mKeyBuffer = 0.25f;
		}
		if (mKeyboard->isKeyDown(OIS::KC_7) && mKeyBuffer < 0 && (mKeyboard->isKeyDown(OIS::KC_LSHIFT) || mKeyboard->isKeyDown(OIS::KC_RSHIFT)))
		{
			SkyXOptions.NumberOfSamples --;
			mKeyBuffer = 0.25f;
		}

		// Height position
		if (mKeyboard->isKeyDown(OIS::KC_8) && !(mKeyboard->isKeyDown(OIS::KC_LSHIFT) || mKeyboard->isKeyDown(OIS::KC_RSHIFT)))
			SkyXOptions.HeightPosition += e.timeSinceLastFrame*0.05f;
		if (mKeyboard->isKeyDown(OIS::KC_8) &&  (mKeyboard->isKeyDown(OIS::KC_LSHIFT) || mKeyboard->isKeyDown(OIS::KC_RSHIFT)))
			SkyXOptions.HeightPosition -= e.timeSinceLastFrame*0.05f;

		// Time multiplier
		if (mKeyboard->isKeyDown(OIS::KC_9) && !(mKeyboard->isKeyDown(OIS::KC_LSHIFT) || mKeyboard->isKeyDown(OIS::KC_RSHIFT)))
			mTimeMultiplier += e.timeSinceLastFrame*0.15f;
		if (mKeyboard->isKeyDown(OIS::KC_9) &&  (mKeyboard->isKeyDown(OIS::KC_LSHIFT) || mKeyboard->isKeyDown(OIS::KC_RSHIFT)))
			mTimeMultiplier -= e.timeSinceLastFrame*0.15f;

		mSkyX->getAtmosphereManager()->setOptions(SkyXOptions);

		// Show/Hide information
		if (mKeyboard->isKeyDown(OIS::KC_F1) && mKeyBuffer < 0)
        {
			mShowInformation = !mShowInformation;

			mKeyBuffer = 0.25f;
		}

		// Post-proccesing effects
		if (mKeyboard->isKeyDown(OIS::KC_F2) && mKeyBuffer < 0)
        {
			mBloomCompositor = !mBloomCompositor;

			Ogre::CompositorManager::getSingleton().
					setCompositorEnabled(mWindow->getViewport(0), "Bloom", mBloomCompositor);

			mKeyBuffer = 0.25f;
		}

		// Shadows
		if (mKeyboard->isKeyDown(OIS::KC_F3) && mKeyBuffer < 0)
        {
			mShadowMode++;

			if (mShadowMode > 2)
			{
				mShadowMode = 0;
			}

			setShadowMode(mSceneMgr, static_cast<ShadowMode>(mShadowMode));

			mKeyBuffer = 0.25f;
		}

		mTextArea->setCaption(buildConfigString(SkyXOptions));

		// Update environment lighting
		updateEnvironmentLighting();

		// Update shadow far distance
		updateShadowFarDistance();

		// Update Hydrax
        mHydrax->update(e.timeSinceLastFrame);
		// Update SkyX
		mSkyX->update(e.timeSinceLastFrame);

		mKeyBuffer -= e.timeSinceLastFrame;

        return true;
    }
示例#21
0
void
System::makeObjectTransparent( const Ogre::Vector3 &start, const Ogre::Vector3 &end, float nNewTrans, float nDelay, IObjectFilter *pFilter )
{
    Ogre::Vector3 vDirction = (start-end);
    Ogre::Real fDistance = vDirction.length();
    Ogre::Ray ray = Ogre::Ray(end,vDirction);
    Ogre::RaySceneQuery* raySceneQuery = getSceneManager()->createRayQuery(Ogre::Ray());
    std::set<Fairy::Object*> setCurrentTransparentObjects;

    raySceneQuery->setRay(ray);
    const Ogre::RaySceneQueryResult& queryResult = raySceneQuery->execute();
    for (Ogre::RaySceneQueryResult::const_iterator it = queryResult.begin(); it != queryResult.end(); ++it)
    {
        Ogre::MovableObject* pMovable = it->movable;
        Ogre::Vector3 vObjectPos = pMovable->getParentNode()->getPosition();
        Ogre::Vector3 vObjectDir = (vObjectPos-end);
        Fairy::ObjectPtr pObject = Fairy::getObjectFromMovable(pMovable);

        if(pObject)
        {
            // 当满足以下条件时设置透明: 1.是StaticEntity类型; 2.相交; 3.允许透明
            if(pObject->getType() == "StaticEntity" && vObjectDir.dotProduct(vDirction) > 0 && static_cast<Fairy::StaticEntityObject*>(pObject.get())->getEnableTransparency())
            {
                Fairy::StaticEntityObject* pModel = static_cast<Fairy::StaticEntityObject*>(pObject.get());
                pModel->setTransparency(0.5f);
                // 删除原有的Object,放到临时的Set中
                m_setTransparencyObjects.erase(pObject.get());
                setCurrentTransparentObjects.insert(pObject.get());
            }
        }
    }

    std::set<Fairy::Object*>::iterator iter = m_setTransparencyObjects.begin();
    std::set<Fairy::Object*>::iterator tempIter;

    while (iter != m_setTransparencyObjects.end())
    {
        tempIter = iter;
        ++iter;
        // 恢复没有遮挡的Object的透明度为0
        Fairy::StaticEntityObject* pModel = static_cast<Fairy::StaticEntityObject*>(*tempIter);
        pModel->setTransparency(0);
        // 删除透明度为0的Object
        if (pModel->getTransparency()==0)
        {
            m_setTransparencyObjects.erase(tempIter);
        }
    }

    // 将遮挡的Object放到m_setTransparencyObjects
    for (std::set<Fairy::Object*>::iterator it = setCurrentTransparentObjects.begin(); it != setCurrentTransparentObjects.end(); ++it)
    {
        m_setTransparencyObjects.insert(*it);
    }

    if(raySceneQuery)
    {
        getSceneManager()->destroyQuery(raySceneQuery);
        raySceneQuery = NULL;
    }
}
示例#22
0
void NPCCharacter::_actionLook(const Ogre::Vector3& target)
{
	Ogre::Bone* headBone;
	std::string n = _node->getName();
	Ogre::Skeleton* skel = static_cast<Ogre::Entity*>(_movableObject)->getSkeleton();
	headBone = skel->getBone("Bip01_Head");

	headBone->setManuallyControlled(true);
	headBone->setInheritOrientation(true);
	int nAnim = skel->getNumAnimations();

	//have to do this to allow the head to turn properly.
	for(int i = 0; i < nAnim; ++i)
	{
		skel->getAnimation(i)->destroyNodeTrack(headBone->getHandle());
	}

	Ogre::Vector3 test = headBone->_getDerivedPosition() * CHARACTER_SCALE_FACTOR + _node->getPosition();
	Ogre::Vector3 dir = target - test;
	Ogre::Quaternion nodeRot,boneRot;
	Ogre::Euler boneEuler; boneEuler.setDirection(dir,true,false);
	/*boneRot = _node->convertLocalToWorldOrientation(_node->getOrientation()) * headBone->_getDerivedOrientation();
	Ogre::Vector3 boneTest = boneRot * Ogre::Vector3::UNIT_Z;*/
	//Ogre::Vector3 boneTest = headBone->getOrientation() * Ogre::Vector3::UNIT_Z;

	//turns the direction vector into a 2D normalized vector on the X/Z axis.
	dir.y = 0;
	dir.normalise();

	//All of this ray query stuff is to make sure that the AI can "see" the target before attempting to look at it.
	Ogre::SceneManager* scene = _node->getCreator();
	Ogre::Ray ray(headBone->_getDerivedPosition() * CHARACTER_SCALE_FACTOR + _node->getPosition(),dir);

	Ogre::RaySceneQuery* query = scene->createRayQuery(ray);
	query->setSortByDistance(true);
	query->setQueryMask(CHARACTER_MASK | SCENERY_MASK);

	Ogre::RaySceneQueryResult results = query->execute();

	bool withinView = false;
	if(results.size() == 0)
	{
		withinView = true;
	}
	else
	{
		if(results.begin()->movable->getParentNode()->getName() == getName())
		{
			if(results.size() == 1)
			{
				withinView = true;
			}
		}
		
		if(!withinView && results.size() > 1 && std::next(results.begin())->distance > test.distance(target))
		{
			withinView = true;
		}
	}

	scene->destroyQuery(query);

	if(withinView)
	{
		Ogre::Euler node;
		Ogre::Euler t = headOrientation.getRotationTo(dir);
		t.limitYaw(Ogre::Radian(3.0));
		t.limitPitch(Ogre::Radian(0.0));

		headOrientation = headOrientation + t;
		headOrientation.limitYaw(Ogre::Degree(100));
		headOrientation.limitPitch(Ogre::Degree(60));

		headBone->setOrientation(headOrientation);

		/*headBone->rotate(boneTest.getRotationTo(dir),Ogre::Node::TS_WORLD);

		Ogre::Quaternion boneRotation = _node->convertLocalToWorldOrientation(_node->getOrientation()) * headBone->_getDerivedOrientation() * (Ogre::Quaternion(Ogre::Degree(180),Ogre::Vector3::UNIT_Y));
		Ogre::Quaternion nodeRotation = _node->_getDerivedOrientation();
		Ogre::Quaternion diff = nodeRotation.Inverse() * boneRotation;*/
	}

	_isActFinished = true;
}
示例#23
0
文件: Camera.cpp 项目: Pured/CSCI356
void DemoApp::generatePath()
{
	for(int j = 0; j < TOTAL_NODES; j++)
	{
		if(pathFindingGraph->getContent(j) == 2)
			pathFindingGraph->setContent(j, 0);
	}

	for(int i = 0; i < TANK_LIMIT; i++)
	{
		//if path already exists
		if(tanks.at(i).mCurrentState > 1)
		{
			// reset
			tanks.at(i).mCurrentState = 0;
			tanks.at(i).path2->clear();
		}
			if(playerControlled == i) //player-controlled tank movement
			{
				// Create RaySceneQuery
				Ogre::Ray mouseRay = mCamera->getCameraToViewportRay(static_cast<float>(mMouse->getMouseState().X.abs)/mMouse->getMouseState().width, static_cast<float>(mMouse->getMouseState().Y.abs)/mMouse->getMouseState().height);

				Ogre::RaySceneQuery *mRaySceneQuery = mSceneMgr->createRayQuery(Ogre::Ray());

				//set ray
				mRaySceneQuery->setRay(mouseRay);

				// Ray-cast and get first hit
				Ogre::RaySceneQueryResult &result = mRaySceneQuery->execute();
				Ogre::RaySceneQueryResult::iterator itr = result.begin();

				// if hit an object
				if((itr != result.end()))
				{
					//Get hit location
					Ogre::Vector3 location = mouseRay.getPoint(itr->distance);

					// if hit the floor
					if((location.y < 0.001 && (selectionMode==1 || selectionMode==2)) || selectionMode==0)
					{
						tanks.at(i).startNode = pathFindingGraph->getNode(tanks.at(i).tankNode->_getDerivedPosition());
						// set goal node
						if(selectionMode==0)
						{
							do
							{
								tanks.at(i).goalNode = (int)rand() % 256;
							}while(pathFindingGraph->getContent(tanks.at(i).goalNode) != 0);
						}
						else
						{
							tanks.at(i).goalNode=pathFindingGraph->getNode(location);
						}
						// check that goal node is not the same as start node
						if(tanks.at(i).goalNode != tanks.at(i).startNode)
						{
							findPath(i);
						}
						else
						{
							resetPath(i);
						}
					}
				}
			}
			else //AI-controlled tank movement
			{
				/*Ogre::Vector3 location; //pre-define location for the if else

				if(tanks.at(i).team == 1)
					location = pathFindingGraph->getPosition((13 + rand() % 16) + rand() % (40 + 1)); //get a random position to move to
				else if(tanks.at(i).team == 2)
					location = pathFindingGraph->getPosition((13 + rand() % 16) * ((rand() % 40 + 1) * 42)); //get a random position to move to
				*/
				int location = ((13 + rand() % 16) + ((rand() % 40 + 1) * 42));
				tanks.at(i).startNode = pathFindingGraph->getNode(tanks.at(i).tankNode->_getDerivedPosition());
				/*
				// set goal node
				if(selectionMode==0)
				{*/
				/*do
				{
					tanks.at(i).goalNode = (int)rand() % 256;
				}while(pathFindingGraph->getContent(tanks.at(i).goalNode) != 0);*/
				/*}
				else
				{
					tanks.at(i).goalNode = pathFindingGraph->getNode(location);
				}*/
				tanks.at(i).goalNode = location;
				//tanks.at(i).goalNode = pathFindingGraph->getNode(location);
				// check that goal node is not the same as start node
				if(tanks.at(i).goalNode != tanks.at(i).startNode)
				{
					findPath(i);
				}
				else
				{
					resetPath(i);
				}
				
			}

			pathFindingGraph->setContent(pathFindingGraph->getNode(tanks.at(i).tankNode->_getDerivedPosition()), 2);
	}
}