void EditorApplication::createSkybox(string skybox_name) {
	LibGens::Model *skybox_model=current_level->getModelLibrary()->getModel(skybox_name);
	if (skybox_model) {
		Ogre::SceneNode *scene_node = scene_manager->getRootSceneNode()->createChildSceneNode();
		buildModel(scene_node, skybox_model, skybox_model->getName(), "", scene_manager, current_level->getMaterialLibrary(), 0, GENERAL_MESH_GROUP, false);


		unsigned short attached_objects=scene_node->numAttachedObjects();
		for (unsigned short i=0; i<attached_objects; i++) {
			Ogre::Entity *entity=static_cast<Ogre::Entity *>(scene_node->getAttachedObject(i));
			entity->setRenderQueueGroup(Ogre::RENDER_QUEUE_SKIES_EARLY);
			unsigned int attached_entities=entity->getNumSubEntities();

			Ogre::AxisAlignedBox aabb;
			aabb.setInfinite();
			entity->getMesh()->_setBounds(aabb, false);

			for (unsigned int j=0; j<attached_entities; j++) {
				Ogre::SubEntity *sub_entity=entity->getSubEntity(j);
				Ogre::MaterialPtr material=sub_entity->getMaterial();
				Ogre::Pass *pass=material->getTechnique(0)->getPass(0);
				pass->setDepthWriteEnabled(false);
			}
		}
	}
}
Пример #2
0
//-------------------------------------------------------------------------------------
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;
};
Пример #3
0
    LoadingScreen::LoadingScreen(Ogre::SceneManager* sceneMgr, Ogre::RenderWindow* rw)
        : mSceneMgr(sceneMgr)
        , mWindow(rw)
        , WindowBase("openmw_loading_screen.layout")
        , mLastRenderTime(0.f)
        , mLastWallpaperChangeTime(0.f)
        , mFirstLoad(true)
        , mProgress(0)
        , mVSyncWasEnabled(false)
    {
        getWidget(mLoadingText, "LoadingText");
        getWidget(mProgressBar, "ProgressBar");
        getWidget(mBackgroundImage, "BackgroundImage");

        mProgressBar->setScrollViewPage(1);

        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);
    }
