int startup(){
		 _root = new Ogre::Root("plugins_d.cfg");
		 if(!_root->showConfigDialog()){
			 return -1;
		 }

		 Ogre::RenderWindow* window = _root->initialise(true, "Ventana Ogre");

		 _sceneManager =  _root->createSceneManager(Ogre::ST_GENERIC);

		 Ogre::Camera* camera = _sceneManager->createCamera("Camera");
		 camera->setPosition(Ogre::Vector3(500,100,500));
		 camera->lookAt(Ogre::Vector3(0,0,0));
		 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()/viewport->getActualHeight()));

		 _listener = new FrameListenerProyectos(window,camera);
		 _root->addFrameListener(_listener);

		 loadResources();
		 createScene();
		 _root->startRendering();

		 return 0;
	 }
示例#2
0
	MapPresenter::MapPresenter(ViewPtr view)
		: view_(view),
		camera_man_(0),
		scene_(0),
		event_listener_(new EventListener(this))
	{
		//add frame listener
		OgreContext* pOgreContext = WorkspaceRoot::instance()->ogreContext();
		Ogre::Root* root = pOgreContext->root();
		root->addFrameListener(event_listener_);
	}
示例#3
0
文件: graphics.cpp 项目: Mononofu/OTE
void GraphicsImpl::createFrameListener()
{
	listener = new MyFrameListener(window, camera, sceneMgr);
	listener->showDebugOverlay(true);
	root->addFrameListener(listener);

	Ogre::WindowEventUtilities::addWindowEventListener(window, this);

	//newtonListener = new OgreNewt::BasicFrameListener( window, sceneMgr, world, 120 );
	//root->addFrameListener(newtonListener);

	//caelumListener = new CaelumFrameListener( window, camera );
	//root->addFrameListener(caelumListener);
}
void application::create_frame_listener()
{
    Ogre::LogManager::getSingletonPtr() -> logMessage("Initializing OIS");
    OIS::ParamList pl;
    size_t wndhnd = 0;
    std::ostringstream wndhndstr;

    wnd->getCustomAttribute ("WINDOW", &wndhnd);
    wndhndstr << wndhnd;
    pl.insert (std::make_pair (std::string {"WINDOW"}, wndhndstr.str()));

    input = OIS::InputManager::createInputSystem(pl);

    kbd   = static_cast<OIS::Keyboard*> (input->createInputObject (OIS::OISKeyboard, true));
    mouse = static_cast<OIS::Mouse*>    (input->createInputObject (OIS::OISMouse,    true));

    mouse -> setEventCallback(this);
    kbd   -> setEventCallback(this);

    windowResized(wnd);

    Ogre::WindowEventUtilities::addWindowEventListener (wnd, this);

    OgreBites::InputContext inctx;
    inctx.mMouse    = mouse;
    inctx.mKeyboard = kbd;
    tray_mgr = new OgreBites::SdkTrayManager ("InterfaceName", wnd, inctx, this);
    tray_mgr->showFrameStats(OgreBites::TL_BOTTOMLEFT);
    tray_mgr->showLogo(OgreBites::TL_BOTTOMRIGHT);
    tray_mgr->hideCursor();

    Ogre::StringVector items;
    items.push_back("cam.pX");
    items.push_back("cam.pY");
    items.push_back("cam.pZ");
    items.push_back("");
    items.push_back("cam.oW");
    items.push_back("cam.oX");
    items.push_back("cam.oY");
    items.push_back("cam.oZ");
    items.push_back("");
    items.push_back("Filtering");
    items.push_back("Poly Mode");

    root->addFrameListener(this);
}
示例#5
0
文件: main.cpp 项目: Isaj7/finalOgre
			//Funcion que inicializa la aplicacion
			int startup(){
				_root = new Ogre::Root("plugins_d.cfg");
				
				//Muestra la ventana inicial...
				
				//if(!_root->showConfigDialog()){
				//	return -1;
				//}


				// Evitan cargar la ventana inicial...
				Ogre::RenderSystem* _rs = _root->getRenderSystemByName("Direct3D9 Rendering Subsystem");
				// or use "OpenGL Rendering Subsystem"
				_root->setRenderSystem(_rs);
				_rs->setConfigOption("Full Screen", "No");
				_rs->setConfigOption("Video Mode", "800 x 600 @ 32-bit colour");
				_rs->setConfigOption("FSAA", "0");
				_rs->setConfigOption("Floating-point mode", "Fastest");
				_rs->setConfigOption("Use Multihead", "Auto");
				_rs->setConfigOption("VSync", "No");
				_rs->setConfigOption("VSync Interval", "1");


			
				Ogre::RenderWindow* window = _root->initialise(true,"Ventana de Ogre3D");
				_sceneManager = _root->createSceneManager(Ogre::ST_GENERIC);

				
				loadResources();
				createScene();
				createCamera(window);



				_listener = new AppFrameListener(window,camera,_sceneManager);
				_root->addFrameListener(_listener);				


				//_root->startRendering();
				return 0;

				
			}
