void SparseOccupancyGridArrayDisplay::allocateCloudsAndNodes(const size_t num)
 {
   if (num > clouds_.size()) { // need to allocate new node and clouds
     for (size_t i = clouds_.size(); i < num; i++) {
       Ogre::SceneNode* node = scene_node_->createChildSceneNode();
       rviz::PointCloud* cloud = new rviz::PointCloud();
       cloud->setRenderMode(rviz::PointCloud::RM_TILES);
       cloud->setCommonDirection( Ogre::Vector3::UNIT_Z );
       cloud->setCommonUpVector( Ogre::Vector3::UNIT_Y );
       node->attachObject(cloud);
       clouds_.push_back(cloud);
       nodes_.push_back(node);
     }
   }
   else if (num < clouds_.size()) // need to destroy
   {
     for (size_t i = num; i < clouds_.size(); i++) {
       nodes_[i]->detachObject(clouds_[i]);
       delete clouds_[i];
       scene_manager_->destroySceneNode(nodes_[i]);
     }
     clouds_.resize(num);
     nodes_.resize(num);
   }
 }
 void FootstepDisplay::allocateTexts(size_t num) {
   if (num > texts_.size()) {
     // need to allocate
     for (size_t i = texts_.size(); i < num; i++) {
       // create nodes
       Ogre::SceneNode* node = scene_node_->createChildSceneNode();
       rviz::MovableText* text 
         = new rviz::MovableText("not initialized", "Arial", 0.05);
       text->setVisible(false);
       text->setTextAlignment(rviz::MovableText::H_CENTER,
                              rviz::MovableText::V_ABOVE);
       text->setCaption("hello world");
       node->attachObject(text);
       texts_.push_back(text);
       text_nodes_.push_back(node);
     }
   }
   else if (num < texts_.size()) {
     for (size_t i = texts_.size() - 1; i >= num; i--) {
       Ogre::SceneNode* node = text_nodes_[i];
       node->removeAndDestroyAllChildren();
       node->detachAllObjects();
       scene_manager_->destroySceneNode(node);
     }
     text_nodes_.resize(num);
     texts_.resize(num);
     
   }
 }
