Beispiel #1
0
 virtual void createCamera()
 {
    mCamera = mSceneMgr->createCamera("PlayerCam");
    mCamera->setPosition(Vector3(-300, 300, -300));
    mCamera->lookAt(Vector3(0, 0, 0));
    mCamera->setNearClipDistance(5);
 }
Beispiel #2
0
	int startup()
	{
		_root = new Root("plugins_d.cfg");
		
		if (!_root->showConfigDialog()) {
			return -1;
		}

		RenderWindow* window = _root->initialise(true, "Lab 4");
		_sceneManager = _root->createSceneManager(ST_GENERIC);

		Camera* camera = _sceneManager->createCamera("Camera");
		camera->setPosition(Ogre::Vector3(0,0,50));
		camera->lookAt(Ogre::Vector3(0,0,0));
		camera->setNearClipDistance(5);

		Viewport *viewPort = window->addViewport(camera);
		viewPort->setBackgroundColour(ColourValue(0.0,0.0,0.0));

		camera->setAspectRatio(Real(viewPort->getActualWidth())/Real(viewPort->getActualHeight()));

		loadResources(); 
		createScene();

		_listener = new MyFrameListener(window, camera, new CylindricalEffect(_myCube, Ogre::Vector3(2.0, 10.0, 0.0), Ogre::Vector3(0.0, 0.0, 0.1)));
		_root->addFrameListener(_listener);
		return 0;
	}
