Esempio n. 1
0
//---------------------------------------------------------------------------
Ogre::CompositorInstance::Listener* HDRLogic::createListener(Ogre::CompositorInstance* instance)
{
    LOG_FUNCTION
	HDRListener* listener = new HDRListener;
	Ogre::Viewport* vp = instance->getChain()->getViewport();
	listener->notifyViewportSize(vp->getActualWidth(), vp->getActualHeight());
	listener->notifyCompositor(instance);
	return listener;
}
Esempio n. 2
0
//---------------------------------------------------------------------------
void BaseApplication::createViewports(void)
{
    // Create one viewport, entire window
    Ogre::Viewport* vp = mWindow->addViewport(mCamera);
    vp->setBackgroundColour(Ogre::ColourValue(0,0,0));

    // Alter the camera aspect ratio to match the viewport
    mCamera->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));
}
//---------------------------------------------------------------------------
void TutorialApplication::createViewports()
{
    Ogre::Viewport* vp = mWindow->addViewport(mCamera);
    vp->setBackgroundColour(Ogre::ColourValue(0,0,0));

    mCamera->setAspectRatio(
        Ogre::Real(vp->getActualWidth()) /
        Ogre::Real(vp->getActualHeight()));
}
Esempio n. 4
0
void GUIManager::AdjustPauseMenuPosition()
{
    Ogre::Viewport* viewport = RoR::App::GetOgreSubsystem()->GetRenderWindow()->getViewport(0);
    int margin = (viewport->getActualHeight() / 15);
    m_impl->panel_GamePauseMenu.SetPosition(
        margin, // left
        viewport->getActualHeight() - m_impl->panel_GamePauseMenu.GetHeight() - margin // top
        );
}
Esempio n. 5
0
int main(int argc, char* argv[]){
    cout << "Test Ogre Program" << endl;

    //Relative to where its executed from, not binary location
    Ogre::Root *mRoot = new Ogre::Root("configs/plugins.cfg","configs/config.cfg","logs/main.log");
    if(!(mRoot->restoreConfig() || mRoot->showConfigDialog())){
        delete mRoot;
        return -1;
    }

    // setup resources
    // Only add the minimally required resource locations to load up the Ogre head mesh
    Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/Users/jgrey/OgreSDK/Media/materials/programs", "FileSystem", "General");
    Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/Users/jgrey/OgreSDK/Media/materials/programs/GLSL", "FileSystem", "General");
    Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/Users/jgrey/OgreSDK/Media/materials/scripts", "FileSystem", "General");
    Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/Users/jgrey/OgreSDK/Media/materials/textures", "FileSystem", "General");
    Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/Users/jgrey/OgreSDK/Media/models", "FileSystem", "General");
    Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/Users/jgrey/github/Ogre_test/data","FileSystem","General");


    //Create the window
    Ogre::RenderWindow *mWindow = mRoot->initialise(true, "initial Render Window");
    Ogre::SceneManager *sceneManager = mRoot->createSceneManager(Ogre::ST_GENERIC);

    Ogre::Camera *camera = sceneManager->createCamera("PlayerCam");

    camera->setPosition(Ogre::Vector3(0,0,80));
    camera->lookAt(Ogre::Vector3(0,0,-300));
    camera->setNearClipDistance(5);

    Ogre::Viewport* vp = mWindow->addViewport(camera);
    vp->setBackgroundColour(Ogre::ColourValue(0,0,0,0));
    camera->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));

    Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

    //Ogre::Entity* ogreHead = sceneManager->createEntity("Head","ogreHead.mesh");
    Ogre::Entity* ogreHead = sceneManager->createEntity("Head","myTest.obj");
    Ogre::SceneNode* headNode = sceneManager->getRootSceneNode()->createChildSceneNode();
    headNode->attachObject(ogreHead);

    sceneManager->setAmbientLight(Ogre::ColourValue(0.5,0.5,0.5));

    //Run the system
    bool continueRunning = true;
    while(continueRunning){
        mRoot->renderOneFrame();
        headNode->rotate(Ogre::Vector3(0,1,0),Ogre::Radian(0.005));
        if(mWindow->isClosed()){
            continueRunning = false;
        }

    }

    delete mRoot;
}
Esempio n. 6
0
//Ogre::Viewport::getBackgroundColour() const
void viewport_get_background_colour(ViewportHandle handle, coiColourValue* cv)
{
    Ogre::Viewport* vp = reinterpret_cast<Ogre::Viewport*>(handle);
    const Ogre::ColourValue &c = vp->getBackgroundColour();

    cv->r = c.r;
    cv->b = c.b;
    cv->g = c.g;
    cv->a = c.a;
}
Esempio n. 7
0
void MultiMgrSample::setupViewport(Ogre::SceneManager *curr)
{
	mWindow->removeAllViewports();

	Ogre::Camera *cam = curr->getCamera(CAMERA_NAME);
	Ogre::Viewport *vp = mWindow->addViewport(cam);

	vp->setBackgroundColour(Ogre::ColourValue(0,0,0));
	cam->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));
}
bool CSimulatorWindowHandler::view3DButtonClicked(const CEGUI::EventArgs& e)
{
    m_renderTexture->removeAllViewports();
    Ogre::Viewport *viewport = m_renderTexture->addViewport(m_cam3D);
    viewport->setOverlaysEnabled(false);
    viewport->setClearEveryFrame(true);
    viewport->setBackgroundColour(Ogre::ColourValue::Black);

    return true;
}
GameState*          StateManager::changeState     ( const std::string& state_name, Ogre::RenderWindow* window ){
    _prev_state = _current_state;
    _current_state = _states[state_name];
    window->removeAllViewports();
    Ogre::Camera* camera = _current_state->getScene()->getCamera(MainCameraName);
    Ogre::Viewport* vp = window->addViewport(camera);
    vp->setBackgroundColour(Ogre::ColourValue(0.5,0.5,0.5));
    camera->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));
    return _current_state;
}
Esempio n. 10
0
// -----------------------------------------------------------------------------
CardEditor::CardEditor(EditorProject* project, DeckEditor* parentEditor, QWidget *parent, Qt::WFlags flags)
	: QWidget(parent, flags), 
		EditorWidget(project, parentEditor), 
		widget(0), 
		cards(project->getCards()), 
		current(0), 
		hasChanged(false),
		notified(false),
		currentItem(0),
		cardCount(cards.size()),
		rsError(false) {

		ui.setupUi(this);

		// We're trying to create a 3D Render Preview. If this fails, the user
		// will still be able to edit stuff, but can't preview changes.
		try {
			// Create Editor RenderView
			widget = new OgreWidget(Util::toQString(EditorSystem::getInstance().getRenderView()), ui.ogreWidget);

			widget->setBaseSize(QSize(288,384));
			widget->setFixedWidth(288);
			widget->setFixedHeight(384);
			widget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
			widget->setFocusPolicy(Qt::NoFocus);

			ui.ogreWidget->setAttribute(Qt::WA_PaintOnScreen);
			ui.ogreWidget->setAttribute(Qt::WA_NoSystemBackground);
			ui.ogreWidget->setAttribute(Qt::WA_NoBackground);
			ui.innerLayout->addWidget(widget, 1, 1);

			// We need a camera and Viewport in order to display anything
			Ogre::Camera* camera = Ogre::Root::getSingletonPtr()->getSceneManager("root")->createCamera("PlayerCam");
			Ogre::Viewport* viewport = static_cast<OgreWidget*>(widget)->getRenderWindow()->addViewport(camera);
			camera->setAspectRatio(
				Ogre::Real(viewport->getActualWidth()) / Ogre::Real(viewport->getActualHeight()));

			// Initialize UI & associated Managers
			Arcomage::UI::UIManager::getInstance().bootstrap();
		
			// Preload required Editor Fonts
			Arcomage::ResourceManager::getInstance().preloadResources(
				Arcomage::ConfigurationManager::getInstance().getPath("Fonts")+"/fonts.xml",
				/* unused, Music */ "", 
				/* unused, Sound effects */ "");
			
		} catch (Ogre::Exception& e) {
			rsError = true; 
			widget = new OgreWidget("errorwidget", ui.ogreWidget, true);
			ToolkitUtil::getInstance().notifyError(e.what());
		}

		populateTree();
		this->connectUI();
}
Esempio n. 11
0
//-------------------------------------------------------------------------------------
void THIS::createViewports(void)
{
    cout << "<TRACE><LOG><SceneManager><createViewports>  " << endl;
    // Create one viewport, entire window
    Ogre::Viewport* vp = mWindow->addViewport(mCamera);
    vp->setBackgroundColour(Ogre::ColourValue(0,0,0));

    // Alter the camera aspect ratio to match the viewport
    mCamera->setAspectRatio(
                Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));
}
		/// r,g,b,a
		static int		SetBackCol 		(lua_State *L) { PROFILE
			Ogre::Viewport* pViewport = checkudata_alive(L)->mpViewport;
			if (!pViewport) return 0;
			int numargs=lua_gettop(L);
			Ogre::Real r 			= (numargs >= 2 && !lua_isnil(L,2)) ? luaL_checknumber(L,2) : 0;
			Ogre::Real g 			= (numargs >= 3 && !lua_isnil(L,3)) ? luaL_checknumber(L,3) : 0;
			Ogre::Real b 			= (numargs >= 4 && !lua_isnil(L,4)) ? luaL_checknumber(L,4) : 0;
			Ogre::Real a 			= (numargs >= 5 && !lua_isnil(L,5)) ? luaL_checknumber(L,5) : 0;
			pViewport->setBackgroundColour(Ogre::ColourValue(r,g,b,a));
			return 0;
		}
