Ejemplo n.º 1
0
  void _makeOgre()
  {
   srand(time(0));
   
   mRoot = new Ogre::Root("","");
   mRoot->addFrameListener(this);
#if 1
#ifdef _DEBUG
   mRoot->loadPlugin("RenderSystem_Direct3D9_d");
#else
   mRoot->loadPlugin("RenderSystem_Direct3D9");
#endif
#else
#ifdef _DEBUG
   mRoot->loadPlugin("RenderSystem_GL_d.dll");
#else
   mRoot->loadPlugin("RenderSystem_GL.dll");
#endif
#endif
   
   mRoot->setRenderSystem(mRoot->getAvailableRenderers()[0]);
    
   Ogre::ResourceGroupManager* rgm = Ogre::ResourceGroupManager::getSingletonPtr();
   rgm->addResourceLocation(".", "FileSystem");
   
   mRoot->initialise(false);
   
   mWindow = mRoot->createRenderWindow("Monkey", 1024, 768, false);
   mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC);
   mCamera = mSceneMgr->createCamera("Camera");
   mViewport = mWindow->addViewport(mCamera);
   mViewport->setBackgroundColour(Gorilla::rgb(128, 70, 27));
   
   rgm->initialiseAllResourceGroups();
  }
Ejemplo n.º 2
0
void gkEngine::loadResources(const gkString& name)
{
	if (name.empty()) return;

	try
	{
		Ogre::ConfigFile fp;
		fp.load(name);

		Ogre::ResourceGroupManager* resourceManager = Ogre::ResourceGroupManager::getSingletonPtr();
		Ogre::ConfigFile::SectionIterator cit = fp.getSectionIterator();

		while (cit.hasMoreElements())
		{
			gkString elementname = cit.peekNextKey();
			Ogre::ConfigFile::SettingsMultiMap* ptr = cit.getNext();
			for (Ogre::ConfigFile::SettingsMultiMap::iterator dit = ptr->begin(); dit != ptr->end(); ++dit)
				resourceManager->addResourceLocation(dit->second, dit->first, elementname);
		}
		Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
	}
	catch (Ogre::Exception& e)
	{
		gkLogMessage("Engine: Failed to load resource file!\n" << e.getDescription());
	}
}
Ejemplo n.º 3
0
//---------------------------------------------------------------------------------
bool CSkyxEditor::load(bool async)
{
    if(mLoaded->get())
        return true;

    Ogre::ResourceGroupManager *mngr = Ogre::ResourceGroupManager::getSingletonPtr();
    Ogre::String value = mOgitorsRoot->GetProjectFile()->getFileSystemName() + "::/SkyX/";
    mngr->addResourceLocation(value, "Ofs", "SkyX");
    mngr->initialiseResourceGroup("SkyX");

	// Create SkyX
    mBasicController = new SkyX::BasicController(true);
    mHandle = new SkyX::SkyX(mOgitorsRoot->GetSceneManager(), mBasicController);
	mHandle->create();

    mHandle->getVCloudsManager()->getVClouds()->registerCamera(mOgitorsRoot->GetViewport()->getCameraEditor()->getCamera());

    mHandle->getVCloudsManager()->getVClouds()->setDistanceFallingParams(Ogre::Vector2(2, -1));

    _restoreState();

    registerForUpdates();

    mLoaded->set(true);
    return true;
}
Ejemplo n.º 4
0
//-----------------------------------------------------------------------------------------
void CTerrainGroupEditorFactory::addEditorResources(bool changeDefaultNames)
{
    OgitorsRoot* ogitorsRoot = OgitorsRoot::getSingletonPtr();
    Ogre::String terrainDir = ogitorsRoot->GetProjectOptions()->TerrainDirectory;
    // create Terrain project folder and folder to hold the terrain
    ogitorsRoot->GetProjectFile()->createDirectory(terrainDir.c_str());
    ogitorsRoot->GetProjectFile()->createDirectory((terrainDir+"/terrain/").c_str());

    // copy default plant textures
    ogitorsRoot->GetProjectFile()->createDirectory((terrainDir+"/plants/").c_str());
    Ogre::String copydir = Ogitors::Globals::MEDIA_PATH + "/plants/";
    OgitorsUtils::CopyDirOfs(copydir, (terrainDir+"/plants/").c_str());

    // copy default terrain textures sorting them into two different folders
    ogitorsRoot->GetProjectFile()->createDirectory((terrainDir+"/textures/").c_str());
    ogitorsRoot->GetProjectFile()->createDirectory((terrainDir+"/textures/diffusespecular").c_str());
    ogitorsRoot->GetProjectFile()->createDirectory((terrainDir+"/textures/normalheight").c_str());

    Ogre::ResourceGroupManager *mngr = Ogre::ResourceGroupManager::getSingletonPtr();
    copydir = Ogitors::Globals::MEDIA_PATH + "/terrainTextures/";
    mngr->addResourceLocation(copydir,"FileSystem","CopyTerrain");

    Ogre::FileInfoListPtr resList = mngr->listResourceFileInfo("CopyTerrain");

    // copy the files to the different directories
    OFS::OfsPtr& file = ogitorsRoot->GetProjectFile();
    for (Ogre::FileInfoList::const_iterator it = resList->begin(); it != resList->end(); ++it)
    {
        Ogre::FileInfo fInfo = (*it);
        Ogre::String loc = copydir + fInfo.path + fInfo.filename;
        Ogre::String newName = fInfo.filename;
        
        if(fInfo.archive->getType() == "FileSystem")
        {
            if(fInfo.filename.find("diffusespecular") != -1)
            {
                /* since we're using different resource groups for the terrain lets
                remove the naming scheme from the filenames except if the project
                is being upgraded, in which case leave the name alone. */
                if (changeDefaultNames) {
                    newName = Ogre::StringUtil::replaceAll(newName, "_diffusespecular", "");
                }
                OgitorsUtils::CopyFileOfs(loc, terrainDir+"/textures/diffusespecular/"+newName);
            }
            
            if(fInfo.filename.find("normalheight") != -1)
            {
                if (changeDefaultNames) {
                    newName = Ogre::StringUtil::replaceAll(newName, "_normalheight", "");
                }
                OgitorsUtils::CopyFileOfs(loc, terrainDir+"/textures/normalheight/"+newName);
            }
        }
    }
    resList.setNull();
    
    ogitorsRoot->DestroyResourceGroup("CopyTerrain");
}
Ejemplo n.º 5
0
//--------------------------------------------------------------------------------------------------
CCaelumEditor::CCaelumEditor(CBaseEditorFactory *factory) : CBaseEditor(factory),
    _mUpdateCounter(0)
{
    mHandle = 0;
    mSceneManager = 0;
    
    mName->init("CaelumSky");

    Ogre::ResourceGroupManager *resmngr = Ogre::ResourceGroupManager::getSingletonPtr();
    Ogre::String value = mOgitorsRoot->GetProjectFile()->getFileSystemName() + "::/" + mOgitorsRoot->GetProjectOptions()->CaelumDirectory + "/";
    resmngr->addResourceLocation(value,"Ofs","Caelum");
    resmngr->initialiseResourceGroup("Caelum");
}
Ejemplo n.º 6
0
//-----------------------------------------------------------------------------------------
CTerrainGroupEditor::CTerrainGroupEditor(CBaseEditorFactory *factory) : CBaseEditor(factory),
mHandle(0), mBrushData(0), mModificationRect(0,0,0,0)
{
    mDecalNode = 0;
    mDecalFrustum = 0;
    mEditMode = EM_NONE;
    mEditActive = false;
    mDecalTexture.setNull();
    mBrushSize = 1;
    mName->init("Terrain Group");
    mTextureGrass = "grass";
    mBrushName = "AllWhite.png";

    mMaxLayersAllowed = 6;

    Ogre::ResourceGroupManager *mngr = Ogre::ResourceGroupManager::getSingletonPtr();
    Ogre::String terrainDir = mOgitorsRoot->GetProjectFile()->getFileSystemName() + "::/" + mOgitorsRoot->GetProjectOptions()->TerrainDirectory + "/terrain";
    mngr->addResourceLocation(terrainDir,"Ofs","TerrainResources");

    mTerrainGlobalOptions = OGRE_NEW Ogre::TerrainGlobalOptions();
}
Ejemplo n.º 7
0
  void  _makeOgre()
  {
   srand(time(0));
   
   mRoot = new Ogre::Root("","");
   mRoot->addFrameListener(this);
   
#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
   mRoot->loadPlugin(OGRE_RENDERER);
#else
#if 1
  #ifdef _DEBUG
   mRoot->loadPlugin("RenderSystem_Direct3D9_d");
  #else
   mRoot->loadPlugin("RenderSystem_Direct3D9");
  #endif
#else
  #ifdef _DEBUG
   mRoot->loadPlugin("RenderSystem_GL_d.dll");
  #else
   mRoot->loadPlugin("RenderSystem_GL.dll");
  #endif
#endif
#endif
   
   mRoot->setRenderSystem(mRoot->getAvailableRenderers()[0]);
   
   Ogre::ResourceGroupManager* rgm = Ogre::ResourceGroupManager::getSingletonPtr();
  	rgm->addResourceLocation(".", "FileSystem");
   
   mRoot->initialise(false);
   
   mWindow = mRoot->createRenderWindow("Gorilla - Press 0 to 9 for unit tests. C to Clear.", 1024, 768, false);
   mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC);
   mCamera = mSceneMgr->createCamera("Camera");
   mViewport = mWindow->addViewport(mCamera);
   mViewport->setBackgroundColour(Ogre::ColourValue::Black);
   
   rgm->initialiseAllResourceGroups();
  }
