JNIEXPORT jint JNICALL Java_com_badlogic_gdx_controllers_desktop_ois_Ois_getVersionNumber(JNIEnv* env, jobject object, jlong inputManagerPtr) {


//@line:88

		OIS::InputManager* inputManager = (OIS::InputManager*)inputManagerPtr;
	 	return inputManager->getVersionNumber();
	

}
void application::windowClosed (Ogre::RenderWindow* wnd)
{
    if (wnd == this->wnd)
        if (input)
        {
            input->destroyInputObject(mouse);
            input->destroyInputObject(kbd);

            OIS::InputManager::destroyInputSystem(input);
            input = 0;
        }
}
Ejemplo n.º 3
0
	void windowClosed(Ogre::RenderWindow* rw)
	{
		mExit = true;

		if (mInputManager) {
			Ogre::LogManager::getSingletonPtr()->logMessage("*-*-* OIS Shutdown");
			mInputManager->destroyInputObject(mMouse);
			mInputManager->destroyInputObject(mKeyboard);
			OIS::InputManager::destroyInputSystem(mInputManager);
			mInputManager = 0;
		}
	}
Ejemplo n.º 4
0
void App::initOIS()
{
    size_t windowHnd = 0;
    mWindow->getCustomAttribute("WINDOW", &windowHnd);
    std::ostringstream windowHndStr;
	windowHndStr << windowHnd;
	OIS::ParamList pl;
    pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
    OIS::InputManager* inputManager = OIS::InputManager::createInputSystem(pl);
    mKeyboard = static_cast<OIS::Keyboard*>(inputManager->createInputObject(OIS::OISKeyboard, true));
	mKeyboard->setEventCallback(this);
}
void cKeyboard::Init()
{
	// Clear the input buffer
	memset(mabInputBuffer, 0, kuiInputChanelSize);

	assert(cInputManager::Get().mpOISInputManager);
	
	// Creates keyboard object
	OIS::InputManager * lpOISInputManager =cInputManager::Get().mpOISInputManager;
	mpOISKeyboard = (OIS::Keyboard*)lpOISInputManager->createInputObject( OIS::OISKeyboard, true );
	
	// Set callbacks
	mpOISKeyboard->setEventCallback( this );
	mbIsValid = true;
}
	MyFrameListener(RenderWindow* win, Ogre::Camera* Cam ){

		size_t windowHnd = 0;
		std::stringstream windowsHndStr;
		win->getCustomAttribute("WINDOW", &windowHnd);
		windowsHndStr << windowHnd;

		OIS::ParamList pl;
		pl.insert(std::make_pair(std::string("WINDOW"), windowsHndStr.str()));

		_man = OIS::InputManager::createInputSystem(pl);
		_key = static_cast<OIS::Keyboard*>(_man->createInputObject(OIS::OISKeyboard,false));
		_mouse = static_cast<OIS::Mouse*>(_man->createInputObject(OIS::OISMouse,false));
		_cam = Cam;
	}
JNIEXPORT jlong JNICALL Java_com_badlogic_gdx_controllers_desktop_ois_Ois_createJoystick(JNIEnv* env, jobject object, jlong inputManagerPtr) {


//@line:103

		OIS::InputManager* inputManager = (OIS::InputManager*)inputManagerPtr;
		try {
			return (jlong)static_cast<OIS::JoyStick*>(inputManager->createInputObject(OIS::OISJoyStick, true));
		} catch (std::exception &ex) {
			printf("Error creating joystick: %s\n", ex.what());
			fflush(stdout);
			return 0;
		}
	

}
Ejemplo n.º 8
0
		AppFrameListener(Ogre::RenderWindow* win, Ogre::Camera* cam, Ogre::SceneManager* _sceneManager){

		OIS::ParamList parameters;
		unsigned int windowHandle = 0;
		std::ostringstream windowHandleString;
		win->getCustomAttribute("WINDOW", &windowHandle);
		windowHandleString << windowHandle;
		parameters.insert(std::make_pair("WINDOW", windowHandleString.str()));
		_InputManager = OIS::InputManager::createInputSystem(parameters);
		_Keyboard = static_cast<OIS::Keyboard*>(_InputManager->createInputObject( OIS::OISKeyboard, false ));
		_Mouse = static_cast<OIS::Mouse*>(_InputManager->createInputObject( OIS::OISMouse, false ));
		_sManager = _sceneManager;
		_Cam = cam;
		_movementspeed = 25;


		}