Esempio n. 13
0
MiniMapManager::MiniMapManager(Ogre::Root *root, Ogre::RenderWindow *window): mRoot(root), mWindow(window)
{
	mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC, "MiniMapSceneMgr");
	mCamera = mSceneMgr->createCamera("miniMapCamera");

	Ogre::Viewport *vp = mWindow->addViewport(mCamera, 1, 0, 0.8, 0.2, 0.2);
	vp->setBackgroundColour(Ogre::ColourValue(0, 0, 0));
	mCamera->setAutoAspectRatio((Ogre::Real(vp->getActualWidth())) / (Ogre::Real(vp->getActualHeight())));
	
	mSceneMgr->setAmbientLight(Ogre::ColourValue(0.8, 0.8, 0.8));
}
Esempio n. 14
0
			// funcion que configura la camara
			void createCamera(Ogre::RenderWindow* window){
				camera = _sceneManager->createCamera("Camera");
				camera->setPosition(Ogre::Vector3(0,60,-100));
				camera->lookAt(Ogre::Vector3(0,0,50));
				camera->setNearClipDistance(5);

				Ogre::Viewport* viewport = window->addViewport(camera);
				viewport->setBackgroundColour(Ogre::ColourValue(0.0,0.0,0.0));
				camera->setAspectRatio(Ogre::Real(viewport->getActualWidth())/Ogre::Real(viewport->getActualHeight()));

			}