Example #3
0
void createBox(std::string name, dReal x, dReal y, dReal z) {
  Ogre::Entity* e;
  e=sceneMgr_->createEntity(name.c_str(), "cube.mesh");
  Ogre::SceneNode* n;
  n=sceneMgr_->getRootSceneNode()->createChildSceneNode(name.c_str());

  n->attachObject(e); 
  n->scale(0.02, 0.02, 0.02);
  e->setMaterialName("Car/Subframe");

  dBodyID b;
  dGeomID g;
  dMass m;

  static dContact contact=boxContact();

  g = World::getSingletonPtr()->addBox(2.0, 2.0, 2.0);
  dMassSetBox (&m, 1 ,2.0, 2.0, 2.0);

  b=World::getSingletonPtr()->add(g,&m);
  
  dGeomSetData(g,(void*)&contact);

  names.push_back(name);//for updating
  geoms.push_back(g);
  dBodySetPosition (b, x, y, z);
  MyTools::byOdeToOgre(b, n);
}
Example #4
0
void OgreEntityRenderer::setEntity(Ogre::Entity* entity)
{
	mActiveAnimation = nullptr;
	Ogre::SceneNode* node = mTexture->getRenderContext()->getSceneNode();

	node->detachAllObjects();
	if (mEntity) {
		if (mMeshListener) {
			mEntity->getMesh()->removeListener(mMeshListener);
		}
		if (mEntity->hasSkeleton()) {
			mEntity->getSkeleton()->removeListener(mSkeletonListener);
		}
	}

	mSkeletonDisplay.reset();

	if (entity) {
		node->attachObject(entity);
		mTexture->getRenderContext()->repositionCamera();
		if (mAutoShowFull) {
			showFull();
		}

		entity->getMesh()->addListener(mMeshListener);
		if (entity->hasSkeleton()) {
			entity->getSkeleton()->addListener(mSkeletonListener);
			if (mShowSkeleton) {
				mSkeletonDisplay.reset(new SkeletonDisplay(*entity));
			}
		}
	}
}
Example #5
0
void createBall(std::string name, dReal x, dReal y, dReal z) {
  Ogre::Entity* e;
  e=sceneMgr_->createEntity(name.c_str(), "sphere.mesh");
  Ogre::SceneNode* n;
  n=sceneMgr_->getRootSceneNode()->createChildSceneNode(name.c_str());

  n->attachObject(e); 
  n->scale(0.03, 0.03, 0.03);
  e->setMaterialName("MyOwn/Sphere");

  dBodyID b;
  dGeomID g;
  dMass m;

  static dContact contact=ballContact();

  g = World::getSingletonPtr()->addSphere(3.0);
  dMassSetSphere (&m,1,3.0);

  b=World::getSingletonPtr()->add(g,&m);
  
  dGeomSetData(g,(void*)&contact);

  names.push_back(name);
  geoms.push_back(g);
  dBodySetPosition (b, x, y, z);
  MyTools::byOdeToOgre(b, n);
}
Example #6
0
void SelectionHandler::createBox(const std::pair<CollObjectHandle, uint64_t>& handles, const Ogre::AxisAlignedBox& aabb, const std::string& material_name)
{
  Ogre::WireBoundingBox* box = 0;
  Ogre::SceneNode* node = 0;

  M_HandleToBox::iterator it = boxes_.find(handles);
  if (it == boxes_.end())
  {
    Ogre::SceneManager* scene_manager = manager_->getSceneManager();
    node = scene_manager->getRootSceneNode()->createChildSceneNode();
    box = new Ogre::WireBoundingBox;

    bool inserted = boxes_.insert(std::make_pair(handles, std::make_pair(node, box))).second;
    ROS_ASSERT(inserted);
  }
  else
  {
    node = it->second.first;
    box = it->second.second;
  }

  box->setMaterial(material_name);

  box->setupBoundingBox(aabb);
  node->detachAllObjects();
  node->attachObject(box);
}
    //-----------------------------------------------------------------------
    void TerrainLiquidObject::createTerrainLiquid(void)
    {
        assert(!mTerrainLiquid);
        assert(mProjectionMaterial.isNull());
        assert(!mProjectionCamera);
        assert(mSystem);
        assert(!mMaterialName.empty());

        Ogre::SceneNode* parent = mSystem->getBaseSceneNode()->createChildSceneNode();
        assert(parent);

		mTerrainLiquid = new TerrainLiquid(mSystem, mPosition, mSubdivision, TERRAIN_LIQUID_VERTEX_LIMIT, mDiffuse, mAdjustDepth, mMatSpecular, mShininess);
        assert(mTerrainLiquid);

        parent->attachObject(mTerrainLiquid);

        mTerrainLiquid->setTexcoordScale(mTexcoordScale);
        mTerrainLiquid->setTexcoordRotate(Ogre::Radian(mTexcoordRotate));
        mTerrainLiquid->setDepthTexLayerSettings(
            mDepthTexLayerEnabled,
            mDepthTexLayerScale,
            mDepthTexLayerAdjust);

        _createRenderTexture();
        _setReflectPlane();

        _prepareProjector();

        if (!mProjectionMaterial.isNull())
            mTerrainLiquid->setMaterialName(mProjectionMaterial->getName());
        else
            mTerrainLiquid->setMaterialName(mMaterialName);
    }