JNIEXPORT jobjectArray JNICALL Java_com_badlogic_gdx_controllers_desktop_ois_Ois_getJoystickNames(JNIEnv* env, jobject object, jlong inputManagerPtr) {


//@line:75

		OIS::InputManager* inputManager = (OIS::InputManager*)inputManagerPtr;
		OIS::DeviceList map = inputManager->listFreeDevices();
		int joystickCount = inputManager->getNumberOfDevices(OIS::OISJoyStick);
		jobjectArray names = (jobjectArray)env->NewObjectArray(joystickCount, env->FindClass("java/lang/String"), env->NewStringUTF(""));
		int index = 0;
		for (OIS::DeviceList::iterator i = map.begin(); i != map.end(); ++i) {
			if (i->first != OIS::OISJoyStick) continue;
			env->SetObjectArrayElement(names, index++, env->NewStringUTF(i->second.c_str()));
		}
		return names;
	

}
Ejemplo n.º 10
0
bool App::setup ()
{
	// Set up the input manager
	input_manager = OIS::InputManager::createInputSystem(window.getSystemHandle());
	
	// Joystick
	cout << input_manager->getNumberOfDevices(OIS::OISJoyStick) << " joysticks" << endl;
	OIS::DeviceList::iterator it = input_manager->listFreeDevices().begin();
	OIS::DeviceList::iterator end = input_manager->listFreeDevices().end();
	for (; it!=end; it++) {
		cout << it->first << ", " << it->second << endl;
	}
	
	joystick = static_cast<OIS::JoyStick*>(input_manager->createInputObject(OIS::OISJoyStick, true));
	joystick->setEventCallback(this);
	
	return true;
}
Ejemplo n.º 11
0
    void setupInputSystem()
    {
	   size_t windowHnd = 0;
       std::ostringstream windowHndStr;
       OIS::ParamList pl;
       RenderWindow *win = mWindow;

       win->getCustomAttribute("WINDOW", &windowHnd);
       windowHndStr << windowHnd;
       pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
       mInputManager = OIS::InputManager::createInputSystem(pl);

	   try
       {
           mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, true));
           mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject(OIS::OISMouse, true));
           //mJoy = static_cast<OIS::JoyStick*>(mInputManager->createInputObject(OIS::OISJoyStick, false));
       }
       catch (const OIS::Exception &e)
       {
           throw Exception(42, e.eText, "Application::setupInputSystem");
       }
    }
Ejemplo n.º 12
0
void OglOIS::init()
{
	OIS::ParamList pl;
	OIS::InputManager *mInputSystem;

	/*SDL_SysWMinfo info;
	SDL_VERSION( &info.version );
	SDL_GetWindowWMInfo( window, &info );*/
	size_t m_windowHandle;
#if defined OIS_WIN32_PLATFORM
	m_windowHandle = (int) GetActiveWindow();//*(reinterpret_cast<std::size_t*>(&(/*info.info.x11.window*/info.info.win.window)));
#elif defined OIS_LINUX_PLATFORM
	Display *display;
	Window focus;
	int revert;

	display = XOpenDisplay( NULL );
	XGetInputFocus( display, &focus, &revert );
	m_windowHandle = (int) focus;
#endif

	ostringstream windowHndStr;
	windowHndStr << m_windowHandle;
	pl.insert( std::make_pair( std::string( "WINDOW" ), windowHndStr.str( ) ) );

#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" ) ) );
#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" ) ) );;
#endif

	mInputSystem = OIS::InputManager::createInputSystem( pl );
	mouse = static_cast<OIS::Mouse*>(mInputSystem->createInputObject( OIS::OISMouse, false ));
	keyb = static_cast<OIS::Keyboard*>(mInputSystem->createInputObject( OIS::OISKeyboard, false ));
}
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);
}
Ejemplo n.º 14
0
	~AppFrameListener(){
		_InputManager->destroyInputObject(_Keyboard);
		_InputManager->destroyInputObject(_Mouse);
		OIS::InputManager::destroyInputSystem(_InputManager);
	}