Esempio n. 15
0
void OGKSceneManager::setActiveScene(const Ogre::String name, Ogre::Real transitionTime)
{
    mPreviousScene = mActiveScene;
    mActiveScene = getScene(name);
    
    Ogre::ColourValue bg = Ogre::ColourValue::Black;
    
    if(mPreviousScene) {
        if(mPreviousScene->mCamera) {
            // save viewport settings for rtt
            Ogre::Camera *cam = mPreviousScene->mCamera->getCamera();
            bg = cam->getViewport()->getBackgroundColour();
        }
        mPreviousScene->onExitTransitionDidStart();
    }
    
    if(mActiveScene) {
        OGKLOG("Transitioning to " + name + " scene");
        mActiveScene->onEnter();
    }
    
    if(transitionTime > 0.01) {
        // transition
        mTransitionTime = transitionTime;
        mTransitionTimeRemaining = transitionTime;
        
        _initRTT();
        
        if(mPreviousScene && mPreviousScene->mCamera &&
           mPreviousScene->mCamera->getCamera()) {
            // render to texture instead
            Ogre::Camera *cam = mPreviousScene->mCamera->getCamera();
            mRenderTexture->removeAllViewports();
            Ogre::Viewport *vp = mRenderTexture->addViewport(cam);
            if(vp) {
                //OGKLOG("Preparing rtt viewport");
                vp->setClearEveryFrame(true);
                vp->setBackgroundColour(bg);
                vp->setOverlaysEnabled(true);
                vp->setCamera(cam);
            }
        }

        if(mOverlay) {
            //OGKLOG("Showing Overlay");
            mOverlay->show();
        }
    }
    else {
        if(mPreviousScene) mPreviousScene->onExit();
        if(mActiveScene) mActiveScene->onEnterTransitionDidFinish();
    }
}
//-------------------------------------------------------------------------------------
void DigitalForensicsVisualisation::createViewports(void)
{
	    // Create one viewport, entire window
    Ogre::Viewport* vp = mWindow->addViewport(mCamera);
    vp->setBackgroundColour(Ogre::ColourValue(.35,.35,.35));
    // Alter the camera aspect ratio to match the viewport
	//mCamera->setFarClipDistance(2000);
	
	mCamera->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));  
	mCamera->pitch(static_cast <Ogre::Radian>(-0.45));

}
Esempio n. 17
0
/**
 * @brief setup the rendering context
 * @author Kito Berg-Taylor
 */