示例#6
0
void
TestScene12::runOgre()
{
	// initialize framework & open window
	Ogre::Root* root = new Ogre::Root();
	root->restoreConfig();
	root->initialise(false);
	auto window = root->createRenderWindow("Ogre RenderWindow", 800, 600, false);
	auto sceneMgr = root->createSceneManager(Ogre::ST_GENERIC);
	// adjust camera
	auto cam1 = sceneMgr->createCamera("cam1");
	auto camNode1 = sceneMgr->getRootSceneNode()->createChildSceneNode("camnode1");
	cam1->setNearClipDistance(5);
	camNode1->attachObject(cam1);
	camNode1->setPosition(Ogre::Vector3(100, 100, 100));
	camNode1->lookAt(Ogre::Vector3(-1, -1, -1), Ogre::Node::TS_LOCAL);
	window->addViewport(cam1);
	// load & integrate model
	root->addResourceLocation("./resources/Ogre", "FileSystem");
	Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
	Mesh_Cube M(1);
	M.createMesh("cube");
	Ogre::SceneNode* groups[ROWS];
	std::list<Ogre::SceneNode*> nodes;
	for (int i = 0; i < ROWS; i++)
	{
		groups[i] = sceneMgr->getRootSceneNode()->createChildSceneNode();
		nodes.push_back(groups[i]);
	}
	for (int i = 0; i < ROWS * COLS; i++)
	{
		auto node = groups[i % ROWS]->createChildSceneNode();
		node->attachObject(sceneMgr->createEntity(std::string("model") + boost::lexical_cast<std::string>(i), "cube"));
		node->setPosition(
			camNode1->getOrientation() * -Ogre::Vector3::UNIT_X * LEFT(i)
			+ camNode1->getOrientation() * Ogre::Vector3::UNIT_Y * UP(i)
		);
	}
	root->addFrameListener(new MoveObjectTask_Ogre12(nodes));
	// loop
	runOgreLoop(root);
}
	 int startup(){
		 _root = new Ogre::Root("plugins_d.cfg");
		 /*
		 if(!_root->showConfigDialog()){
			 return -1;
		 }
		 */

		 Ogre::RenderSystem* _rs = _root->getRenderSystemByName("Direct3D9 Rendering Subsystem");
		// or use "OpenGL Rendering Subsystem"
		_root->setRenderSystem(_rs);
		_rs->setConfigOption("Full Screen", "No");
		_rs->setConfigOption("Video Mode", "800 x 600 @ 32-bit colour");
		_rs->setConfigOption("FSAA", "0");
		_rs->setConfigOption("Floating-point mode", "Fastest");
		_rs->setConfigOption("Use Multihead", "Auto");
		_rs->setConfigOption("VSync", "No");
		_rs->setConfigOption("VSync Interval", "1");

		 Ogre::RenderWindow* window = _root->initialise(true, "Ventana Ogre");

		 _sceneManager =  _root->createSceneManager(Ogre::ST_GENERIC);

		 Ogre::Camera* camera = _sceneManager->createCamera("Camera");
		 camera->setPosition(Ogre::Vector3(0.0f,300.0f,-1000.0f));
		 camera->lookAt(Ogre::Vector3(0,0,0));
		 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()/viewport->getActualHeight()));

		 _listener = new FrameListenerProyectos(window,camera);
		 _root->addFrameListener(_listener);

		 loadResources();
		 createScene();
		 _root->startRendering();

		 return 0;
	 }
