void OgreCharacterController::update(Ogre::Real elapsedTime, OIS::Keyboard * input)
{
  Ogre::SceneNode * node = getMainNode();
  OGRE_ANIMATION_STATE state = IDLE;

  if(input->isKeyDown(OIS::KC_W)) {
    node->translate(node->getOrientation() * Ogre::Vector3(0, 0, elapsedTime*100));
    state = RUN;
  }
  if(input->isKeyDown(OIS::KC_S)) {
    node->translate(node->getOrientation() * Ogre::Vector3(0, 0, elapsedTime*-50));
    state = RUN;
  }
  if(input->isKeyDown(OIS::KC_A)) {
    node->yaw(Ogre::Radian(2*elapsedTime));
  }
  if(input->isKeyDown(OIS::KC_D))
    node->yaw(Ogre::Radian(-2*elapsedTime));

  if(input->isKeyDown(OIS::KC_RETURN)) {
    state = DRAWSWORDS;
  }

  if(input->isKeyDown(OIS::KC_SPACE)) {
    state = SLICE;
  }

  if(input->isKeyDown(OIS::KC_PGUP)) {
    //mRigidBody->setLinearVelocity(btVector3(0, 50, 0));
  }

  animate(elapsedTime, state);
}
Exemplo n.º 2
0
//---------------------------------------------------------------------------
void TutorialApplication::createScene()
{
	mSceneMgr->setAmbientLight(Ogre::ColourValue(.2f, .2f, .2f));

	Ogre::Entity* tudorEntity = mSceneMgr->createEntity("tudorhouse.mesh");
	Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode(
		"Node");
	node->attachObject(tudorEntity);

	Ogre::Light* light = mSceneMgr->createLight("Light1");
	light->setType(Ogre::Light::LT_POINT);
	light->setPosition(Ogre::Vector3(250, 150, 250));
	light->setDiffuseColour(Ogre::ColourValue::White);
	light->setSpecularColour(Ogre::ColourValue::White);

	node = mSceneMgr->getRootSceneNode()->createChildSceneNode(
		"CamNode1", Ogre::Vector3(1200, -370, 0));
	node->yaw(Ogre::Degree(90));

	mCamNode = node;
	node->attachObject(mCamera);

	node = mSceneMgr->getRootSceneNode()->createChildSceneNode(
		"CamNode2", Ogre::Vector3(-500, -370, 1000));
	node->yaw(Ogre::Degree(-30));

}
void GameState::createScene()
{
    // --- Objects
    m_pNpc01 = new BaseNpc("Blacksmith", m_pSceneMgr, Ogre::Vector3(50.0f,  0.0f,  50.0f));
    m_pNpc01->ChangeState(Work::Instance());
    //m_pNpc02 = new BaseNpc("Woman", m_pSceneMgr, Ogre::Vector3(-50.0f,  0.0f,  -50.0f));
    //m_pNpc01->addLocation(Ogre::Vector3(-100.0f,0.0f,-100.0f));

    // --- World
    // Light
    m_pSceneMgr->setAmbientLight(Ogre::ColourValue(0.7, 0.7, 0.7));

    // Objects
    // Home
    Ogre::Entity* home = m_pSceneMgr->createEntity("Home", "tudorhouse.mesh");
    //home->setCastShadows(true);
    Ogre::SceneNode* homeNode = m_pSceneMgr->getRootSceneNode()->createChildSceneNode("HomeNode");
    homeNode->attachObject(home);
    homeNode->setPosition(Ogre::Vector3(-400.0f,220.0f,-400.0f));
    homeNode->setScale(0.4f, 0.4f, 0.4f);

    // Work
    Ogre::Entity* work = m_pSceneMgr->createEntity("Work", "tudorhouse.mesh");
    //work->setCastShadows(true);
    Ogre::SceneNode* workNode = m_pSceneMgr->getRootSceneNode()->createChildSceneNode("WorkNode");
    workNode->attachObject(work);
    workNode->setPosition(Ogre::Vector3(400.0f,220.0f,400.0f));
    workNode->setScale(0.4f, 0.4f, 0.4f);
    workNode->yaw(Ogre::Degree(180));

    // Tavern
    Ogre::Entity* tavern = m_pSceneMgr->createEntity("Tavern", "tudorhouse.mesh");
    //tavern->setCastShadows(true);
    Ogre::SceneNode* tavernNode = m_pSceneMgr->getRootSceneNode()->createChildSceneNode("TavernNode");
    tavernNode->attachObject(tavern);
    tavernNode->setPosition(Ogre::Vector3(-400.0f,220.0f,400.0f));
    tavernNode->setScale(0.4f, 0.4f, 0.4f);
    tavernNode->yaw(Ogre::Degree(180));


    // Ground
    Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0);
    Ogre::MeshManager::getSingleton().createPlane("ground", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
    plane, 1500, 1500, 20, 20, true, 1, 5, 5, Ogre::Vector3::UNIT_Z);
    Ogre::Entity* entGround = m_pSceneMgr->createEntity("GroundEntity", "ground");
    m_pSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(entGround);
    entGround->setMaterialName("Examples/Rockwall");
    entGround->setCastShadows(false);
}
void COrbitViewView::OnMouseMove(UINT nFlags, CPoint point)
{
	Ogre::Vector3 CameraMove(0.0, 0.0, 0.0);

	CEngine * Engine = ((COrbitViewApp*)AfxGetApp())->m_Engine;
	if (Engine == NULL)
	  return;
	Ogre::Root *Root = Engine->GetRoot();
	if (m_Camera == NULL)
	  return;

	if (m_MouseNavigation)
	{
	if (m_Orbit)
	{
		Ogre::SceneNode* CameraNode = m_SceneManager->getSceneNode("CameraNode");
		CameraMove[1] = m_MousePosition.y - point.y;
		m_Camera->moveRelative(CameraMove);
		CameraNode->yaw(Ogre::Radian(0.01 * (m_MousePosition.x - point.x)));
	}
	else
	{
		CameraMove[0] = -(m_MousePosition.x - point.x);
		CameraMove[1] = m_MousePosition.y - point.y;
		m_Camera->moveRelative(CameraMove);
	}

		m_MousePosition = point;
		Root->renderOneFrame();
	}

	CView::OnMouseMove(nFlags, point);
}
Exemplo n.º 5
0
//-------------------------------------------------------------------------------------
void TutorialApplication::createScene(void)
{
    // create your scene here :)

	// Set the scene's ambient light
    mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5f, 0.5f, 0.5f));
 
    Ogre::Entity* ogreHead = mSceneMgr->createEntity("Head", "ogrehead.mesh");
	Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("HeadNode");
	headNode->attachObject(ogreHead);
	 
	headNode->yaw( Ogre::Degree( -90 ) );
 
	Ogre::Entity* ogreHead2 = mSceneMgr->createEntity( "Head2", "ogrehead.mesh" );
	Ogre::SceneNode* headNode2 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "HeadNode2", Ogre::Vector3( 100, 0, 0 ) );
	headNode2->attachObject( ogreHead2 );
 
	headNode2->pitch( Ogre::Degree( -90 ) );
 
	Ogre::Entity* ogreHead3 = mSceneMgr->createEntity( "Head3", "ogrehead.mesh" );
	Ogre::SceneNode* headNode3 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "HeadNode3", Ogre::Vector3( 200, 0, 0 ) );
	headNode3->attachObject( ogreHead3 );
 
	headNode3->roll( Ogre::Degree( -90 ) );

    // Create a Light and set its position
    Ogre::Light* light = mSceneMgr->createLight("MainLight");
    light->setPosition(20.0f, 80.0f, 50.0f);
}
void ProjectileManager::createProjectile(const Ogre::Vector3& tankPosition, const Ogre::Quaternion& turretOrientation, 
										 const Ogre::Degree& angle, const float& velocity, const float& dmg){
	
	std::ostringstream oss;
	oss << "Projectile" << time(0) << projectiles.size() << counter++;										 
											 
	Ogre::ParticleSystem* particleSystem = mSceneMgr->createParticleSystem(oss.str(), "Examples/PurpleFountain");

	scaleBy(1.f, particleSystem);

	Ogre::SceneNode* parentParticleSn = mSceneMgr->getRootSceneNode()->createChildSceneNode();

	Ogre::SceneNode* particleSn = parentParticleSn->createChildSceneNode();

	Ogre::Vector3 start(-115.f, 10.f, 0.f);

	parentParticleSn->setPosition(tankPosition);
	particleSn->setPosition(start);

	parentParticleSn->yaw(turretOrientation.getYaw());

	particleSn->attachObject(particleSystem);

	particleSn->roll(Ogre::Degree(-90.f));

	particleSn->scale(Ogre::Vector3(0.1f));

	projectiles.insert(new Projectile(start, particleSn, angle, velocity, dmg));
}
//-------------------------------------------------------------------------------------
void TutorialApplication::createScene(void)
{
	mSceneMgr->setAmbientLight(Ogre::ColourValue(0.25, 0.25, 0.25));

    // add the ninja
	Ogre::Entity *ent = mSceneMgr->createEntity("Ninja", "ninja.mesh");
    Ogre::SceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode("NinjaNode");
    node->attachObject(ent);

    // create the light
    Ogre::Light *light = mSceneMgr->createLight("Light1");
    light->setType(Ogre::Light::LT_POINT);
    light->setPosition(Ogre::Vector3(250, 150, 250));
    light->setDiffuseColour(Ogre::ColourValue::White);
    light->setSpecularColour(Ogre::ColourValue::White);

   // Create the scene node
    node = mSceneMgr->getRootSceneNode()->createChildSceneNode("CamNode1", Ogre::Vector3(-400, 200, 400));

    // Make it look towards the ninja
    node->yaw(Ogre::Degree(-45));

    // Create the pitch node
    node = node->createChildSceneNode("PitchNode1");
    node->attachObject(mCamera);

    // create the second camera node/pitch node
    node = mSceneMgr->getRootSceneNode()->createChildSceneNode("CamNode2", Ogre::Vector3(0, 200, 400));
    node = node->createChildSceneNode("PitchNode2");
}
Exemplo n.º 8
0
void DrivingSimulatorV1::createScene1() // city
{
	// create world node
	Ogre::SceneNode* worldNode = sceneManager->getRootSceneNode()->createChildSceneNode();
	Ogre::Entity* cityWorld = sceneManager->createEntity("CityWorld.mesh");
	worldNode->scale(0.05, 0.05, 0.05);
	worldNode->attachObject(cityWorld);

	// create ETH Node
	Ogre::SceneNode* ethNode = sceneManager->getRootSceneNode()->createChildSceneNode();
	Ogre::Entity* eth = sceneManager->createEntity("ETH.mesh");
	ethNode->attachObject(eth);
	ethNode->scale(1.3, 1.3, 1.3);
	ethNode->setPosition(428, 0, 235);
	ethNode->yaw(Ogre::Degree(210));

	// create ambient light
	sceneManager->setAmbientLight(Ogre::ColourValue(0.7, 0.7, 0.7));

	// create sun light
	Ogre::Light* sunLight = sceneManager->createLight();
	sunLight->setType(Ogre::Light::LT_DIRECTIONAL);
	sunLight->setDirection(Ogre::Vector3(-0.5, -0.5, 0.5));
	sunLight->setDiffuseColour(Ogre::ColourValue(1, 1, 1));
	sunLight->setSpecularColour(Ogre::ColourValue(0.7, 0.7, 0.7));

	// set car to initial position and orientation
	carNode->setPosition(584, 0, 121);
	carNode->setOrientation(Ogre::Quaternion(Ogre::Degree(-4.5), Ogre::Vector3::UNIT_Y));
}
Exemplo n.º 9
0
void ModelMountTestCase::testModelMountScaling()
{
	Ogre::Root root;
	Ogre::SceneManager* sceneManager = root.createSceneManager(Ogre::ST_GENERIC);

	TestModel model(*sceneManager);

	//First test with a straight forward case.
	Ogre::SceneNode* node = sceneManager->getRootSceneNode()->createChildSceneNode();
	//We get an error when it's destroyed. So we don't destroy it.
	SceneNodeProvider* nodeProvider = new SceneNodeProvider(node, nullptr);
	Model::ModelMount mount(model, nodeProvider);
	scaleAndTestMount(model, mount, nodeProvider->getNode());

	//Test with the parent node being scaled
	node->setScale(Ogre::Vector3(3.0f, 0.2f, 200.0f));
	Ogre::SceneNode* subNode = node->createChildSceneNode();
	nodeProvider = new SceneNodeProvider(subNode, nullptr);
	Model::ModelMount mount2(model, nodeProvider);
	scaleAndTestMount(model, mount2, nodeProvider->getNode());

	//Test with the parent node being scaled and rotated
	node->setScale(Ogre::Vector3(3.0f, 0.2f, 200.0f));
	node->yaw(Ogre::Degree(42));
	node->pitch(Ogre::Degree(76));
	node->roll(Ogre::Degree(98));
	subNode = node->createChildSceneNode();
	nodeProvider = new SceneNodeProvider(subNode, nullptr);
	Model::ModelMount mount3(model, nodeProvider);
	scaleAndTestMount(model, mount3, nodeProvider->getNode());
}
Exemplo n.º 10
0
void Hundir::createScene() {

    Ogre::Entity* inicio = _sceneManager->createEntity("Inicio.mesh");
    Ogre::SceneNode* ninicio = _sceneManager->createSceneNode("ninicio");
    _sceneManager->getRootSceneNode()->addChild(ninicio);
    ninicio->attachObject(inicio);
    ninicio->yaw(Ogre::Degree(-15));
    ninicio->pitch(Ogre::Degree(50));
    ninicio->roll(Ogre::Degree(90));
    ninicio->setScale(1,1.5,1.2);
    ninicio->setPosition(0,0,-2);

    /* Sombras */
    _sceneManager->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_MODULATIVE);
    _sceneManager->setShadowColour(Ogre::ColourValue(0.5, 0.5, 0.5) );
    _sceneManager->setAmbientLight(Ogre::ColourValue(0.9, 0.9, 0.9));
    _sceneManager->setShadowTextureCount(2);
    _sceneManager->setShadowTextureSize(512);
    /* Iluminacion */
    Ogre::Light *light = _sceneManager->createLight("Light");
    light->setType(Ogre::Light::LT_SPOTLIGHT);
    light->setDirection(Ogre::Vector3(0,-1,0));
    light->setSpotlightInnerAngle(Ogre::Degree(25.0f));
    light->setSpotlightOuterAngle(Ogre::Degree(200.0f));
    light->setPosition(0, 150, 0);
    light->setSpecularColour(1, 1, 1);
    light->setDiffuseColour(1, 1, 1);
    light->setSpotlightFalloff(5.0f);
    light->setCastShadows(true);
}
Exemplo n.º 11
0
    bool frameStarted(const Ogre::FrameEvent &evt)
    {
        if (Ogre::Root::getSingletonPtr()->getAutoCreatedWindow()->isClosed())
        {
            return false;
        }

        m_renderNode->yaw(Ogre::Radian(evt.timeSinceLastFrame)*Ogre::Math::PI*2.*(1./10.)); // one turn in 10sec

        CefDoMessageLoopWork();

        return true;
    }