Beispiel #3
0
PlayerCamera::PlayerCamera(const std::string& name)
: LCamera(name)
{
	SceneManager* sceneMgr = getG<SceneManager>();

	// make our camera and set some properties
	camera = sceneMgr->createCamera(name);
	camera->setNearClipDistance(0.1f);
	camera->setFarClipDistance(300.f);
	camera->setAutoAspectRatio(true);

	// create the nodes we're going to interpolate
	cameraNode = sceneMgr->getRootSceneNode()->createChildSceneNode(name+"_PlayerCameraNode", Vector3(0, Settings::CameraNodeYOffset, Settings::CameraNodeZOffset));
    targetNode = sceneMgr->getRootSceneNode()->createChildSceneNode(name+"_PlayerCameraTargetNode", Vector3(0, Settings::CameraTargetYOffset, 0));

	//cameraNode->setAutoTracking(true, targetNode);
	cameraNode->setFixedYawAxis(true);
    cameraNode->attachObject(camera);

	// create the fixed nodes that are attached to the kart
	followKart = getG<PlayerManager>()->getMainPlayer()->getKart();
	kartCamNode = followKart->getRootNode()->createChildSceneNode(name + "_KartCameraNode", Vector3(0, Settings::CameraNodeYOffset, Settings::CameraNodeZOffset));
    kartTargetNode = followKart->getRootNode()->createChildSceneNode(name + "_KartCameraTargetNode", Vector3(0, Settings::CameraTargetYOffset, 0));

	cameraNode->setPosition(kartCamNode->_getDerivedPosition());
    //targetNode->setPosition(kartTargetNode->_getDerivedPosition());

	// initialise some stuff for the ray casting
    rayLength = (cameraNode->getPosition() - targetNode->getPosition()).length();
	world = getG<PhysicsMain>()->getWorld();

	camera->setAutoTracking(true, followKart->getRootNode(), Vector3(0, 0.4f, 0));
    //kartCamNode->attachObject(camera);
}
CEGuiOgreBaseApplication::CEGuiOgreBaseApplication() :
        d_ogreRoot(0),
        d_renderer(0),
        d_initialised(false),
        d_frameListener(0),
        d_windowEventListener(0)
{
    using namespace Ogre;

    d_ogreRoot = new Root();

    initialiseResources();

    if (d_ogreRoot->showConfigDialog())
    {
        // initialise system according to user options.
        d_window = d_ogreRoot->initialise(true);

        // Create the scene manager
        SceneManager* sm = d_ogreRoot->
            createSceneManager(ST_GENERIC, "SampleSceneMgr");
        // Create and initialise the camera
        d_camera = sm->createCamera("SampleCam");
        d_camera->setPosition(Vector3(0,0,500));
        d_camera->lookAt(Vector3(0,0,-300));
        d_camera->setNearClipDistance(5);

        // Create a viewport covering whole window
        Viewport* vp = d_window->addViewport(d_camera);
        vp->setBackgroundColour(ColourValue(0,0,0));

        // Update the camera aspect ratio to that of the viewport
        d_camera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));

        // initialise resources
        ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

        // initialise GUI system
        d_renderer = new CEGUI::OgreCEGUIRenderer(d_window, RENDER_QUEUE_OVERLAY, false, 0, sm);
        new CEGUI::System(d_renderer);

        // create frame listener
        d_frameListener= new CEGuiDemoFrameListener(this, d_window, d_camera);
        d_ogreRoot->addFrameListener(d_frameListener);

        // add a listener for OS framework window events (for resizing)
        d_windowEventListener = new WndEvtListener(d_renderer);
        WindowEventUtilities::addWindowEventListener(d_window,
                                                     d_windowEventListener);

        d_initialised = true;
    }
    else
    {
        // aborted.  Clean up and set root to 0 so when app attempts to run it knows what happened here.
        delete d_ogreRoot;
        d_ogreRoot = 0;
    }
}
Beispiel #5
0
  void go(void)
  {
    // OGRE의 메인 루트 오브젝트 생성
#if !defined(_DEBUG)
    mRoot = new Root("plugins.cfg", "ogre.cfg", "ogre.log");
#else
    mRoot = new Root("plugins_d.cfg", "ogre.cfg", "ogre.log");
#endif


    // 초기 시작의 컨피규레이션 설정 - ogre.cfg 이용
    if (!mRoot->restoreConfig()) {
      if (!mRoot->showConfigDialog()) return;
    }
    mWindow = mRoot->initialise(true, "Hello Professor : Copyleft Dae-Hyun Lee");

    // ESC key를 눌렀을 경우, 오우거 메인 렌더링 루프의 탈출을 처리
	size_t windowHnd = 0;
	std::ostringstream windowHndStr;
	OIS::ParamList pl;
	mWindow->getCustomAttribute("WINDOW", &windowHnd);
	windowHndStr << windowHnd;
	pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
	mInputManager = OIS::InputManager::createInputSystem(pl);
	mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, false));

	mESCListener = new ESCListener(mKeyboard);
    mRoot->addFrameListener(mESCListener);

	mSceneMgr = mRoot->createSceneManager(ST_GENERIC);

    mCamera = mSceneMgr->createCamera("camera");
    mCamera->setPosition(0.0f, 200.0f, 300.0f);
    mCamera->lookAt(0.0f, 100.0f, 0.00f);
    mCamera->setNearClipDistance(5.0f);

    mViewport = mWindow->addViewport(mCamera);
    mViewport->setBackgroundColour(ColourValue(0.0f,0.0f,0.5f));
    mCamera->setAspectRatio(Real(mViewport->getActualWidth()) / Real(mViewport->getActualHeight()));

    ResourceGroupManager::getSingleton().addResourceLocation("resource.zip", "Zip");
    ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

    mSceneMgr->setAmbientLight(ColourValue(1.0f, 1.0f, 1.0f));

    Entity* daehyunEntity = mSceneMgr->createEntity("Daehyun", "DustinBody.mesh");

    SceneNode* daehyunNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
    daehyunNode->attachObject(daehyunEntity);

    mRoot->startRendering();

    mInputManager->destroyInputObject(mKeyboard);
    OIS::InputManager::destroyInputSystem(mInputManager);

    delete mRoot;
  }
    void setupScene()
    {
        mSceneMgr = mRoot->createSceneManager(ST_GENERIC, "Default SceneManager");
        Camera *cam = mSceneMgr->createCamera("Camera");
        Viewport *vp = mRoot->getAutoCreatedWindow()->addViewport(cam);

          Entity *ent;

        mSceneMgr->setAmbientLight(ColourValue(0.25, 0.25, 0.25));
        mSceneMgr->setShadowTechnique( SHADOWTYPE_STENCIL_ADDITIVE );

        // EN:: make a cube to bounce around
        // BR:: cria um cubo pra quicar
      ManualObject *cmo = createCubeMesh("manual", "");
      cmo->convertToMesh("cube");
      ent = mSceneMgr->createEntity("Cube", "cube.mesh");
      ent->setCastShadows(true);
      boxNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
      boxNode->attachObject(ent);
      boxNode->setScale(Vector3(0.1,0.1,0.1));


      // EN:: make a rock wall on the floor
      // BR:: adiciona piso de pedra no chão
        Plane plane(Vector3::UNIT_Y, 0);
        MeshManager::getSingleton().createPlane("ground",
               ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
               1500,1500,20,20,true,1,5,5,Vector3::UNIT_Z);
        ent = mSceneMgr->createEntity("GroundEntity", "ground");
        mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent);
      ent->setMaterialName("Examples/Rockwall");
      ent->setCastShadows(false);


      // EN:: make a light to see stuff with
      // BR:: adiciona uma iluminação
        Light *light = mSceneMgr->createLight("Light1");
        light->setType(Light::LT_POINT);
        light->setPosition(Vector3(250, 150, 250));
        light->setDiffuseColour(ColourValue::White);
        light->setSpecularColour(ColourValue::White);

        // EN:: Create the scene node
        // BR:: cria o SceneNode (nó da cena)
        SceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode("CamNode1", Vector3(-200, 100, 200));
        node->yaw(Degree(-45));
        node->attachObject(cam);
    }