示例#8
0
    /**
     * Application main function:
     *   Initializes Ogre, creates a window, creates scenes, starts the rendering loop
     */
    void run() {
        // ----------------------- Create root object & window --------------------- //
        // Initialize (~ glutInit)
        mRoot = new Ogre::Root();
        mRoot->restoreConfig();                  // Read config from ogre.cfg
        //if(!mRoot->showConfigDialog()) return; // Alternatively, you can show a dialog window here

        // Create window (~ glutCreateWindow)
        mWindow = mRoot->initialise(true, "Basic OGRE example");

        // Register per-frame callbacks (~ glutIdleFunc)
        mRoot->addFrameListener(this);

        // Register keyboard and mouse callbacks (~ glutMouseFunc, glutKeyboardFunc, glutWindowFunc)
        // This class already implements some logic, such as "quit on Escape".
        // It is described in input_util.h, feel free to play with that implementation.
        mEventListener = new SimpleMouseAndKeyboardListener(mWindow, mRoot, this);

        // ----------- Create scene ----------------- //
        // Each scene is represented by a "SceneManager" object, which
        // combines a SceneGraph (set of objects with their model transforms)
        // with a Camera (view-projection transform)
        mScene = createTriangleScene();      // Very basic colored triangle

        // This is like (~ glViewport), in that you could specify the region of the window to draw to.
        // You can have several scenes rendered to different parts in the window.
        Ogre::Viewport* vp = mWindow->addViewport(mScene->getCamera("MainCamera"));

        // ~ glClearColor
        vp->setBackgroundColour(Ogre::ColourValue(0, 0, 0));

        // Enable control of a camera with mouse & keyboard using the utility class.
        mEventListener->controlCamera(mScene->getCamera("MainCamera"));

        // ------------------------ Configuration complete ----------------- //
        // Enter the infinite rendering & event processing loop.
        // ~ glutMainLoop()
        mRoot->startRendering();
    }