Ejemplo n.º 8
0
  void  _makeOgre()
  {
   srand(time(0));
   
   mRoot = new Ogre::Root("","");
   mRoot->addFrameListener(this);

  #ifdef _DEBUG
    #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
   // Change this to where ever you've squirrelled away your RenderSystem debug library
   mRoot->loadPlugin("/usr/local/lib/OGRE/RenderSystem_GL_d");
    #else
   mRoot->loadPlugin("RenderSystem_Direct3D9_d");
    #endif
  #else
    #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
   // Change this to where ever you've squirrelled away your RenderSystem release library
   mRoot->loadPlugin("/usr/local/lib/OGRE/RenderSystem_GL");
    #else
   mRoot->loadPlugin("RenderSystem_Direct3D9");
   #endif
#endif
   
   mRoot->setRenderSystem(mRoot->getAvailableRenderers()[0]);
   
   Ogre::ResourceGroupManager* rgm = Ogre::ResourceGroupManager::getSingletonPtr();
  	rgm->addResourceLocation(".", "FileSystem");
   
   mRoot->initialise(false);
   
   mWindow = mRoot->createRenderWindow("Gorilla", 1024, 768, false);
   mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC);
   mCamera = mSceneMgr->createCamera("Camera");
   mViewport = mWindow->addViewport(mCamera);
   mViewport->setBackgroundColour(Gorilla::rgb(13, 13, 13));
   
   rgm->initialiseAllResourceGroups();
  }