Beispiel #7
0
int main()
{
  Root *root = new Root(StringUtil::BLANK, StringUtil::BLANK);
  GLPlugin *glPlugin = new GLPlugin();
  root->installPlugin(glPlugin);
  RenderSystem *renderSystem = root->getAvailableRenderers().at(0);
  renderSystem->setConfigOption("Fixed Pipeline Enabled", "No");
  root->setRenderSystem(renderSystem);
  root->initialise(false);
  RenderWindow *window = root->createRenderWindow("Hello, OGRE", 800, 600, false);
  SceneManager *sceneManager = root->createSceneManager(ST_GENERIC);
  ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
  RTShader::ShaderGenerator::initialize();
  RTShader::ShaderGenerator::getSingleton().addSceneManager(sceneManager);

  createSphereMesh("SphereMesh", 10.f, 16, 16);
  ResourceGroupManager::getSingleton().addResourceLocation("shader", "FileSystem");
  createSphereMaterial("SphereMaterial", 1.f, 0.f, 0.f);

  Camera *camera = sceneManager->createCamera("Camera");
  camera->setPosition(0.f, 0.f, 80.f);
  camera->lookAt(0.f, 0.f, 0.f);
  camera->setNearClipDistance(5.f);
  Viewport *viewport = window->addViewport(camera);
  viewport->setBackgroundColour(ColourValue(0.f, 0.f, 0.f));
  viewport->setMaterialScheme(RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);
  camera->setAspectRatio((Real)(viewport->getActualWidth()) / (Real)(viewport->getActualHeight()));

  sceneManager->setAmbientLight(ColourValue(0.5f, 0.5f, 0.5f));
  Light *light = sceneManager->createLight("Light");
  light->setPosition(50.f, 50.f, 50.f);

  Entity *sphereEntity = sceneManager->createEntity("SphereEntity", "SphereMesh");
  sphereEntity->setMaterialName("SphereMaterial");
  SceneNode *sphereNode = sceneManager->getRootSceneNode()->createChildSceneNode();
  sphereNode->attachObject(sphereEntity);

  HelloOgreFrameListener *frameListener = new HelloOgreFrameListener(window);
  root->addFrameListener(frameListener);
  root->startRendering();

  delete frameListener;
  delete root;
  delete glPlugin;

  return 0;
}
Beispiel #8
0
    void createCamera(void){
        // Create the camera
        mCamera = mSceneMgr->createCamera("PlayerCam");

        // Look back along -Z
        mCamera->lookAt(Vector3(0,0,-300));
        mCamera->setNearClipDistance(5);

        // Create the node for the camera
        node = mSceneMgr->getRootSceneNode()->createChildSceneNode("CamNode1", Vector3(-400, 200, 400));

        // Make it look towards the ninja
        node->yaw(Degree(-45));

        // Create the pitch node
        node = node->createChildSceneNode("PitchNode1");
        node->attachObject(mCamera);
    }