示例#9
0
文件: graphics.cpp 项目: Mononofu/OTE
void GraphicsImpl::createScene()
{
	// Set ambient light
	sceneMgr->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5));

	// Create a light
	Ogre::Light* l = sceneMgr->createLight("MainLight");
	l->setPosition(20,80,50);

	caelumSystem = new Caelum::CaelumSystem(root, sceneMgr, Caelum::CaelumSystem::CAELUM_COMPONENTS_NONE);

	try {
		caelumSystem->setSkyDome(new Caelum::SkyDome(sceneMgr, caelumSystem->getCaelumCameraNode()));
	} catch (Caelum::UnsupportedException& ex) {
		Dout << ex.getFullDescription();
	}

	try {
		caelumSystem->setSun(new Caelum::SphereSun(sceneMgr, caelumSystem->getCaelumCameraNode()));
	} catch (Caelum::UnsupportedException& ex) {
		Dout << ex.getFullDescription();
	}

	try {
		caelumSystem->setMoon(new Caelum::Moon(sceneMgr, caelumSystem->getCaelumCameraNode()));
	} catch (Caelum::UnsupportedException& ex) {
		Dout << ex.getFullDescription();
	}

	try {
		caelumSystem->setCloudSystem(new Caelum::CloudSystem(sceneMgr, caelumSystem->getCaelumGroundNode()));
	} catch (Caelum::UnsupportedException& ex) {
		Dout << ex.getFullDescription();
	}

	try {
		caelumSystem->setPointStarfield(new Caelum::PointStarfield(sceneMgr, caelumSystem->getCaelumCameraNode()));
	} catch (Caelum::UnsupportedException& ex) {
		Dout << ex.getFullDescription();
	}

	// Register caelum.
	// Don't make it a frame listener; update it by hand.
	//Root::getSingletonPtr ()->addFrameListener (caelumSystem.get ());
	caelumSystem->attachViewport(viewPort);

	try {
		caelumSystem->setPrecipitationController(new Caelum::PrecipitationController(sceneMgr));
	} catch (Caelum::UnsupportedException& ex) {
		Dout << ex.getFullDescription();
	}

	caelumSystem->setSceneFogDensityMultiplier(0.0015);

	caelumSystem->setManageAmbientLight(true);
	caelumSystem->setMinimumAmbientLight(Ogre::ColourValue(0.1, 0.1, 0.1));

	// Setup sun options

	if (caelumSystem->getSun()) {
		// Make the sun very obvious:
		//caelumSystem->getSun ()->setDiffuseMultiplier (Ogre::ColourValue (1, 10, 1));

		caelumSystem->getSun()->setAutoDisableThreshold(0.05);
		caelumSystem->getSun()->setAutoDisable(false);
	}

	if (caelumSystem->getMoon()) {
		// Make the moon very obvious:
		//caelumSystem->getMoon ()->setDiffuseMultiplier (Ogre::ColourValue (1, 1, 10));

		caelumSystem->getMoon()->setAutoDisableThreshold(0.05);
		caelumSystem->getMoon()->setAutoDisable(false);
	}

	if (caelumSystem->getCloudSystem()) {
		try {
			caelumSystem->getCloudSystem()->createLayerAtHeight(2000);
			caelumSystem->getCloudSystem()->createLayerAtHeight(5000);
			caelumSystem->getCloudSystem()->getLayer(0)->setCloudSpeed(Ogre::Vector2(0.000005, -0.000009));
			caelumSystem->getCloudSystem()->getLayer(1)->setCloudSpeed(Ogre::Vector2(0.0000045, -0.0000085));
		}

		catch (Caelum::UnsupportedException& ex) {
			Dout << ex.getFullDescription();
		}
	}

	if (caelumSystem->getPrecipitationController()) {
		caelumSystem->getPrecipitationController()->setIntensity(0);
	}

	// Set time acceleration.
	//caelumSystem->getUniversalClock ()->setTimeScale (0);

	// Sunrise with visible moon.
	caelumSystem->getUniversalClock()->setGregorianDateTime(2007, 4, 9, 9, 33, 0);

	caelumSystem->getUniversalClock()->setTimeScale(1024);

	window->addListener(caelumSystem);

	root->addFrameListener(caelumSystem);
}
void AnimationManager::initailise()
{
    Ogre::Root *root = Ogre::Root::getSingletonPtr();
    root->addFrameListener( this );
}
示例#11
0
    bool initialise()
    {
		mRoot = new Ogre::Root(PLUGINS_CFG, OGRE_CFG, OGRE_LOG);

		if (!mRoot->restoreConfig())
			if (!mRoot->showConfigDialog())
				return false;

		initResources();

        mWindow = mRoot->initialise(true, "CS Clone Editor v0.0");
        Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this);

		mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC);
		mSceneMgr->setAmbientLight(Ogre::ColourValue(0.7, 0.7, 0.7));
		mCamera = mSceneMgr->createCamera("camera");
        mWindow->addViewport(mCamera);
        mCamera->setAutoAspectRatio(true);
        mCamera->setNearClipDistance(0.1);
        mCamera->setFarClipDistance(10000);
        mCamera->setPosition(10, 10, 10);
//        mCamera->lookAt(0, 0, 0);

        mRoot->addFrameListener(this);

		Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