Exemplo n.º 12
0
void MainApplication::spawn_enemy()
{
   // if(enemyCounter < MAX_ENEMY)
    //{
        Ogre::String number = Ogre::StringConverter::toString(enemyCounter + 1); 
        enemies.push_back("HeadNode" + number);
        Ogre::Entity* ogreHead = mSceneMgr->createEntity("ogrehead.mesh");
        Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("HeadNode" + number);
        Ogre::Vector3 pos1(mSceneMgr-> getSceneNode("NinjaNode")->getPosition());
        headNode -> setPosition(Ogre::Vector3(1000, rand() % 800 - 400, pos1.z));
        headNode -> attachObject(ogreHead);
        headNode->yaw(Ogre::Degree(-90));
        enemyCounter++;
   // }
}
Exemplo n.º 13
0
///重载,被用于进入消息管理调用
void SanZhugeActor::doEnable(void)
{
	_zhuge = ComponentFactories::getInstance().create("SanZhuGe");
	COgreEntityInterface * entity = _zhuge->queryInterface<COgreEntityInterface>();

	Ogre::SceneNode *sn =  entity->getSceneNode();
	sn->setPosition(_pos);
	sn->setScale(_scale);
	sn->yaw(Ogre::Radian(_radian));


	_process
		->queryInterface<CSanProcessInterface>()
		->addObject(_zhuge);
	setChannel(Orz::EventChannel::create().clear());

}
Exemplo n.º 14
0
//-------------------------------------------------------------------------------------
bool
PlayersManager::moving(zappy::Player *p, int i)
{
  OPlayer *OPlayer = this->mOPlayers.at(i);
  this->speed = Constants::SquareSize /
    ((Constants::timeUnit / static_cast<Ogre::Real>(time)));

  Ogre::SceneNode *node = OPlayer->getSceneNode();
  Ogre::Vector3 &direction = OPlayer->getDirection();
  Ogre::Real &distance = OPlayer->getDistance();
  Ogre::Real move = this->speed * this->tslf;
  Ogre::Vector3 destination(p->getX() * Constants::SquareSize, 0, p->getY() * Constants::SquareSize);
  Ogre::AnimationState *anim = OPlayer->getEntity()->
    getAnimationState(distance <= 0.0f ? "Idle" : "Walk");

  anim->setLoop(true);
  anim->setEnabled(true);
  if (direction == Ogre::Vector3::ZERO)
    {
      Ogre::Vector3 src = node->getOrientation() * Ogre::Vector3::UNIT_X;
      direction = destination - node->getPosition();
      distance = direction.normalise();
      if ((1.0f + src.dotProduct(direction)) < 0.0001f)
        node->yaw(Ogre::Degree(180));
      else
        node->rotate(src.getRotationTo(direction));
      if (distance > Constants::SquareSize)
        distance = 0.0f;
    }
  else
    {
      distance -= move;
      if (distance <= 0.0f)
        {
          node->setPosition(destination);
          direction = Ogre::Vector3::ZERO;
        }
      else
        node->translate(direction * move);
    }
  if (OPlayer->stateHasChanged())
    OPlayer->detachAnim();
  anim->addTime(this->tslf);
  return true;
}
Exemplo n.º 15
0
Wall* Application::createWall(Ogre::String nme, GameObject::objectType tp, Ogre::String meshName, int x, int y, int z, Ogre::Vector3 scale, Ogre::Degree pitch, Ogre::Degree yaw, Ogre::Degree roll, Ogre::SceneManager* scnMgr, GameManager* ssm, Ogre::Real mss, Ogre::Real rest, Ogre::Real frict, bool kinematic, Simulator* mySim) {

	createRootEntity(nme, meshName, x, y, z);
	Ogre::SceneNode* sn = mSceneManager->getSceneNode(nme);
	Ogre::Entity* ent = SceneHelper::getEntity(mSceneManager, nme, 0);
	const btTransform pos;
	OgreMotionState* ms = new OgreMotionState(pos, sn);
	sn->setScale(scale.x, scale.y, scale.z);

	sn->pitch(pitch);
	sn->yaw(yaw);
	sn->roll(roll);

	Wall* obj = new Wall(nme, tp, mSceneManager, ssm, sn, ent, ms, mySim, mss, rest, frict, scale, kinematic);
	obj->addToSimulator();

	return obj;
}
Exemplo n.º 16
0
CField::CField()
: CBaseGameEntity()
{
	Ogre::SceneManager *scnMgr = Ogre::Root::getSingletonPtr()->getSceneManager(SIMULATION_SCENE_MANAGER_NODE_NAME);

	m_centerOfMassOffset.setOrigin(btVector3(0,1,0));
    m_entity = scnMgr->createEntity("Field", "Field.mesh");
    m_node = scnMgr->getRootSceneNode()->createChildSceneNode("FieldNode", Ogre::Vector3(0, 0, 0));
    m_node->attachObject(m_entity);

    Ogre::Entity *goal = scnMgr->createEntity("Goal_left", "Goal.mesh");
    Ogre::Entity *net  = scnMgr->createEntity("Net_left", "Net.mesh");
    Ogre::SceneNode *node = m_node->createChildSceneNode("GoalLeftNode", Ogre::Vector3(-55,0,0));
    node->attachObject(goal);
    node->attachObject(net);
    goal = scnMgr->createEntity("Goal_right", "Goal.mesh");
    net = scnMgr->createEntity("Net_right", "Net.mesh");
    node = m_node->createChildSceneNode("GoalRightNode", Ogre::Vector3(55,0,0));
    node->attachObject(goal);
    node->attachObject(net);
    node->yaw(Ogre::Degree(180));

    m_shape = new btBoxShape(btVector3(btScalar(60.0),btScalar(1.0),btScalar(45.0)));
    btScalar mass(0);

    //rigidbody is dynamic if and only if mass is non zero, otherwise static
    bool isDynamic = (mass != 0.f);

    btVector3 localInertia(0,0,0);
    if (isDynamic)
        m_shape->calculateLocalInertia(mass,localInertia);
    btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,this,m_shape,localInertia);
    rbInfo.m_restitution = btScalar(0.4);
    rbInfo.m_friction = 0.4;
    m_body = new btRigidBody(rbInfo);

    //Penalty area rectangles and Goals
    m_leftArea = new CRectangle(btVector3(-38.5, 0.0, -20.16), btVector3(-55.0, 0.0, 20.16));
    m_rightArea = new CRectangle(btVector3(55.0, 0.0, -20.16), btVector3(38.5, 0.0, 20.16));
    m_leftGoalCenter = btVector3(-55.0, 0.0, 0.0);
    m_leftGoalFacing = btVector3(1.0, 0.0, 0.0);;
    m_rightGoalCenter = btVector3(55.0, 0.0, 0.0);
    m_rightGoalFacing = btVector3(-1.0, 0.0, 0.0);;
}
Exemplo n.º 17
0
  void createScene()
  {
    // Create the Entity
    Ogre::Entity* robot = mSceneMgr->createEntity("Robot", "robot.mesh");
    // Attach robot to scene graph
    Ogre::SceneNode* RobotNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("Robot");
    //RobotNode->setPosition((Ogre::Real)-0.3, (Ogre::Real)0.2, (Ogre::Real)0);
    RobotNode->attachObject(robot);
    RobotNode->scale((Ogre::Real)0.001,(Ogre::Real)0.001,(Ogre::Real)0.001);
    RobotNode->pitch(Ogre::Degree(180));
    RobotNode->yaw(Ogre::Degree(-90));

    // The animation
    // Set the good animation
    mAnimationState = robot->getAnimationState( "Idle" );
    // Start over when finished
    mAnimationState->setLoop( true );
    // Animation enabled
    mAnimationState->setEnabled( true );
  }