Beispiel #9
0
    void SetUp() {
        RootWithoutRenderSystemFixture::SetUp();

        mSceneMgr = mRoot->createSceneManager();
        mCamera = mSceneMgr->createCamera("Camera");
        mCameraNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
        mCameraNode->attachObject(mCamera);
        mCameraNode->setPosition(0,0,500);
        mCameraNode->lookAt(Vector3(0, 0, 0), Node::TS_PARENT);

        // Create a set of random balls
        Entity* ent = mSceneMgr->createEntity("501", "sphere.mesh", "General");

        // stick one at the origin so one will always be hit by ray
        mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent);
        createRandomEntityClones(ent, 500, Vector3(-2500,-2500,-2500), Vector3(2500,2500,2500), mSceneMgr);

        mSceneMgr->_updateSceneGraph(mCamera);
    }
Beispiel #10
0
    // ------------------------- Scene description ------------------------- //
    SceneManager* createOgreScene() {
        SceneManager* scene = mRoot->createSceneManager(ST_GENERIC);

        // Initialize camera
        Camera* camera = scene->createCamera("MainCamera");
        camera->setPosition(Vector3(0, 10, 30));
        camera->lookAt(Vector3(0, 0, 0));
        camera->setNearClipDistance(0.5);
        camera->setFOVy(Ogre::Degree(60.0));
        camera->setAspectRatio((float) mWindow->getWidth() / mWindow->getHeight());

        // Set up lighting (~ glEnable(GL_LIGHTING), glEnable(GL_LIGHT0), glLightfv(...)):
        scene->setAmbientLight(ColourValue(0.5f, 0.5f, 0.5f));
        Light* light = scene->createLight("MainLight");
        light->setType(Light::LT_POINT);
        light->setDiffuseColour(1, 1, 1);
        light->setSpecularColour(1, 1, 1);
        light->setPosition(20.0f, 80.0f, 50.0f);

        // Enable shadow computations
        scene->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE);

        // Scenery
        Ogre::Entity* plane = scene->createEntity("Plane", Ogre::SceneManager::PT_PLANE);
        Ogre::SceneNode* planeNode = scene->getRootSceneNode()->createChildSceneNode("PlaneNode");
        planeNode->attachObject(plane);
        planeNode->rotate(Ogre::Vector3(-1, 0, 0), Ogre::Degree(90));
        plane->setCastShadows(false);
        plane->setMaterialName("Floor/Marble");

        // Load character mesh
		mBodyNode = scene->getRootSceneNode()->createChildSceneNode(Vector3::UNIT_Y * 5);
		mBodyEnt = scene->createEntity("SinbadBody", "Sinbad.mesh");
		mBodyNode->attachObject(mBodyEnt);

        // Load animations
        // Exercise 5: Get pointer to animation state
        // ...

        return scene;
    }
//-----------------------------------------------------------------------
void CollideCamera::setUp(const String& name)
{
    // Create visual presence
    SceneManager* sm = World::getSingleton().getSceneManager();
    mSceneNode = sm->getRootSceneNode()->createChildSceneNode(name);

    mCamera = sm->createCamera(name);

    mSceneNode->attachObject(mCamera);
    // Add reverse reference (to self!)
    mCamera->setUserObject(this);

    // No mass body (considered static)

    // Create collision proxy, at near dist
    // SpaceID is irrelevant, we're doing our own spacial partitioning
    dSphere* odeSphere = new dSphere(0, mCamera->getNearClipDistance());
    mCollisionProxies.push_back(odeSphere);
    updateCollisionProxies();


}
Beispiel #12
0
 void setupScene(void){
     SceneManager *mgr = mRoot->createSceneManager(ST_GENERIC, "Default SceneManager"); //make a scenemanager
     mCamera = mgr->createCamera("Camera"); //make a camera
 }