//Initializing OIS
		Ogre::LogManager::getSingletonPtr()->logMessage("*-*-* OIS Initialising");

		OIS::ParamList pl;
		size_t windowHnd = 0;
		mWindow->getCustomAttribute("WINDOW", &windowHnd);
		pl.insert(std::make_pair(std::string("WINDOW"), Ogre::StringConverter::toString(windowHnd)));

#if OGRE_DEBUG_MODE == 1
	#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
		#define NO_EXCLUSIVE_INPUT
	#endif
#endif

#ifdef NO_EXCLUSIVE_INPUT
	#if defined OIS_WIN32_PLATFORM
		pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND" )));
		pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
		pl.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_FOREGROUND")));
		pl.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_NONEXCLUSIVE")));
	#elif defined OIS_LINUX_PLATFORM
		pl.insert(std::make_pair(std::string("x11_mouse_grab"), std::string("false")));
		pl.insert(std::make_pair(std::string("x11_mouse_hide"), std::string("false")));
		pl.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string("false")));
		pl.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
	#endif
#endif
		mInputManager = OIS::InputManager::createInputSystem(pl);

		mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, true));
		mKeyboard->setEventCallback(this);
		mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject(OIS::OISMouse, true));
		mMouse->setEventCallback(this);

		windowResized(mWindow);
//Initialising GUI
		Ogre::LogManager::getSingletonPtr()->logMessage("*-*-* MyGUI Initialising");
		mGUI = new MyGUI::Gui;
		mGUI->initialise(mWindow);
		mGUI->load("editor.layout");

		mMenuBar = mGUI->createWidget<MyGUI::MenuBar>("MenuBar",
			MyGUI::IntCoord(0, 0, mGUI->getViewWidth(), 28),
			MyGUI::ALIGN_TOP | MyGUI::ALIGN_HSTRETCH, "Overlapped");

		mMenuBar->addItem("File");
		mPopupMenuFile = mMenuBar->getItemMenu(0);
		mPopupMenuFile->addItem("New");
		mPopupMenuFile->addItem("Open ...");
		mPopupMenuFile->addItem("Save");
		mPopupMenuFile->addItem("Save as ...", false, true);
		mPopupMenuFile->addItem("Settings", false, true);
		mPopupMenuFile->addItem("Quit");

		mMenuBar->addItem("Help");
		mPopupMenuHelp = mMenuBar->getItemMenu(1);
		mPopupMenuHelp->addItem("Help");
		mPopupMenuHelp->addItem("About ...");

		return (true);
    }
示例#12
0
int
main( int argc, char *argv[] )
{
    Ogre::Root*         root;
    Ogre::RenderWindow* window;

    root = new Ogre::Root( "", "" );
#ifndef _DEBUG
    root->loadPlugin( "RenderSystem_GL.dll" );
#else
    root->loadPlugin( "RenderSystem_GL_d.dll" );
#endif
    root->setRenderSystem( root->getAvailableRenderers()[ 0 ] );
    root->initialise( false );
    Ogre::NameValuePairList misc;
    misc[ "title" ] = "Xenogears SoundDumper";
    window = root->createRenderWindow( "QGearsWindow", 800, 600, false, &misc );




    LOGGER = new Logger( "game.log" );

    state = GAME;



    DisplayFrameListener* frame_listener = new DisplayFrameListener( window );
    root->addFrameListener( frame_listener );

    Ogre::SceneManager* scene_manager = root->createSceneManager( Ogre::ST_GENERIC, "Scene" );
    scene_manager->setAmbientLight( Ogre::ColourValue( 1.0, 1.0, 1.0 ) );

    Ogre::Camera* camera = scene_manager->createCamera( "Camera" );
    camera->setNearClipDistance( 5 );

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



    SOUNDMAN = new SoundManager();
    SOUND_PARSER = new SoundParser();



    Ogre::Root::getSingleton().startRendering();



    delete SOUND_PARSER;
    delete SOUNDMAN;



    delete root;
    delete frame_listener;

    delete LOGGER;

    return 0;
}