Ejemplo n.º 15
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) {
#else
int main(int argc, char** argv) {
#endif
    Window window("Sample_InteractiveWater", 1024, 768, true);
    RenderParameters_t renderParameters;
    renderParameters.width = 1024;
    renderParameters.height = 768;
    renderParameters.displayFormat = DISPLAY_FORMAT_X8R8G8B8;
    renderParameters.refreshRate = 0;
    renderParameters.depthStencilBits = DEPTH_STENCIL_BITS_D24X8;

    Renderer::GetInstance()->Initialize(RENDER_SYSTEM_OPENGL, window, renderParameters);
    Renderer::GetInstance()->SetClearColor(0.2f, 0.2f, 0.2f);

    // Water surface creation
    const int NUM_VERTICES = 64;
    SurfaceTriangles_t surface;
    surface.numVertices = NUM_VERTICES * NUM_VERTICES;
    surface.numNormals = NUM_VERTICES * NUM_VERTICES;
    surface.numTexCoords = NUM_VERTICES * NUM_VERTICES;
    surface.vertices = new Vector3[surface.numVertices];
    surface.normals = new Vector3[surface.numNormals];
    surface.texCoords = new Vector2[surface.numTexCoords];

    Vector3* buffer = new Vector3[surface.numVertices];
    Vector3* buffer2 = surface.vertices;

    size_t idx = 0;
    const int NUM_CELLS = NUM_VERTICES - 1;
    float step = 2.0f / NUM_CELLS;
    float uvStep = 1.0f / NUM_VERTICES;

    for (size_t i = 0; i < NUM_VERTICES; i++) {
        for (size_t j = 0; j < NUM_VERTICES; j++) {
            idx = i * NUM_VERTICES + j;
            buffer[idx] = surface.vertices[idx] = Vector3(j * step - 1.0f, i * step - 1.0f, 0.0f);
            surface.normals[idx] = -Vector3::LOOK;
            surface.texCoords[idx] = Vector2(uvStep * j, uvStep * i);
        }
    }

    surface.numIndices = NUM_CELLS * NUM_CELLS * 6;
    surface.indices = new unsigned short[surface.numIndices];
    idx = 0;

    for (size_t i = 0; i < NUM_CELLS; i++) {
        for (size_t j = 0; j < NUM_CELLS; j++) {
            surface.indices[idx++] = i * NUM_VERTICES + j;
            surface.indices[idx++] = (i + 1) * NUM_VERTICES + j;
            surface.indices[idx++] = (i + 1) * NUM_VERTICES + j + 1;

            surface.indices[idx++] = i * NUM_VERTICES + j;
            surface.indices[idx++] = (i + 1) * NUM_VERTICES + j + 1;
            surface.indices[idx++] = i * NUM_VERTICES + j + 1;
        }
    }

    Mesh waterMesh(MESH_TYPE_DYNAMIC);
    waterMesh.AddSurface(&surface);

    VertexAttributesMap_t vertexAttributes;
    vertexAttributes[VERTEX_ATTRIBUTES_POSITION] = 0;
    vertexAttributes[VERTEX_ATTRIBUTES_NORMAL] = 1;
    vertexAttributes[VERTEX_ATTRIBUTES_TEX_COORDS] = 2;
    waterMesh.Initialize(vertexAttributes);

    // Material surface
    Shader* waterShader = Renderer::GetInstance()->CreateShader();
    waterShader->SetSourceFile("Shaders/vert", "Shaders/frag");

    Material waterMaterial(waterShader);
    Texture2D* waterTexture = Renderer::GetInstance()->CreateTexture2DFromFile("Media/water.jpg");
    waterMaterial.SetUniformTexture("waterTexture", waterTexture);

    // Water node
    Node waterNode;
    waterNode.SetMaterial(&waterMaterial);
    waterNode.SetMesh(&waterMesh);
    Renderer::GetInstance()->GetSceneTree().AddNode(&waterNode);

    Renderer::GetInstance()->CameraLookAt(Vector3(0.0f, 0.0f, -3.5f), Vector3::ZERO);

    // Create the OIS system if present
#ifdef OIS_AVAILABLE

    size_t windowHandle = (size_t)window.GetHandle();

    OIS::ParamList paramList;
    paramList.insert(pair<string, string>("WINDOW", to_string(windowHandle)));

#if defined OIS_WIN32_PLATFORM
    paramList.insert(pair<string, string>("w32_mouse", "DISCL_FOREGROUND"));
    paramList.insert(pair<string, string>("w32_mouse", "DISCL_NONEXCLUSIVE"));
#elif defined OIS_LINUX_PLATFORM
    paramList.insert(pair<string, string>("x11_mouse_grab", "false"));
    paramList.insert(pair<string, string>("x11_mouse_hide", "false"));
#endif

    OIS::InputManager* inputManager = OIS::InputManager::createInputSystem(paramList);

    OIS::Keyboard* keyboard = static_cast<OIS::Keyboard*>(inputManager->createInputObject(OIS::OISKeyboard, false));
    OIS::Mouse* mouse = static_cast<OIS::Mouse*>(inputManager->createInputObject(OIS::OISMouse, false));

    const OIS::MouseState& ms = mouse->getMouseState();
    ms.width = window.GetWidth();
    ms.height = window.GetHeight();
#endif

    //Renderer::GetInstance()->SetRenderFillMode(RENDER_MODE_WIREFRAME);
    float splashForce = 0.1f;
    float damping = 0.999f;
    float maxHeight = 0.15f;

    while (window.IsOpen()) {
        WindowEvent windowEvent;
        if (window.PollEvents(windowEvent)) {
        }

        // Poll the mouse if OIS is present
#ifdef OIS_AVAILABLE
        keyboard->capture();

        if (keyboard->isKeyDown(OIS::KC_ESCAPE)) {
            break;
        }

        mouse->capture();

        // If we clicked on the surface, get the point on the water plane and send it to the shader
        // for it to compute the ripples

        if (mouse->getMouseState().buttonDown(OIS::MB_Left)) {
            Vector3 pos = Renderer::GetInstance()->ScreenToWorldPoint(Vector2((float)mouse->getMouseState().X.abs, (float)mouse->getMouseState().Y.abs));

            // Transform the position into the range [0, 1] so that we can map it as texture coordinates of the water plane
            // Because the water plane ranges from (-1, -1) to (1, 1), the transformation is trivial
            Vector2 point;
            point.y = pos.x / 2.0f + 0.5f;
            point.x = pos.y / 2.0f + 0.5f;

            if (point.x >= 0.0f && point.y >= 0.0f && point.x <= 1.0f && point.y <= 1.0f) {
                //waterShader->SetUniformVector2("disturbancePoint", pos.x, pos.y);
                /*
                size_t i = (size_t) min(maxf(point.x * NUM_VERTICES, 1), NUM_VERTICES - 1);
                size_t j = (size_t) minsf(maxf(point.y * NUM_VERTICES, 1), NUM_VERTICES - 1);
                size_t idx = i * NUM_VERTICES + j;

                buffer[idx].z = splashForce;
                buffer[idx + 1].z = splashForce;
                buffer[idx - 1].z = splashForce;
                buffer[(i + 1) * NUM_VERTICES + j].z = splashForce;
                buffer[(i - 1) * NUM_VERTICES + j].z = splashForce;
                buffer[(i + 1) * NUM_VERTICES + j + 1].z = splashForce;
                buffer[(i + 1) * NUM_VERTICES + j - 1].z = splashForce;
                buffer[(i - 1) * NUM_VERTICES + j + 1].z = splashForce;
                buffer[(i - 1) * NUM_VERTICES + j - 1].z = splashForce;
                */
            } else {
                //waterShader->SetUniformVector2("disturbancePoint", -1.0f, -1.0f);
            }
        }
#endif
        for (size_t i = 1; i < NUM_VERTICES - 1; i++) {
            for (size_t j = 1; j < NUM_VERTICES - 1; j++) {
                idx = i * NUM_VERTICES + j;

                buffer[idx].z = (buffer2[idx - 1].z + buffer2[idx + 1].z +
                                 buffer2[(i - 1) * NUM_VERTICES + j].z +
                                 buffer2[(i + 1) * NUM_VERTICES + j].z) / 2.0f - buffer[idx].z;
                buffer[idx].z *= damping;
            }
        }

        for (size_t i = 1; i < NUM_VERTICES - 1; i++) {
            for (size_t j = 1; j < NUM_VERTICES - 1; j++) {
                idx = i * NUM_VERTICES + j;

                surface.normals[idx] = (buffer[idx + 1] - buffer[idx - 1]).Normalized();
            }
        }

        buffer2 = surface.vertices;
        surface.vertices = buffer;
        buffer = buffer2;
        waterMesh.UpdateMeshData();

        Renderer::GetInstance()->Clear();
        Renderer::GetInstance()->Render();
        Renderer::GetInstance()->EndRender();

        Renderer::GetInstance()->PresentFrame();
    }

    delete[] buffer;

    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; 
}
	~FrameListenerProyectos(){
		_man->destroyInputObject(_key);
		_man->destroyInputObject(_mouse);
		OIS::InputManager::destroyInputSystem(_man);
	}
Ejemplo n.º 18
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);
    }
Ejemplo n.º 19
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, "Walking Around Professor : 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, 500.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("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);

		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;
	}
Ejemplo n.º 20
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;
	}