Ejemplo n.º 1
0
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));
}
Ejemplo n.º 2
0
	void DemoKeeper::createEntities()
	{
#ifdef MYGUI_OGRE_PLATFORM
		Ogre::Entity* entity = getSceneManager()->createEntity("friend", "Mikki.mesh");
		Ogre::SceneNode* node = getSceneManager()->getRootSceneNode()->createChildSceneNode();
		node->attachObject(entity);
		node->setPosition(0, 0, 300);

		entity = getSceneManager()->createEntity("enemy", "Robot.mesh");
		node = getSceneManager()->getRootSceneNode()->createChildSceneNode();
		node->attachObject(entity);
		node->setPosition(0, 0, -300);
		//node->showBoundingBox(true);

		Ogre::MeshManager::getSingleton().createPlane(
			"FloorPlane", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
			Ogre::Plane(Ogre::Vector3::UNIT_Y, 0), 2000, 2000, 1, 1, true, 1, 1, 1, Ogre::Vector3::UNIT_Z);

		entity = getSceneManager()->createEntity("floor", "FloorPlane");
		entity->setMaterialName("Ground");
		node = getSceneManager()->getRootSceneNode()->createChildSceneNode();
		node->attachObject(entity);

		gRaySceneQuery = getSceneManager()->createRayQuery(Ogre::Ray());
#else
		MyGUI::LayoutManager::getInstance().loadLayout("Wallpaper.layout");
#endif
	}