void CSceneEditorView::OnEditsceneAddentity()
{
	CEntityCreatorDlg EntityCreatorDlg;

	if (IDOK == EntityCreatorDlg.DoModal())
	{
		HTREEITEM Selected = m_SceneManagerDlg->m_SceneTree.GetSelectedItem();
		m_SceneManagerDlg->m_SceneTree.InsertItem(EntityCreatorDlg.m_EntityName, Selected);
		
		Ogre::String SceneNodeName = m_SceneManagerDlg->m_SceneTree.GetItemText(Selected);
		Ogre::Entity *Entity = m_SceneManager->createEntity(Ogre::String(EntityCreatorDlg.m_EntityName), Ogre::String(EntityCreatorDlg.m_MeshName));
		Ogre::SceneNode *SceneNode = m_SceneManager->getSceneNode(SceneNodeName);
		SceneNode->attachObject(Entity);
	
		Ogre::AxisAlignedBox Box = Entity->getBoundingBox();
		Ogre::Vector3 Center = Box.getCenter();
		m_Camera->lookAt(Center);

		m_SceneManagerDlg->m_SceneTree.Expand(Selected, TVE_EXPAND);
		
		if (m_Root != NULL)
		{
			m_Root->renderOneFrame();
		}
	}
}
Example #9
0
void Game::run()
{
	if (!ogreRoot)
		return;

	if (!ogreRoot->showConfigDialog())
		return;

	ogreRoot->initialise(true, "OgreWindow");

	createWindow();
	createSceneManager();
	createCamera();
	createViewport();
	createInput();
	setupResourceManager();

	Ogre::Entity *ogreHead = sceneManager->createEntity("OgreHead", "T80_obj.mesh");
	Ogre::SceneNode *ogreHeadNode = sceneManager->getRootSceneNode()
									->createChildSceneNode("Head Node", Ogre::Vector3(-50.0f, 30.0f, 0.0f));
	ogreHeadNode->attachObject(ogreHead);

	Ogre::Light *directionalLight = sceneManager->createLight("DirectionalLight");
	directionalLight->setType(Ogre::Light::LT_DIRECTIONAL);
	directionalLight->setDiffuseColour(Ogre::ColourValue(.4, 0, 0));
	directionalLight->setSpecularColour(Ogre::ColourValue(.4, 0, 0));
	directionalLight->setDirection(Ogre::Vector3(0, -1, 1));

	ogreRoot->addFrameListener(this);
	ogreRoot->startRendering();
}
Example #10
0
void NavViewPanel::createRadiusObject()
{
  static int count = 0;
  std::stringstream ss;
  ss << "NavViewRadius" << count++;
  radius_object_ = scene_manager_->createManualObject( ss.str() );
  Ogre::SceneNode* node = root_node_->createChildSceneNode();
  node->attachObject( radius_object_ );

  radius_object_->begin( "BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_STRIP );
  {
    Ogre::ColourValue color( 0.2, 1.0, 0.4 );
    for( float f = 0; f < Ogre::Math::TWO_PI; f += 0.5f )
    {
      radius_object_->position( ROBOT_RADIUS * cos(f), ROBOT_RADIUS * sin(f), 0.0f );
      radius_object_->colour(color);
    }

    radius_object_->position( ROBOT_RADIUS , 0.0f, 0.0f );
    radius_object_->colour(color);

    radius_object_->position( 0.0f, 0.0f, 0.0f );
    radius_object_->colour(color);
  }
  radius_object_->end();

  updateRadiusPosition();
}
Example #11
0
Shuriken::Shuriken(Ogre::SceneManager* mSceneMgr, Ogre::SceneNode* parentNode, PhysicsEngine* bulletEngine, const Ogre::Vector3& pos, bool isTennis) :  
	graphicsEngine(mSceneMgr),
	positionNode(0),
	active(true),
	physicsEngine(bulletEngine),
	colliding(false),
	shooting(false)
{
	Ogre::Real ratio = SIZE_REGULAR_SHURIKEN;
	
	if(isTennis){
		entShuriken = mSceneMgr->createEntity(Ogre::SceneManager::PT_SPHERE);
		entShuriken->setMaterialName("Examples/TennisBall");
		ratio = ratio/100;
	} else
		entShuriken = mSceneMgr->createEntity("Shuriken.mesh");
	entShuriken->setCastShadows(true);

	positionNode = parentNode->createChildSceneNode(pos);
	Ogre::SceneNode* tempNode = positionNode->createChildSceneNode();
	tempNode->attachObject(entShuriken);
	tempNode->scale(ratio, ratio, ratio);
	
	physicsObject.setToSphere(
		SIZE_REGULAR_SHURIKEN, 
		2, 
		btQuaternion(0.2f, 0.6f, 0.1f, 1.0f).normalized(),
		btVector3(pos.x,pos.y,pos.z) 
	);
	physicsObject.setRestitution(0.99);
	physicsObject.setLinearVelocity(btVector3(0,0,0));
	physicsObject.setFriction(0.5);  
	physicsObject.setAngularVelocity(btVector3(0.2f, 0.5f, 0.2f));
	physicsEngine->addObject(&physicsObject);
}
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);
}
Example #13
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);
	
}
Example #14
0
void DPSHelper::createOgreHead(void)
{
	Ogre::Vector3 pos = Ogre::Vector3(0,100,0);
	Ogre::Quaternion rot = Ogre::Quaternion::IDENTITY;

	//Create Ogre stuff.
	Ogre::Entity* ogreHeadEntity = mSceneMgr->createEntity("ogrehead.mesh");
	Ogre::SceneNode* ogreHeadNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(pos, rot);
	ogreHeadNode->attachObject(ogreHeadEntity);
	ogreHeadNode->setScale(Ogre::Vector3(1,1,1));
	ogreHeadEntity->setCastShadows(true);
	//setColor(mNinjaEntity, Ogre::Vector3(0.3021,0.3308,0.3671));
	//mNinjaEntity->setMaterialName("Examples/Rockwall");

	//Create shape.
	BtOgre::StaticMeshToShapeConverter converter(ogreHeadEntity);
	//BtOgre::AnimatedMeshToShapeConverter converter(mNinjaEntity);

	//mNinjaShape = converter.createTrimesh();
	btCollisionShape* ogreHeadShape = converter.createConvex();
	//mNinjaShape = converter.createConvex();

	//Calculate inertia.
	btScalar mass = 1;
	btVector3 inertia;
	ogreHeadShape->calculateLocalInertia(mass, inertia);

	//Create BtOgre MotionState (connects Ogre and Bullet).
	BtOgre::RigidBodyState *ogreheadState = new BtOgre::RigidBodyState(ogreHeadNode);

	//Create the Body.
	btRigidBody* ogreHeadBody = new btRigidBody(mass, ogreheadState, ogreHeadShape, inertia);
	phyWorld->addRigidBody(ogreHeadBody);
}
Example #15
0
	void _drawGridPlane(void)
	{
		Ogre::ManualObject* gridPlane = mSceneMgr->createManualObject("GridPlane");
		Ogre::SceneNode* gridPlaneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("GridPlaneNode");

		Ogre::MaterialPtr gridPlaneMaterial = Ogre::MaterialManager::getSingleton().create("GridPlanMaterial", "General");
		gridPlaneMaterial->setReceiveShadows(false);
		gridPlaneMaterial->getTechnique(0)->setLightingEnabled(true);
		gridPlaneMaterial->getTechnique(0)->getPass(0)->setDiffuse(1, 1, 1, 0);
		gridPlaneMaterial->getTechnique(0)->getPass(0)->setAmbient(1, 1, 1);
		gridPlaneMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(1, 1, 1);

		gridPlane->begin("GridPlaneMaterial", Ogre::RenderOperation::OT_LINE_LIST);
		for (int i = 0; i < 21; i++)
		{
			gridPlane->position(-500.0f, 0.0f, 500.0f - i * 50);
			gridPlane->position(500.0f, 0.0f, 500.0f - i * 50);

			gridPlane->position(-500.f + i * 50, 0.f, 500.0f);
			gridPlane->position(-500.f + i * 50, 0.f, -500.f);
		}

		gridPlane->end();

		gridPlaneNode->attachObject(gridPlane);
	}