Ejemplo n.º 9
0
//---------------------------------------------------------------------------------
bool CSkyxEditor::load(bool async)
{
    if(mLoaded->get())
        return true;

    Ogre::ResourceGroupManager *mngr = Ogre::ResourceGroupManager::getSingletonPtr();
    Ogre::String value = OgitorsUtils::QualifyPath(mOgitorsRoot->GetProjectOptions()->ProjectDir + "/SkyX");
    mngr->addResourceLocation(value,"FileSystem","SkyX");
    mngr->initialiseResourceGroup("SkyX");

	// Create SkyX
    mHandle = new SkyX::SkyX(mOgitorsRoot->GetSceneManager(), mOgitorsRoot->GetViewport()->getCameraEditor()->getCamera());
	mHandle->create();

    mHandle->getVCloudsManager()->create();

    _restoreState();

    registerForUpdates();

    mLoaded->set(true);
    return true;
}
Ejemplo n.º 10
0
bool Game::init()
{
  try
  {
    // Read config first
    config.read("./config.cfg");

    // Init SDL
    SDL_Init(SDL_INIT_VIDEO);
    SDL_putenv((char*)"SDL_VIDEO_CENTERED=true");
    int flags = SDL_OPENGL;
    if (config.getFullscreen())
      flags |= SDL_FULLSCREEN;
    SDL_SetVideoMode(config.getCanvasWidth(), config.getCanvasHeight(), config.getBits(), flags);
    SDL_WM_SetCaption("Yet Another Rubik's Cube", NULL);

    // Ogre
    root = new Ogre::Root();
    #ifdef _WINDOWS
      root->loadPlugin("./RenderSystem_GL.dll");
    #else
      root->loadPlugin("./RenderSystem_GL.so");
    #endif
    Ogre::RenderSystem *rs = root->getRenderSystemByName("OpenGL Rendering Subsystem");
    root->setRenderSystem(rs);
    rs->setConfigOption("Full Screen", config.getFullscreenStr());
    rs->setConfigOption("Video Mode", config.getVideoModeStr());
    root->initialise(false);

    // Window
    Ogre::NameValuePairList params;
    #ifdef _WINDOWS
      SDL_SysWMinfo info;
      SDL_VERSION(&info.version);
      SDL_GetWMInfo(&info);
      params["externalWindowHandle"] = Ogre::StringConverter::toString(reinterpret_cast<size_t>(info.window));
      params["externalGLContent"] = Ogre::StringConverter::toString(reinterpret_cast<size_t>(info.hglrc));
      params["externalGLControl"] = Ogre::String("True");
    #else
      params["currentGLContext"] = Ogre::String("True");
    #endif
    wnd = root->createRenderWindow("Main window", config.getCanvasWidth(), config.getCanvasHeight(),
        config.getFullscreen(), &params);
    wnd->setVisible(true);

    // Input
    imgr = new InputManager();

    // Hard-code res location
    Ogre::ResourceGroupManager *rgm = Ogre::ResourceGroupManager::getSingletonPtr();
    rgm->addResourceLocation("res.gdat", "Zip", "General");
    rgm->initialiseAllResourceGroups();

    // Window and rendering events listener
    root->addFrameListener(this);
    imgr->regEventListener(this);
    imgr->regKeyboardListener(this);
  }
  catch (std::exception &e)
  {
    #ifdef _WINDOWS
      MessageBoxA(NULL, e.what(), "Exception occured", MB_OK | MB_ICONERROR);
    #else
      std::cout << e.what();
    #endif
    return false;
  }
  return true;
}
Ejemplo n.º 11
0
//-----------------------------------------------------------------------------------------
bool CTerrainGroupEditor::load(bool async)
{
    if(mLoaded->get())
        return true;

    if(!getParent()->load())
        return false;

    Ogre::ResourceGroupManager *mngr = Ogre::ResourceGroupManager::getSingletonPtr();
    Ogre::String terrainDir = OgitorsRoot::getSingletonPtr()->GetProjectOptions()->TerrainDirectory;
    terrainDir = mOgitorsRoot->GetProjectFile()->getFileSystemName() + "::/" + terrainDir + "/";

    mngr->addResourceLocation(terrainDir + "textures/normalheight", "Ofs", "TerrainGroupNormalHeight");
    mngr->initialiseResourceGroup("TerrainGroupNormalHeight");

    mngr->addResourceLocation(terrainDir + "textures/diffusespecular", "Ofs", "TerrainGroupDiffuseSpecular");
    mngr->initialiseResourceGroup("TerrainGroupDiffuseSpecular");

    mngr->addResourceLocation(terrainDir + "plants", "Ofs", "TerrainGroupPlants");
    mngr->initialiseResourceGroup("TerrainGroupPlants");

    OgitorsRoot::getSingletonPtr()->PrepareTerrainResources();
    OgitorsRoot::getSingletonPtr()->ReloadUserResources();

    mDecalFrustum = OGRE_NEW Ogre::Frustum();
    mDecalNode = getSceneManager()->getRootSceneNode()->createChildSceneNode("OgitorTerrainDecalNode");
    mDecalNode->setPosition(99999, -99999, 99999);
    mDecalNode->attachObject(mDecalFrustum);
    mDecalFrustum->setProjectionType(Ogre::PT_ORTHOGRAPHIC);
    mDecalNode->setOrientation(Ogre::Quaternion(Ogre::Degree(-90), Ogre::Vector3::UNIT_X));
    mDecalFrustum->setFOVy(Ogre::Degree(45));
    mDecalFrustum->setNearClipDistance(10);
    mDecalFrustum->setOrthoWindow(10, 10);
    mDecalFrustum->setVisible(false);
    mDecalTexture = Ogre::TextureManager::getSingletonPtr()->createManual("OgitorDecalTexture", "TerrainResources", 
        Ogre::TEX_TYPE_2D, 256, 256, 1, 1, Ogre::PF_A8R8G8B8, Ogre::TU_DYNAMIC_WRITE_ONLY, this);

    mBrushData = OGRE_ALLOC_T(float, BRUSH_DATA_SIZE * BRUSH_DATA_SIZE, Ogre::MEMCATEGORY_GEOMETRY);

    mTerrainGlobalOptions->setMaxPixelError(mMaxPixelError->get());
    mTerrainGlobalOptions->setCompositeMapSize(mCompositeMapTextureSize->get());
    mTerrainGlobalOptions->setCompositeMapDistance(mCompositeMapDistance->get());
    mTerrainGlobalOptions->setLightMapSize(mLightMapTextureSize->get());
    mTerrainGlobalOptions->setLayerBlendMapSize(mBlendMapTextureSize->get());
    mTerrainGlobalOptions->setUseVertexCompressionWhenAvailable(false);
    mTerrainGlobalOptions->setSkirtSize(mSkirtSize->get());
    mTerrainGlobalOptions->setUseRayBoxDistanceCalculation(mUseRayBoxDistanceCalculation->get());

    if(mMaterialGeneratorType->get() == 1)
    {
        Ogre::TerrainMaterialGeneratorPtr matGenPtr(OGRE_NEW Ogre::TerrainMaterialGeneratorC(this, mDecalFrustum));
        mTerrainGlobalOptions->setDefaultMaterialGenerator(matGenPtr);
        mMaxLayersAllowed = 10;
    }
    else
    {
        Ogre::TerrainMaterialGeneratorPtr matGenPtr(OGRE_NEW Ogre::TerrainMaterialGeneratorB(this, mDecalFrustum));
        mTerrainGlobalOptions->setDefaultMaterialGenerator(matGenPtr);
        mMaxLayersAllowed = 6;
    }

    CSceneManagerEditor *mSceneMgr = static_cast<CSceneManagerEditor*>(mOgitorsRoot->GetSceneManagerEditor());

    if(mSceneMgr->getShadowsEnabled())
    {
        if(mMaterialGeneratorType->get() == 1)
        {
            Ogre::TerrainMaterialGeneratorC::SM2Profile* matProfile = static_cast<Ogre::TerrainMaterialGeneratorC::SM2Profile*>(mTerrainGlobalOptions->getDefaultMaterialGenerator()->getActiveProfile());
            matProfile->setReceiveDynamicShadowsEnabled(true);
            matProfile->setReceiveDynamicShadowsLowLod(false);
            matProfile->setReceiveDynamicShadowsDepth(true);
            matProfile->setReceiveDynamicShadowsPSSM(static_cast<Ogre::PSSMShadowCameraSetup*>(mSceneMgr->getPSSMSetup().get()));
        }
        else
        {
            Ogre::TerrainMaterialGeneratorB::SM2Profile* matProfile = static_cast<Ogre::TerrainMaterialGeneratorB::SM2Profile*>(mTerrainGlobalOptions->getDefaultMaterialGenerator()->getActiveProfile());
            matProfile->setReceiveDynamicShadowsEnabled(true);
            matProfile->setReceiveDynamicShadowsLowLod(false);
            matProfile->setReceiveDynamicShadowsDepth(true);
            matProfile->setReceiveDynamicShadowsPSSM(static_cast<Ogre::PSSMShadowCameraSetup*>(mSceneMgr->getPSSMSetup().get()));
        }
    }

    CONNECT_PROPERTY_MEMFN(mSceneMgr, "shadows::enabled", CTerrainGroupEditor, onShadowsChange, mShadowsConnection[0]);
    CONNECT_PROPERTY_MEMFN(mSceneMgr, "shadows::technique", CTerrainGroupEditor, onShadowsTechniqueChange, mShadowsConnection[1]);

    mHandle = OGRE_NEW Ogre::TerrainGroup(mOgitorsRoot->GetSceneManager(), Ogre::Terrain::ALIGN_X_Z, mMapSize->get(), mWorldSize->get());
    mHandle->setOrigin(Ogre::Vector3::ZERO);
    mHandle->setResourceGroup("TerrainResources");
    mHandle->setFilenameConvention(mPageNamePrefix->get(), "ogt");
    StaticGroupPtr = mHandle;

    mPGHandle = new PagedGeometry(mOgitorsRoot->GetViewport()->getCameraEditor()->getCamera(), mPGPageSize->get());
    mPGHandle->addDetailLevel<GrassPage>(mPGDetailDistance->get());

    //Create a GrassLoader object
    mGrassLoaderHandle = new GrassLoader(mPGHandle);
    mGrassLoaderHandle->setVisibilityFlags(1 << mLayer->get());

    //Assign the "grassLoader" to be used to load geometry for the PagedGrass instance
    mPGHandle->setPageLoader(mGrassLoaderHandle);

    //Supply a height function to GrassLoader so it can calculate grass Y values
    mGrassLoaderHandle->setHeightFunction(OgitorTerrainGroupHeightFunction);

    Ogre::Vector3 vDir;
    Ogre::ColourValue cDiffuse;
    Ogre::SceneManager::MovableObjectIterator mit = mOgitorsRoot->GetSceneManager()->getMovableObjectIterator("Light");
    while(mit.hasMoreElements())
    {
        Ogre::Light *l = static_cast<Ogre::Light*>(mit.getNext());
        if(l->getType() == Ogre::Light::LT_DIRECTIONAL && l->getCastShadows())
        {
            vDir = l->getDerivedDirection();
            cDiffuse = l->getDiffuseColour();
            break;
        }
    }

    mTerrainGlobalOptions->setLightMapDirection(vDir);
    mTerrainGlobalOptions->setCompositeMapAmbient(mOgitorsRoot->GetSceneManager()->getAmbientLight());
    mTerrainGlobalOptions->setCompositeMapDiffuse(cDiffuse);

    terrainDir = OgitorsRoot::getSingletonPtr()->GetProjectOptions()->TerrainDirectory + "/terrain/";

    OFS::FileList TGAList = mOgitorsRoot->GetProjectFile()->listFiles(terrainDir.c_str(), OFS::OFS_FILE);

    for(unsigned int t = 0; t < TGAList.size(); t++)
    {
        int pos = TGAList[t].name.find("_density.tga");
        if(pos > 0)
        {
            Ogre::Image _img;
            Ogre::String sLoc = terrainDir + TGAList[t].name;

            // Block to ensure streams are freed when exiting the block
            {
                OFS::OFSHANDLE *iHandle = new OFS::OFSHANDLE();
                mOgitorsRoot->GetProjectFile()->openFile( *iHandle, sLoc.c_str() );
                Ogre::DataStreamPtr img_stream = Ogre::DataStreamPtr(OGRE_NEW OfsDataStream(mOgitorsRoot->GetProjectFile(), iHandle));
                _img.load(img_stream);
            }

            Ogre::String nLoc = terrainDir + TGAList[t].name.substr(0, pos);
            nLoc += "_density.png";

            OgitorsUtils::SaveImageOfs( _img, nLoc );
            mOgitorsRoot->GetProjectFile()->deleteFile( sLoc.c_str() );
        }
    }

    registerForUpdates();

    mLoaded->set(true);
    return true;
}
Ejemplo n.º 12
0
	void OgreSubsystem::_init()
	{
		if(!mInitialized)
		{
			Logger::getPtr()->logMessage("Ogre Subsystem starting up...");

			mRoot = new Ogre::Root("","");

			// suppress log output (TODO allow this to be redirected and enabled)
			//Ogre::LogManager::getSingleton().getDefaultLog()->setDebugOutputEnabled(false);
			//Ogre::LogManager::getSingleton().getDefaultLog()->setLogDetail(Ogre::LL_LOW);

			//#if (ORYX_PLATFORM == ORYX_PLATFORM_WIN32)
			//mRoot->loadPlugin("OgrePlugins/RenderSystem_GL.dll");
			//mRoot->loadPlugin("OgrePlugins/Plugin_CgProgramManager.dll");
			//mRoot->loadPlugin("OgrePlugins/Plugin_ParticleFX.dll");
			//#else
			mRoot->loadPlugin("OgrePlugins/RenderSystem_GL");
			//mRoot->loadPlugin("OgrePlugins/Plugin_CgProgramManager");
			mRoot->loadPlugin("OgrePlugins/Plugin_ParticleFX");
			//#endif

			Ogre::RenderSystem* rs = mRoot->getRenderSystemByName(
				"OpenGL Rendering Subsystem");
			mRoot->setRenderSystem(rs);

			mRoot->initialise(false);

			Ogre::NameValuePairList miscP;

			miscP["vsync"] = "false";
			miscP["FSAA"] = "0";
			miscP["gamma"] = "false";
			miscP["border"] = "fixed";
			miscP["colourDepth"] = "32";
			miscP["monitorIndex"] = "0";

      for (std::map<String, String>::iterator it = mParams.begin();
        it != mParams.end(); ++it) {
        miscP[it->first] = it->second;
      }

      mCurrentParams = mParams;

      mWindow = mRoot->createRenderWindow((getGfxParameter("window_name") != "")
        ? getGfxParameter("window_name") : "OryxEngine Application",
        mResolutionX,mResolutionY,mFullscreen,&miscP);

			mWindow->setActive(true);

			mSceneManager = mRoot->createSceneManager(Ogre::ST_GENERIC,"mSceneManager");
			Ogre::SceneNode* defaultCamNode = mSceneManager->createSceneNode("DefaultCameraNode");
			mDefaultCamera = new Camera("DefaultCamera",defaultCamNode,mSceneManager
				->createCamera("DefaultCamera"));
			defaultCamNode->attachObject(mDefaultCamera->getCamera());
			mDefaultCamera->setPosition(Vector3(0,0,0));
			mDefaultCamera->getCamera()->setDirection(0,0,-1);
			mDefaultCamera->setFarClip(60);
			mDefaultCamera->setNearClip(0.1f);
			mDefaultCamera->setFOV(60.f);

			mViewport = mWindow->addViewport(mDefaultCamera->getCamera());
			mViewport->setBackgroundColour(Ogre::ColourValue(1.0f,0.5f,0.2f));

			mDefaultCamera->getCamera()->setAspectRatio(Ogre::Real(mViewport->getActualWidth())
									/ Ogre::Real(mViewport->getActualHeight()));

			Ogre::ResourceGroupManager* resourceMgr = Ogre::ResourceGroupManager::getSingletonPtr();
			resourceMgr->addResourceLocation("../media","FileSystem","General");
			resourceMgr->addResourceLocation("../media/models","FileSystem","General");
			resourceMgr->addResourceLocation("../media/materials","FileSystem","General");
			resourceMgr->addResourceLocation("../media/textures","FileSystem","General");
			resourceMgr->addResourceLocation("../media/audio","FileSystem","General");
			resourceMgr->addResourceLocation("../media/gui","FileSystem","General");
			resourceMgr->addResourceLocation("../media/scripts","FileSystem","General");
			resourceMgr->addResourceLocation("../media/fonts","FileSystem","General");
			resourceMgr->initialiseAllResourceGroups();

			mRootSceneNode = new SceneNode(mSceneManager->getRootSceneNode()->getName(),
				mSceneManager->getRootSceneNode());

			Logger::getPtr()->logMessage("Ogre Subsystem started up.");
			mInitialized = true;
      /*mSceneManager->setShadowCameraSetup(Ogre::ShadowCameraSetupPtr(new Ogre::LiSPSMShadowCameraSetup()));
      mSceneManager->setShadowTexturePixelFormat(Ogre::PF_FLOAT16_R);
      mSceneManager->setShadowTextureCasterMaterial("depthcaster");
      mSceneManager->setShadowTextureSelfShadow(true);	
      mSceneManager->setShadowTextureSize(512);	
      mSceneManager->setShadowTextureCount(3);
      mSceneManager->setShadowCasterRenderBackFaces(false);
      mSceneManager->setShadowTechnique(Ogre::SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED);;
      mSceneManager->setShadowFarDistance(1000000.f);*/
		}
	}