Ejemplo n.º 3
0
void StencilShadowTest::setupContent()
{
    // turn ambient light off
    mSceneMgr->setAmbientLight(ColourValue(0.0, 0.0, 0.0));

    // turn on stencil shadows
    mSceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE);
    
    // add a couple lights
    Ogre::Light* light = mSceneMgr->createLight("Light1");
    light->setDiffuseColour(0.5f,0.4f,0.35f);
    light->setSpecularColour(0, 0, 0);
    light->setAttenuation(8000,1,0.0005,0);
    light->setPosition(220,100,0);
    light->setCastShadows(true);
    light->setType(Light::LT_POINT);
    light = mSceneMgr->createLight("Light2");
    light->setDiffuseColour(0.5f,0.4f,0.35f);
    light->setSpecularColour(0, 0, 0);
    light->setAttenuation(8000,1,0.0005,0);
    light->setPosition(220,100,-200);
    light->setCastShadows(true);
    light->setType(Light::LT_POINT);
    
    // create a ground plane to receive some shadows
    Plane pln = MovablePlane("plane");
    pln.normal = Vector3::UNIT_Y;
    pln.d = 107;
    MeshManager::getSingleton().createPlane("ground_plane",
        ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, pln,
        1500,1500,50,50,true,1,5,5,Vector3::UNIT_Z);
    Ogre::Entity* groundPlane = mSceneMgr->createEntity( "plane", "ground_plane" );
    groundPlane->setMaterialName("Examples/Rocky");
    groundPlane->setCastShadows(false);
    mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(groundPlane);

    // and a couple objects to cast the shadows
    Ogre::Entity* bar = mSceneMgr->createEntity( "barrel", "Barrel.mesh" );
    bar->setCastShadows(true);
    Ogre::SceneNode* barNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
    barNode->attachObject(bar);
    barNode->setScale(7,7,7);
    barNode->setPosition(Ogre::Vector3(0,-85,-320));
    Ogre::Entity* head = mSceneMgr->createEntity( "ogrehead", "ogrehead.mesh" );
    head->setCastShadows(true);
    Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
    headNode->attachObject(head);
    headNode->setPosition(Ogre::Vector3(-100,-80,-320));
    Ogre::Entity* torus = mSceneMgr->createEntity( "torus", "knot.mesh" );
    torus->setCastShadows(true);
    torus->setMaterialName("Examples/RustySteel");
    Ogre::SceneNode* torusNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
    torusNode->setScale(0.5,0.5,0.5);
    torusNode->attachObject(torus);
    torusNode->setPosition(Ogre::Vector3(100,-60,-320));
    
    // point the camera down a bit
    mCamera->pitch(Ogre::Degree(-20.f));
}
Ejemplo n.º 4
0
void OgreAppLogic::createCanvasCube(void)
{
	Ogre::SceneNode* mClockNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
	mClockNode->setPosition(-1.0, 0.5, 0);
	mClockNode->attachObject(createCubeMesh("ClockCube1", "CanvasClock1"));

					  mClockNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
	mClockNode->setPosition(1.0, 0.5, 0);
	mClockNode->attachObject(createCubeMesh("ClockCube2", "CanvasClock2"));
}
Ejemplo n.º 5
0
bool SimonSays::keyPressed( const OIS::KeyEvent &arg ) {
	bool ret = BaseApplication::keyPressed( arg );

	if (arg.key == KEY_START ) {
		if( !gameStarted ) {
			restartGame( true );
			gameStarted = true;
		}
		// (re-)starts the game
		if( turnEnded ) {
			restartGame( !correctOrder ); // if the order is correct, NO restart
		}
	} 

	if( !showMode && !turnEnded ) {
		if (arg.key == KEY_YELLOW) {
			Ogre::SceneNode* playerNode = mSceneMgr->getSceneNode("PlayerNode");
			playerNode->setPosition(0,20,0);
		} else if (arg.key == KEY_RED) {
			Ogre::SceneNode* playerNode = mSceneMgr->getSceneNode("PlayerNode");
			playerNode->setPosition(65,20,0);
		} else if (arg.key == KEY_BLUE) {
			Ogre::SceneNode* playerNode = mSceneMgr->getSceneNode("PlayerNode");
			playerNode->setPosition(0,20,65);
		} else if (arg.key == KEY_GREEN) {
			Ogre::SceneNode* playerNode = mSceneMgr->getSceneNode("PlayerNode");
			playerNode->setPosition(65,20,65);
		}

		// check key after moving the player
		if( playerOrder.size() > 0 ) {
			if( !checkKey(arg.key) ) {
				mSceneMgr->getLight("yellowSpot")->setVisible( false );
				mSceneMgr->getLight("redSpot")->setVisible( false );
				mSceneMgr->getLight("blueSpot")->setVisible( false );
				mSceneMgr->getLight("greenSpot")->setVisible( false );
				mSceneMgr->setAmbientLight(Ogre::ColourValue(1,0.2,0.2));
			};
		} 
		
		if( playerOrder.size() < 1 ) {
			mSceneMgr->getLight("yellowSpot")->setVisible( false );
			mSceneMgr->getLight("redSpot")->setVisible( false );
			mSceneMgr->getLight("blueSpot")->setVisible( false );
			mSceneMgr->getLight("greenSpot")->setVisible( false );
			mSceneMgr->getEntity("Player")->setVisible( false );
			mSceneMgr->setAmbientLight(Ogre::ColourValue(0.2,1,0.2));
		}

	} // eof !showMode

	return ret;
}
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);
}
Ejemplo n.º 7
0
GameEntity* SphereFactory::make(const rapidjson::Value& jsonobj, SpaceObject*spaceobj){

  // Create the sphere
  Ogre::Entity* entity = game_manager->GetSceneManager()->createEntity(jsonobj["name"].GetString(), Ogre::SceneManager::PT_SPHERE);
  entity->setMaterialName(jsonobj["material"].GetString());

  // Create a SceneNode and attach the Entity to it
  Ogre::SceneNode *node = game_manager->GetSceneManager()->getRootSceneNode()->createChildSceneNode(jsonobj["name"].GetString());
  node->attachObject(entity);

  // Set the node's position
  Eigen::Vector3f positionVec=spaceobj->position.cast<float>();
  node->setPosition(Ogre::Vector3( static_cast<Ogre::Real*>(positionVec.data()) ));

  // Set the node's orientation
  Eigen::Vector4f attitudeVec=spaceobj->attitude.coeffs().cast<float>();
  node->setOrientation(Ogre::Quaternion(static_cast<Ogre::Real*>(attitudeVec.data()) ));

  // Scale the sphere
  node->scale( jsonobj["scale"][0u].GetDouble(), jsonobj["scale"][1u].GetDouble(),jsonobj["scale"][2u].GetDouble() );

  GameEntity*game_entity=new GameEntity(spaceobj,entity,node);
  this->game_manager->add_allocated_object(game_entity);

  return game_entity;
}
Ejemplo n.º 8
0
void QOgreWindow::createScene()
{
    // Put anything in here, I'll just put a plane and a dragon here for testing purposes. Go crazy.

    // Plane
    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* ground = oSceneMgr->createEntity("ground");
    oSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ground);
    ground->setCastShadows(false);
    ground->setMaterialName("Examples/Rockwall");

    // Dragon Mesh
    oSceneMgr->setAmbientLight(Ogre::ColourValue(0.5,0.5,0.5));
    Ogre::Entity* ogreHead = oSceneMgr->createEntity("Icosphere.mesh");
    Ogre::SceneNode* node = oSceneMgr->getRootSceneNode()->createChildSceneNode();

    node->attachObject(ogreHead);
    node->setPosition(0.0,70.0,0.0);

    Ogre::Light* light = oSceneMgr->createLight("MainLight");
    light->setPosition(20, 80, 50);
}
Ejemplo n.º 9
0
bool BallApp::frameStarted(const Ogre::FrameEvent &evt) {
  bool result = BaseApplication::frameStarted(evt);
  if (mPhysics != NULL) {
    btDiscreteDynamicsWorld* world = mPhysics->getDynamicsWorld();
    world->stepSimulation(1.0f/60.0f);

    btAlignedObjectArray<btCollisionObject*> objs = world->getCollisionObjectArray();
    for (int i = 0; i < objs.size(); i++) {
      btCollisionObject *obj = objs[i];
      btRigidBody *body = btRigidBody::upcast(obj);
      
      if (body && body->getMotionState()) {
        btTransform trans;
        body->getMotionState()->getWorldTransform(trans);
        
        void *userPointer = body->getUserPointer();
        if (userPointer) {
          btQuaternion orientation = trans.getRotation();
          Ogre::SceneNode *sceneNode = static_cast<Ogre::SceneNode *>(userPointer);
          sceneNode->setPosition(Ogre::Vector3(trans.getOrigin().getX(), trans.getOrigin().getY(), trans.getOrigin().getZ()));
          sceneNode->setOrientation(Ogre::Quaternion(orientation.getW(), orientation.getX(), orientation.getY(), orientation.getZ()));
        }
      }
    }
  }

  return result;
}
Ejemplo n.º 10
0
void OgreBase::addNode(const std::string &name, const std::string &mesh, Ogre::Real x, Ogre::Real y, Ogre::Real z){
    // "ogrehead.mesh"
    Ogre::Entity* entity = mSceneMgr->createEntity(name, mesh);
    Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
    node->setPosition(x, y, z);
    node->attachObject(entity);
}
void TutorialApplication::summonEvilBall() {
    Ogre::Entity* ball = mSceneMgr->createEntity("evilBall");
	ball->setMaterialName("Ogre/Skin");

	Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
    node->setPosition(Ogre::Vector3(Ogre::Math::SymmetricRandom() * (AREA_RANGE/2),
                                    Ogre::Math::SymmetricRandom() * (AREA_RANGE/2),
                                    Ogre::Math::SymmetricRandom() * (AREA_RANGE/2)));
	node->attachObject(ball);

    ShipProject::GameObject* oBall = new ShipProject::GameObject(ball, 2);
    oBall->SetupCollision(new btSphereShape(BALL_RADIUS), CollisionGroup::BALLS, CollisionGroup::PLAYER | CollisionGroup::WALLS 
                                                   | CollisionGroup::BALLS | CollisionGroup::PROJECTILES_PLAYER);
    objects_.push_back( oBall );

    if (Ogre::Math::UnitRandom() < 0.5) {
        oBall->body()->setLinearVelocity( btVector3(Ogre::Math::SymmetricRandom(), 
                                                    Ogre::Math::SymmetricRandom(), 
                                                    Ogre::Math::SymmetricRandom()) * Ogre::Math::RangeRandom(0.0, 70.0) );
    }
    oBall->body()->setRestitution(1.0);
    oBall->body()->activate(true);
    
    enemies_[oBall->entity_name()] = Enemy(oBall, Ogre::Math::UnitRandom() * 5);
}
Ejemplo n.º 12
0
void Application::createSceneSet1()
{
	int sNumber = 0;

	Ogre::Entity* groundEntity = m_sceneManager->createEntity( "Ground1", "ground.mesh" );
	Ogre::SceneNode* groundSceneNode = m_sceneManager->getRootSceneNode()->createChildSceneNode();
	groundSceneNode->attachObject( groundEntity );
	groundSceneNode->setPosition(Ogre::Vector3(0, 0, DISTANCE_TO_ANOTHER * sNumber * -1));
	groundSceneNode->setScale( ROW_WIDTH, 1, ROW_HEIGHT );

	/*
	Ogre::ParticleSystem* pTest1 = m_sceneManager->createParticleSystem("pFireworks", "Examples/Fireworks");
	Ogre::SceneNode* pTest1SceneNode = m_sceneManager->getRootSceneNode()->createChildSceneNode();
	pTest1SceneNode->attachObject(pTest1);
	pTest1SceneNode->setPosition(Ogre::Vector3(150, DISTANCE_TO_FLOOR, DISTANCE_TO_ANOTHER * sNumber * -1));
	*/

	ParticleUniverse::ParticleSystem * pTest1 = 
		ParticleUniverse::ParticleSystemManager::getSingleton().createParticleSystem("pTest1", "PUMediaPack/Teleport", m_sceneManager);
	Ogre::SceneNode* pTest1SceneNode = m_sceneManager->getRootSceneNode()->createChildSceneNode();
	pTest1SceneNode->attachObject(pTest1);
	pTest1SceneNode->setPosition(Ogre::Vector3(150, DISTANCE_TO_FLOOR, DISTANCE_TO_ANOTHER * sNumber * -1));

	Ogre::ParticleSystem* pTest2 = m_sceneManager->createParticleSystem("pSmoke1", "Examples/Smoke");
	Ogre::SceneNode* pTest2SceneNode = m_sceneManager->getRootSceneNode()->createChildSceneNode();
	pTest2SceneNode->attachObject(pTest2);
	pTest2SceneNode->setPosition(Ogre::Vector3(-100, DISTANCE_TO_FLOOR, DISTANCE_TO_ANOTHER * sNumber * -1));

	Ogre::ParticleSystem* pTest3 = m_sceneManager->createParticleSystem("pGreeny", "Examples/GreenyNimbus");
	Ogre::SceneNode* pTest3SceneNode = m_sceneManager->getRootSceneNode()->createChildSceneNode();
	pTest3SceneNode->attachObject(pTest3);
	pTest3SceneNode->setPosition(Ogre::Vector3(-350, DISTANCE_TO_FLOOR, DISTANCE_TO_ANOTHER * sNumber * -1));
}
Ejemplo n.º 13
0
Ogre::SceneNode* AWGraphics::SceneDirector::createPlane(float x, float y, float z)
{
    Ogre::Plane plane = Ogre::Plane(Ogre::Vector3::UNIT_Y, 0);

    // Initialize a ground entity for later use
    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::MeshManager::getSingleton().createPlane()

    Ogre::Entity* groundEntity = mSceneMgr->createEntity("ground");
    groundEntity->setMaterialName("Rockwall");
    groundEntity->setCastShadows(false);

    Ogre::SceneNode* ogreNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
    ogreNode->attachObject(groundEntity);
    ogreNode->setPosition(x, y, z);
    ogreNode->setOrientation(Ogre::Quaternion::IDENTITY); // hope this is  a good reference

    return ogreNode;
}
Ejemplo n.º 14
0
void AWGraphics::SceneDirector::createPlayer()
{
    // Add player entity to the scene
    Ogre::Entity* ogreEntity = mSceneMgr->createEntity("ogrehead.mesh");

    Ogre::SceneNode* parentNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
    Ogre::SceneNode* ogreNode = parentNode->createChildSceneNode();
    ogreNode->attachObject(ogreEntity);
    ogreNode->rotate(Ogre::Vector3(0.0, 1.0, 0.0), Ogre::Radian(Ogre::Degree(180)));
    ogreNode->setPosition(0, 80, 0);

    mPlayerNode = parentNode;

    // Initialize and add a light
    mSceneMgr->setAmbientLight(Ogre::ColourValue(.5, .5, .5));

    Ogre::Light* light = mSceneMgr->createLight("MainLight");
    light->setType(Ogre::Light::LT_DIRECTIONAL);
    light->setDirection(Ogre::Vector3(0, -1, 1));

    /*// Directional light
    Ogre::Light* directionalLight = mSceneMgr->createLight("DirectionalLight");
    directionalLight->setType(Ogre::Light::LT_DIRECTIONAL);

    directionalLight->setDiffuseColour(Ogre::ColourValue(.8, .6, .2));
    directionalLight->setSpecularColour(Ogre::ColourValue(.8, .6, .2));
    */

    // Add skydome
    mSceneMgr->setSkyDome(true, "CloudySky", 5, 8); // cannot find... :(
}
Ejemplo n.º 15
0
void OBTutorial2::createBoxShape(Ogre::Entity* entity, Ogre::Vector3 position, bool bStatic)
{

   Ogre::SceneNode *node = entity->getParentSceneNode();
   Vector3 size = node->_getDerivedScale()*entity->getBoundingBox().getHalfSize();
   float mass =  bStatic ? 0.0f : 1.0f;
   srand( (unsigned)time( NULL ) );

   node->setPosition(position);
   node->setOrientation(Quaternion(Degree(Ogre::Math::RangeRandom(0.0,60.0)), Vector3::UNIT_Y));

   btBoxShape *sceneBoxShape = new btBoxShape(toBulletVector(size)); // konvertovat vektor size

   // and the Bullet rigid body
   MyMotionState * defaultMotionState = new MyMotionState(btTransform(btQuaternion(btScalar(0),btScalar(0),btScalar(0),btScalar(1))), node);
   btRigidBody *defaultBody = new btRigidBody(btScalar(1), defaultMotionState, sceneBoxShape);
  /* defaultBody->setShape(node, 
						sceneBoxShape, 
						0.6f,                             // dynamic body restitution
		                0.6f,                             // dynamic body friction
		                mass,                             // dynamic bodymass
		                node->_getDerivedPosition(),      // starting position of the box
		                node->_getDerivedOrientation());  // orientation of the box**/
	mShapes.push_back(sceneBoxShape);
	mBodies.push_back(defaultBody);
	mNumEntitiesInstanced++;				
}
Ejemplo n.º 16
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));
}
Ejemplo n.º 17
0
//-------------------------------------------------------------------------------------
void TutorialApplication::createScene(void)
{
	mElapsedTime = 0;
	createPhysics();
	createLights();

	// create actual soft mesh
	string name = "Swimmer";
	
	string path = "swimmer.mesh";
	Ogre::Entity* entity = mSceneMgr->createEntity( name, path);
	Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode( name + ".SceneNode" );
	node->attachObject(entity);
	node->setPosition(ROOT_POSITION);
	
	// save
	mFigureEnt = entity;
	mFigureNode = node;
	
	mFigureEnt->getSkeleton()->reset();
	
	// pose controller
	loadSkeletonController(SKELETON_CONTROLLER_FILENAME);
	
}
Ejemplo n.º 18
0
	Lightning* LightningManager::addLightning(const Ogre::Vector3& p, const Ogre::Vector3& d, const Ogre::Real l, const Ogre::uint32& div)
	{
		if (!mCreated || mLightnings.size() == 3)
		{
			return static_cast<Lightning*>(NULL);
		}

		Ogre::SceneNode* sn = mVClouds->getSceneManager()->getRootSceneNode()->createChildSceneNode();
		sn->setPosition(p);

		Lightning* lightning = new Lightning(mVClouds->getSceneManager(), sn, Ogre::Vector3(0,0,0), d, l, div, 3, mLightningTimeMultiplier, mVClouds->getGeometrySettings().Radius/9500);
		lightning->create();
		lightning->_updateRenderQueueGroup(
			mVClouds->getGeometryManager()->_getCurrentDistance().y < mVClouds->getGeometryManager()->getHeight().y/2 ?
			mVClouds->getRenderQueueGroups().vcloudsLightningsUnder : mVClouds->getRenderQueueGroups().vcloudsLightningsOver);
		lightning->getBillboardSet()->setVisible(mVClouds->isVisible());

		mSceneNodes.push_back(sn);
		mLightnings.push_back(lightning);

		for(Ogre::uint32 k = 0; k < mListeners.size(); k++)
		{
			mListeners.at(k)->lightningAdded(lightning);
		}

		return lightning;
	}