Example #16
0
    LoadingScreen::LoadingScreen(Ogre::SceneManager* sceneMgr, Ogre::RenderWindow* rw, MWBase::WindowManager& parWindowManager)
        : mSceneMgr(sceneMgr)
        , mWindow(rw)
        , WindowBase("openmw_loading_screen.layout", parWindowManager)
        , mLoadingOn(false)
        , mLastRenderTime(0.f)
        , mLastWallpaperChangeTime(0.f)
        , mFirstLoad(true)
    {
        getWidget(mLoadingText, "LoadingText");
        getWidget(mProgressBar, "ProgressBar");
        getWidget(mBackgroundImage, "BackgroundImage");


        mBackgroundMaterial = Ogre::MaterialManager::getSingleton().create("BackgroundMaterial", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
        mBackgroundMaterial->getTechnique(0)->getPass(0)->setLightingEnabled(false);
        mBackgroundMaterial->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false);
        mBackgroundMaterial->getTechnique(0)->getPass(0)->createTextureUnitState("");

        mRectangle = new Ogre::Rectangle2D(true);
        mRectangle->setCorners(-1.0, 1.0, 1.0, -1.0);
        mRectangle->setMaterial("BackgroundMaterial");
        // Render the background before everything else
        mRectangle->setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY-1);
        // Use infinite AAB to always stay visible
        Ogre::AxisAlignedBox aabInf;
        aabInf.setInfinite();
        mRectangle->setBoundingBox(aabInf);
        // Attach background to the scene
        Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
        node->attachObject(mRectangle);
        mRectangle->setVisible(false);
    }
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));
}
Example #18
0
// create billboardset
void Test::createBillboardSet(void)
{
	mBillboardSet = GLOBAL_SCN_MNGR->createBillboardSet("testbb", 3);
	mBillboardSet->createBillboard(Ogre::Vector3::ZERO + Ogre::Vector3(0,0,0),Ogre::ColourValue::Green);
	mBillboardSet->createBillboard(Ogre::Vector3::ZERO + Ogre::Vector3(0,0,0),Ogre::ColourValue::Green);
	mBillboardSet->createBillboard(Ogre::Vector3::ZERO + Ogre::Vector3(0,0,0),Ogre::ColourValue::Green);
//	mBillboardSet->createBillboard(Ogre::Vector3::ZERO + Ogre::Vector3(0,0,0),Ogre::ColourValue::Green);
//	mBillboardSet->createBillboard(Ogre::Vector3::ZERO + Ogre::Vector3(0,0,0),Ogre::ColourValue::Green);
	mBillboardSet->setDefaultDimensions(50,50);
	mBillboardSet->setBillboardType(Ogre::BBT_PERPENDICULAR_COMMON);
	mBillboardSet->setCommonDirection(Ogre::Vector3::UNIT_Y);
	mBillboardSet->setCommonUpVector(Ogre::Vector3::UNIT_Z);
	mBillboardSet->setMaterialName("Billboard/GreenCircle");
	mBillboardSet->setVisible(true);
	mBillboardSet->setBounds(Ogre::AxisAlignedBox(
			Ogre::Vector3(0,0,0), Ogre::Vector3(25000,25000,25000)),25000*0.5f);

	debug("Number of billboards: %d\n", mBillboardSet->getNumBillboards());
//	mZombies[0]->getSceneNode()->attachObject(mBillboardSet);

	Ogre::SceneNode *node = GLOBAL_SCN_MNGR->getRootSceneNode()->createChildSceneNode();
	node->attachObject(mBillboardSet);
//	mBillboardSet->setCullIndividually(true);

}
Example #19
0
	void DemoKeeper::createScene()
	{
		base::BaseDemoManager::createScene();
		MyGUI::ResourceManager::getInstance().load("FrameworkFonts.xml");
		MyGUI::ResourceManager::getInstance().load("SplineSkin.xml");
		MyGUI::ResourceManager::getInstance().load("GraphNodeSkin.xml");

		new tools::DialogManager();
		tools::DialogManager::getInstance().initialise();

		Ogre::SceneNode* node = getSceneManager()->getRootSceneNode()->createChildSceneNode();
		Ogre::Entity* entity = getSceneManager()->createEntity("Object", "Robot.mesh");
		node->attachObject(entity);
		getCamera()->setPosition(400, 400, 400);

		mFileDialog = new tools::OpenSaveFileDialog();
		mFileDialog->eventEndDialog = MyGUI::newDelegate(this, &DemoKeeper::notifyEndDialog);

		mGraph = new animation::AnimationGraph();
		mGraph->addData("OwnerEntity", Ogre::Any(entity));

		createGrapView();

		mContextMenu = new wraps::ContextMenu("ContextMenu.layout");
		mContextMenu->eventMenuAccept = MyGUI::newDelegate(this, &DemoKeeper::notifyMenuCtrlAccept);

		MyGUI::Gui::getInstance().eventFrameStart += MyGUI::newDelegate(this, &DemoKeeper::notifyFrameStarted);
	}
