Ejemplo n.º 1
0
    RelocMap
    reloc_map(Volume& v,
              const scrubbing::ScrubReply& scrub_reply)
    {
        const auto scrub_res(get_scrub_result(v,
                                              scrub_reply));

        std::map<ClusterAddress, ClusterLocation> relocmap;

        auto treader(CombinedTLogReader::create(getTempPath(testName_).string(),
                                                scrub_res.relocs,
                                                v.getBackendInterface()->clone()));

        const Entry* e = nullptr;
        while ((e = treader->nextLocation()))
        {
            const Entry* f = treader->nextLocation();

            EXPECT_TRUE(f != nullptr);
            EXPECT_EQ(e->clusterAddress(),
                      f->clusterAddress());

            auto r(relocmap.insert(std::make_pair(f->clusterAddress(),
                                                  f->clusterLocation())));
            EXPECT_TRUE(r.second);
        }

        return relocmap;
    }
Ejemplo n.º 2
0
//-----------------------------------------------------------------------------
bool IntermediateTutorial1::frameRenderingQueued(const Ogre::FrameEvent &evt)
{
	if (mDirection == Ogre::Vector3::ZERO) 
	{
		if (nextLocation()) 
		{
			// Set walking animation
			mAnimationState = mEntity->getAnimationState("Walk");
			mAnimationState->setLoop(true);
			mAnimationState->setEnabled(true);

			rotateRobotToDirection();
		}
	}
	else
	{
		Ogre::Real move = mWalkSpeed * evt.timeSinceLastFrame;
		mDistance -= move;
		if (mDistance <= 0.0f)
		{
			mNode->setPosition(mDestination);
			mDirection = Ogre::Vector3::ZERO;

			// Set animation based on if the robot has another point to walk to. 
			if (!nextLocation())
			{
				// Set Idle animation                     
				mAnimationState = mEntity->getAnimationState("Idle");
				mAnimationState->setLoop(true);
				mAnimationState->setEnabled(true);
			} 
			else
			{
				// Rotation Code will go here later
				Ogre::Vector3 src = mNode->getOrientation() * Ogre::Vector3::UNIT_X;
				if ((1.0f + src.dotProduct(mDirection)) < 0.0001f) 
				{
					mNode->yaw(Ogre::Degree(180));
				}
				else
				{
					Ogre::Quaternion quat = src.getRotationTo(mDirection);
					mNode->rotate(quat);
				} // else
			}
		}
		else
		{
			mNode->translate(mDirection * move);
		} // else
	} // if


	mAnimationState->addTime(evt.timeSinceLastFrame);

	return BaseApplication::frameRenderingQueued(evt);
}
Ejemplo n.º 3
0
void BaseNpc::update(double timeSinceLastFrame)
{
  mAnimationState->addTime(timeSinceLastFrame);

  if (m_pCurrentState) {
    m_pCurrentState->Execute(this);
  }

  if (isMoving == false) {
    if (nextLocation(m_pNpcNode)) {
      // Set walking animation
      mAnimationState = m_pNPC->getAnimationState("Walk");
      mAnimationState->setLoop(true);
      mAnimationState->setEnabled(true);
      isMoving = true;
    } else {
      // Not moving and no locations in list
    }
  } else {
    Ogre::Real move = mWalkSpeed * timeSinceLastFrame;
    mDistance -= move;
    if (mDistance <= 0.0f) {
      m_pNpcNode->setPosition(mDestination);
      mDirection = Ogre::Vector3::ZERO;
      // Set animation based on if the robot has another point to walk to.
      if (! nextLocation(m_pNpcNode)) {
          // Set Idle animation
          mAnimationState = m_pNPC->getAnimationState("Idle");
          mAnimationState->setLoop(true);
          mAnimationState->setEnabled(true);
      } else {
        Ogre::Vector3 src = m_pNpcNode->getOrientation() * Ogre::Vector3::UNIT_X;
        if ((1.0f + src.dotProduct(mDirection)) < 0.0001f) {
          m_pNpcNode->yaw(Ogre::Degree(180));
        } else {
          Ogre::Quaternion quat = src.getRotationTo(mDirection);
          m_pNpcNode->rotate(quat);
        }
      }
    } else {
      m_pNpcNode->translate(mDirection * move);
    }
  }
}
Ejemplo n.º 4
0
void
TLogReaderInterface::SCONames(std::vector<SCO>& out)
{
    SCO prevContainer;

    const Entry* e;

    while ((e = nextLocation())){
        const ClusterLocation l = e->clusterLocation();
        const SCO tmp = l.sco();
        if(not (tmp == prevContainer))
        {
            out.push_back(tmp);
            prevContainer = tmp;
        }
    }
}
Ejemplo n.º 5
0
//WEE ADDED CODE HERE
void Tank::aStarMovement(const float & deltaTime)
{
	if(pathCreated)
	{
		if (mDirection == Ogre::Vector3::ZERO) 
		{
			nextLocation();
		}
		else
		{

			Ogre::Real move = mMoveSpd * (deltaTime);
			mDistance -= move;
			Ogre::Vector3 src = mTankBodyNode->getOrientation() * Ogre::Vector3::NEGATIVE_UNIT_X;
	
			//http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Quaternion+and+Rotation+Primer
			//this is used for rotation of the tank
			if ((1.0 + src.dotProduct(mDirection)) < 0.0001) 
			{
				mTankBodyNode->yaw(Ogre::Degree(180));
			}
			else
			{
				mDirection.y = 0;
				Ogre::Quaternion quat = src.getRotationTo(mDirection);
				
				Ogre::Quaternion mOrientSrc = mTankBodyNode->getOrientation();
				Ogre::Quaternion mOrientDest = quat * mOrientSrc;
				Ogre::Quaternion delta = Ogre::Quaternion::nlerp(deltaTime * 2.0, mOrientSrc, mOrientDest, true);
				mTankBodyNode->setOrientation(delta);
			}      
			//for movement
			if (mDistance <= 0)
			{
				mTankBodyNode->setPosition(mDestination);
				mDirection = Ogre::Vector3::ZERO;
			}
			else
			{
				mTankBodyNode->translate(move * mDirection);
			}
		}
	}
}
Ejemplo n.º 6
0
	void EnemyDragon::update(float time)
	{
			if(fireLastingTime > 0)
			{
				fireLastingTime -= time;
				ps->setVisible(true);
			}else
				ps->setVisible(false);

			
			if(frostLastingTime <=0)
				frostCoefficient = 1;
			else
				frostLastingTime -= time;

			if(attackToHome)
			{
				attackToHome = false;
				userGUI->resetHealthBar(50);
				//mWorld->homeHealth -= 100;
				//mWorld->homeText->setCaption(convertInt(mWorld->homeHealth));
			}


			if(die){
				mtext->setCaption("0");
				mtext->setVisible(false);
				return;
			}
			if(saveBody < 0){
				die = true;
				mtext->setCaption("0");
				return;
			}
			 
			if(!nearlyDie && !die)
			{
				mtext->setCaption(convertInt(lifeValue));
			}else{
				mtext->setCaption("0");
				mtext->setVisible(false);
			}


			if(nearlyDie)
			{
				mAnimationState= entity->getAnimationState("Death");
				mAnimationState->setLoop(false);
				mAnimationState->setEnabled(true);
				nearlyDieTime -= time;

				if(nearlyDieTime < 0)
				{
					saveBody -= time;
					mAnimationState= entity->getAnimationState("Death");
					//die = true;
					//cleanBody = true;
				}
				mAnimationState->addTime(time * frostCoefficient);
				return;
			}

			if(caught)
				return;



		    if (mDirection == Ogre::Vector3::ZERO) {
				if (nextLocation()) {
					// Set walking animation
					mAnimationState = entity->getAnimationState("Run");
					mAnimationState->setLoop(true);
					mAnimationState->setEnabled(true);				
				}//if
			}else{
				Ogre::Real move = mWalkSpeed * time * frostCoefficient;
				mDistance -= move * frostCoefficient;
				if (mDistance <= 0.0f){                 
					sceneNode->setPosition(mDestination);
					mDirection = Ogre::Vector3::ZERO;				
					// Set animation based on if the robot has another point to walk to. 
					if (!nextLocation()){
						// Set Jump animation                     
						mAnimationState = entity->getAnimationState("BattleRoar");
						mAnimationState->setLoop(true);
						mAnimationState->setEnabled(true);
						nearlyDie = true;  
						attackToHome = true;
						mtext->setCaption("0");
					}else{
						// Rotation Code will go here later
						Ogre::Vector3 src = sceneNode->getOrientation() *(- Ogre::Vector3::UNIT_Z);
						if ((1.0f + src.dotProduct(mDirection)) < 0.0001f) {
							sceneNode->yaw(Ogre::Degree(180));						
						}else{
							Ogre::Quaternion quat = src.getRotationTo(mDirection);
							sceneNode->rotate(quat);
							sceneNode->yaw(Ogre::Degree(90));	
						} // else
					}//else
				}else{
					sceneNode->translate(mDirection * move * frostCoefficient);
				} // else
			} // if
			mAnimationState->addTime(time * frostCoefficient);

			

			if(reachHome)
			{
				ps->setVisible(true);
				happy2Dead -= time;
				if(happy2Dead < 0)
				{
					die = true;
				}
			}
		
	}
Ejemplo n.º 7
0
ClusterLocation
TLogReaderInterface::nextClusterLocation()
{
    const Entry* e = nextLocation();
    return e ? e->clusterLocation() : ClusterLocation();
}