Ejemplo n.º 13
0
  void  _makeOgre()
  {
   srand(time(0));
   
   mRoot = new Ogre::Root("","");
   mRoot->addFrameListener(this);
   
#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
   mRoot->loadPlugin(OGRE_RENDERER);
#else
#if 1
  #ifdef _DEBUG
   mRoot->loadPlugin("RenderSystem_Direct3D9_d");
  #else
   mRoot->loadPlugin("RenderSystem_Direct3D9");
  #endif
#else
  #ifdef _DEBUG
   mRoot->loadPlugin("RenderSystem_GL_d.dll");
  #else
   mRoot->loadPlugin("RenderSystem_GL.dll");
  #endif
#endif
#endif
   
   mRoot->setRenderSystem(mRoot->getAvailableRenderers()[0]);
   
   Ogre::ResourceGroupManager* rgm = Ogre::ResourceGroupManager::getSingletonPtr();
  	rgm->addResourceLocation(".", "FileSystem");
   
   mRoot->initialise(false);
   
   mWindow = mRoot->createRenderWindow("Gorilla", 1024, 768, false);
   mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC);
   mCamera = mSceneMgr->createCamera("Camera");
   mViewport = mWindow->addViewport(mCamera);

   Ogre::ColourValue BackgroundColour = Ogre::ColourValue(0.1337f, 0.1337f, 0.1337f, 1.0f);
   Ogre::ColourValue GridColour = Ogre::ColourValue(0.2000f, 0.2000f, 0.2000f, 1.0f);

   mViewport->setBackgroundColour(BackgroundColour);
   
   rgm->initialiseAllResourceGroups();
   
   mCamera->setPosition(10,2,10);
   mCamera->lookAt(0,2,0);
   mCamera->setNearClipDistance(0.05f);
   mCamera->setFarClipDistance(1000);
   
   mReferenceObject = new Ogre::ManualObject("ReferenceGrid");

   mReferenceObject->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_LIST);
   
   Ogre::Real step = 1.0f;
   unsigned int count = 200;
   unsigned int halfCount = count / 2;
   Ogre::Real full = (step * count);
   Ogre::Real half = full / 2;
   Ogre::Real y = 0;
   Ogre::ColourValue c;
   for (unsigned i=0;i < count+1;i++)
   {
    
    if (i == halfCount)
     c = Ogre::ColourValue(0.5f,0.3f,0.3f,1.0f);
    else
     c = GridColour;
    
    mReferenceObject->position(-half,y,-half+(step*i));
    mReferenceObject->colour(BackgroundColour);
    mReferenceObject->position(0,y,-half+(step*i));
    mReferenceObject->colour(c);
    mReferenceObject->position(0,y,-half+(step*i));
    mReferenceObject->colour(c);
    mReferenceObject->position(half,y,-half+(step*i));
    mReferenceObject->colour(BackgroundColour);

    if (i == halfCount)
     c = Ogre::ColourValue(0.3f,0.3f,0.5f,1.0f);
    else
     c = GridColour;
    
    mReferenceObject->position(-half+(step*i),y,-half);
    mReferenceObject->colour(BackgroundColour);
    mReferenceObject->position(-half+(step*i),y,0);
    mReferenceObject->colour(c);
    mReferenceObject->position(-half+(step*i),y,0);
    mReferenceObject->colour(c);
    mReferenceObject->position(-half+(step*i),y, half);
    mReferenceObject->colour(BackgroundColour);

   }
   
   mReferenceObject->end();
   mSceneMgr->getRootSceneNode()->attachObject(mReferenceObject);
    
    
    
  }