Example #20
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);

}
//-------------------------------------------------------------------------------------
bool BaseApplication::setup(void)
{
    mRoot = new Ogre::Root(mPluginsCfg);

    setupResources();

    bool carryOn = configure();
    if (!carryOn) return false;

    chooseSceneManager();
    createCamera();
    createViewports();

    // Set default mipmap level (NB some APIs ignore this)
    Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);


    
    // Create background material
    Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create("Background", "General");
    material->getTechnique(0)->getPass(0)->createTextureUnitState("space.jpg");
    material->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false);
    material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
    material->getTechnique(0)->getPass(0)->setLightingEnabled(false);

    // Create background rectangle covering the whole screen
    rect = new Ogre::Rectangle2D(true);
    rect->setCorners(-1.0, 1.0, 1.0, -1.0);
    rect->setMaterial("Background");
     
    // Render the background before everything else
    rect->setRenderQueueGroup(Ogre::RENDER_QUEUE_BACKGROUND);
     
    // Use infinite AAB to always stay visible
    Ogre::AxisAlignedBox aabInf;
    aabInf.setInfinite();
    rect->setBoundingBox(aabInf);
     
    // Attach background to the scene
    Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode("Background");
    node->attachObject(rect);
     
    // Example of background scrolling
    material->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setScrollAnimation(-0.10, 0.0);
     
    // Don't forget to delete the Rectangle2D in the destructor of your application:

    // Create any resource listeners (for loading screens)
    createResourceListener();
    // Load resources
    loadResources();

    // Create the scene
    createScene();
    

    createFrameListener();

    return true;
};
void NavigationCell::debugDrawClassification( Ogre::Vector3 start, Ogre::Vector3 end )
{
    Ogre::Root *root = Ogre::Root::getSingletonPtr();
    Ogre::SceneManager* mgr = root->getSceneManager( "SceneManagerInstance" );
    Ogre::ManualObject* debug;
    Ogre::SceneNode* node;

    if( mgr->hasManualObject( "debugDrawClassification" ) )
        debug = mgr->getManualObject( "debugDrawClassification" );
    else
    {
        debug = mgr->createManualObject( "debugDrawClassification" );
        node = mgr->getRootSceneNode()->createChildSceneNode();
        node->attachObject( debug );
        node->translate( 0, 1, 0 );
        debug->setQueryFlags( 0 );
        debug->setRenderQueueGroup( Ogre::RENDER_QUEUE_OVERLAY );
    }

    debug->begin( "debug/blue", Ogre::RenderOperation::OT_LINE_LIST );
    debug->position( start );
    debug->position( end );
    debug->end();

//    debugDrawCell( debug, "debug/yellow", "debug/blue" );
}
Example #23
0
bool HydraxSample1App::keyPressed(const OIS::KeyEvent &arg)
{
/*
	if (arg.key == OIS::KC_Q)
	{
		mCurrentSkyBox++;
		if (mCurrentSkyBox == 3)
		{
			mCurrentSkyBox = 0;
		}
	}
	mSceneMgr->setSkyBox(true,mSkyBoxes[mCurrentSkyBox],1000,true);

	mHydrax->setSunPosition(mSunPosition[mCurrentSkyBox]);
	mHydrax->setSunColor(mSunColor[mCurrentSkyBox]);

	mSceneMgr->getLight("Light0")->setPosition(mSunPosition[mCurrentSkyBox]);
	mSceneMgr->getLight("Light0")->setSpecularColour(mSunColor[mCurrentSkyBox].x,mSunColor[mCurrentSkyBox].y,mSunColor[mCurrentSkyBox].z);*/

	if (arg.key == OIS::KC_1 || arg.key == OIS::KC_2 || arg.key == OIS::KC_3)
	{
		CEGUI::Point point = CEGUI::MouseCursor::getSingleton().getPosition();
		Ogre::Ray ray = mCameraMan->getCamera()->getCameraToViewportRay(point.d_x/mWindow->getWidth(),point.d_y/mWindow->getHeight());
		mRaySceneQuery->setRay(ray);
		Ogre::RaySceneQueryResult * mRayQueryResult = &(mRaySceneQuery->execute());

		Ogre::RaySceneQueryResult::iterator itr = mRayQueryResult->begin();
		while(itr != mRayQueryResult->end())
		{
			if(itr->worldFragment)
			{
				Ogre::Entity * ent;
				Ogre::SceneNode * node;
				if (arg.key == OIS::KC_1)
				{			
					ent = mSceneMgr->createEntity(entityNames[0]);
					ent->setMaterialName(materialNames[0]);
					node = mSceneMgr->getRootSceneNode()->createChildSceneNode(itr->worldFragment->singleIntersection + Ogre::Vector3(0,200,0));
				}
				else if (arg.key == OIS::KC_2)
				{
					ent = mSceneMgr->createEntity(entityNames[1]);
					ent->setMaterialName(materialNames[1]);
					node = mSceneMgr->getRootSceneNode()->createChildSceneNode(itr->worldFragment->singleIntersection);
				}
				else if (arg.key == OIS::KC_3)
				{
					ent = mSceneMgr->createEntity(entityNames[2]);
					ent->setMaterialName(materialNames[2]);
					node = mSceneMgr->getRootSceneNode()->createChildSceneNode(itr->worldFragment->singleIntersection);
				}
				node->attachObject(ent);
				break;
			}
			itr++;
		}
	}
	return true;
}
Example #24
0
    void *mesh_new ( const char *mesh_file, void *scene_node ) {
        Ogre::SceneNode *node = static_cast<Ogre::SceneNode *> ( scene_node );

        Ogre::Entity *ent = Kernel::inst().getOGRESceneMgr()->createEntity ( mesh_file );
        node->attachObject ( ent );

        return ent;
    }