Beispiel #13
0
	void go(void)
	{
		// OGRE의 메인 루트 오브젝트 생성
#if !defined(_DEBUG)
		mRoot = new Root("plugins.cfg", "ogre.cfg", "ogre.log");
#else
		mRoot = new Root("plugins_d.cfg", "ogre.cfg", "ogre.log");
#endif


		// 초기 시작의 컨피규레이션 설정 - ogre.cfg 이용
		if (!mRoot->restoreConfig()) {
			if (!mRoot->showConfigDialog()) return;
		}

		mWindow = mRoot->initialise(true, CLIENT_DESCRIPTION " : Copyleft by Dae-Hyun Lee");

		mSceneMgr = mRoot->createSceneManager(ST_GENERIC, "main");
		mCamera = mSceneMgr->createCamera("main");


		mCamera->setPosition(0.0f, 150.0f, 1000.0f);
		mCamera->lookAt(0.0f, 100.0f, 0.0f);

		mViewport = mWindow->addViewport(mCamera);
		mViewport->setBackgroundColour(ColourValue(0.0f, 0.0f, 0.5f));
		mCamera->setAspectRatio(Real(mViewport->getActualWidth()) / Real(mViewport->getActualHeight()));


		ResourceGroupManager::getSingleton().addResourceLocation("resource.zip", "Zip");
		ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

		mSceneMgr->setAmbientLight(ColourValue(1.0f, 1.0f, 1.0f));

		// 좌표축 표시
		Ogre::Entity* mAxesEntity = mSceneMgr->createEntity("Axes", "axes.mesh");
		mSceneMgr->getRootSceneNode()->createChildSceneNode("AxesNode", Ogre::Vector3(0, 0, 0))->attachObject(mAxesEntity);
		mSceneMgr->getSceneNode("AxesNode")->setScale(5, 5, 5);

		_drawGridPlane();


		Entity* entity1 = mSceneMgr->createEntity("Ninja", "ninja.mesh");
		SceneNode* node1 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Ninja", Vector3(-100.0f, 0.0f, 0.0f));
		node1->attachObject(entity1);

		Entity* entity2 = mSceneMgr->createEntity("Professor", "DustinBody.mesh");
		SceneNode* node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Professor", Vector3(200.0f, 0.0f, 200.0f));
		node2->attachObject(entity2);


#if 0
		Entity* entity2 = mSceneMgr->createEntity("Ninja", "ninja.mesh");
		SceneNode* node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Ninja", Vector3(0.0f, 0.0f, 0.0f));
		node2->attachObject(entity2);
		node2->setOrientation(Ogre::Quaternion(Ogre::Degree(180), Ogre::Vector3::UNIT_Y));
#endif

		size_t windowHnd = 0;
		std::ostringstream windowHndStr;
		OIS::ParamList pl;
		mWindow->getCustomAttribute("WINDOW", &windowHnd);
		windowHndStr << windowHnd;
		pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
		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")));
		mInputManager = OIS::InputManager::createInputSystem(pl);


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

		InputController* inputController = new InputController(mRoot, mKeyboard, mMouse);
		mRoot->addFrameListener(inputController);


		ProfessorController* professorController = new ProfessorController(mRoot);
		mRoot->addFrameListener(professorController);

		mRoot->startRendering();

		mInputManager->destroyInputObject(mKeyboard);
		mInputManager->destroyInputObject(mMouse);
		OIS::InputManager::destroyInputSystem(mInputManager);

		delete professorController;
		delete inputController;

		delete mRoot;
	}