void OgreWidget::initializeGL()
{
 //== Creating and Acquiring Ogre Window ==//
 
  // Get the parameters of the window QT created
  Ogre::String winHandle;
  #ifdef WIN32
  // Windows code
  winHandle += Ogre::StringConverter::toString((unsigned long)(this->parentWidget()->winId()));
  #else
  // Unix code
  QX11Info info = x11Info();
  winHandle  = Ogre::StringConverter::toString((unsigned long)(info.display()));
  winHandle += ":";
  winHandle += Ogre::StringConverter::toString((unsigned int)(info.screen()));
  winHandle += ":";
  winHandle += Ogre::StringConverter::toString((unsigned long)(this->parentWidget()->winId()));
  #endif
 
  Ogre::NameValuePairList params;
  params["parentWindowHandle"] = winHandle;
 
  mOgreWindow = mOgreRoot->createRenderWindow( "QOgreWidget_RenderWindow",
                           this->width(),
                           this->height(),
                           false,
                           &params );
 
  mOgreWindow->setActive(true);
  WId ogreWinId = 0x0;
  mOgreWindow->getCustomAttribute( "WINDOW", &ogreWinId );
 
  assert( ogreWinId );
 
  this->create( ogreWinId );
  setAttribute( Qt::WA_PaintOnScreen, true );
  setAttribute( Qt::WA_NoBackground );
 
  //== Ogre Initialization ==//
  Ogre::SceneType scene_manager_type = Ogre::ST_EXTERIOR_CLOSE;
 
  mSceneMgr = mOgreRoot->createSceneManager( scene_manager_type );
  mSceneMgr->setAmbientLight( Ogre::ColourValue(1,1,1) );
 
  mCamera = mSceneMgr->createCamera( "QOgreWidget_Cam" );
  mCamera->setPosition( Ogre::Vector3(0,1,0) );
  mCamera->lookAt( Ogre::Vector3(0,0,0) );
  mCamera->setNearClipDistance( 1.0 );
 
  Ogre::Viewport *mViewport = mOgreWindow->addViewport( mCamera );
  mViewport->setBackgroundColour( Ogre::ColourValue( 0.8,0.8,1 ) );
}
Esempio n. 18
0
void OgreWidget::moveAndResize()
{
    mWindow->reposition(x(), y());
    mWindow->resize(width(), height());
    mWindow->windowMovedOrResized();

    for (int ct = 0; ct < mWindow->getNumViewports(); ++ct)
    {
        Ogre::Viewport* pViewport = mWindow->getViewport(ct);
        Ogre::Camera* pCamera = pViewport->getCamera();
        pCamera->setAspectRatio(static_cast<Ogre::Real>(pViewport->getActualWidth()) / static_cast<Ogre::Real>(pViewport->getActualHeight()));
    }
}
Esempio n. 19
0
	// дл¤ оповещений об изменении окна рендера
	void Gui::windowResized(Ogre::RenderWindow* rw)
	{
		FloatSize oldViewSize = mViewSize;

		Ogre::Viewport * port = rw->getViewport(mActiveViewport);
		mViewSize.set(port->getActualWidth(), port->getActualHeight());
		mLayerManager->_windowResized(mViewSize);

		// выравниваем рутовые окна
		for (VectorWidgetPtr::iterator iter = mWidgetChild.begin(); iter!=mWidgetChild.end(); ++iter) {
			_alignWidget((*iter), oldViewSize, mViewSize);
		}
	}