Exemplo n.º 18
0
void PlayState::ColocarWolfAndRedilAndPig() {
  // CREACION REDIL PARA PONER ANIMALES
  Entity *entityRedil = _sceneMgr->createEntity("Redil","Redil.mesh");
  SceneNode *nodeRedil = _sceneMgr->createSceneNode("Redil");
  nodeRedil->attachObject(entityRedil);
  //nodeRedil-> setPosition(9,7,20);

  _sceneMgr->getRootSceneNode()->addChild(nodeRedil);
  OgreBulletCollisions::StaticMeshToShapeConverter *trimeshConverterR = new 
          OgreBulletCollisions::StaticMeshToShapeConverter(entityRedil);

  OgreBulletCollisions::TriangleMeshCollisionShape *TrimeshR = 
          trimeshConverterR->createTrimesh();

  OgreBulletDynamics::RigidBody *rigidObjectR = new 
    OgreBulletDynamics::RigidBody("Redil", _world);
  rigidObjectR->setShape(nodeRedil, TrimeshR, 0.5, 0.5, 0, Ogre::Vector3(30,0,0), 
       Quaternion::IDENTITY);        
  
  int posx[] = {30,35,35};
  int posz[] = {0,-2,2};
  int posD[] = {0,-120,200};
  
  for (int i = 0; i < 3; ++i){
      std::ostringstream os;
      os << "pigA" << i;

      Ogre::Entity* entc = _sceneMgr->createEntity(os.str(), "CerdoAnim.mesh");
      Ogre::SceneNode* nodecer = _sceneMgr->createSceneNode(os.str());
      nodecer->attachObject(entc);
      nodecer-> setPosition(posx[i],0,posz[i]);
      // roll --> z
      // pitch --> x
      // yaw --> y
      nodecer->yaw(Ogre::Degree(posD[i]));
      _sceneMgr->getRootSceneNode()->addChild(nodecer);
      
  }
}
Exemplo n.º 19
0
//-------------------------------------------------------------------------------------
void TutorialApplication::createScene(void)
{
	mSceneMgr->setAmbientLight(Ogre::ColourValue(0.2, 0.2, 0.2));
    mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
 
	//'Ball' entity
    Ogre::Entity* head = mSceneMgr->createEntity("Head", "ogrehead.mesh");
		head->setCastShadows(true);
	Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("ball", Ogre::Vector3(0, 30, 0));
		headNode->attachObject(head);
		headNode->yaw(Ogre::Angle(250));
		mBall = headNode;

	//Paddle entities
	Ogre::Entity* paddle1 = mSceneMgr->createEntity("paddle1", "Prefab_Cube");
		paddle1->setCastShadows(true);
		Ogre::SceneNode* paddle1Node = mSceneMgr->getRootSceneNode()->createChildSceneNode("paddle1Node", Ogre::Vector3(-240, 20, 0));
			paddle1Node->attachObject(paddle1);
			paddle1Node->scale(Ogre::Vector3(0.1, 0.3, 0.9));

	Ogre::Entity* paddle2 = mSceneMgr->createEntity("paddle2", "Prefab_Cube");
		paddle2->setCastShadows(true);
		Ogre::SceneNode* paddle2Node = mSceneMgr->getRootSceneNode()->createChildSceneNode("paddle2Node", Ogre::Vector3(240, 20, 0));
			paddle2Node->attachObject(paddle2);
			paddle2Node->scale(Ogre::Vector3(0.1, 0.3, 0.9));

	//Create plane
    Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0);
	   Ogre::MeshManager::getSingleton().createPlane("ground", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
        plane, 500, 400, 20, 20, true, 1, 5, 5, Ogre::Vector3::UNIT_Z);
		Ogre::Entity* entGround = mSceneMgr->createEntity("GroundEntity", "ground");
		mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(entGround);
	    entGround->setMaterialName("Examples/Rockwall");
		entGround->setCastShadows(false);
 
    Ogre::Light* pointLight = mSceneMgr->createLight("pointLight");
		pointLight->setType(Ogre::Light::LT_POINT);
		pointLight->setPosition(Ogre::Vector3(0, 150, 250));
		pointLight->setDiffuseColour(0.0, 0.5, 0.0);
		pointLight->setSpecularColour(0.0, 0.5, 0.0);
 
    /*Ogre::Light* directionalLight = mSceneMgr->createLight("directionalLight");
		directionalLight->setType(Ogre::Light::LT_DIRECTIONAL);
		directionalLight->setDiffuseColour(Ogre::ColourValue(.25, .25, 0));
		directionalLight->setSpecularColour(Ogre::ColourValue(.25, .25, 0));
		directionalLight->setDirection(Ogre::Vector3( 0, -1, 1 )); */
 
    Ogre::Light* spotLight = mSceneMgr->createLight("spotLight");
		spotLight->setType(Ogre::Light::LT_SPOTLIGHT);
		spotLight->setDiffuseColour(0, 0, 1.0);
		spotLight->setSpecularColour(0, 0, 1.0);
		spotLight->setDirection(-1, -1, 0);
		spotLight->setPosition(Ogre::Vector3(300, 300, 0));
		spotLight->setSpotlightRange(Ogre::Degree(25), Ogre::Degree(40));
	Ogre::Light* spotLight2 = mSceneMgr->createLight("spotLight2");
		spotLight2->setType(Ogre::Light::LT_SPOTLIGHT);
		spotLight2->setDiffuseColour(1, 0, 0);
		spotLight2->setSpecularColour(0, 0, 1.0);
		spotLight2->setDirection(-1, -1, 0);
		spotLight2->setPosition(Ogre::Vector3(-300, 300, 0));
		spotLight2->setSpotlightRange(Ogre::Degree(25), Ogre::Degree(40));
}
Exemplo n.º 20
0
Ogre::Entity*
ModelFile::GetModel( const ModelInfo& info )
{
    VectorTexForGen textures;
    Ogre::MeshPtr mesh = Ogre::MeshManager::getSingleton().create( info.data.name + "export", "General" );
    Ogre::SkeletonPtr skeleton = Ogre::SkeletonManager::getSingleton().create( info.data.name + "export", "General" );

    int number_of_bones = GetU8( 0x02 );
    int number_of_parts = GetU8( 0x03 );
    int offset_to_bones = GetU32LE( 0x0c );
    int offset_to_parts = GetU32LE( 0x10 );



    Ogre::Bone* root1 = skeleton->createBone( "0", 0 );
    Ogre::Bone* root2 = skeleton->createBone( "1", 1 );
    root1->addChild( root2 );

    for( int i = 0; i < number_of_bones; ++i )
    {
        Bone bone;
        bone.parent_id = ( i != 0 ) ? ( s8 )GetU8( offset_to_bones + i * 0x04 + 0x03 ) : -1;
        bone.length    = ( s16 )GetU16LE( offset_to_bones + i * 0x04 + 0x00 );
        m_Skeleton.push_back(bone);

        Ogre::Bone* bone1 = skeleton->createBone( Ogre::StringConverter::toString( i * 2 + 2 ), i * 2 + 2 );
        Ogre::Bone* bone2 = skeleton->createBone( Ogre::StringConverter::toString( i * 2 + 3 ), i * 2 + 3 );

        LOGGER->Log( "Add skeleton bone: bone_id = " + Ogre::StringConverter::toString( i ) + ", length = " + Ogre::StringConverter::toString( bone.length ) + ", parent = " + Ogre::StringConverter::toString( bone.parent_id ) + ".\n" );

        if( bone.parent_id == -1 )
        {
            skeleton->getBone( 1 )->addChild( bone1 );
        }
        else
        {
            skeleton->getBone( bone.parent_id * 2 + 3 )->addChild( bone1 );
        }
        bone1->addChild( bone2 );
    }



    AnimationExtractor( skeleton, info, m_Skeleton );



    // draw skeleton
    {
        //DrawSkeleton( m_Skeleton, mesh );
    }



    for( int i = 0; i < number_of_parts; ++i )
    {
        MeshExtractor( info.data, "ffix/field_model/" + info.data.name, this, offset_to_parts + i * 0x28, textures, mesh );
    }



    // <OGRE> ///////////////////////////////
    skeleton->optimiseAllAnimations();
    Ogre::SkeletonSerializer skeleton_serializer;
    skeleton_serializer.exportSkeleton( skeleton.getPointer(), "exported/models/field/units/" + info.data.name + ".skeleton" );

    // Update bounds
    Ogre::AxisAlignedBox aabb( -999, -999, -999, 999, 999, 999 );
    mesh->_setBounds( aabb, false );
    mesh->_setBoundingSphereRadius( 999 );

    mesh->setSkeletonName( "models/field/units/" + info.data.name + ".skeleton" );

    Ogre::MeshSerializer ser;
    ser.exportMesh( mesh.getPointer(), "exported/models/field/units/" + info.data.name + ".mesh" );



    // create and export textures for model
    //if (textures.size() > 0)
    {
        Vram* vram = new Vram();

        File* tex = new File( "./data/field/5/1b/2/4/1.tim" );
        LoadTimFileToVram( tex, 0, vram );
        delete tex;
        tex = new File( "./data/field/5/1b/2/4/2.tim" );
        LoadTimFileToVram( tex, 0, vram );
        delete tex;

        vram->Save( "1.jpg" );

        CreateTexture( vram, info.data, "exported/models/field/units/" + info.data.name + ".png", textures );

        delete vram;
    }



    CreateMaterial( "ffix/field_model/" + info.data.name, "exported/models/field/units/" + info.data.name + ".material", ( textures.size() > 0 ) ? "models/field/units/" + info.data.name + ".png" : "", "", "" );



    Ogre::SceneManager* scene_manager = Ogre::Root::getSingleton().getSceneManager( "Scene" );
    Ogre::Entity* thisEntity = scene_manager->createEntity( info.data.name, "models/field/units/" + info.data.name + ".mesh" );
    //thisEntity->setDisplaySkeleton(true);
    //thisEntity->setDebugDisplayEnabled(true);
    thisEntity->setVisible( false );
    thisEntity->getAnimationState( info.animations_name[ 0 ] )->setEnabled(true);
    thisEntity->getAnimationState( info.animations_name[ 0 ] )->setLoop(true);
    Ogre::SceneNode* thisSceneNode = scene_manager->getRootSceneNode()->createChildSceneNode();
    thisSceneNode->setPosition( 0, 0, 0 );
    thisSceneNode->roll( Ogre::Radian( Ogre::Degree( 180.0f ) ) );
    thisSceneNode->yaw( Ogre::Radian( Ogre::Degree( 120.0f ) ) );
    thisSceneNode->pitch( Ogre::Radian( Ogre::Degree(90.0f ) ) );
    thisSceneNode->attachObject( thisEntity );

    return thisEntity;
}
Exemplo n.º 21
0
void GameG::drawBoard()
{
	Ogre::SceneManager*  m_pSceneMgr=OgreFramework::getSingletonPtr()->m_pRoot->getSceneManager("GameSceneMgr");
	float widthKw = 30;
	float heightKw = 30;
	Ogre::ManualObject mo("Pole");
	 

	mo.begin("Examples/Rocky", Ogre::RenderOperation::OT_TRIANGLE_LIST);
		mo.position(0, 0, heightKw);
			mo.textureCoord(0, 0);
	 
			mo.position(widthKw, 0, heightKw);
			mo.textureCoord(1, 0);
	 
			mo.position(widthKw, 0, 0);
			mo.textureCoord(0, 1);
	 
			mo.position(0, 0, 0);
			mo.textureCoord(1, 1);
			
			mo.triangle(0, 1, 2);
			mo.triangle(0, 2, 3);
	
	mo.end();
	mo.convertToMesh("PoleKw");

	float width = 18;
	float height = 30;

	
	mo.clear();
	mo.begin("Examples/Rocky", Ogre::RenderOperation::OT_TRIANGLE_LIST);
		mo.position(0, 0, height);
			mo.textureCoord(0, 0);
	 
			mo.position(width, 0, height);
			mo.textureCoord(1, 0);
	 
			mo.position(width, 0, 0);
			mo.textureCoord(0, 1);
	 
			mo.position(0, 0, 0);
			mo.textureCoord(1, 1);
			
			mo.triangle(0, 1, 2);
			mo.triangle(0, 2, 3);
	
	mo.end();

	mo.convertToMesh("Pole");
	
	Ogre::Entity *pole = m_pSceneMgr->createEntity("pole0", "PoleKw");
	pole->setMaterialName("Examples/Chrome");
	Ogre::SceneNode *poleNode = m_pSceneMgr->getRootSceneNode()->createChildSceneNode("poleNode0");
	poleNode->attachObject(pole);
	poleNode->setPosition(Ogre::Vector3(4.5*width, 0,-4.5*width));
	poleNode->showBoundingBox(true);

	Ogre::Entity *pole2 = m_pSceneMgr->createEntity("pole10", "PoleKw");
	pole2->setMaterialName("Examples/OgreLogo");
	Ogre::SceneNode *poleNode2 = m_pSceneMgr->getRootSceneNode()->createChildSceneNode("poleNode10");
	poleNode2->attachObject(pole2);
	poleNode2->setPosition(Ogre::Vector3(-4.5*width-height, 0,-4.5*width));
	poleNode2->showBoundingBox(true);

	Ogre::Entity *pole3 = m_pSceneMgr->createEntity("pole20", "PoleKw");
	pole3->setMaterialName("Examples/OgreLogo");
	Ogre::SceneNode *poleNode3 = m_pSceneMgr->getRootSceneNode()->createChildSceneNode("poleNode20");
	poleNode3->attachObject(pole3);
	poleNode3->setPosition(Ogre::Vector3(-4.5*width-height, 0,4.5*width+height));
	poleNode3->showBoundingBox(true);

	Ogre::Entity *pole4 = m_pSceneMgr->createEntity("pole30", "PoleKw");
	pole4->setMaterialName("Examples/OgreLogo");
	Ogre::SceneNode *poleNode4 = m_pSceneMgr->getRootSceneNode()->createChildSceneNode("poleNode30");
	poleNode4->attachObject(pole4);
	poleNode4->setPosition(Ogre::Vector3(4.5*width , 0,4.5*width+height));
	poleNode4->showBoundingBox(true);

	for (int i=0; i<9; i++)
	{
		Ogre::Entity *pole = m_pSceneMgr->createEntity("pole"+Ogre::StringConverter::toString(i+1), "Pole");
		
		Ogre::SceneNode *poleNode = m_pSceneMgr->getRootSceneNode()->createChildSceneNode("poleNode"+Ogre::StringConverter::toString(i+1));
		poleNode->attachObject(pole);
		poleNode->setPosition(Ogre::Vector3(3.5*width-i*width, 0, -4.5*width));
		poleNode->showBoundingBox(true);
	}

		for (int i=0; i<9; i++)
	{
		Ogre::Entity *pole = m_pSceneMgr->createEntity("pole"+Ogre::StringConverter::toString(i+11), "Pole");
		
		Ogre::SceneNode *poleNode = m_pSceneMgr->getRootSceneNode()->createChildSceneNode("poleNode"+Ogre::StringConverter::toString(i+11));
		poleNode->attachObject(pole);
		poleNode->yaw(Ogre::Radian(Ogre::Math::PI/2.f));
		poleNode->setPosition(Ogre::Vector3(-4.5*width-height, 0, -1.8*width+i*width));
		poleNode->showBoundingBox(true);
	}

	for (int i=0; i<9; i++)
	{
		Ogre::Entity *pole = m_pSceneMgr->createEntity("pole"+Ogre::StringConverter::toString(i+21), "Pole");
		
		Ogre::SceneNode *poleNode = m_pSceneMgr->getRootSceneNode()->createChildSceneNode("poleNode"+Ogre::StringConverter::toString(i+21));
		poleNode->attachObject(pole);
		poleNode->yaw(Ogre::Radian(Ogre::Math::PI));
		poleNode->setPosition(Ogre::Vector3(-3.5*width+i*width, 0, 4.5*width+2*height));
		poleNode->showBoundingBox(true);
	}

	for (int i=0; i<9; i++)
	{
		Ogre::Entity *pole = m_pSceneMgr->createEntity("pole"+Ogre::StringConverter::toString(i+31), "Pole");
		
		Ogre::SceneNode *poleNode = m_pSceneMgr->getRootSceneNode()->createChildSceneNode("poleNode"+Ogre::StringConverter::toString(i+31));
		poleNode->attachObject(pole);
		poleNode->yaw(Ogre::Radian(-Ogre::Math::PI/2.f));
		poleNode->setPosition(Ogre::Vector3(4.5*width+height, 0, 5.2*width-i*width));
		poleNode->showBoundingBox(true);
	}

	
}
	void createScene()
	{ 

		 mSceneMgr->setAmbientLight(Ogre::ColourValue(1.0, 1.0, 1.0));

		 
	/*			
		Ogre::Entity* entMesh01 = mSceneMgr->createEntity("MyEntity1","ogrehead.mesh");
		Ogre::SceneNode* nodeMesh01 = mSceneMgr->createSceneNode("NodeMesh01");
		mSceneMgr->getRootSceneNode()->addChild(nodeMesh01);
		nodeMesh01->setPosition(0.0,0.0,0.0);
		nodeMesh01->attachObject(entMesh01);
	*/	
		
		Ogre::Entity* ent01 = mSceneMgr->createEntity("MyEntity1","ejes01.mesh");
		Ogre::SceneNode* node01 = mSceneMgr->createSceneNode("Node01");
		mSceneMgr->getRootSceneNode()->addChild(node01);
		node01->attachObject(ent01);

		Ogre::Entity* ent02 = mSceneMgr->createEntity("MyEntity2","cuadriculaX01.mesh");
		Ogre::SceneNode* node02 = mSceneMgr->createSceneNode("Node02");
		mSceneMgr->getRootSceneNode()->addChild(node02);
		node02->attachObject(ent02);

		Ogre::SceneNode* nodeSinbad = mSceneMgr->createSceneNode("NodeSinbad");
		Ogre::SceneNode* nodeEjeSinbad = mSceneMgr->createSceneNode("NodeEjeSinbad");
		Ogre::SceneNode* nodeNinja = mSceneMgr->createSceneNode("NodeNinja");

		Ogre::Entity* entSinbad = mSceneMgr->createEntity("MyEntitySinbad","sinbad.mesh");
		Ogre::Entity* entEjeSinbad = mSceneMgr->createEntity("MyEntityEjeSinbad","ejes01.mesh");
		Ogre::Entity* entNinja = mSceneMgr->createEntity("MyEntityNinja","ninja.mesh");
		
		mSceneMgr->getRootSceneNode()->addChild(nodeEjeSinbad);
		nodeEjeSinbad->attachObject(entEjeSinbad);
		nodeEjeSinbad->addChild(nodeSinbad);
		nodeEjeSinbad->addChild(nodeNinja);


		nodeSinbad->attachObject(entSinbad);
		nodeNinja->attachObject(entNinja);

		//eje
		nodeEjeSinbad->setScale(0.6,0.6,0.6);
		nodeEjeSinbad->setPosition(5.0,0.0,0.0);
		nodeEjeSinbad->translate(2.0,0.0,2.0);
		nodeEjeSinbad->yaw(Ogre::Degree(45.0f)); //rota en Y
		//nodeEjeSinbad->pitch(Ogre::Degree(45.0f));//rota en X
		//nodeEjeSinbad->roll(Ogre::Degree(45.0f));//rota en Z

		//Hijo Sinbad
		nodeSinbad->setScale(0.8,0.8,0.8);
		nodeSinbad->translate(0.0,0.0,8.0,Ogre::Node::TS_WORLD);

		//Hijo Ninja
		nodeNinja->setScale(0.04,0.04,0.04);
		nodeNinja->yaw(Ogre::Degree(180.0f));
		nodeNinja->setPosition(4.0,-4.0,5.0);

		/*nodeSinbad->attachObject(entEjeSinbad);
		nodeSinbad->attachObject(ejeSinbad);
		*/

	}