Ejemplo n.º 19
0
	const Ogre::Vector3 Mesh::getWorldSpacePosition(const Ogre::Vector3& ObjectSpacePosition) const
	{
		Ogre::Matrix4 mWorldMatrix;

		if (mCreated)
		{
	#if OGRE_VERSION_MAJOR >= 1 && OGRE_VERSION_MINOR >= 7
			 mWorldMatrix = mEntity->getParentSceneNode()->_getFullTransform();
	#else
			 mEntity->getParentSceneNode()->getWorldTransforms(&mWorldMatrix);
	#endif
		}
		else
		{
			Ogre::SceneNode *mTmpSN = new Ogre::SceneNode(0);
		    mTmpSN->setPosition(mHydrax->getPosition());

	#if OGRE_VERSION_MAJOR >= 1 && OGRE_VERSION_MINOR >= 7
			 mWorldMatrix = mTmpSN->_getFullTransform();
	#else
			 mTmpSN->getWorldTransforms(&mWorldMatrix);
	#endif

		    delete mTmpSN;
		}

		return mWorldMatrix.transformAffine(ObjectSpacePosition);
	}
Ejemplo n.º 20
0
bool Game::update( float deltaSec ) {
	m_pDynamicsWorld->stepSimulation(deltaSec);
	btCollisionObjectArray objArray = m_pDynamicsWorld->getCollisionObjectArray();
	for( int i = 0; i < objArray.size(); i++ ) {
		btCollisionObject* obj = objArray[i];
		btRigidBody* body = btRigidBody::upcast(obj);

		if( body && body->getMotionState() ) {
			btTransform trans;
			body->getMotionState()->getWorldTransform(trans);

			void* userPointer = body->getUserPointer();
			if( userPointer ) {
				btQuaternion orientation = trans.getRotation();
				Ogre::SceneNode* sceneNode = static_cast<Ogre::SceneNode*>(userPointer);
				sceneNode->setPosition(Ogre::Vector3(trans.getOrigin().getX(), trans.getOrigin().getY(), trans.getOrigin().getZ()));
				sceneNode->setOrientation(Ogre::Quaternion(orientation.getW(), orientation.getX(), orientation.getY(), orientation.getZ()));
			}
		}
	}

//	m_pPlayerSceneNode->translate(m_PlayerVelocity * deltaSec );
//	Ogre::Vector3 src = m_pPlayerSceneNode->getOrientation() * Ogre::Vector3::UNIT_X;
//	Ogre::Quaternion quat = src.getRotationTo(m_PlayerVelocity);
//	m_pPlayerSceneNode->rotate(quat);

	return true;
}//Game::update
Ejemplo n.º 21
0
void Application::createSceneSet3()
{
	int sNumber = 2;

	Ogre::Entity* groundEntity = m_sceneManager->createEntity( "Ground3", "ground.mesh" );
	Ogre::SceneNode* groundSceneNode = m_sceneManager->getRootSceneNode()->createChildSceneNode();
	groundSceneNode->attachObject( groundEntity );
	groundSceneNode->setPosition(Ogre::Vector3(0, 0, DISTANCE_TO_ANOTHER * sNumber * -1));
	groundSceneNode->setScale( ROW_WIDTH, 1, ROW_HEIGHT );

	Ogre::ParticleSystem* pTest1 = m_sceneManager->createParticleSystem("pBlast", "PEExamples/blast");
	Ogre::SceneNode* pTest1SceneNode = m_sceneManager->getRootSceneNode()->createChildSceneNode();
	pTest1SceneNode->attachObject(pTest1);
	pTest1SceneNode->setPosition(Ogre::Vector3(150, DISTANCE_TO_FLOOR, DISTANCE_TO_ANOTHER * sNumber * -1));
	
	Ogre::ParticleSystem* pTest2 = m_sceneManager->createParticleSystem("pBlast2", "PEExamples/blast2");
	Ogre::SceneNode* pTest2SceneNode = m_sceneManager->getRootSceneNode()->createChildSceneNode();
	pTest2SceneNode->attachObject(pTest2);
	pTest2SceneNode->setPosition(Ogre::Vector3(-100, DISTANCE_TO_FLOOR, DISTANCE_TO_ANOTHER * sNumber * -1));

	Ogre::ParticleSystem* pTest3 = m_sceneManager->createParticleSystem("pFloaty", "PEExamples/floatyGreeny");
	Ogre::SceneNode* pTest3SceneNode = m_sceneManager->getRootSceneNode()->createChildSceneNode();
	pTest3SceneNode->attachObject(pTest3);
	pTest3SceneNode->setPosition(Ogre::Vector3(-350, DISTANCE_TO_FLOOR, DISTANCE_TO_ANOTHER * sNumber * -1));
}
Ejemplo n.º 22
0
void ControleurMain::replacerBlocs(NodeBloc* node) {
    /*On replace les blocs dans leur position avant l'application de la vue éclatée*/

    Bloc* bloc;
    Ogre::Vector3 positionBloc;
    Ogre::SceneNode* nodeBloc;

    if(node == NULL)
    {
        node = modeleMain->getModeleBloc()->getRootNode();
    }

    //Récupération des fils du noeud bloc
    QVector<Bloc*> * listeFils = node->getListeFils();

    //On parcourt tous les fils du noeud
    for(int i = 0; i < listeFils->count(); i++)
    {
        bloc = listeFils->data()[i];
        nodeBloc = bloc->getNodeBloc3d();

        switch(bloc->getType())
        {
        case Bloc::BLOC:
            positionBloc = bloc->getPositionVueEclatee();
            bloc->setPosition(positionBloc);
            nodeBloc->setPosition(positionBloc);
            break;

        case Bloc::NODE:
            replacerBlocs((NodeBloc*)bloc);
            break;
        }
    }
}
Ejemplo n.º 23
0
void Actors::insertBegin(const MWWorld::Ptr &ptr)
{
    Ogre::SceneNode* cellnode;
    CellSceneNodeMap::const_iterator celliter = mCellSceneNodes.find(ptr.getCell());
    if(celliter != mCellSceneNodes.end())
        cellnode = celliter->second;
    else
    {
        //Create the scenenode and put it in the map
        cellnode = mRootNode->createChildSceneNode();
        mCellSceneNodes[ptr.getCell()] = cellnode;
    }

    Ogre::SceneNode* insert = cellnode->createChildSceneNode();
    const float *f = ptr.getRefData().getPosition().pos;
    insert->setPosition(f[0], f[1], f[2]);
    insert->setScale(ptr.getCellRef().mScale, ptr.getCellRef().mScale, ptr.getCellRef().mScale);

    // Convert MW rotation to a quaternion:
    f = ptr.getCellRef().mPos.rot;

    // Rotate around X axis
    Ogre::Quaternion xr(Ogre::Radian(-f[0]), Ogre::Vector3::UNIT_X);

    // Rotate around Y axis
    Ogre::Quaternion yr(Ogre::Radian(-f[1]), Ogre::Vector3::UNIT_Y);

    // Rotate around Z axis
    Ogre::Quaternion zr(Ogre::Radian(-f[2]), Ogre::Vector3::UNIT_Z);

    // Rotates first around z, then y, then x
    insert->setOrientation(xr*yr*zr);
    ptr.getRefData().setBaseNode(insert);
}
Ejemplo n.º 24
0
void World::createScene(void) {
    mSceneMgr->setAmbientLight(Ogre::ColourValue(1.0f,1.0f,1.0f));
    addAxesLines(50);

    int numRobots = 4;
    std::stringstream name;
    for (int i=0; i<numRobots; ++i) {
        name.str("");
        name << "robot" << i;
        Ogre::Entity* entity = mSceneMgr->createEntity(name.str(), "robot.mesh");
        name.str("");
        name << "robotNode" << i;
        Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode(name.str());
        node->attachObject(entity);

        node->setPosition(Utils::randomFlatVector3(500,0));

        AnimatedShape anim(node, entity);
        for (int j=0; j<Utils::randomInt(4); ++j) {
            anim.addLocation(Utils::randomFlatVector3(200,0));
        }
        anim.setAnimations("Walk", "Idle");
        anim.startAnimation("Idle", true);
        mAnimatedShapes.push_back(anim);
    }

}
Ejemplo n.º 25
0
	Graphics::CEntity* CCamera::addEntityChild(const std::string &nameEntity, const std::string &nameMesh, Vector3 position){
	
		// creo escena para la entidad nueva
		Ogre::SceneNode* sceneNode;
		sceneNode = new Ogre::SceneNode(_scene->getSceneMgr(), "_SceneCamera_"+nameEntity);

		// creo la entidad nueva
		Ogre::Entity *entity;
		entity = _scene->getSceneMgr()->createEntity(nameMesh);

		
		// atacho la entidad a la escena recien creada
		sceneNode->attachObject(entity);
		
		entity->setRenderQueueGroupAndPriority(Ogre::RenderQueueGroupID::RENDER_QUEUE_6, 200);

		//entity->getSubEntity(0)->getMaterial()->setDepthCheckEnabled(false); 
		//entity->getSubEntity(0)->getMaterial()->setDepthWriteEnabled(false);

		// especifico su posicion
		sceneNode->setPosition(position);

		// añado la escena como hija de la camara
		_cameraNode->addChild(sceneNode);

		// Esto es una pequeña ñapa, me creo un entidad grafica pero sin inicializar, y le añado una escena ahierro
		// Hago esto para que se pueda desplazar desde la logica sin ningun problema.
		Graphics::CEntity *entityTemp = new CEntity(nameEntity, nameMesh);
		entityTemp->setOgreEntity(entity);
		entityTemp->setSceneNode(sceneNode);
		entityTemp->setScene(_scene);

		return entityTemp;
	}