Esempio n. 20
0
void AsteroidGame::InitViewport(void){

    try {

        /* Retrieve scene manager and root scene node */
        Ogre::SceneManager* scene_manager = ogre_root_->createSceneManager(Ogre::ST_GENERIC, "MySceneManager");
        Ogre::SceneNode* root_scene_node = scene_manager->getRootSceneNode();

        /* Create camera object */
        camera = scene_manager->createCamera("MyCamera");
        Ogre::SceneNode* camera_scene_node = root_scene_node->createChildSceneNode("MyCameraNode");
        camera_scene_node->attachObject(camera);

        camera->setNearClipDistance(camera_near_clip_distance_g);
        camera->setFarClipDistance(camera_far_clip_distance_g); 

		camera->setPosition(camera_position_g);
		camera->lookAt(camera_look_at_g);
		//camera->setFixedYawAxis(true, camera_up_g);

        /* Create second camera object */
        camera_2 = scene_manager->createCamera("MyCamera_2");
        Ogre::SceneNode* camera_scene_node_2 = root_scene_node->createChildSceneNode("MyCameraNode_2");
        camera_scene_node_2->attachObject(camera_2);

        camera_2->setNearClipDistance(camera_near_clip_distance_g);
        camera_2->setFarClipDistance(camera_far_clip_distance_g); 

		camera_2->setPosition(camera_position_g);
		camera_2->lookAt(camera_look_at_g);
		//camera->setFixedYawAxis(true, camera_up_g);

		/*Create viewport */
        Ogre::Viewport *viewport = ogre_window_->addViewport(camera, viewport_z_order_g, viewport_left_g, viewport_top_g, viewport_width_g, viewport_height_g);

        viewport->setAutoUpdated(true);
        viewport->setBackgroundColour(viewport_background_color_g);

		/* Set aspect ratio */
		float ratio = float(viewport->getActualWidth()) / float(viewport->getActualHeight());
        camera->setAspectRatio(ratio);
		camera_2->setAspectRatio(ratio);

    }
    catch (Ogre::Exception &e){
        throw(OgreAppException(std::string("Ogre::Exception: ") + std::string(e.what())));
    }
    catch(std::exception &e){
        throw(OgreAppException(std::string("std::Exception: ") + std::string(e.what())));
    }
}
Esempio n. 21
0
void EC_RttTarget::PrepareRtt()
{
    if (!ViewEnabled())
        return;

    //\todo XXX reconfig via AttributeUpdated when these change
    int x = width.Get();
    int y = height.Get();

    // Get the camera ec
    EC_Camera *ec_camera = ParentEntity()->GetComponent<EC_Camera>().get();
    if (!ec_camera)
    {
        LogInfo("No camera for rtt.");
        return; //XXX note: doesn't reschedule, so won't start working if cam added afterwards
    }

    ec_camera->GetCamera()->setAspectRatio(Ogre::Real(x) / Ogre::Real(y));

    Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton().getByName(textureName.Get().toStdString());
    if (tex.isNull())
    {
        tex = Ogre::TextureManager::getSingleton().createManual(textureName.Get().toStdString(),
            Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, x, y, 0,
            Ogre::PF_A8R8G8B8, Ogre::TU_RENDERTARGET);
    }

    Ogre::RenderTexture *render_texture = tex->getBuffer()->getRenderTarget();
    if (render_texture)
    {
        render_texture->removeAllViewports();
        Ogre::Viewport *vp = 0;
        vp = render_texture->addViewport(ec_camera->GetCamera());
        // Exclude ui overlays
        vp->setOverlaysEnabled(false);
        // Exclude highlight mesh from rendering
        vp->setVisibilityMask(0x2);

        render_texture->update(false);
        tex->getBuffer()->getRenderTarget()->setAutoUpdated(false); 
    }
    else
        LogError("render target texture getting failed.");

    //create material to show the texture
    material_name_ = textureName.Get().toStdString() + "_mat"; //renderer_.lock()->GetUniqueObjectName("EC_BillboardWidget_mat");
    OgreRenderer::CloneMaterial("HoveringText", material_name_); //would LitTextured be the right thing? XXX \todo
    Ogre::MaterialManager &material_manager = Ogre::MaterialManager::getSingleton();
    Ogre::MaterialPtr material = material_manager.getByName(material_name_);
    OgreRenderer::SetTextureUnitOnMaterial(material, textureName.Get().toStdString());
}
Esempio n. 22
0
 void ReliefApp::GenerateRelief()
 {
     //Get depth data
     Ogre::TexturePtr depthTex = Ogre::TextureManager::getSingleton().createManual(  
         "DepthTexture",      // name   
         Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,  
         Ogre::TEX_TYPE_2D,   // type   
         512,  // width   
         512,  // height   
         0,                   // number of mipmaps   
         //Ogre::PF_B8G8R8A8,   // pixel format
         Ogre::PF_FLOAT32_R,
         Ogre::TU_RENDERTARGET
         ); 
     Ogre::RenderTarget* pTarget = depthTex->getBuffer()->getRenderTarget();
     Ogre::Camera* pOrthCam = MagicCore::RenderSystem::GetSingleton()->GetMainCamera();
     pOrthCam->setProjectionType(Ogre::PT_ORTHOGRAPHIC);
     pOrthCam->setOrthoWindow(3, 3);
     pOrthCam->setPosition(0, 0, 3);
     pOrthCam->lookAt(0, 0, 0);
     pOrthCam->setAspectRatio(1.0);
     pOrthCam->setNearClipDistance(0.5);
     pOrthCam->setFarClipDistance(5);
     Ogre::Viewport* pViewport = pTarget->addViewport(pOrthCam);
     pViewport->setDimensions(0, 0, 1, 1);
     MagicCore::RenderSystem::GetSingleton()->RenderLightMesh3D("RenderMesh", "Depth", mpLightMesh);
     MagicCore::RenderSystem::GetSingleton()->Update();
     Ogre::Image img;
     depthTex->convertToImage(img);
     std::vector<double> heightField(512 * 512);
     for(int x = 0; x < 512; x++)  
     {  
         for(int y = 0; y < 512; y++)  
         {
             heightField.at(x * 512 + y) = (img.getColourAt(x, 511 - y, 0))[1];
         }
     }
     Ogre::TextureManager::getSingleton().remove("DepthTexture");
     //
     MagicDGP::LightMesh3D* pReliefMesh = MagicDGP::ReliefGeneration::PlaneReliefFromHeightField(heightField, 511, 511);
     //MagicDGP::LightMesh3D* pReliefMesh = MagicDGP::ReliefGeneration::CylinderReliefFromHeightField(heightField, 511, 511);
     if (pReliefMesh != NULL)
     {
         delete mpLightMesh;
         mpLightMesh = pReliefMesh;
         mpLightMesh->UnifyPosition(2);
         mpLightMesh->UpdateNormal();
     }
     MagicCore::RenderSystem::GetSingleton()->SetupCameraDefaultParameter();
     MagicCore::RenderSystem::GetSingleton()->RenderLightMesh3D("RenderMesh", "MyCookTorrance", mpLightMesh);
 }