Exemplo n.º 23
0
void CameraApp::createScene()
{
    /***************************************************************************/
    /* This create a scene with a textured plane and a penguin.  The camera    */
    /* is placed directly behind the penguin.  Both the camera and the penguin */
    /* are attached to the same scene node.  As a result, when the node is     */
    /* moved or rotated, the camera and the penguin move or rotate exactly the */
    /* same.  This gives you a first person camera that is always looking over */
    /* the shoulder of your character.                                         */
    /***************************************************************************/
    sceneMgr->setAmbientLight( Ogre::ColourValue( 1, 1, 1 ) );
    Ogre::Light *l = sceneMgr->createLight("MainLight");

    Ogre::Camera *camera = sceneMgr->createCamera("MainCam");
    camNode = sceneMgr->getRootSceneNode()->createChildSceneNode( "CameraNode" );
    camNode->attachObject(camera);
    camera->setPosition(0.0, 0.0, 0.0);

    int originX = -15;
    int distancebetween = 10;

    for (int i = 0; i < 4; i++)
    {
        Ogre::Entity *sinbadEntity = sceneMgr->createEntity("Sinbad" + i, "Sinbad.mesh");
        Ogre::SceneNode *sinbadNode = sceneMgr->getRootSceneNode()->createChildSceneNode("SinbadNode" + i);
        sinbadNode->attachObject(sinbadEntity);
        sinbadNode->setScale(1,1,1);
        sinbadNode->translate(originX + (distancebetween * i), 0, -40);
        switch (i)
        {
        case 1:
            sinbadNode->yaw(Ogre::Degree(90.0f));
            break;
        case 2:
            sinbadNode->pitch(Ogre::Degree(90.0f));

            break;
        case 3:
            sinbadNode->roll(Ogre::Degree(90.0f));
            break;
        }
    }

    Ogre::Entity *sinbadEntity = sceneMgr->createEntity("SinbadScaled", "Sinbad.mesh");
    Ogre::SceneNode *sinbadNode = sceneMgr->getRootSceneNode()->createChildSceneNode("SinbadScaledNode");
    sinbadNode->attachObject(sinbadEntity);
    sinbadNode->setScale(5,5,5);
    //sinbadNode->rotate(Ogre::Vector3(1,0,0), Ogre::Degree(90));
    //sinbadNode->rotate(Ogre::Vector3(0,0,1), Ogre::Degree(-90));
    sinbadNode->translate(0, 0, -60);



    Ogre::Viewport *vp = window->addViewport(camera);
    vp->setDimensions(0.0f, 0.0f, 1.0f, 1.0f);
    camera->setAspectRatio((float)vp->getActualWidth() / (float) vp->getActualHeight());
    camera->setFarClipDistance(1000.0f);
    camera->setNearClipDistance(5.0f);
    camera->lookAt(0,0,-10);
    setActiveCamera(camera);

    /*Ogre::Plane plane(Ogre::Vector3::UNIT_Y, -10);
    Ogre::MeshManager::getSingleton().createPlane("plane",
    	ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
    	1500, 1500, 20, 20, true, 1, 5, 5, Ogre::Vector3::UNIT_Z);
    Ogre::Entity *planeEntity = sceneMgr->createEntity("PlaneEntity", "plane");
    sceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(planeEntity);
    planeEntity->setMaterialName("Examples/BeachStones");*/



}
Exemplo n.º 24
0
void CsCameraManager::Update()  {
	static clock_t prevTime = clock();

	static Ogre::Vector3 lerpPos;
	static Ogre::Quaternion slerpRot;
	static float linLerpStep;
	static float angLerpStep;

	clock_t curTime = clock();
	float timeStep = (curTime - prevTime) / (float) CLOCKS_PER_SEC;
	
	Ogre::SceneNode* camNode = mCameraList[mCurrentCamera].second;
	
	// the interpolation ----------------------------------------
	// the current camera is not actually used, the default camera is used to approximate 
	// the current camera

	posA = mDefaultCamNode->_getDerivedPosition();
	rotA = mDefaultCamNode->_getDerivedOrientation();

	posB = camNode->_getDerivedPosition();
	rotB = camNode->_getDerivedOrientation();

	linLerpStep = 0.5 * timeStep / 0.12;	// reaches half i 0.3 seconds
	angLerpStep = 0.5 * timeStep / 0.12;

	// for fast moving targets
	if (mTargetObject) {
		float linear = mTargetObject->GetLinearVelocity().length();
		float angular = mTargetObject->GetAngularVelocity().length();

		if (linear > 200.0f) {
			linLerpStep += (linear - 150) / 300.0f;
			angLerpStep += (linear - 150) / 300.0f;
		}
		if (angular > 3.0f) {
			linLerpStep += (angular - 2.0f) / 8.0f;
			angLerpStep += (angular - 2.0f) / 8.0f;
		}
	}

	if (linLerpStep > 1.0f) linLerpStep = 0.90f;
	if (angLerpStep > 1.0f) angLerpStep = 0.90f;
	if (linLerpStep < 0.0f) linLerpStep = 0.1f;
	if (angLerpStep < 0.0f) angLerpStep = 0.1f;

	lerpPos = (posB - posA) * linLerpStep + posA;
	slerpRot = Ogre::Quaternion::Slerp(angLerpStep, rotA, rotB, true);

	mDefaultCamNode->setPosition(lerpPos);
	mDefaultCamNode->setOrientation(slerpRot);
	// ----------------------------------------------------------
	if (mCameraType[mCurrentCamera] == Chaos::ORBIT_CAMERA) 
	{
		Orbit(timeStep);
	}
	else if (mCameraType[mCurrentCamera] == Chaos::FREE_CAMERA) 
	{
		if ( mButtonState[Chaos::ARROW_UP]) camNode->translate(0,0,-timeStep * MOVE_SPEED, Ogre::Node::TS_LOCAL);
		if ( mButtonState[Chaos::ARROW_DOWN]) camNode->translate(0,0,timeStep * MOVE_SPEED, Ogre::Node::TS_LOCAL);
		if ( mButtonState[Chaos::ARROW_LEFT]) camNode->translate(-timeStep * MOVE_SPEED,0,0, Ogre::Node::TS_LOCAL);
		if ( mButtonState[Chaos::ARROW_RIGHT]) camNode->translate(timeStep * MOVE_SPEED,0,0, Ogre::Node::TS_LOCAL);

		if (xrel) camNode->yaw(Ogre::Radian(Ogre::Degree(-LOOK_SPEED * xrel * timeStep)), Ogre::Node::TS_WORLD);
		if (yrel) camNode->pitch(Ogre::Radian(Ogre::Degree(-LOOK_SPEED * yrel * timeStep)), Ogre::Node::TS_LOCAL);
	}


	xrel = yrel = zrel = 0;
	prevTime = curTime;
}
void CViewManagerView::On3dViews()
{
	int ViewIndex = CMFCRibbonGallery::GetLastSelectedItem(ID_3DVIEWS);
	CEngine *Engine = ((CViewManagerApp*)AfxGetApp())->m_Engine;
	Ogre::Root *Root = Engine->GetRoot();
	m_SceneManager->_updateSceneGraph(m_Camera);
	Ogre::SceneNode *CubeNode = m_SceneManager->getSceneNode("Cube");

	Ogre::AxisAlignedBox Box = m_SceneManager->getRootSceneNode()->_getWorldAABB();
	Ogre::Vector3 Center = Box.getCenter();
	Ogre::Vector3 Position;
	Ogre::Vector3 Destination;

	switch (ViewIndex)
	{
		case 0: //top

			Position = Center;
			Position.y += 4.0 * Box.getSize().y;
			Destination = Center;

		break;
		case 1://bottom
			
			Position = Center;
			Position.y -= 4.0 * Box.getSize().y;
			Destination = Center;

		break;
		case 2:

			Position = Center;
			Position.x += 4.0 * Box.getSize().x;
			Destination = Center;

		break;
		case 3:

			Position = Center;
			Position.x -= 4.0 * Box.getSize().x;
			Destination = Center;

		break;
		case 4:

			Position = Center;
			Position.z -= 4.0 * Box.getSize().z;
			Destination = Center;

		break;
		case 5:

			Position = Center;
			Position.z += 4.0 * Box.getSize().z;
			Destination = Center;

		break;

		case 9:

			CubeNode->roll(Ogre::Radian(-atan(sin(Ogre::Math::PI/4.0))));
			CubeNode->yaw(Ogre::Radian(Ogre::Math::PI/4.0));
			Destination = Center;
			Position = m_Camera->getPosition();

		break;
	}

	m_Camera->setPosition(Position);
	m_Camera->lookAt(Destination);
	Root->renderOneFrame();
}
Exemplo n.º 26
0
Tank* TankManager::createTank(const Ogre::Vector3& position, int side, Graph* pathFindingGraph, PathFinding mPathFinder){
	int tankNumber = tankSideA.size() + tankSideB.size();
	std::ostringstream oss1;
	oss1 << "tankbody" << tankNumber;

	Ogre::Entity* tankBody = mSceneMgr->createEntity(oss1.str(), "lpbody.mesh");
	tankBody->setCastShadows(true);

	std::ostringstream oss2;
	oss2 << "tankturret" << tankNumber;

	// Create tank turret entity
	Ogre::Entity* tankTurret = mSceneMgr->createEntity(oss2.str(), "lpturret.mesh");
	tankTurret->setCastShadows(true);

	std::ostringstream oss3;
	oss3 << "tankbarrel" << tankNumber;

	// Create tank barrel entity
	Ogre::Entity* tankBarrel = mSceneMgr->createEntity(oss3.str(), "lpbarrel.mesh");
	tankBarrel->setCastShadows(true);

	// Create a child scene node and attach tank body to it
	Ogre::SceneNode* mTankBodyNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
	mTankBodyNode->attachObject(tankBody);
	// Move it above the ground
	mTankBodyNode->translate(position.x, position.y + 13.f, position.z);

	if(side == 1){
		tankBody->setMaterialName("lp_tank_materialred");
		tankTurret->setMaterialName("lp_tank_materialred");
		tankBarrel->setMaterialName("lp_tank_materialred");

		mTankBodyNode->yaw(Ogre::Degree(180.f));
	}
	else if(side == 2)
	{
		tankBody->setMaterialName("lp_tank_materialblue");
		tankTurret->setMaterialName("lp_tank_materialblue");
		tankBarrel->setMaterialName("lp_tank_materialblue");
	}

	// Create a child scene node from tank body's scene node and attach the tank turret to it
	Ogre::SceneNode* mTankTurretNode = mTankBodyNode->createChildSceneNode();
	mTankTurretNode->attachObject(tankTurret);
	// Move it above tank body
	mTankTurretNode->translate(0.f, 3.f, 0.f);

	// Create a child scene node from tank turret's scene node and attach the tank barrel to it
	Ogre::SceneNode* mTankBarrelNode = mTankTurretNode->createChildSceneNode();
	mTankBarrelNode->attachObject(tankBarrel);
	// Move it to the appropriate position on the turret
	mTankBarrelNode->translate(-30.f, 10.f, -1.5f);

	//WEE ADDED HERE TO MAKE THE MANUAL OBJECT
		std::string pathName = "AStarPath" + std::to_string(tankNumber);
		Ogre::ManualObject* aStarPath = mSceneMgr->createManualObject(pathName);
		aStarPath->clear();
		aStarPath->setQueryFlags(0);
		mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(aStarPath);

	Tank* newTank = new Tank(mSceneMgr->createBillboardSet(), mSceneMgr->createBillboardSet(),
		mTankBodyNode, mTankTurretNode, mTankBarrelNode, this, pathFindingGraph, mPathFinder, aStarPath, side, mSceneMgr, tankBody, tankTurret, tankBarrel);

	newTank->resetAll();
	
	if (side == 1)
	{
		tankSideA.insert(newTank);
	} else if(side == 2){
		tankSideB.insert(newTank);
	}

	return newTank;
}
Exemplo n.º 27
0
int OgreOculus::go(void)
{
	// Create Root object
	root = new Ogre::Root("plugin.cfg", "ogre.cfg");

	// OpenGL
    root->loadPlugin("RenderSystem_GL_d");
    root->setRenderSystem(root->getRenderSystemByName("OpenGL Rendering Subsystem"));

	// Initialize Root
	root->initialise(false);

	// Initialize Oculus
	ovrHmd hmd;
	ovrHmdDesc hmdDesc;
	ovrGraphicsLuid luid;
	ovr_Initialize(nullptr);
	if(ovr_Create(&hmd, &luid) != ovrSuccess)
		exit(-1);
	hmdDesc = ovr_GetHmdDesc(hmd);
	if(ovr_ConfigureTracking(hmd,
		ovrTrackingCap_Orientation |ovrTrackingCap_MagYawCorrection |ovrTrackingCap_Position,
		0) != ovrSuccess)
		exit(-2);

	// Turn off HUD
	ovr_SetInt(hmd, "PerfHudMode", ovrPerfHud_Off);

	// Create a window
	window = root->createRenderWindow("Ogre + Oculus = <3", hmdDesc.Resolution.w/2, hmdDesc.Resolution.h/2, false);

	// Create scene manager and cameras
	smgr = root->createSceneManager(Ogre::ST_GENERIC);

	// Load Ogre resource paths from config file
    Ogre::ConfigFile cf;
    cf.load("resources_d.cfg");

    // Go through all sections & settings in the file and add resources
    Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();

    Ogre::String secName, typeName, archName;
    while (seci.hasMoreElements())
    {
        secName = seci.peekNextKey();
        Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
        Ogre::ConfigFile::SettingsMultiMap::iterator i;
        for (i = settings->begin(); i != settings->end(); ++i)
        {
            typeName = i->first;
            archName = i->second;

            Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
                archName, typeName, secName);
        }
    }

	// Set resources
	Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
	Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

	// Create the model itself via OgreModel.cpp
	createOgreModel(smgr);

	// Create camera
	createCamera();

	// Set viewport and background color
	Ogre::Viewport* vp = window->addViewport(mCamera);
	vp->setBackgroundColour(Ogre::ColourValue(34, 89, 0)); // Yellow

	// Set aspect ratio
	mCamera->setAspectRatio(
    Ogre::Real(vp->getActualWidth()) /
    Ogre::Real(vp->getActualHeight()));

	// Initialize glew
	if(glewInit() != GLEW_OK)
		exit(-3);

	// Get texture sizes
	ovrSizei texSizeL, texSizeR;
	texSizeL = ovr_GetFovTextureSize(hmd, ovrEye_Left, hmdDesc.DefaultEyeFov[left], 1);
	texSizeR = ovr_GetFovTextureSize(hmd, ovrEye_Right, hmdDesc.DefaultEyeFov[right], 1);

	// Calculate render buffer size
	ovrSizei bufferSize;
	bufferSize.w = texSizeL.w + texSizeR.w;
	bufferSize.h = max(texSizeL.h, texSizeR.h);

	// Create render texture set
	ovrSwapTextureSet* textureSet;
	if(ovr_CreateSwapTextureSetGL(hmd, GL_RGB, bufferSize.w, bufferSize.h, &textureSet) != ovrSuccess)
		exit(-4);

	// Create Ogre render texture
	Ogre::GLTextureManager* textureManager = static_cast<Ogre::GLTextureManager*>(Ogre::GLTextureManager::getSingletonPtr());
	Ogre::TexturePtr rtt_texture(textureManager->createManual("RttTex", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
		Ogre::TEX_TYPE_2D, bufferSize.w, bufferSize.h, 0, Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET));
	Ogre::RenderTexture* rttEyes = rtt_texture->getBuffer(0, 0)->getRenderTarget();
	Ogre::GLTexture* gltex = static_cast<Ogre::GLTexture*>(Ogre::GLTextureManager::getSingleton().getByName("RttTex").getPointer());
	GLuint renderTextureID = gltex->getGLID();

	// Put camera viewport on the ogre render texture
	Ogre::Viewport* vpts[nbEyes];
	vpts[left]=rttEyes->addViewport(cams[left], 0, 0, 0, 0.5f);
	vpts[right]=rttEyes->addViewport(cams[right], 1, 0.5f, 0, 0.5f);
	vpts[left]->setBackgroundColour(Ogre::ColourValue(34, 89, 0)); // Black background
	vpts[right]->setBackgroundColour(Ogre::ColourValue(34, 89, 0));

	ovrTexture* mirrorTexture;
	if(ovr_CreateMirrorTextureGL(hmd, GL_RGB, hmdDesc.Resolution.w, hmdDesc.Resolution.h, &mirrorTexture) != ovrSuccess)
		exit(-5);
	Ogre::TexturePtr mirror_texture(textureManager->createManual("MirrorTex", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
		Ogre::TEX_TYPE_2D, hmdDesc.Resolution.w, hmdDesc.Resolution.h, 0, Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET));

	// Get GLIDs
	GLuint ogreMirrorTextureID = static_cast<Ogre::GLTexture*>(Ogre::GLTextureManager::getSingleton().getByName("MirrorTex").getPointer())->getGLID();
	GLuint oculusMirrorTextureID = ((ovrGLTexture*)mirrorTexture)->OGL.TexId;

	// Create EyeRenderDesc
	ovrEyeRenderDesc EyeRenderDesc[nbEyes];
	EyeRenderDesc[left] = ovr_GetRenderDesc(hmd, ovrEye_Left, hmdDesc.DefaultEyeFov[left]);
	EyeRenderDesc[right] = ovr_GetRenderDesc(hmd, ovrEye_Right, hmdDesc.DefaultEyeFov[right]);

	// Get offsets
	ovrVector3f offset[nbEyes];
	offset[left]=EyeRenderDesc[left].HmdToEyeViewOffset;
	offset[right]=EyeRenderDesc[right].HmdToEyeViewOffset;

	// Compositor layer
	ovrLayerEyeFov layer;
	layer.Header.Type = ovrLayerType_EyeFov;
	layer.Header.Flags = 0;
	layer.ColorTexture[left] = textureSet;
	layer.ColorTexture[right] = textureSet;
	layer.Fov[left] = EyeRenderDesc[left].Fov;
	layer.Fov[right] = EyeRenderDesc[right].Fov;
	layer.Viewport[left] = OVR::Recti(0, 0, bufferSize.w/2, bufferSize.h);
	layer.Viewport[right] = OVR::Recti(bufferSize.w/2, 0, bufferSize.w/2, bufferSize.h);

	// Get projection matrices
	for(size_t eyeIndex(0); eyeIndex < ovrEye_Count; eyeIndex++)
	{
		// Get the projection matrix
		OVR::Matrix4f proj = ovrMatrix4f_Projection(EyeRenderDesc[eyeIndex].Fov,
			static_cast<float>(0.01f),
			4000,
			true);

		// Convert it to Ogre matrix
		Ogre::Matrix4 OgreProj;
		for(size_t x(0); x < 4; x++)
			for(size_t y(0); y < 4; y++)
				OgreProj[x][y] = proj.M[x][y];

		// Set the matrix
		cams[eyeIndex]->setCustomProjectionMatrix(true, OgreProj);
	}

	// Variables for render loop
	bool render(true);
	ovrFrameTiming hmdFrameTiming;
	ovrTrackingState ts;
	OVR::Posef pose;
	ovrLayerHeader* layers;

	// Create event listener for handling user input
	createEventListener();

	//Run physics loop in a new thread
	std::map<Ogre::Entity*, Ogre::Vector3> positionRequests;
	std::map<Ogre::Entity*, std::string> animationRequests;
	std::map<Ogre::Entity*, std::vector<int>> rotationRequests;
	std::map<std::string, std::string> message;
	std::thread physicsThread(physicsLoop, smgr, &message, &positionRequests, &animationRequests, &rotationRequests);

	// Render loop
	while(render)
	{
		// Suspend physics loop and perform requested movement/rotations/animations
		if(positionRequests.size() > 0 || animationRequests.size() > 0 || rotationRequests.size() > 0){
			message.insert(std::pair<std::string, std::string>("", ""));
		
			for(auto const &request : positionRequests) {
				Ogre::Vector3 pos = request.second;
				Ogre::SceneNode* sceneNode = request.first->getParentSceneNode();
				sceneNode->setPosition(pos);
			}

			for(auto const &request : animationRequests) {
				request.first->getAnimationState(request.second)->addTime(0.1);
			}

			for(auto const &request : rotationRequests) {
				Ogre::SceneNode* sceneNode = request.first->getParentSceneNode();
				sceneNode->roll(Ogre::Degree(request.second[0]));
				sceneNode->pitch(Ogre::Degree(request.second[1]));
				sceneNode->yaw(Ogre::Degree(request.second[2]));
			}

			positionRequests.clear();
			animationRequests.clear();
			rotationRequests.clear();

			// Resume physics loop
			message.clear();
		}

		// Update Ogre window
		Ogre::WindowEventUtilities::messagePump();

		// Advance textureset index
		textureSet->CurrentIndex = (textureSet->CurrentIndex + 1) % textureSet->TextureCount;
		
		// Capture user input
		mKeyboard->capture();
		mMouse->capture();

		// Movement calculations
		mPlayerNode->translate(mDirection, Ogre::Node::TS_LOCAL);
		hmdFrameTiming = ovr_GetFrameTiming(hmd, 0);
		ts = ovr_GetTrackingState(hmd, hmdFrameTiming.DisplayMidpointSeconds);
		pose = ts.HeadPose.ThePose;
		ovr_CalcEyePoses(pose, offset, layer.RenderPose);
		oculusOrient = pose.Rotation;
		oculusPos = pose.Translation;
		mHeadNode->setOrientation(Ogre::Quaternion(oculusOrient.w, oculusOrient.x, oculusOrient.y, oculusOrient.z) * initialOculusOrientation.Inverse());
		
		// Apply head tracking
		mHeadNode->setPosition(headPositionTrackingSensitivity * Ogre::Vector3(oculusPos.x, oculusPos.y,oculusPos.z));
		
		// Update Ogre viewports
		root->_fireFrameRenderingQueued();
		vpts[left]->update();
		vpts[right]->update();

		// Copy the rendered image to the Oculus Swap Texture
		glCopyImageSubData(renderTextureID, GL_TEXTURE_2D, 0, 0, 0, 0,
		((ovrGLTexture*)(&textureSet->Textures[textureSet->CurrentIndex]))->OGL.TexId, GL_TEXTURE_2D, 0, 0, 0, 0,
		bufferSize.w,bufferSize.h, 1);
		layers = &layer.Header;

		// Submit new frame to the Oculus and update window
		ovr_SubmitFrame(hmd, 0, nullptr, &layers, 1);
		window->update();

		// Exit loop when window is closed
		if(window->isClosed()) render = false;
	}

	// Shud down Oculus
	ovr_Destroy(hmd);
	ovr_Shutdown();

	// Delete Ogre root and return
	delete root;
	return EXIT_SUCCESS;
}
Exemplo n.º 28
0
//-------------------------------------------------------------------------------------
void Cenario::iniciarCenario(){

	// Crio um nó filho do nó raiz na hierarquia de cena
	Cenario::cenarioNode = Bomberman::getInstance()->mSceneMgr->getRootSceneNode()->createChildSceneNode("cenarioNode");

	//Posiciona o Nó
	Cenario::cenarioNode->setPosition( Ogre::Vector3(0,0,0) );

	Ogre::Entity* campoEntity = Bomberman::getInstance()->mSceneMgr->createEntity("cenario", "scenario_green.mesh");

    Ogre::SceneNode * campo = Bomberman::getInstance()->mSceneMgr->getRootSceneNode()->createChildSceneNode( "campo" );
    campo->attachObject(campoEntity);
	campo->setPosition(6,-0.5f,-7);
	campo->setScale( 10.0f, 10.0f, 10.0f );
	campo->pitch( Ogre::Degree( -90 ) );


	Ogre::SceneNode* elementoNode;
	Ogre::Entity* elementoEntidade;

	for( int i = 0; i < LINHAS; i++ ){
		for( int j = 0; j < COLUNAS; j++){
			Ogre::String nomeEntidade, nomeCenarioNode;

			Square square = Cenario::criarSquare( i, j, &nomeCenarioNode, &nomeEntidade );

			switch( Cenario::cenario[i][j] ){
			case 'X':
				elementoNode = Cenario::cenarioNode->createChildSceneNode( nomeCenarioNode );

				elementoEntidade = Bomberman::getInstance()->mSceneMgr->createEntity( nomeEntidade, "block_hard.mesh" );
				elementoEntidade->setCastShadows(true);
				
				elementoNode->setPosition( Ogre::Vector3( i, 0, j * - 1 ) );
				elementoNode->attachObject( elementoEntidade );
				elementoNode->setScale( 0.5f, 0.5f, 0.5f );
				break;
			case 'B':
				elementoNode = Cenario::cenarioNode->createChildSceneNode( nomeCenarioNode );

				elementoEntidade = Bomberman::getInstance()->mSceneMgr->createEntity( nomeEntidade, "block_normal.mesh" );
				elementoEntidade->setCastShadows(true);
				
				elementoNode->setPosition( Ogre::Vector3( i, 0, j * - 1 ) );
				elementoNode->attachObject( elementoEntidade );
				elementoNode->setScale( 0.5f, 0.5f, 0.5f );
				

				break;
			case 'H':
				elementoNode = Cenario::cenarioNode->createChildSceneNode( "bomberman_node" );

				elementoEntidade = Bomberman::getInstance()->mSceneMgr->createEntity( "bomberman", "bomberman.mesh" );
				elementoEntidade->setCastShadows(true);

				elementoNode->setPosition( Ogre::Vector3( i, 0.5f, j * - 1 ) );
				elementoNode->attachObject( elementoEntidade );
				elementoNode->setScale( 0.3f, 0.3f, 0.3f );
				elementoNode->yaw( Ogre::Degree( 180 ) );

				break;
			}

			Cenario::cenarioSquare[i][j] = square;
		}
	}

}
Exemplo n.º 29
0
	void createScene()
	{
		/*Ogre::Entity* ent = mSceneMgr->createEntity("MyEntity","Sinbad.mesh");
		Ogre::Entity* ent2 = mSceneMgr->createEntity("MyEntity2","Sinbad.mesh");
		Ogre::Entity* ent3 = mSceneMgr->createEntity("MyEntity3","Sinbad.mesh");
		Ogre::Entity* ent4 = mSceneMgr->createEntity("MyEntity4","Sinbad.mesh");*/
		/*Ogre::SceneNode* node1 = mSceneMgr->createSceneNode("Node1");
		Ogre::SceneNode* node2 = mSceneMgr->createSceneNode("Node2");
		Ogre::SceneNode* node3 = mSceneMgr->createSceneNode("Node3");
		Ogre::SceneNode* node4 = mSceneMgr->createSceneNode("Node4");*/
		
       /* node1->setPosition(10,10,0);
		mSceneMgr->getRootSceneNode()->addChild(node1);

		node2->setPosition(10,0,0);
		node2->pitch(Ogre::Radian(Ogre::Math::HALF_PI));
		node1->addChild(node2);
        node2->attachObject(ent2);

		node3->translate(20,0,0); 
		node3->yaw(Ogre::Degree(90.0f)); 
		node1->addChild(node3);
        node3->attachObject(ent3);

		node4->setPosition(30,0,0); 
		node4->roll(Ogre::Radian(Ogre::Math::HALF_PI)); 
		node1->addChild(node4);
		node1->attachObject(ent);
		
		node4->attachObject(ent4);*/

		/*mSceneMgr->getRootSceneNode()->addChild(node1);
		node1->setPosition(0,0,0);
		node1->attachObject(ent);

		node1->addChild(node2);
		node2->translate(10,0,0);
		node2->pitch(Ogre::Degree(90.0f));
		node2->attachObject(ent2);

		node2->addChild(node3);
		node3->translate(10,0,0);
		node3->pitch(Ogre::Degree(-90.0f));
		node3->yaw(Ogre::Radian(Math::HALF_PI));
		node3->attachObject(ent3);

		node3->addChild(node4);
		node4->translate(0,0,10);
		node4->yaw(Ogre::Degree(-90.0f));
		node4->roll(Ogre::Degree(90.0f));
		node4->attachObject(ent4);*/
		
	/*	Ogre::SceneNode* node = mSceneMgr->createSceneNode("Node1"); 
		node->setPosition(10,10,0); 
		mSceneMgr->getRootSceneNode()->addChild(node); 
		node->attachObject(ent);

		Ogre::SceneNode* node2 = node->createChildSceneNode("node2"); 
		node2->setPosition(10,0,0); 
		node2->attachObject(ent2);
		node2->scale(2.0f,2.0f,2.0f);

		Ogre::SceneNode* node3 = node->createChildSceneNode("node3",Ogre::Vector3(20,0,0));
		node3->scale(0.2f,0.2f,0.2f);
		node3->attachObject(ent3);*/

		Ogre::Entity* ent = mSceneMgr->createEntity("MyEntity","Sinbad.mesh");
        Ogre::SceneNode* node = mSceneMgr->createSceneNode("Node1");
        node->setPosition(0,0,400);
        node->yaw(Ogre::Degree(180.0f));
        mSceneMgr->getRootSceneNode()->addChild(node);
        node->attachObject(ent);

		Ogre::Entity* ent2 = mSceneMgr->createEntity("MyEntity2","Sinbad.mesh");
        Ogre::SceneNode* node2 = node->createChildSceneNode("node2");
        node2->yaw(Ogre::Degree(45.0f));
        node2->translate(0,0,20);
        node2->attachObject(ent2);

		Ogre::Entity* ent3 = mSceneMgr->createEntity("MyEntity3","Sinbad.mesh");
        Ogre::SceneNode* node3 = node->createChildSceneNode("node3");
        node3->yaw(Ogre::Degree(45.0f));
        node3->translate(0,0,20,Ogre::Node::TS_LOCAL);
        node3->attachObject(ent3);
	}