Ejemplo n.º 26
0
bool TutorialApplication::mouseMoved(const OIS::MouseEvent& me) 
{ 
	// Move the camera around an origin point if the user is holding the right mouse button
	if(me.state.buttonDown(OIS::MB_Right))
	{
		int relativeX = me.state.X.rel;
		int relativeY = me.state.Y.rel;
		int relativeZ = me.state.Z.rel;

		Ogre::SceneNode* positionNode = mSceneMgr->getSceneNode("CAMERA_POSITION");
		Ogre::Vector3 pos = positionNode->getPosition();

		Ogre::Vector3 origin = Ogre::Vector3(0,0,0);
		Ogre::Vector3 scale = origin - pos;
		scale.normalise();
		
		
		//if(pos.z > 50.0f)
		//{
			positionNode->setPosition(pos+(scale*relativeZ));
		//}

		//currentDegree += ;

		if(currentDegree > maxDegree){ currentDegree = maxDegree; }
		if(currentDegree < minDegree){ currentDegree = minDegree; }

		Ogre::SceneNode* rotationNode = mSceneMgr->getSceneNode("CAMERA_ROTATION");
		rotationNode->rotate(Ogre::Quaternion(Ogre::Degree(relativeX*0.1f), Ogre::Vector3(0,1,0)) , Ogre::Node::TransformSpace::TS_WORLD);
		rotationNode->rotate(Ogre::Quaternion(Ogre::Degree(relativeY*0.1f), Ogre::Vector3(1,0,0)) , Ogre::Node::TransformSpace::TS_LOCAL);
	}
	return true; 
}
Ejemplo n.º 27
0
void OgreARAppLogic::createCameraPlane(int width, int height, Ogre::Real _distanceFromCamera)
{
	// Create a prefab plane dedicated to display video
	float videoAspectRatio = width / (float) height;

	float planeHeight = 2 * _distanceFromCamera * Ogre::Math::Tan(Degree(26)*0.5); //FOVy webcam = 26° (intrinsic param)
	float planeWidth = planeHeight * videoAspectRatio;

	Plane p(Vector3::UNIT_Z, 0.0);
	MeshManager::getSingleton().createPlane("VerticalPlane", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, p , planeWidth, planeHeight, 1, 1, true, 1, 1, 1, Vector3::UNIT_Y);
	Entity* planeEntity = mSceneMgr->createEntity("VideoPlane", "VerticalPlane"); 
	planeEntity->setMaterialName("CameraMaterial");
	planeEntity->setRenderQueueGroup(RENDER_QUEUE_WORLD_GEOMETRY_1);

	// Create a node for the plane, inserts it in the scene
	Ogre::SceneNode* node = mCameraNode->createChildSceneNode("planeNode");
	node->attachObject(planeEntity);

	// Update position    
	Vector3 planePos = mCamera->getPosition() + mCamera->getDirection() * _distanceFromCamera;
	node->setPosition(planePos);

	// Update orientation
	node->setOrientation(mCamera->getOrientation());
}
Ejemplo n.º 28
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);
}
void GPUSurfApplication::createWebcamPlane(Real _distanceFromCamera)
{
	// Create a prefab plane dedicated to display video
    Vector2 videoDim = mVideo->getDimensions();
	float videoAspectRatio = videoDim.x / videoDim.y;

	float planeHeight = 2 * _distanceFromCamera * Ogre::Math::Tan(Degree(26.53)*0.5);
	float planeWidth = planeHeight * videoAspectRatio;

    Plane p(Vector3::UNIT_Z, 0.0);
	MeshManager::getSingleton().createPlane("VerticalPlane", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, p , planeWidth, planeHeight, 1, 1, true, 1, 1, 1, Vector3::UNIT_Y);
	Entity* planeEntity = mSceneMgr->createEntity("VideoPlane", "VerticalPlane"); 
	planeEntity->setMaterialName("WebcamVideoMaterial");
	planeEntity->setRenderQueueGroup(RENDER_QUEUE_WORLD_GEOMETRY_1);

	// Create a node for the plane, inserts it in the scene
	Ogre::SceneNode* node = mCameraNode->createChildSceneNode("planeNode");
	node->attachObject(planeEntity);

    // Update position    
	Vector3 planePos = mCamera->getPosition() + mCamera->getDirection() * _distanceFromCamera;
	node->setPosition(planePos);

	// Update orientation
	node->setOrientation(mCamera->getOrientation());
}
Ejemplo n.º 30
0
//-------------------------------------------------------------------------------------
void DeltaControl::createScene(void) {

    mSceneMgr->setSkyBox(true, "StormySkyBox");

    mControlCenter = new ControlCenter(mSceneMgr);

    /* *********************************************************
     * ENTITIES
     * *********************************************************/

//	Telephone* phone = new Telephone(mSceneMgr, "phone1");
//	phone->init();

    // Create entity from mesh and attach it to a scene node.
    Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
    Ogre::Entity* ent = mSceneMgr->createEntity("Sinbad", "Sinbad.mesh");
    node->attachObject(ent);
    node->setPosition(0,50,0);
    node->scale(10,10,10);

    // Set animation blend mode to additive / cumulative.
    ent->getSkeleton()->setBlendMode(Ogre::ANIMBLEND_CUMULATIVE);

    // Get the two halves of the idle animation
    Ogre::AnimationState* baseAnim = ent->getAnimationState("IdleBase");
    Ogre::AnimationState* topAnim = ent->getAnimationState("IdleTop");

    // Enable both of them and set them to loop.
    baseAnim->setLoop(true);
    topAnim->setLoop(true);
    baseAnim->setEnabled(true);
    topAnim->setEnabled(true);

}