Esempio n. 23
0
Player* PlayerManager::createHumanPlayer(const Ogre::String& name, Ogre::RenderWindow *window, GUI* gui)
{
    // TODO: Handle Human Multiplayer, also this code should be somewhere else
    Ogre::Camera *camera = mSceneMgr->createCamera("Player1");
    camera->setNearClipDistance(NEAR_CLIP_DISTANCE);
    Ogre::Viewport *vp = window->addViewport(camera);
    vp->setBackgroundColour(Ogre::ColourValue(0,0,0));
    camera->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));

    HumanController* hc = new HumanController(gui);
    Player* player = createPlayer(name + "Human", hc, false);
    player->attachCamera(camera);
    return player;
}
Esempio n. 24
0
		OgreCameraWrapper::OgreCameraWrapper(const Glib::ustring& name) :
			CameraWrapper(name)
		{
			// Create the camera from the scenemanager
			// ---------------------------------------
			camera = GraphicModule::getInstancePtr()->getSceneManager()->createCamera(name);

			// Create one viewport, entire window
			// ----------------------------------
			Ogre::Root* ogreRoot       = Ogre::Root::getSingletonPtr();
			Ogre::RenderWindow* window = ogreRoot->getAutoCreatedWindow();
			Ogre::Viewport* vp         = window->addViewport(camera);
			vp->setBackgroundColour(Ogre::ColourValue(0.5,1,0));
		}