Пример #4
0
Fader::Fader(Ogre::SceneManager* sceneMgr)
    : mSceneMgr(sceneMgr)
    , mMode(FadingMode_In)
    , mRemainingTime(0.f)
    , mTargetTime(0.f)
    , mTargetAlpha(0.f)
    , mCurrentAlpha(0.f)
    , mStartAlpha(0.f)
    , mFactor(1.f)
{
    // Create the fading material
    MaterialPtr material = MaterialManager::getSingleton().create("FadeInOutMaterial", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
    Pass* pass = material->getTechnique(0)->getPass(0);
    pass->setSceneBlending(SBT_TRANSPARENT_ALPHA);
    pass->setDepthWriteEnabled (false);
    mFadeTextureUnit = pass->createTextureUnitState("black.png");
    mFadeTextureUnit->setColourOperationEx(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, ColourValue(0.f, 0.f, 0.f)); // always black colour    

    mRectangle = new Ogre::Rectangle2D(true);
    mRectangle->setCorners(-1.0, 1.0, 1.0, -1.0);
    mRectangle->setMaterial("FadeInOutMaterial");
    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);
    mRectangle->setVisibilityFlags (2048);
}
Пример #5
0
const Ogre::AxisAlignedBox& Canvas::getBoundingBox() const
{
	static Ogre::AxisAlignedBox box;
	box.setInfinite();

	return box;
}
Пример #6
0
void ImageDisplay::onInitialize()
{
  ImageDisplayBase::onInitialize();
  {
    static uint32_t count = 0;
    std::stringstream ss;
    ss << "ImageDisplay" << count++;
    img_scene_manager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC, ss.str());
  }

  img_scene_node_ = img_scene_manager_->getRootSceneNode()->createChildSceneNode();

  {
    static int count = 0;
    std::stringstream ss;
    ss << "ImageDisplayObject" << count++;

    screen_rect_ = new Ogre::Rectangle2D(true);
    screen_rect_->setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY - 1);
    screen_rect_->setCorners(-1.0f, 1.0f, 1.0f, -1.0f);

    ss << "Material";
    material_ = Ogre::MaterialManager::getSingleton().create( ss.str(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
    material_->setSceneBlending( Ogre::SBT_REPLACE );
    material_->setDepthWriteEnabled(false);
    material_->setReceiveShadows(false);
    material_->setDepthCheckEnabled(false);

    material_->getTechnique(0)->setLightingEnabled(false);
    Ogre::TextureUnitState* tu = material_->getTechnique(0)->getPass(0)->createTextureUnitState();
    tu->setTextureName(texture_.getTexture()->getName());
    tu->setTextureFiltering( Ogre::TFO_NONE );

    material_->setCullingMode(Ogre::CULL_NONE);
    Ogre::AxisAlignedBox aabInf;
    aabInf.setInfinite();
    screen_rect_->setBoundingBox(aabInf);
    screen_rect_->setMaterial(material_->getName());
    img_scene_node_->attachObject(screen_rect_);
  }

  render_panel_ = new RenderPanel();
  render_panel_->getRenderWindow()->setAutoUpdated(false);
  render_panel_->getRenderWindow()->setActive( false );

  render_panel_->resize( 640, 480 );
  render_panel_->initialize(img_scene_manager_, context_);

  setAssociatedWidget( render_panel_ );

  render_panel_->setAutoRender(false);
  render_panel_->setOverlaysEnabled(false);
  render_panel_->getCamera()->setNearClipDistance( 0.01f );

  updateNormalizeOptions();
}
Пример #7
0
void RenderedCompassImpl::_setCompass(Compass* compass)
{
	Ogre::MaterialPtr originalMaterial = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().getByName(mMaterialName));
	if (originalMaterial) {
		originalMaterial->load();
		mCompassMaterial = originalMaterial->clone(OgreInfo::createUniqueResourceName(originalMaterial->getName()));
		if (Ogre::Technique* tech = mCompassMaterial->getBestTechnique()) {
			Ogre::Pass* pass = nullptr;
			if (tech->getNumPasses() && (pass = tech->getPass(0))) {
				mCompassMaterialMapTUS = pass->getTextureUnitState("Background");
				if (mCompassMaterialMapTUS) {
					//Make sure that the compass material is using the map texture for the base rendering
					mCompassMaterialMapTUS->setTexture(mMap->getTexture());

					mTexture = Ogre::TextureManager::getSingleton().createManual("RenderedCompass", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 128, 128, 1, Ogre::PF_A8R8G8B8, Ogre::TU_RENDERTARGET);
					mRenderTexture = mTexture->getBuffer()->getRenderTarget();
					mRenderTexture->removeAllViewports();
					mRenderTexture->setAutoUpdated(false);
					mRenderTexture->setActive(true);

					mCamera = mSceneManager->createCamera("RenderedCompassCamera");
					mViewport = mRenderTexture->addViewport(mCamera);
					mViewport->setOverlaysEnabled(false);
					mViewport->setShadowsEnabled(false);
					mViewport->setSkiesEnabled(false);
					mViewport->setClearEveryFrame(true);
					mViewport->setBackgroundColour(Ogre::ColourValue::ZERO);

					mMapRectangle = OGRE_NEW Ogre::Rectangle2D(true);
					auto mapMaterialPtr = Ogre::MaterialManager::getSingleton().getByName(mCompassMaterial->getName(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
					if (mapMaterialPtr) {
						mMapRectangle->setMaterial(mapMaterialPtr);
					}

					//We need to maximise the rendered texture to cover the whole screen
					Ogre::RenderSystem* rs = Ogre::Root::getSingleton().getRenderSystem();
					Ogre::Real hOffset = rs->getHorizontalTexelOffset() / (0.5 * mViewport->getActualWidth());
					Ogre::Real vOffset = rs->getVerticalTexelOffset() / (0.5 * mViewport->getActualHeight());
					mMapRectangle->setCorners(-1 + hOffset, 1 - vOffset, 1 + hOffset, -1 - vOffset);

					//Since a Rectangle2D instance is a moveable object it won't be rendered unless it's in the frustrum. If we set the axis aligned box to be "infinite" it will always be rendered.
					Ogre::AxisAlignedBox aabInf;
					aabInf.setInfinite();
					mMapRectangle->setBoundingBox(aabInf);

					//We can't attach something to the root node, so we'll attach it to a newly created node. We won't keep a reference to this node since it will be destroyed along with the scene manager when we ourselves are destroyed.
					mSceneManager->getRootSceneNode()->createChildSceneNode()->attachObject(mMapRectangle);

					//Return early since everything is good.
					return;
				}
			}
		}
	}
	S_LOG_WARNING("Could not load material '" << mMaterialName << "' for the compass.");
}
Пример #8
0
Ogre::SceneNode* Terminal::createTexturedRect(std::string object_name, std::string texture_name, float left, float top, float right, float bottom)
{
    MaterialPtr material = MaterialManager::getSingleton().create(object_name,Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    material->getTechnique(0)->getPass(0)->createTextureUnitState(texture_name);
    material->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false);
    material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(true);
    material->getTechnique(0)->getPass(0)->setLightingEnabled(false);

//    Ogre::Rectangle2D* rect = new Ogre::Rectangle2D(true);
    ManualObject* manual = Entropy::getSingletonPtr()->mSceneMgr->createManualObject(object_name);
    manual->setUseIdentityProjection(true);
    manual->setUseIdentityView(true);

    manual->begin(object_name, RenderOperation::OT_TRIANGLE_STRIP);

    manual->position(left, bottom, 0.0);
    manual->position(left, top, 0.0);
    manual->position(right, bottom, 0.0);
    manual->position(right,  top, 0.0);

    manual->index(0);
    manual->index(1);
    manual->index(2);
    manual->index(3);

    manual->end();

//    rect->setCorners(left,top,right,bottom);
//    rect->setMaterial(object_name);

    manual->setRenderQueueGroup(RENDER_QUEUE_OVERLAY);

    Ogre::AxisAlignedBox aabInf;
    aabInf.setInfinite();
    manual->setBoundingBox(aabInf);

    Ogre::SceneNode* rect_node = Entropy::getSingletonPtr()->mSceneMgr->getRootSceneNode()->createChildSceneNode(object_name);
    rect_node->attachObject(manual);


//    rect->setVisible(false);



//    rect_node->setPosition(0,0,0);

    return rect_node;
}
Пример #9
0
void Player::init_manual()
{
    manual = Neurocaster::getSingletonPtr()->mSceneMgr->createManualObject(name);
    manual->setUseIdentityView(true);

    manual->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_STRIP);

    double left = -0.25;
    double top = 0.25;
    double right = 0.25;
    double bottom = -0.25;

    float r = 1;
    float g = 1;
    float b = 1;


    manual->position(Square(left,top).relative_convert());
    manual->textureCoord(0,1);
    manual->colour(r,g,b);

    manual->position(Square(left,bottom).relative_convert());
    manual->textureCoord(0,0);
    manual->colour(r,g,b);

    manual->position(Square(right,top).relative_convert());
    manual->textureCoord(1,1);
    manual->colour(r,g,b);

    manual->position(Square(right,bottom).relative_convert());
    manual->textureCoord(1,0);
    manual->colour(r,g,b);

    manual->end();

    Ogre::AxisAlignedBox aabInf;
    aabInf.setInfinite();
    manual->setBoundingBox(aabInf);

    manual->setRenderQueueGroup(Ogre::RENDER_QUEUE_2);

    scene_node = Neurocaster::getSingletonPtr()->mSceneMgr->getRootSceneNode()->createChildSceneNode(name);
    scene_node->attachObject(manual);
    scene_node->setPosition(pos.convert());
}
void OgreBillboardInterface::addBillboardType(const std::string& name, const std::string& material) {
	billboard_types[name] = material;
	billboard_sets[name] = scene->createBillboardSet(name.c_str(), 50);
	billboard_sets[name]->setMaterialName(material.c_str());
	billboard_sets[name]->setCommonDirection(Ogre::Vector3::UNIT_X);
    billboard_sets[name]->setCommonUpVector(Ogre::Vector3::UNIT_Y);
    billboard_sets[name]->setBillboardOrigin(Ogre::BBO_TOP_CENTER);


	Ogre::AxisAlignedBox boundingBox;
	boundingBox.setInfinite();
	billboard_sets[name]->setBounds(boundingBox, 100.f);

	Ogre::FloatRect textCords[]={Ogre::FloatRect(0.f, 0.f, 1.f, 1.f)};
	billboard_sets[name]->setTextureCoords(textCords, 1);

	node->attachObject(billboard_sets[name]);
}
Пример #11
0
void SplashScreenState::createScene()
{
	// creation image splash screen
	Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create("SplashScreen", "General");
	material->getTechnique(0)->getPass(0)->createTextureUnitState("splash_screen.jpg");
	material->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false);
	material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
	material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
	// creation rect
	Ogre::Rectangle2D *rect = new Ogre::Rectangle2D(true);
	rect->setCorners(-1.0, 1.0, 1.0, -1.0);
	rect->setMaterial("SplashScreen");
	// priorité chargement
	rect->setRenderQueueGroup(Ogre::RenderQueueGroupID::RENDER_QUEUE_BACKGROUND);
	// stay visible
	Ogre::AxisAlignedBox aabInf;
	aabInf.setInfinite();
	rect->setBoundingBox(aabInf);
	//
	Ogre::SceneNode* node = m_pSceneMgr->getRootSceneNode()->createChildSceneNode("SplashScreen");
	node->attachObject(rect);
	m_pSceneMgr->setAmbientLight(Ogre::ColourValue(1, 1, 1));
}
Пример #12
0
NxRectangle2D::NxRectangle2D( NxNode * RectangleSceneNode, bool includeTextureCoordinates ) : NxEntity()
{
	mType = NxTypeEntity;

	static int index = 0;
	mRectangle = new Ogre::Rectangle2D(includeTextureCoordinates); 
	mRectangle->setCorners(-1.0, 1.0, 1.0, -1.0);

	// Render the background before everything else
	mRectangle->setRenderQueueGroup(Ogre::RENDER_QUEUE_BACKGROUND);
 
	// Use infinite AAB to always stay visible
	Ogre::AxisAlignedBox aabInf;
	aabInf.setInfinite();
	mRectangle->setBoundingBox(aabInf);

	mNode = RectangleSceneNode->GetNxScene().GetNxSceneManager()->createSceneNode( RectangleSceneNode->GetName() + Ogre::StringConverter::toString( index ) );
	mNode->attachObject( mRectangle );
	mNxNodeParent = RectangleSceneNode;
	mNxNodeParent->GetNxSceneNode()->addChild( mNode );

	index++;
}
void ImageSelectionToolCustom::onInitialize()
{
    move_tool_->initialize( context_ );

    // Create our highlight rectangle
    Ogre::SceneManager* scene_manager = context_->getSceneManager();
    highlight_node_ = scene_manager->getRootSceneNode()->createChildSceneNode();

    std::stringstream ss;
    static int count = 0;
    ss << "ImageSelectionRect" << count++;
    highlight_rectangle_ = new Ogre::Rectangle2D(true);

    const static uint32_t texture_data[1] = { 0xffff0070 };
    Ogre::DataStreamPtr pixel_stream;
    pixel_stream.bind(new Ogre::MemoryDataStream( (void*)&texture_data[0], 4 ));

    Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton().loadRawData(ss.str() + "Texture", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, pixel_stream, 1, 1, Ogre::PF_R8G8B8A8, Ogre::TEX_TYPE_2D, 0);

    Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create(ss.str(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    material->setLightingEnabled(false);
    //material->getTechnique(0)->getPass(0)->setPolygonMode(Ogre::PM_WIREFRAME);
    highlight_rectangle_->setMaterial(material->getName());
    Ogre::AxisAlignedBox aabInf;
    aabInf.setInfinite();
    highlight_rectangle_->setBoundingBox(aabInf);
    highlight_rectangle_->setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY + 4);
    material->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
    material->setCullingMode(Ogre::CULL_NONE);

    Ogre::TextureUnitState* tex_unit = material->getTechnique(0)->getPass(0)->createTextureUnitState();
    tex_unit->setTextureName(tex->getName());
    tex_unit->setTextureFiltering( Ogre::TFO_NONE );

    highlight_node_->attachObject(highlight_rectangle_);
}
Пример #14
0
void CameraDisplay::onInitialize()
{
  caminfo_tf_filter_ = new tf::MessageFilter<sensor_msgs::CameraInfo>(*vis_manager_->getTFClient(), "", 2, update_nh_);

  bg_scene_node_ = scene_manager_->getRootSceneNode()->createChildSceneNode();
  fg_scene_node_ = scene_manager_->getRootSceneNode()->createChildSceneNode();

  {
    static int count = 0;
    UniformStringStream ss;
    ss << "CameraDisplayObject" << count++;

    //background rectangle
    bg_screen_rect_ = new Ogre::Rectangle2D(true);
    bg_screen_rect_->setCorners(-1.0f, 1.0f, 1.0f, -1.0f);

    ss << "Material";
    bg_material_ = Ogre::MaterialManager::getSingleton().create( ss.str(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
    bg_material_->setDepthWriteEnabled(false);

    bg_material_->setReceiveShadows(false);
    bg_material_->setDepthCheckEnabled(false);

    bg_material_->getTechnique(0)->setLightingEnabled(false);
    Ogre::TextureUnitState* tu = bg_material_->getTechnique(0)->getPass(0)->createTextureUnitState();
    tu->setTextureName(texture_.getTexture()->getName());
    tu->setTextureFiltering( Ogre::TFO_NONE );
    tu->setAlphaOperation( Ogre::LBX_SOURCE1, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, 0.0 );

    bg_material_->setCullingMode(Ogre::CULL_NONE);
    bg_material_->setSceneBlending( Ogre::SBT_REPLACE );

    Ogre::AxisAlignedBox aabInf;
    aabInf.setInfinite();

    bg_screen_rect_->setRenderQueueGroup(Ogre::RENDER_QUEUE_BACKGROUND);
    bg_screen_rect_->setBoundingBox(aabInf);
    bg_screen_rect_->setMaterial(bg_material_->getName());

    bg_scene_node_->attachObject(bg_screen_rect_);
    bg_scene_node_->setVisible(false);

    //overlay rectangle
    fg_screen_rect_ = new Ogre::Rectangle2D(true);
    fg_screen_rect_->setCorners(-1.0f, 1.0f, 1.0f, -1.0f);

    fg_material_ = bg_material_->clone( ss.str()+"fg" );
    fg_screen_rect_->setBoundingBox(aabInf);
    fg_screen_rect_->setMaterial(fg_material_->getName());

    fg_material_->setSceneBlending( Ogre::SBT_TRANSPARENT_ALPHA );
    fg_screen_rect_->setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY - 1);

    fg_scene_node_->attachObject(fg_screen_rect_);
    fg_scene_node_->setVisible(false);
  }

  setAlpha( 0.5f );

  render_panel_ = new RenderPanel();
  render_panel_->getRenderWindow()->addListener( this );
  render_panel_->getRenderWindow()->setAutoUpdated(false);
  render_panel_->getRenderWindow()->setActive( false );
  render_panel_->resize( 640, 480 );
  render_panel_->initialize(vis_manager_->getSceneManager(), vis_manager_);

  WindowManagerInterface* wm = vis_manager_->getWindowManager();
  if( wm )
  {
    panel_container_ = wm->addPane(name_, render_panel_);
  }
  render_panel_->setAutoRender(false);
  render_panel_->setOverlaysEnabled(false);
  render_panel_->getCamera()->setNearClipDistance( 0.01f );

  caminfo_tf_filter_->connectInput(caminfo_sub_);
  caminfo_tf_filter_->registerCallback(boost::bind(&CameraDisplay::caminfoCallback, this, _1));
  vis_manager_->getFrameManager()->registerFilterForTransformStatusCheck(caminfo_tf_filter_, this);

  if( panel_container_ )
  {
    // TODO: wouldn't it be better to connect this straight to the wrapper?
    connect( panel_container_, SIGNAL( visibilityChanged( bool ) ), this, SLOT( setWrapperEnabled( bool )));
  }
}
Пример #15
0
void CameraDisplay::updateCamera()
{
  sensor_msgs::CameraInfo::ConstPtr info;
  sensor_msgs::Image::ConstPtr image;
  {
    boost::mutex::scoped_lock lock(caminfo_mutex_);

    info = current_caminfo_;
    image = texture_.getImage();
  }

  if (!info || !image)
  {
    return;
  }

  stat_tracker_.sample(image->header);

  if (!validateFloats(*info))
  {
    setStatus(status_levels::Error, "CameraInfo", "Contains invalid floating point values (nans or infs)");
    return;
  }

  Ogre::Vector3 position;
  Ogre::Quaternion orientation;
  //uses the latest TF info to make sure 3D rendered view is up to date with rendered robot pose
  vis_manager_->getFrameManager()->getTransform(image->header.frame_id, ros::Time(0), position, orientation);

  // convert vision (Z-forward) frame to ogre frame (Z-out)
  orientation = orientation * Ogre::Quaternion(Ogre::Degree(180), Ogre::Vector3::UNIT_X);

  float img_width = info->width;
  float img_height = info->height;

  // If the image width is 0 due to a malformed caminfo, try to grab the width from the image.
  if (img_width == 0)
  {
    ROS_DEBUG("Malformed CameraInfo on camera [%s], width = 0", getName().c_str());

    img_width = texture_.getWidth();
  }

  if (img_height == 0)
  {
    ROS_DEBUG("Malformed CameraInfo on camera [%s], height = 0", getName().c_str());

    img_height = texture_.getHeight();
  }

  if (img_height == 0.0 || img_width == 0.0)
  {
    setStatus(status_levels::Error, "CameraInfo", "Could not determine width/height of image due to malformed CameraInfo (either width or height is 0)");
    return;
  }

  double fx = info->P[0];
  double fy = info->P[5];

  float win_width = render_panel_->width();
  float win_height = render_panel_->height();
  float zoom_x = zoom_;
  float zoom_y = zoom_;

  //preserve aspect ratio
  if ( win_width != 0 && win_height != 0 )
  {
    float img_aspect = (img_width/fx) / (img_height/fy);
    float win_aspect = win_width / win_height;

    if ( img_aspect > win_aspect )
    {
      zoom_y = zoom_y / img_aspect * win_aspect;
    }
    else
    {
      zoom_x = zoom_x / win_aspect * img_aspect;
    }
  }

  // Add the camera's translation relative to the left camera (from P[3]);
  double tx = -1 * (info->P[3] / fx);
  Ogre::Vector3 right = orientation * Ogre::Vector3::UNIT_X;
  position = position + (right * tx);

  double ty = -1 * (info->P[7] / fy);
  Ogre::Vector3 down = orientation * Ogre::Vector3::UNIT_Y;
  position = position + (down * ty);

  if (!validateFloats(position))
  {
    setStatus(status_levels::Error, "CameraInfo", "CameraInfo/P resulted in an invalid position calculation (nans or infs)");
    return;
  }

  render_panel_->getCamera()->setPosition(position);
  render_panel_->getCamera()->setOrientation(orientation);

  // calculate the projection matrix
  double cx = info->P[2];
  double cy = info->P[6];

  double far_plane = 100;
  double near_plane = 0.01;

  Ogre::Matrix4 proj_matrix;
  proj_matrix = Ogre::Matrix4::ZERO;
 
  proj_matrix[0][0]= 2.0 * fx/img_width * zoom_x;
  proj_matrix[1][1]= 2.0 * fy/img_height * zoom_y;

  proj_matrix[0][2]= 2.0 * (0.5 - cx/img_width) * zoom_x;
  proj_matrix[1][2]= 2.0 * (cy/img_height - 0.5) * zoom_y;

  proj_matrix[2][2]= -(far_plane+near_plane) / (far_plane-near_plane);
  proj_matrix[2][3]= -2.0*far_plane*near_plane / (far_plane-near_plane);

  proj_matrix[3][2]= -1;

  render_panel_->getCamera()->setCustomProjectionMatrix( true, proj_matrix );

  setStatus(status_levels::Ok, "CameraInfo", "OK");

#if 0
  static Axes* debug_axes = new Axes(scene_manager_, 0, 0.2, 0.01);
  debug_axes->setPosition(position);
  debug_axes->setOrientation(orientation);
#endif

  //adjust the image rectangles to fit the zoom & aspect ratio
  bg_screen_rect_->setCorners(-1.0f*zoom_x, 1.0f*zoom_y, 1.0f*zoom_x, -1.0f*zoom_y);
  fg_screen_rect_->setCorners(-1.0f*zoom_x, 1.0f*zoom_y, 1.0f*zoom_x, -1.0f*zoom_y);

  Ogre::AxisAlignedBox aabInf;
  aabInf.setInfinite();
  bg_screen_rect_->setBoundingBox(aabInf);
  fg_screen_rect_->setBoundingBox(aabInf);
}
Пример #16
0
CameraDisplaySave::CameraDisplaySave( const std::string& name, VisualizationManager* manager )
: Display( name, manager )
, transport_("raw")
, caminfo_tf_filter_(*manager->getTFClient(), "", 2, update_nh_)
, new_caminfo_(false)
, texture_(update_nh_)
, frame_(0)
, force_render_(false)
, render_listener_(this)
{
  scene_node_ = scene_manager_->getRootSceneNode()->createChildSceneNode();

  {
    static int count = 0;
    std::stringstream ss;
    ss << "CameraDisplaySaveObject" << count++;

    screen_rect_ = new Ogre::Rectangle2D(true);
    screen_rect_->setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY - 1);
    screen_rect_->setCorners(-1.0f, 1.0f, 1.0f, -1.0f);

    ss << "Material";
    material_ = Ogre::MaterialManager::getSingleton().create( ss.str(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
    material_->setSceneBlending( Ogre::SBT_TRANSPARENT_ALPHA );
    material_->setDepthWriteEnabled(false);

    material_->setReceiveShadows(false);
    material_->setDepthCheckEnabled(false);


#if 1
    material_->getTechnique(0)->setLightingEnabled(false);
    Ogre::TextureUnitState* tu = material_->getTechnique(0)->getPass(0)->createTextureUnitState();
    tu->setTextureName(texture_.getTexture()->getName());
    tu->setTextureFiltering( Ogre::TFO_NONE );
    tu->setAlphaOperation( Ogre::LBX_SOURCE1, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, 0.0 );
#else
    material_->getTechnique(0)->setLightingEnabled(true);
    material_->setAmbient(Ogre::ColourValue(0.0f, 1.0f, 1.0f, 1.0f));
#endif

    material_->setCullingMode(Ogre::CULL_NONE);
    Ogre::AxisAlignedBox aabInf;
    aabInf.setInfinite();
    screen_rect_->setBoundingBox(aabInf);
    screen_rect_->setMaterial(material_->getName());
    scene_node_->attachObject(screen_rect_);

  }

  setAlpha( 0.5f );

  wxWindow* parent = 0;

  WindowManagerInterface* wm = vis_manager_->getWindowManager();
  if (wm)
  {
    parent = wm->getParentWindow();
  }
  else
  {
    frame_ = new wxFrame(0, wxID_ANY, wxString::FromAscii(name.c_str()), wxPoint(100,100), wxDefaultSize, wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxRESIZE_BORDER | wxCAPTION | wxCLIP_CHILDREN);
    parent = frame_;
  }

  render_panel_ = new RenderPanel(parent, false);
  render_panel_->SetSize(wxSize(640, 480));
  if (wm)
  {
    wm->addPane(name, render_panel_);
  }

  render_panel_->createRenderWindow();
  render_panel_->initialize(vis_manager_->getSceneManager(), vis_manager_);

  render_panel_->setAutoRender(false);
  render_panel_->getRenderWindow()->addListener(&render_listener_);
  render_panel_->getViewport()->setOverlaysEnabled(false);
  render_panel_->getViewport()->setClearEveryFrame(true);
  render_panel_->getRenderWindow()->setActive(false);
  render_panel_->getRenderWindow()->setAutoUpdated(false);
  render_panel_->getCamera()->setNearClipDistance( 0.1f );

  caminfo_tf_filter_.connectInput(caminfo_sub_);
  caminfo_tf_filter_.registerCallback(boost::bind(&CameraDisplaySave::caminfoCallback, this, _1));
  vis_manager_->getFrameManager()->registerFilterForTransformStatusCheck(caminfo_tf_filter_, this);
}
Пример #17
0
EntityCollision::EntityCollision()
{
    mRenderOp.vertexData = new Ogre::VertexData();

    mRenderOp.indexData = 0;
    mRenderOp.vertexData->vertexCount = 74;
    mRenderOp.vertexData->vertexStart = 0;
    mRenderOp.operationType = Ogre::RenderOperation::OT_LINE_LIST;
    mRenderOp.useIndexes = false;

    Ogre::VertexDeclaration* decl = mRenderOp.vertexData->vertexDeclaration;
    Ogre::VertexBufferBinding* bind = mRenderOp.vertexData->vertexBufferBinding;

    decl->addElement( 0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION );
    Ogre::HardwareVertexBufferSharedPtr vbuf0 = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
            decl->getVertexSize( 0 ),
            mRenderOp.vertexData->vertexCount,
            Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY );
    bind->setBinding( 0, vbuf0 );

    float* pPos = static_cast< float* >( vbuf0->lock( Ogre::HardwareBuffer::HBL_DISCARD ) );

    *pPos++ = -1.0f; *pPos++ =  0.0f; *pPos++ =  0.0f;
    *pPos++ = -1.0f; *pPos++ =  0.0f; *pPos++ =  1.0f;

    *pPos++ = -1.0f; *pPos++ =  0.0f; *pPos++ =  0.0f;
    *pPos++ = -0.9f; *pPos++ =  0.5f; *pPos++ =  0.0f;
    *pPos++ = -0.9f; *pPos++ =  0.5f; *pPos++ =  0.0f;
    *pPos++ = -0.9f; *pPos++ =  0.5f; *pPos++ =  1.0f;
    *pPos++ = -0.9f; *pPos++ =  0.5f; *pPos++ =  1.0f;
    *pPos++ = -1.0f; *pPos++ =  0.0f; *pPos++ =  1.0f;

    *pPos++ = -0.9f; *pPos++ =  0.5f; *pPos++ =  0.0f;
    *pPos++ = -0.5f; *pPos++ =  0.9f; *pPos++ =  0.0f;
    *pPos++ = -0.5f; *pPos++ =  0.9f; *pPos++ =  0.0f;
    *pPos++ = -0.5f; *pPos++ =  0.9f; *pPos++ =  1.0f;
    *pPos++ = -0.5f; *pPos++ =  0.9f; *pPos++ =  1.0f;
    *pPos++ = -0.9f;  *pPos++ =  0.5f;*pPos++ =  1.0f;

    *pPos++ = -0.5f; *pPos++ =  0.9f; *pPos++ =  0.0f;
    *pPos++ =  0.0f; *pPos++ =  1.0f; *pPos++ =  0.0f;
    *pPos++ =  0.0f; *pPos++ =  1.0f; *pPos++ =  0.0f;
    *pPos++ =  0.0f; *pPos++ =  1.0f; *pPos++ =  1.0f;
    *pPos++ =  0.0f; *pPos++ =  1.0f; *pPos++ =  1.0f;
    *pPos++ = -0.5f; *pPos++ =  0.9f; *pPos++ =  1.0f;

    *pPos++ =  0.0f; *pPos++ =  1.0f; *pPos++ =  0.0f;
    *pPos++ =  0.5f; *pPos++ =  0.9f; *pPos++ =  0.0f;
    *pPos++ =  0.5f; *pPos++ =  0.9f; *pPos++ =  0.0f;
    *pPos++ =  0.5f; *pPos++ =  0.9f; *pPos++ =  1.0f;
    *pPos++ =  0.5f; *pPos++ =  0.9f; *pPos++ =  1.0f;
    *pPos++ =  0.0f; *pPos++ =  1.0f; *pPos++ =  1.0f;

    *pPos++ =  0.5f; *pPos++ =  0.9f; *pPos++ =  0.0f;
    *pPos++ =  0.9f; *pPos++ =  0.5f; *pPos++ =  0.0f;
    *pPos++ =  0.9f; *pPos++ =  0.5f; *pPos++ =  0.0f;
    *pPos++ =  0.9f; *pPos++ =  0.5f; *pPos++ =  1.0f;
    *pPos++ =  0.9f; *pPos++ =  0.5f; *pPos++ =  1.0f;
    *pPos++ =  0.5f; *pPos++ =  0.9f; *pPos++ =  1.0f;

    *pPos++ =  0.9f; *pPos++ =  0.5f; *pPos++ =  0.0f;
    *pPos++ =  1.0f; *pPos++ =  0.0f; *pPos++ =  0.0f;
    *pPos++ =  1.0f; *pPos++ =  0.0f; *pPos++ =  0.0f;
    *pPos++ =  1.0f; *pPos++ =  0.0f; *pPos++ =  1.0f;
    *pPos++ =  1.0f; *pPos++ =  0.0f; *pPos++ =  1.0f;
    *pPos++ =  0.9f; *pPos++ =  0.5f; *pPos++ =  1.0f;

    *pPos++ = -1.0f; *pPos++ =  0.0f; *pPos++ =  0.0f;
    *pPos++ = -0.9f; *pPos++ = -0.5f; *pPos++ =  0.0f;
    *pPos++ = -0.9f; *pPos++ = -0.5f; *pPos++ =  0.0f;
    *pPos++ = -0.9f; *pPos++ = -0.5f; *pPos++ =  1.0f;
    *pPos++ = -0.9f; *pPos++ = -0.5f; *pPos++ =  1.0f;
    *pPos++ = -1.0f; *pPos++ =  0.0f; *pPos++ =  1.0f;

    *pPos++ = -0.9f; *pPos++ = -0.5f; *pPos++ =  0.0f;
    *pPos++ = -0.5f; *pPos++ = -0.9f; *pPos++ =  0.0f;
    *pPos++ = -0.5f; *pPos++ = -0.9f; *pPos++ =  0.0f;
    *pPos++ = -0.5f; *pPos++ = -0.9f; *pPos++ =  1.0f;
    *pPos++ = -0.5f; *pPos++ = -0.9f; *pPos++ =  1.0f;
    *pPos++ = -0.9f; *pPos++ = -0.5f; *pPos++ =  1.0f;

    *pPos++ = -0.5f; *pPos++ = -0.9f; *pPos++ =  0.0f;
    *pPos++ =  0.0f; *pPos++ = -1.0f; *pPos++ =  0.0f;
    *pPos++ =  0.0f; *pPos++ = -1.0f; *pPos++ =  0.0f;
    *pPos++ =  0.0f; *pPos++ = -1.0f; *pPos++ =  1.0f;
    *pPos++ =  0.0f; *pPos++ = -1.0f; *pPos++ =  1.0f;
    *pPos++ = -0.5f; *pPos++ = -0.9f; *pPos++ =  1.0f;

    *pPos++ =  0.0f; *pPos++ = -1.0f; *pPos++ =  0.0f;
    *pPos++ =  0.5f; *pPos++ = -0.9f; *pPos++ =  0.0f;
    *pPos++ =  0.5f; *pPos++ = -0.9f; *pPos++ =  0.0f;
    *pPos++ =  0.5f; *pPos++ = -0.9f; *pPos++ =  1.0f;
    *pPos++ =  0.5f; *pPos++ = -0.9f; *pPos++ =  1.0f;
    *pPos++ =  0.0f; *pPos++ = -1.0f; *pPos++ =  1.0f;

    *pPos++ =  0.5f; *pPos++ = -0.9f; *pPos++ =  0.0f;
    *pPos++ =  0.9f; *pPos++ = -0.5f; *pPos++ =  0.0f;
    *pPos++ =  0.9f; *pPos++ = -0.5f; *pPos++ =  0.0f;
    *pPos++ =  0.9f; *pPos++ = -0.5f; *pPos++ =  1.0f;
    *pPos++ =  0.9f; *pPos++ = -0.5f; *pPos++ =  1.0f;
    *pPos++ =  0.5f; *pPos++ = -0.9f; *pPos++ =  1.0f;

    *pPos++ =  0.9f; *pPos++ = -0.5f; *pPos++ =  0.0f;
    *pPos++ =  1.0f; *pPos++ =  0.0f; *pPos++ =  0.0f;
    *pPos++ =  1.0f; *pPos++ =  0.0f; *pPos++ =  0.0f;
    *pPos++ =  1.0f; *pPos++ =  0.0f; *pPos++ =  1.0f;
    *pPos++ =  1.0f; *pPos++ =  0.0f; *pPos++ =  1.0f;
    *pPos++ =  0.9f; *pPos++ = -0.5f; *pPos++ =  1.0f;

    vbuf0->unlock();

    Ogre::AxisAlignedBox aabb;
    aabb.setInfinite();
    setBoundingBox( aabb );
}
Пример #18
0
int initOgreAR(aruco::CameraParameters camParams, unsigned char* buffer, std::string resourcePath)
{
	/// INIT OGRE FUNCTIONS
#ifdef _WIN32
  	root = new Ogre::Root(resourcePath + "plugins_win.cfg", resourcePath + "ogre_win.cfg");
#elif __x86_64__ || __ppc64__
	root = new Ogre::Root(resourcePath + "plugins_x64.cfg", resourcePath + "ogre.cfg");
#else
	root = new Ogre::Root(resourcePath + "plugins.cfg", resourcePath + "ogre.cfg");
#endif
  	if (!root->showConfigDialog()) return -1;
	Ogre::SceneManager* smgr = root->createSceneManager(Ogre::ST_GENERIC);


	/// CREATE WINDOW, CAMERA AND VIEWPORT
    Ogre::RenderWindow* window = root->initialise(true);
	Ogre::Camera *camera;
	Ogre::SceneNode* cameraNode;
	camera = smgr->createCamera("camera");
	camera->setNearClipDistance(0.01f);
	camera->setFarClipDistance(10.0f);
	camera->setProjectionType(Ogre::PT_ORTHOGRAPHIC);
	camera->setPosition(0, 0, 0);
	camera->lookAt(0, 0, 1);
	double pMatrix[16];
	camParams.OgreGetProjectionMatrix(camParams.CamSize,camParams.CamSize, pMatrix, 0.05,10, false);
	Ogre::Matrix4 PM(pMatrix[0], pMatrix[1], pMatrix[2] , pMatrix[3],
			pMatrix[4], pMatrix[5], pMatrix[6] , pMatrix[7],
			pMatrix[8], pMatrix[9], pMatrix[10], pMatrix[11],
			pMatrix[12], pMatrix[13], pMatrix[14], pMatrix[15]);
	camera->setCustomProjectionMatrix(true, PM);
	camera->setCustomViewMatrix(true, Ogre::Matrix4::IDENTITY);
	window->addViewport(camera);
	cameraNode = smgr->getRootSceneNode()->createChildSceneNode("cameraNode");
	cameraNode->attachObject(camera);


	/// CREATE BACKGROUND FROM CAMERA IMAGE
	int width = camParams.CamSize.width;
	int height = camParams.CamSize.height;
	// create background camera image
	mPixelBox = Ogre::PixelBox(width, height, 1, Ogre::PF_R8G8B8, buffer);
	// Create Texture
	mTexture = Ogre::TextureManager::getSingleton().createManual("CameraTexture",Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
		      Ogre::TEX_TYPE_2D,width,height,0,Ogre::PF_R8G8B8,Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);

	//Create Camera Material
	Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create("CameraMaterial", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
	Ogre::Technique *technique = material->createTechnique();
	technique->createPass();
	material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
	material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
	material->getTechnique(0)->getPass(0)->createTextureUnitState("CameraTexture");

	Ogre::Rectangle2D* rect = new Ogre::Rectangle2D(true);
	rect->setCorners(-1.0, 1.0, 1.0, -1.0);
	rect->setMaterial("CameraMaterial");

	// Render the background before everything else
	rect->setRenderQueueGroup(Ogre::RENDER_QUEUE_BACKGROUND);

	// Hacky, but we need to set the bounding box to something big, use infinite AAB to always stay visible
	Ogre::AxisAlignedBox aabInf;
	aabInf.setInfinite();
	rect->setBoundingBox(aabInf);

	// Attach background to the scene
	Ogre::SceneNode* node = smgr->getRootSceneNode()->createChildSceneNode("Background");
	node->attachObject(rect);


	/// CREATE SIMPLE OGRE SCENE
	// add sinbad.mesh
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(resourcePath + "Sinbad.zip", "Zip", "Popular");
 	Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
	for(int i=0; i<MAX_MARKERS; i++) {
	  Ogre::String entityName = "Marker_" + Ogre::StringConverter::toString(i);
	  Ogre::Entity* ogreEntity = smgr->createEntity(entityName, "Sinbad.mesh");
	  Ogre::Real offset = ogreEntity->getBoundingBox().getHalfSize().y;
	  ogreNode[i] = smgr->getRootSceneNode()->createChildSceneNode();
	  // add entity to a child node to correct position (this way, entity axis is on feet of sinbad)
	  Ogre::SceneNode *ogreNodeChild = ogreNode[i]->createChildSceneNode();
	  ogreNodeChild->attachObject(ogreEntity);
	  // Sinbad is placed along Y axis, we need to rotate to put it along Z axis so it stands up over the marker
	  // first rotate along X axis, then add offset in Z dir so it is over the marker and not in the middle of it
	  ogreNodeChild->rotate(Ogre::Vector3(1,0,0), Ogre::Radian(Ogre::Degree(90)));
	  ogreNodeChild->translate(0,0,offset,Ogre::Node::TS_PARENT);
	  // mesh is too big, rescale!
	  const float scale = 0.006675f;
	  ogreNode[i]->setScale(scale, scale, scale);

	    // Init animation
	  ogreEntity->getSkeleton()->setBlendMode(Ogre::ANIMBLEND_CUMULATIVE);
	  if(i==0)
	  {
        baseAnim[i] = ogreEntity->getAnimationState("HandsClosed");
        topAnim[i] = ogreEntity->getAnimationState("HandsRelaxed");
	  }
	  else if(i==1)
	  {
        baseAnim[i] = ogreEntity->getAnimationState("Dance");
        topAnim[i] = ogreEntity->getAnimationState("Dance");
	  }
	  else if(i==2)
	  {
        baseAnim[i] = ogreEntity->getAnimationState("RunBase");
        topAnim[i] = ogreEntity->getAnimationState("RunTop");
	  }
	  else
	  {
        baseAnim[i] = ogreEntity->getAnimationState("IdleBase");
        topAnim[i] = ogreEntity->getAnimationState("IdleTop");
	  }
	  baseAnim[i]->setLoop(true);
	  topAnim[i]->setLoop(true);
	  baseAnim[i]->setEnabled(true);
	  topAnim[i]->setEnabled(true);
	}


 	/// KEYBOARD INPUT READING
 	size_t windowHnd = 0;
 	window->getCustomAttribute("WINDOW", &windowHnd);
 	im = OIS::InputManager::createInputSystem(windowHnd);
 	keyboard = static_cast<OIS::Keyboard*>(im->createInputObject(OIS::OISKeyboard, true));

	return 1;
}