Example #25
0
void Application::createChildEntity(std::string name, std::string mesh, Ogre::SceneNode* sceneNode, int x, int y, int z) {

	Ogre::Entity* ogreEntity = mSceneManager->createEntity(name, mesh);
	ogreEntity->setCastShadows(true);
	Ogre::SceneNode* ogreNode = sceneNode->createChildSceneNode(name);
	ogreNode->attachObject(ogreEntity);
	ogreNode->setPosition(x, y, z);
}
Example #26
0
bool HUDCentre::Init()
{	
	Ogre::SceneNode *root = CommonDeclarations::GetSceneManager()->getRootSceneNode();
	root->attachObject(AutoPilotIndicator);

	for (size_t i =0; i<Equipments.Size; ++i)
	{
		root->attachObject(Equipments.Data[i].Rect);		 
	}
	for (size_t i =0; i<Bonuses.Size; ++i)
	{
		root->attachObject(Bonuses.Data[i].Rect);		 
	}
	GuiltyConscienceOverlayVisible = false;
	
    return true;
}
Example #27
0
bool MyFrameListener::deleteBoard()
{
	for (int i=0; i<_XMAX; i++)
	{
		for (int j=0; j<_YMAX; j++)
		{
			myBoard[i][j]=0;
		}
	}
	for (int i=0; i<_XMAX; i++)
	{
		for (int j=0; j<_YMAX; j++)
		{
			myBoardPlayer[i][j]=0;
		}
	}

	_maxFires=0;

	_sceneManager->getRootSceneNode()->removeAndDestroyAllChildren();
	_sceneManager->clearScene();

	// Añadir el plano a la escena
	// Creacion del plano
	Ogre::Plane pl1(Ogre::Vector3::UNIT_Y,-5);
	Ogre::MeshManager::getSingleton().createPlane("pl1",
	Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
	pl1,200,200,1,1,true,1,20,20,Ogre::Vector3::UNIT_Z);

	// Añadir el plano a la escena
	Ogre::SceneNode* nodeG = _sceneManager->createSceneNode("nodeG");
	Ogre::Entity* grEnt = _sceneManager->createEntity("pEnt", "pl1");
	grEnt->setMaterialName("Ground");
	nodeG->attachObject(grEnt);

	// Sombras
	_sceneManager->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
	Ogre::Light* light = _sceneManager->createLight("light1");
	light->setType(Ogre::Light::LT_DIRECTIONAL);
	light->setDirection(Ogre::Vector3(1,-1,0));
	nodeG->attachObject(light);
	_sceneManager->getRootSceneNode()->addChild(nodeG);


	return true;
}
Example #28
0
void OgreView::addObject(Ogre::String name)
{
	Ogre::String filename = name;
	filename += ".mesh";
	Ogre::Entity* test = mSceneMgr->createEntity(name, filename);
	Ogre::SceneNode* testNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
    testNode->attachObject(test);
}
Example #29
0
	void DemoKeeper::createObject()
	{
#ifdef MYGUI_OGRE_PLATFORM
		Ogre::Entity* entity = getSceneManager()->createEntity("ControlPanel", "ControlPanel.mesh");
		Ogre::SceneNode* node = getSceneManager()->getRootSceneNode()->createChildSceneNode();
		node->attachObject(entity);
#endif
	}