Esempio n. 25
0
static void setupScene()
{
	LOGI("------->setupScene()");

	Ogre::ConfigFile cf;
	cf.load(openAPKFile("resources.cfg"));

	Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
	while (seci.hasMoreElements())
	{
		Ogre::String sec, type, arch;
		sec = seci.peekNextKey();
		Ogre::ConfigFile::SettingsMultiMap* settings = seci.getNext();
		Ogre::ConfigFile::SettingsMultiMap::iterator i;

		for (i = settings->begin(); i != settings->end(); i++)
		{
			type = i->first;
			arch = i->second;
			Ogre::ResourceGroupManager::getSingleton().addResourceLocation(arch, type, sec);
		}
	}

	Ogre::ResourceGroupManager::getSingletonPtr()->initialiseResourceGroup(
			Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);

	gSceneMgr = gRoot->createSceneManager(Ogre::ST_GENERIC);
	Ogre::Camera* camera = gSceneMgr->createCamera("MyCam");

	Ogre::Entity* pEntity = gSceneMgr->createEntity("SinbadInstance", "Sinbad.mesh");
	Ogre::SceneNode* pNode = gSceneMgr->getRootSceneNode()->createChildSceneNode();
	pNode->attachObject(pEntity);

	Ogre::Light* pDirLight = gSceneMgr->createLight();
	pDirLight->setDirection(Ogre::Vector3(0, -1, 0));
	pDirLight->setType(Ogre::Light::LT_DIRECTIONAL);
	pNode->attachObject(pDirLight);

	camera->setNearClipDistance(1.0f);
	camera->setFarClipDistance(100000.0f);
	camera->setPosition(0, 0, 20.0f);
	camera->lookAt(0, 0, 0);
	camera->setAutoAspectRatio(true);

	Ogre::Viewport* vp = gRenderWnd->addViewport(camera);
	vp->setBackgroundColour(Ogre::ColourValue(1, 0, 0));

	LOGI("<-------setupScene()");
}
Esempio n. 26
0
// We will have a single viewport.  If you wanted splitscreen, or a rear-view mirror, then
// you may want multiple viewports.
void
OgreTank::createViewports(void)
{
    // Create one viewport, entire window
    Ogre::Viewport* vp = mWindow->addViewport(mCamera);
    vp->setBackgroundColour(Ogre::ColourValue(0,0,0));
    // Alter the camera aspect ratio to match the viewport
    mCamera->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));

    Ogre::Viewport* vp2 = mWindow->addViewport(mCamera2, 1, 0.03, 0.03, 0.3, 0.3);
    vp2->setBackgroundColour(Ogre::ColourValue(0,0,0));
    vp2->setOverlaysEnabled(false);
    mCamera->setAspectRatio(Ogre::Real(vp2->getActualWidth()) / Ogre::Real(vp2->getActualHeight()));

}
Esempio n. 27
0
/**
 * @brief resize the GL window
 * @author Kito Berg-Taylor
 */