INT WINAPI EmbeddedMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
{
	try 
	{
		// Create a new window

		// Style & size
		DWORD dwStyle = WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_OVERLAPPEDWINDOW;

		// Register the window class
		WNDCLASS wc = { 0, TestWndProc, 0, 0, hInst,
			LoadIcon(0, IDI_APPLICATION), LoadCursor(NULL, IDC_ARROW),
			(HBRUSH)GetStockObject(BLACK_BRUSH), 0, "TestWnd" };
		RegisterClass(&wc);

		HWND hwnd = CreateWindow("TestWnd", "Test embedding", dwStyle,
				0, 0, 800, 600, 0, 0, hInst, 0);

		Root root("", "");

		root.loadPlugin("RenderSystem_GL");
		//root.loadPlugin("RenderSystem_Direct3D9");
		root.loadPlugin("Plugin_ParticleFX");
		root.loadPlugin("Plugin_CgProgramManager");

		// select first renderer & init with no window
		root.setRenderSystem(*(root.getAvailableRenderers().begin()));
		root.initialise(false);

		// create first window manually
		NameValuePairList options;
		options["externalWindowHandle"] = 
			StringConverter::toString((size_t)hwnd);

		renderWindow = root.createRenderWindow("embedded", 800, 600, false, &options);

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

		SceneManager *scene = root.createSceneManager(Ogre::ST_GENERIC, "default");


		Camera *cam = scene->createCamera("cam");


		Viewport* vp = renderWindow->addViewport(cam);
		vp->setBackgroundColour(Ogre::ColourValue(0.5, 0.5, 0.7));
		cam->setAutoAspectRatio(true);
		cam->setPosition(0,0,300);
		cam->setDirection(0,0,-1);

		Entity* e = scene->createEntity("1", "ogrehead.mesh");
		scene->getRootSceneNode()->createChildSceneNode()->attachObject(e);
		Light* l = scene->createLight("l");
		l->setPosition(300, 100, -100);

		// message loop
		MSG msg;
		while(GetMessage(&msg, NULL, 0, 0 ) != 0)
		{ 
			TranslateMessage(&msg); 
			DispatchMessage(&msg); 
		} 

	} 
	catch( Exception& e ) 
	{
		MessageBox( NULL, e.getFullDescription().c_str(), 
			"An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
	}


	return 0;
}
    int main(int argc, char **argv)
#endif
{
    //-----------------------------------------------------
    // 1 enter ogre
    //-----------------------------------------------------
    Root* root = new Root;
 
    //-----------------------------------------------------
    // 2 configure resource paths
    //-----------------------------------------------------
    // Load resource paths from config file
 
    // File format is:
    //  [ResourceGroupName]
    //  ArchiveType=Path
    //  .. repeat
    // For example:
    //  [General]
    //  FileSystem=media/
    //  Zip=packages/level1.zip
 
    ConfigFile cf;
    cf.load("./resources.cfg");
 
    // Go through all sections & settings in the file
    ConfigFile::SectionIterator seci = cf.getSectionIterator();
 
    String secName, typeName, archName;
    while (seci.hasMoreElements())
    {
        secName = seci.peekNextKey();
        ConfigFile::SettingsMultiMap *settings = seci.getNext();
        ConfigFile::SettingsMultiMap::iterator i;
        for (i = settings->begin(); i != settings->end(); ++i)
        {
            typeName = i->first;
            archName = i->second;
            ResourceGroupManager::getSingleton().addResourceLocation(
                archName, typeName, secName);
        }
    }
    //-----------------------------------------------------
    // 3 Configures the application and creates the window
    //-----------------------------------------------------
    if(!root->showConfigDialog())
    {
        //Ogre
        delete root;
        return false; // Exit the application on cancel
    }
 
    RenderWindow* window = root->initialise(true, "Simple Ogre App");
 
    ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
 
    //-----------------------------------------------------
    // 4 Create the SceneManager
    //
    //        ST_GENERIC = octree
    //        ST_EXTERIOR_CLOSE = simple terrain
    //        ST_EXTERIOR_FAR = nature terrain (depreciated)
    //        ST_EXTERIOR_REAL_FAR = paging landscape
    //        ST_INTERIOR = Quake3 BSP
    //----------------------------------------------------- 
    SceneManager* sceneMgr = root->createSceneManager(ST_GENERIC); 
 
    //----------------------------------------------------- 
    // 5 Create the camera 
    //----------------------------------------------------- 
    Camera* camera = sceneMgr->createCamera("SimpleCamera"); 
 
    //----------------------------------------------------- 
    // 6 Create one viewport, entire window 
    //----------------------------------------------------- 
    Viewport* viewPort = window->addViewport(camera);
 
    //---------------------------------------------------- 
    // 7 add OIS input handling 
    //----------------------------------------------------
    OIS::ParamList pl;
    size_t windowHnd = 0;
    std::ostringstream windowHndStr;
 
    //tell OIS about the Ogre window
    window->getCustomAttribute("WINDOW", &windowHnd);
    windowHndStr << windowHnd;
    pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
 
    //setup the manager, keyboard and mouse to handle input
    OIS::InputManager* inputManager = OIS::InputManager::createInputSystem(pl);
    OIS::Keyboard* keyboard = static_cast<OIS::Keyboard*>(inputManager->createInputObject(OIS::OISKeyboard, true));
    OIS::Mouse*    mouse = static_cast<OIS::Mouse*>(inputManager->createInputObject(OIS::OISMouse, true));
 
    //tell OIS about the window's dimensions
    unsigned int width, height, depth;
    int top, left;
    window->getMetrics(width, height, depth, left, top);
    const OIS::MouseState &ms = mouse->getMouseState();
    ms.width = width;
    ms.height = height;
 
    // everything is set up, now we listen for input and frames (replaces while loops)
    //key events
    SimpleKeyListener* keyListener = new SimpleKeyListener();
    keyboard->setEventCallback(keyListener);
    //mouse events
    SimpleMouseListener* mouseListener = new SimpleMouseListener();
    mouse->setEventCallback(mouseListener);
    //render events
    SimpleFrameListener* frameListener = new SimpleFrameListener(keyboard, mouse);
    root->addFrameListener(frameListener); 
 
    //----------------------------------------------------
    // 8 start rendering 
    //----------------------------------------------------
    root->startRendering(); // blocks until a frame listener returns false. eg from pressing escape in this example
 
    //----------------------------------------------------
    // 9 clean 
    //----------------------------------------------------
    //OIS
    inputManager->destroyInputObject(mouse); mouse = 0;
    inputManager->destroyInputObject(keyboard); keyboard = 0;
    OIS::InputManager::destroyInputSystem(inputManager); inputManager = 0;
    //listeners
    delete frameListener; 
    delete mouseListener; 
    delete keyListener;
    //Ogre
    delete root;
 
    return 0; 
}
Beispiel #16
0
  void go(void)
  {
    // OGRE의 메인 루트 오브젝트 생성
#if !defined(_DEBUG)
    mRoot = new Root("plugins.cfg", "ogre.cfg", "ogre.log");
#else
    mRoot = new Root("plugins_d.cfg", "ogre.cfg", "ogre.log");
#endif


    // 초기 시작의 컨피규레이션 설정 - ogre.cfg 이용
    if (!mRoot->restoreConfig()) {
      if (!mRoot->showConfigDialog()) return;
    }

    mWindow = mRoot->initialise(true, "Rotate : Copyleft by Dae-Hyun Lee");


    // ESC key를 눌렀을 경우, 오우거 메인 렌더링 루프의 탈출을 처리
    size_t windowHnd = 0;
    std::ostringstream windowHndStr;
    OIS::ParamList pl;
    mWindow->getCustomAttribute("WINDOW", &windowHnd);
    windowHndStr << windowHnd;
    pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
    mInputManager = OIS::InputManager::createInputSystem(pl);
    mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, false));


    mSceneMgr = mRoot->createSceneManager(ST_GENERIC, "main");
    mCamera = mSceneMgr->createCamera("main");


    mCamera->setPosition(0.0f, 100.0f, 700.0f);
    mCamera->lookAt(0.0f, 100.0f, 0.0f);

    mCamera->setNearClipDistance(5.0f);

    mViewport = mWindow->addViewport(mCamera);
    mViewport->setBackgroundColour(ColourValue(0.0f,0.0f,0.5f));
    mCamera->setAspectRatio(Real(mViewport->getActualWidth()) / Real(mViewport->getActualHeight()));


	ResourceGroupManager::getSingleton().addResourceLocation("fish.zip", "Zip");
    ResourceGroupManager::getSingleton().addResourceLocation("resource.zip", "Zip");
    ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

    mSceneMgr->setAmbientLight(ColourValue(1.0f, 1.0f, 1.0f));

    // 좌표축 표시
    Ogre::Entity* mAxesEntity = mSceneMgr->createEntity("Axes", "axes.mesh");
    mSceneMgr->getRootSceneNode()->createChildSceneNode("AxesNode",Ogre::Vector3(0,0,0))->attachObject(mAxesEntity);
    mSceneMgr->getSceneNode("AxesNode")->setScale(5, 5, 5);

    _drawGridPlane();


    Entity* entity1 = mSceneMgr->createEntity("Professor", "DustinBody.mesh");
    SceneNode* node1 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Professor", Vector3(0.0f, 0.0f, 0.0f));
    node1->attachObject(entity1);

	SceneNode* pivotNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("Pivot", Vector3(0, 0, 0));

	Entity* entity2 = mSceneMgr->createEntity("Fish", "fish.mesh");
	SceneNode* node2 = pivotNode->createChildSceneNode("Fish", Vector3(50.0f, 0.0f, 0.0f));
	node2->yaw(Degree(90.0f));
    node2->attachObject(entity2);
	node2->scale(5, 5, 5);



    mESCListener =new ESCListener(mKeyboard);
    mRoot->addFrameListener(mESCListener);

    mMainListener = new MainListener(mRoot, mKeyboard);
    mRoot->addFrameListener(mMainListener);


    mRoot->startRendering();

    mInputManager->destroyInputObject(mKeyboard);
    OIS::InputManager::destroyInputSystem(mInputManager);

    delete mRoot;
  }