Exemplo n.º 30
0
Ogre::Entity*
StageFile::GetModel( const StageInfo& info )
{
    //DumpSettings("exported/" + info.data.name + ".lua");

    VectorTexForGen textures;
    Ogre::MeshPtr mesh = Ogre::MeshManager::getSingleton().create(info.data.name + "export", "General");
    Ogre::SkeletonPtr skeleton = Ogre::SkeletonManager::getSingleton().create(info.data.name + "export", "General");

    u32 number_of_files = GetU32LE(0);
    LOGGER->Log("Number of file " + IntToString(number_of_files) + "\n");



    Ogre::Bone* root1 = skeleton->createBone( "0", 0 );
    Ogre::Bone* root2 = skeleton->createBone( "1", 1 );
    root1->addChild( root2 );

    Ogre::Animation* anim = skeleton->createAnimation( "Idle", 1 );
    Ogre::NodeAnimationTrack* track1 = anim->createNodeTrack( 0, root1 );
    track1->removeAllKeyFrames();
    Ogre::TransformKeyFrame* frame1 = track1->createNodeKeyFrame( 0 );
    Ogre::Matrix3 matrix;
    matrix.FromEulerAnglesYXZ( Ogre::Radian( Ogre::Degree( 0 ) ), Ogre::Radian( Ogre::Degree( -90 ) ), Ogre::Radian( Ogre::Degree( 0 ) ) );
    Ogre::Quaternion rot;
    rot.FromRotationMatrix( matrix );
    frame1->setRotation( rot );



    for (u32 i = 1; i < number_of_files - 1; ++i)
    {
        int offset_to_vertex = GetU32LE(0x04 + i * 0x04);
        MeshExtractor(info.data, "ffvii/battle_stage/" + info.data.name, this, offset_to_vertex, textures, mesh, Ogre::StringConverter::toString(i), 1);
    }



    // <OGRE> ///////////////////////////////
    skeleton->optimiseAllAnimations();
    Ogre::SkeletonSerializer skeleton_serializer;
    skeleton_serializer.exportSkeleton(skeleton.getPointer(), "exported/models/ffvii/battle/stages/" + info.data.name + ".skeleton");

    // Update bounds
    Ogre::AxisAlignedBox aabb(-999, -999, -999, 999, 999, 999);
    mesh->_setBounds(aabb, false);
    mesh->_setBoundingSphereRadius(999);

    mesh->setSkeletonName( "models/ffvii/battle/stages/" + info.data.name + ".skeleton" );

    Ogre::MeshSerializer ser;
    ser.exportMesh(mesh.getPointer(), "exported/models/ffvii/battle/stages/" + info.data.name + ".mesh");



    // create and export textures for model
    if( textures.size() > 0 )
    {
        int number_of_files = GetU32LE( 0x00 );
        int offset_to_texture = GetU32LE( number_of_files * 0x04 );
        Vram* vram = Vram::MakeInstance().release();

        LoadTimFileToVram( this, offset_to_texture, vram );
        //vram->Save( "qqq" );
        CreateTexture( vram, info.data, "exported/models/ffvii/battle/stages/" + info.data.name + ".png", textures );
        delete vram;
    }



    CreateMaterial("ffvii/battle_stage/" + info.data.name, "exported/models/ffvii/battle/stages/" + info.data.name + ".material", "models/ffvii/battle/stages/" + info.data.name + ".png", "", "");



    Ogre::SceneManager* scene_manager = Ogre::Root::getSingleton().getSceneManager( "Scene" );
    Ogre::Entity* thisEntity = scene_manager->createEntity( info.data.name, "models/ffvii/battle/stages/" + info.data.name + ".mesh" );
    //thisEntity->setDisplaySkeleton(true);
    //thisEntity->setDebugDisplayEnabled(true);
    thisEntity->setVisible(false);
    thisEntity->getAnimationState( "Idle" )->setEnabled( true );
    thisEntity->getAnimationState( "Idle" )->setLoop( true );
    Ogre::SceneNode* thisSceneNode = scene_manager->getRootSceneNode()->createChildSceneNode();
    thisSceneNode->setPosition( 0, 0, 0 );
    thisSceneNode->roll( Ogre::Radian( Ogre::Degree( 180.0f ) ) );
    thisSceneNode->yaw( Ogre::Radian( Ogre::Degree( 120.0f ) ) );
    thisSceneNode->pitch( Ogre::Radian( Ogre::Degree( 90.0f ) ) );
    thisSceneNode->attachObject( thisEntity );

    return thisEntity;
}