void THIS::resizeGL( int width, int height )
{
    if ( !mWindow ) return;

    mWindow->resize(width, height);
    mWindow->windowMovedOrResized();
    for(int i = 0; i < mWindow->getNumViewports(); ++i)
    {
        Ogre::Viewport* pViewport = mWindow->getViewport(i);
        Ogre::Camera* pCamera = pViewport->getCamera();
        pCamera->setAspectRatio(static_cast<Ogre::Real>(pViewport->getActualWidth()) / static_cast<Ogre::Real>(pViewport->getActualHeight()));
        pViewport->_updateDimensions();
    }
    paintGL();
}
Esempio n. 28
0
void StateManager::setupViewport( OgreManager & _ogreManager, Ogre::Camera * camera )
{
	if (camera != NULL && (camera != _ogreManager.getActiveCamera()))
	{
		_ogreManager.getWindowHandle()->removeAllViewports();
		// Create one viewport, entire window
		Ogre::Viewport* vp = _ogreManager.getWindowHandle()->addViewport(camera);
		//Set Background color
		vp->setBackgroundColour(Ogre::ColourValue(0,0,0));
		// Alter the camera aspect ratio to match the viewport
		camera->setAspectRatio(
			Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));
		_ogreManager.setActiveCamera(camera);
	}
}
Esempio n. 29
0
	void OgreWidget::resizeEvent(QResizeEvent* evt)
	{
		if(m_pOgreRenderWindow)
		{
			m_pOgreRenderWindow->resize(width(), height());
			m_pOgreRenderWindow->windowMovedOrResized();

			for(int ct = 0; ct < m_pOgreRenderWindow->getNumViewports(); ++ct)
			{
				Ogre::Viewport* pViewport = m_pOgreRenderWindow->getViewport(ct);
				Ogre::Camera* pCamera = pViewport->getCamera();
				pCamera->setAspectRatio(static_cast<Ogre::Real>(pViewport->getActualWidth()) / static_cast<Ogre::Real>(pViewport->getActualHeight()));
			}
		}
	}
	//---------------------------------------------------------------------
	void OverlaySystem::renderQueueStarted(uint8 queueGroupId, const String& invocation, 
			bool& skipThisInvocation)
	{
		if(queueGroupId == Ogre::RENDER_QUEUE_OVERLAY)
		{
			Ogre::Viewport* vp = Ogre::Root::getSingletonPtr()->getRenderSystem()->_getViewport();
			if(vp != NULL)
			{
				Ogre::SceneManager* sceneMgr = vp->getCamera()->getSceneManager();
				if (vp->getOverlaysEnabled() && sceneMgr->_getCurrentRenderStage() != Ogre::SceneManager::IRS_RENDER_TO_TEXTURE)
				{
					OverlayManager::getSingleton()._queueOverlaysForRendering(vp->getCamera(), sceneMgr->getRenderQueue(), vp);
				}
			}
		}
	}