Example #30
0
void EC_ChatBubble::ShowMessage(const QString &msg)
{
    if (renderer_.expired())
        return;

    Ogre::SceneManager *scene = renderer_.lock()->GetSceneManager();
    assert(scene);
    if (!scene)
        return;

    Scene::Entity *entity = GetParentEntity();
    assert(entity);
    if (!entity)
        return;

    OgreRenderer::EC_OgrePlaceable *node = entity->GetComponent<OgreRenderer::EC_OgrePlaceable>().get();
    if (!node)
        return;

    Ogre::SceneNode *sceneNode = node->GetSceneNode();
    assert(sceneNode);
    if (!sceneNode)
        return;

    // Create billboard if it doesn't exist.
    if (!billboardSet_ && !billboard_)
    {
        billboardSet_ = scene->createBillboardSet(renderer_.lock()->GetUniqueObjectName(), 1);
        assert(billboardSet_);

        std::string newName = std::string("material") + renderer_.lock()->GetUniqueObjectName(); 
        Ogre::MaterialPtr material = OgreRenderer::CloneMaterial("UnlitTexturedSoftAlpha", newName);
        billboardSet_->setMaterialName(newName);

        billboard_ = billboardSet_->createBillboard(Ogre::Vector3(0, 0, 1.5f));
        assert(billboard_);
        billboard_->setDimensions(2, 1);

        sceneNode->attachObject(billboardSet_);
    }

    if (msg.isNull() || msg.isEmpty())
        return;

    messages_.push_back(msg);

    // Set timer for removing the message
    int timeToShow = 0;
    const int minTime = 4000;
    if (msg.length() * 400 < minTime)
        timeToShow = minTime;
    else
        timeToShow = msg.length() * 400;

    QTimer::singleShot(timeToShow, this, SLOT(RemoveLastMessage()));

    Refresh();
}