Exemplo n.º 1
0
//-----------------------------------------------------------------------------------------
void CPGInstanceManager::onSave(bool forced)
{
    Ogre::String dir = mOgitorsRoot->GetProjectOptions()->ProjectDir + "/PGInstances/";
    dir = OgitorsUtils::QualifyPath(dir);
    mSystem->MakeDirectory(dir);

    Ogre::String name = mName->get();
    std::replace(name.begin(), name.end(), '<', ' ');
    std::replace(name.begin(), name.end(), '>', ' ');
    std::replace(name.begin(), name.end(), '#', ' ');

    if(!mLastFileName.empty())
        mSystem->DeleteFile(mLastFileName);

    if(!mTempFileName.empty())
        mSystem->DeleteFile(mTempFileName);

    Ogre::String filename = OgitorsUtils::QualifyPath(dir + "/" + Ogre::StringConverter::toString(mObjectID->get()) + "_" + name + ".instance");

    mLastFileName = filename;

    _save(filename);

    mTempModified->set(false);
    mTempFileName = "";
}
Exemplo n.º 2
0
//-----------------------------------------------------------------------------------------
void CPGInstanceManager::onSave(bool forced)
{
    Ogre::String dir = "/PGInstances/";
    OFS::OfsPtr& mFile = mOgitorsRoot->GetProjectFile();
    mFile->createDirectory(dir.c_str());

    Ogre::String name = mName->get();
    std::replace(name.begin(), name.end(), '<', ' ');
    std::replace(name.begin(), name.end(), '>', ' ');
    std::replace(name.begin(), name.end(), '#', ' ');

    if(!mLastFileName.empty())
        mFile->deleteFile(mLastFileName.c_str());

    if(!mTempFileName.empty())
        mFile->deleteFile(mTempFileName.c_str());

    Ogre::String filename = dir + Ogre::StringConverter::toString(mObjectID->get()) + "_" + name + ".instance";

    mLastFileName = filename;

    _save(filename);

    mTempModified->set(false);
    mTempFileName = "";
}
Exemplo n.º 3
0
	virtual void setupResources(void)
	{
	GraphicsSystem::setupResources();

	Ogre::ConfigFile cf;
	cf.load(mResourcePath + "resources2.cfg");

	Ogre::String originalDataFolder = cf.getSetting("DoNotUseAsResource", "Hlms", "");

	if (originalDataFolder.empty())
	originalDataFolder = "./";
	else if (*(originalDataFolder.end() - 1) != '/')
	originalDataFolder += "/";

	const char *c_locations[4] =
	{
	"2.0/scripts/materials/Tutorial_Terrain",
	"2.0/scripts/materials/Tutorial_Terrain/GLSL",
	"2.0/scripts/materials/Tutorial_Terrain/HLSL",
	"2.0/scripts/materials/Postprocessing/SceneAssets"
	};

	for (size_t i = 0; i<4; ++i)
	{
	Ogre::String dataFolder = originalDataFolder + c_locations[i];
	addResourceLocation(dataFolder, "FileSystem", "General");
	}
	}
	//-----------------------------------------------------------------------
	void CoherentUIView::loadUrl(const Ogre::String& url)
	{
		if (mView)
		{
			std::wstring urlConverted(url.begin(), url.end());
			mView->Load(urlConverted.c_str());
		}
	}
Exemplo n.º 5
0
	virtual void registerHlms(void)
	{
	GraphicsSystem::registerHlms();

	Ogre::ConfigFile cf;
	cf.load(mResourcePath + "resources2.cfg");

	Ogre::String dataFolder = cf.getSetting("DoNotUseAsResource", "Hlms", "");

	if (dataFolder.empty())
	dataFolder = "./";
	else if (*(dataFolder.end() - 1) != '/')
	dataFolder += "/";

	Ogre::RenderSystem *renderSystem = mpRoot->getRenderSystem();

	Ogre::String shaderSyntax = "GLSL";
	if (renderSystem->getName() == "Direct3D11 Rendering Subsystem")
	shaderSyntax = "HLSL";

	Ogre::Archive *archiveLibrary = Ogre::ArchiveManager::getSingletonPtr()->load(
	dataFolder + "Hlms/Common/" + shaderSyntax,
	"FileSystem", true);
	Ogre::Archive *archiveLibraryAny = Ogre::ArchiveManager::getSingletonPtr()->load(
	dataFolder + "Hlms/Common/Any",
	"FileSystem", true);
	Ogre::Archive *archivePbsLibraryAny = Ogre::ArchiveManager::getSingletonPtr()->load(
	dataFolder + "Hlms/Pbs/Any",
	"FileSystem", true);
	Ogre::Archive *pbsLibrary = Ogre::ArchiveManager::getSingletonPtr()->load(
	dataFolder + "Hlms/Pbs/" + shaderSyntax,
	"FileSystem", true);

	Ogre::ArchiveVec library;
	library.push_back(archiveLibrary);
	library.push_back(archiveLibraryAny);
	library.push_back(archivePbsLibraryAny);
	library.push_back(pbsLibrary);

	Ogre::Archive *archiveTerra = Ogre::ArchiveManager::getSingletonPtr()->load(
	dataFolder + "Hlms/Terra/" + shaderSyntax,
	"FileSystem", true);
	Ogre::HlmsTerra *hlmsTerra = OGRE_NEW Ogre::HlmsTerra(archiveTerra, &library);
	Ogre::HlmsManager *hlmsManager = mpRoot->getHlmsManager();
	hlmsManager->registerHlms(hlmsTerra);

	//Add Terra's piece files that customize the PBS implementation.
	//These pieces are coded so that they will be activated when
	//we set the HlmsPbsTerraShadows listener and there's an active Terra
	//(see Tutorial_TerrainGameState::createScene01)
	Ogre::Hlms *hlmsPbs = hlmsManager->getHlms(Ogre::HLMS_PBS);
	Ogre::Archive *archivePbs = hlmsPbs->getDataFolder();
	Ogre::ArchiveVec libraryPbs = hlmsPbs->getPiecesLibraryAsArchiveVec();
	libraryPbs.push_back(Ogre::ArchiveManager::getSingletonPtr()->load(
	dataFolder + "Hlms/Terra/" + shaderSyntax + "/PbsTerraShadows",
	"FileSystem", true));
	hlmsPbs->reloadFrom(archivePbs, &libraryPbs);
	}
Exemplo n.º 6
0
//-----------------------------------------------------------------------------------------
TiXmlElement* CPGInstanceManager::exportDotScene(TiXmlElement *pParent)
{
    Ogre::String name = mName->get();
    std::replace(name.begin(), name.end(), '<', ' ');
    std::replace(name.begin(), name.end(), '>', ' ');
    std::replace(name.begin(), name.end(), '#', ' ');

    name = Ogre::StringConverter::toString(mObjectID->get()) + "_" + name;

    Ogre::String filename = "PGInstances/" + name + ".instance";

    TiXmlElement *pNode = pParent->InsertEndChild(TiXmlElement("node"))->ToElement();

    // node properties
    pNode->SetAttribute("name", mName->get().c_str());
    pNode->SetAttribute("id", Ogre::StringConverter::toString(mObjectID->get()).c_str());
    // position
    TiXmlElement *pPosition = pNode->InsertEndChild(TiXmlElement("position"))->ToElement();
    pPosition->SetAttribute("x", "0");
    pPosition->SetAttribute("y", "0");
    pPosition->SetAttribute("z", "0");
    // rotation
    TiXmlElement *pRotation = pNode->InsertEndChild(TiXmlElement("rotation"))->ToElement();
    pRotation->SetAttribute("qw", "1");
    pRotation->SetAttribute("qx", "0");
    pRotation->SetAttribute("qy", "0");
    pRotation->SetAttribute("qz", "0");
    // scale
    TiXmlElement *pScale = pNode->InsertEndChild(TiXmlElement("scale"))->ToElement();
    pScale->SetAttribute("x", "1");
    pScale->SetAttribute("y", "1");
    pScale->SetAttribute("z", "1");
    
    
    TiXmlElement *pPG = pNode->InsertEndChild(TiXmlElement("pagedgeometry"))->ToElement();
    pPG->SetAttribute("fileName", filename.c_str());
    pPG->SetAttribute("model", mModel->get().c_str());
    pPG->SetAttribute("pageSize", Ogre::StringConverter::toString(mPageSize->get()).c_str());
    pPG->SetAttribute("batchDistance", Ogre::StringConverter::toString(mBatchDistance->get()).c_str());
    pPG->SetAttribute("impostorDistance", Ogre::StringConverter::toString(mImpostorDistance->get()).c_str());
    pPG->SetAttribute("bounds", Ogre::StringConverter::toString(mBounds->get()).c_str());
    pPG->SetAttribute("castShadows", Ogre::StringConverter::toString(mCastShadows->get()).c_str());

    return pPG;
}
Exemplo n.º 7
0
		virtual void setupResources(void)
		{
			GraphicsSystem::setupResources();

			Ogre::ConfigFile cf;
			cf.load(mResourcePath + "resources2.cfg");

			Ogre::String dataFolder = cf.getSetting("DoNotUseAsResource", "Hlms", "");

			if (dataFolder.empty())
				dataFolder = "./";
			else if (*(dataFolder.end() - 1) != '/')
				dataFolder += "/";

			dataFolder += "2.0/scripts/materials/PbsMaterials";

			addResourceLocation(dataFolder, "FileSystem", "General");
		}
//----------------------------------------------------------------------------------------
int CDotSceneSerializer::Export(bool SaveAs, Ogre::String exportfile)
{
    OgitorsRoot *ogRoot = OgitorsRoot::getSingletonPtr();
    OgitorsSystem *mSystem = OgitorsSystem::getSingletonPtr();

    PROJECTOPTIONS *pOpt = ogRoot->GetProjectOptions();
    Ogre::String fileName = pOpt->ProjectName;

    UTFStringVector extlist;
    extlist.push_back(OTR("DotScene File"));
    extlist.push_back("*.scene");
    extlist.push_back(OTR("DotScene File"));
    extlist.push_back("*.xml");
    fileName = mSystem->DisplaySaveDialog(OTR("Export DotScene File"),extlist);
    if(fileName == "")
        return SCF_CANCEL;

    Ogre::String newDir = OgitorsUtils::ExtractFilePath(fileName);

    extractOFS(newDir);
    mSystem->DeleteFile(newDir + "/" + pOpt->ProjectName + ".ogscene");

    TiXmlDocument *pXMLDoc = new TiXmlDocument();
    pXMLDoc->InsertEndChild(TiXmlDeclaration("1.0", "UTF-8", ""));
    pXMLDoc->InsertEndChild(TiXmlElement("scene"));

    // export basic info
    TiXmlElement *pRoot = pXMLDoc->RootElement();
    pRoot->SetAttribute("formatVersion", "1.0.0");
    pRoot->SetAttribute("generator", Ogre::String(Ogre::String("Ogitor SceneBuilder ") + Ogre::String(OGITOR_VERSION)).c_str());

    // export resource locations
    TiXmlElement *pResourceLocations = pRoot->InsertEndChild(TiXmlElement("resourceLocations"))->ToElement();

    for(unsigned int r = 0; r < pOpt->ResourceDirectories.size(); r++)
    {
        TiXmlElement *pResourceLocation = pResourceLocations->InsertEndChild(TiXmlElement("resourceLocation"))->ToElement();
        Ogre::String loc = pOpt->ResourceDirectories[r];

        pResourceLocation->SetAttribute("type", "FileSystem");

        std::replace(loc.begin(),loc.end(),'\\','/');

        if(loc[0] != '.')
            loc = "./" + loc;

        pResourceLocation->SetAttribute("name", loc.c_str());
    }

    //TODO: do we need all those object id's ?

    TiXmlElement *pEnvironment = pRoot->InsertEndChild(TiXmlElement("environment"))->ToElement();

    // export octree scenemanagers
    NameObjectPairList smList = ogRoot->GetObjectsByTypeName("OctreeSceneManager");
    NameObjectPairList::const_iterator smIt = smList.begin();
    while(smIt != smList.end())
    {
        TiXmlElement *result = smIt->second->exportDotScene(pEnvironment);
        saveUserData(smIt->second->getCustomProperties(), result);
        smIt++;
    }

    // export viewports
    NameObjectPairList vpList = ogRoot->GetObjectsByTypeName("Viewport Object");
    NameObjectPairList::const_iterator vpIt = vpList.begin();
    while(vpIt != vpList.end())
    {
        TiXmlElement *result = vpIt->second->exportDotScene(pEnvironment);
        saveUserData(vpIt->second->getCustomProperties(), result);
        vpIt++;
    }

    // export terrains
    NameObjectPairList terrainList = ogRoot->GetObjectsByType(ETYPE_TERRAIN_MANAGER);
    NameObjectPairList::const_iterator tlIt = terrainList.begin();
    while(tlIt != terrainList.end())
    {
        TiXmlElement *result = tlIt->second->exportDotScene(pRoot);
        saveUserData(tlIt->second->getCustomProperties(), result);
        tlIt++;
    }

    NameObjectPairList items = ogRoot->GetSceneManagerEditor()->getChildren();

    // export lights
    NameObjectPairList::const_iterator nodeIt = items.begin();

    while(nodeIt != items.end())
    {
        if(nodeIt->second->getEditorType() == ETYPE_LIGHT)
        {
            TiXmlElement *result = nodeIt->second->exportDotScene(pRoot);
            saveUserData(nodeIt->second->getCustomProperties(), result);
        }
        nodeIt++;
    }

    // export cameras
    nodeIt = items.begin();

    while(nodeIt != items.end())
    {
        if(nodeIt->second->getEditorType() == ETYPE_CAMERA)
        {
            TiXmlElement *result = nodeIt->second->exportDotScene(pRoot);
            saveUserData(nodeIt->second->getCustomProperties(), result);
        }
        nodeIt++;
    }

    // export nodes
    TiXmlElement *pNodes = pRoot->InsertEndChild(TiXmlElement("nodes"))->ToElement();
    nodeIt = items.begin();

    while(nodeIt != items.end())
    {
        if( nodeIt->second->getEditorType() != ETYPE_TERRAIN_MANAGER &&
                nodeIt->second->getEditorType() != ETYPE_LIGHT &&
                nodeIt->second->getEditorType() != ETYPE_CAMERA )
        {
            TiXmlElement *result = nodeIt->second->exportDotScene(pNodes);
            saveUserData(nodeIt->second->getCustomProperties(), result);
        }
        nodeIt++;
    }

    if (pXMLDoc->SaveFile(fileName.c_str()))
    {
        OgitorsSystem::getSingletonPtr()->DisplayMessageDialog(OTR("Scene has been exported succesfully"), DLGTYPE_OK);
        delete pXMLDoc;
    }
    else
        OgitorsSystem::getSingletonPtr()->DisplayMessageDialog(OTR("An error occured during export.. :("), DLGTYPE_OK);

    return SCF_OK;
}
Exemplo n.º 9
0
/****************************************************************************
**
** Copyright (C) 2016 - 2017
**
** This file is generated by the Magus toolkit
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE go (ODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
****************************************************************************/

#include "ogre3_renderman.h"
#include "OgreConfigFile.h"
#include "OgreArchiveManager.h"
#include "OgreHlms.h"
#include "OgreHlmsUnlit.h"
#include "OgreHlmsPbs.h"
#include "OgreHlmsManager.h"
#include "OgreHlmsCommon.h"
#include "OgreLogManager.h"
#include "OgreFrameStats.h"

namespace Magus
{
    //****************************************************************************/
    OgreManager::OgreManager(void)
    {
        mGlContext = 0;
        mCompositorPassProvider = 0;
        mPause = true;

        #if _DEBUG || DEBUG
            mResourcesCfg = "resources_d.cfg";
            mPluginsCfg = "plugins_d.cfg";
        #else
            mResourcesCfg = "resources.cfg";
            mPluginsCfg = "plugins.cfg";
        #endif

        // Create Ogre tt and initialize
        mRoot = new Ogre::Root(mPluginsCfg);

        // Setup renderer
        mCurrentRenderSystem = 0;
        const Ogre::RenderSystemList& rsList = mRoot->getAvailableRenderers();
        Ogre::RenderSystem* renderSystem = rsList[0];
        std::vector<Ogre::String> renderOrder;
        #if defined(Q_OS_WIN)
            renderOrder.push_back("Direct3D11");
        #endif
            renderOrder.push_back("OpenGL 3+");
        for (std::vector<Ogre::String>::iterator iter = renderOrder.begin(); iter != renderOrder.end(); iter++)
        {
            for (Ogre::RenderSystemList::const_iterator it = rsList.begin(); it != rsList.end(); it++)
            {
                if ((*it)->getName().find(*iter) != Ogre::String::npos)
                {
                    renderSystem = *it;
                    break;
                }
            }
            if (renderSystem != 0) break;
        }

        if (renderSystem == 0)
        {
            if (!mRoot->restoreConfig())
            {
                if (!mRoot->showConfigDialog())
                    OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Abort render system configuration", "OgreManager::OgreManager");
            }
        }

        renderSystem->setConfigOption("Full Screen", "No");
        renderSystem->setConfigOption("VSync", "Yes");
        mRoot->setRenderSystem(renderSystem);
        mCurrentRenderSystem = renderSystem;

        // Uncomment next line to show dialog
        //if(mRoot->restoreConfig() || mRoot->showConfigDialog())
        //{
            mRoot->initialise(false);
        //}


        // Initialize resources
        setupResources();

        // Start timer
        mTimer = new Ogre::Timer();
        mTimer->reset();
    }

    //****************************************************************************/
    OgreManager::~OgreManager(void)
    {
        // Added removeAllWorkspaces after Ogre 2.1 upgrade (commit 2783a361c0b8)
        // In debug mode, the application crashed in deleting mRoot
        Ogre::CompositorManager2* compositorManager = mRoot->getCompositorManager2();
        compositorManager->removeAllWorkspaces();

        // Delete the dummy CompositorPassProvider
        compositorManager->setCompositorPassProvider(0);
        OGRE_DELETE mCompositorPassProvider;

        // Destroy render textures
        // This is a piece of custom code specific for the HLMS Editor (assume that the OgreWidget is still available)
        QMap<int, QOgreWidget*>::iterator i;
        QOgreWidget* item = 0;
        for (i = mQOgreWidgetMap.begin(); i != mQOgreWidgetMap.end(); ++i)
        {
            item = i.value();
            item->cleanup();
        }

        // Delete Ogre root
        delete mRoot;
    }

    //-------------------------------------------------------------------------------------
    void OgreManager::initialize(void)
    {
        // Create dummy CompositorPassProvider (see http://www.ogre3d.org/forums/viewtopic.php?f=11&t=84816&p=525752&hilit=CompositorPassProvider#p525752)
        // If one of the resource locations contains a compositor with a custom pass, the editor doesn't work anymore. This is to prevent it
        Ogre::MyCompositorPassProvider* mCompositorPassProvider = OGRE_NEW Ogre::MyCompositorPassProvider;
        Ogre::CompositorManager2* compositorManager = mRoot->getCompositorManager2();
        compositorManager->setCompositorPassProvider(mCompositorPassProvider);

        // After resources have been setup and renderwindows created (in ogre widget), the Hlms managers are registered
        registerHlms();

        // Initialise, parse scripts etc
        try
        {
            Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(false);
        }
        catch (Ogre::Exception e){}
        mPause = false;
        try
        {
            mRoot->renderOneFrame(); // Render first
        }
        catch (Ogre::Exception e) {}
    }

    //-------------------------------------------------------------------------------------
    void OgreManager::setupResources(void)
    {
        // Load resource paths from config file
        Ogre::ConfigFile cf;
        cf.load(mResourcesCfg);

        // Go through all sections & settings in the file
        Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();

        Ogre::String secName, typeName, archName;
        while( seci.hasMoreElements() )
        {
            secName = seci.peekNextKey();
            Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();

            if( secName != "Hlms" )
            {
                Ogre::ConfigFile::SettingsMultiMap::iterator i;
                for (i = settings->begin(); i != settings->end(); ++i)
                {
                    typeName = i->first;
                    archName = i->second;
                    Ogre::ResourceGroupManager::getSingleton().addResourceLocation( archName, typeName, secName );
                }
            }
        }
    }

    //****************************************************************************/
    bool OgreManager::isRenderSystemGL(void)
    {
        if (mCurrentRenderSystem)
            return (mCurrentRenderSystem->getName() == OGRE_RENDERSYSTEM_OPENGL3PLUS);

        return false;
    }

    //****************************************************************************/
    GL_CONTEXT OgreManager::getGlContext(void) const
    {
        return mGlContext;
    }

    //****************************************************************************/
    void OgreManager::setGlContext(GL_CONTEXT glContext)
    {
        mGlContext = glContext;
    }

    //****************************************************************************/
    void OgreManager::registerHlms(void)
    {
        Ogre::ConfigFile cf;
        cf.load(mResourcesCfg);

        Ogre::String dataFolder = cf.getSetting( "DoNotUseAsResource", "Hlms", "" );

        if( dataFolder.empty() )
            dataFolder = "./";
        else if( *(dataFolder.end() - 1) != '/' )
            dataFolder += "/";

        Ogre::RenderSystem* renderSystem = mRoot->getRenderSystem();
        Ogre::String shaderSyntax = "GLSL";
        if( renderSystem->getName() == OGRE_RENDERSYSTEM_DIRECTX11 )
            shaderSyntax = "HLSL";
        else if( renderSystem->getName() == OGRE_RENDERSYSTEM_METAL )
            shaderSyntax = "Metal";

        Ogre::Archive* archiveLibrary = Ogre::ArchiveManager::getSingletonPtr()->load(
                        dataFolder + "Hlms/Common/" + shaderSyntax,
                        "FileSystem", true );
        Ogre::Archive* archiveLibraryAny = Ogre::ArchiveManager::getSingletonPtr()->load(
                        dataFolder + "Hlms/Common/Any",
                        "FileSystem", true );
        Ogre::Archive* archivePbsLibraryAny = Ogre::ArchiveManager::getSingletonPtr()->load(
                        dataFolder + "Hlms/Pbs/Any",
                        "FileSystem", true );
        Ogre::Archive* archiveUnlitLibraryAny = Ogre::ArchiveManager::getSingletonPtr()->load(
                        dataFolder + "Hlms/Unlit/Any",
                        "FileSystem", true );

        Ogre::ArchiveVec library;
        library.push_back( archiveLibrary );
        library.push_back( archiveLibraryAny );

        Ogre::Archive* archiveUnlit = Ogre::ArchiveManager::getSingletonPtr()->load(
                        dataFolder + "Hlms/Unlit/" + shaderSyntax,
                        "FileSystem", true );

        library.push_back( archiveUnlitLibraryAny );
        Ogre::HlmsUnlit* hlmsUnlit = OGRE_NEW Ogre::HlmsUnlit( archiveUnlit, &library );
        mRoot->getHlmsManager()->registerHlms( hlmsUnlit );
        library.pop_back();

        Ogre::Archive* archivePbs = Ogre::ArchiveManager::getSingletonPtr()->load(
                        dataFolder + "Hlms/Pbs/" + shaderSyntax,
                        "FileSystem", true );

        library.push_back( archivePbsLibraryAny );
        Ogre::HlmsPbs* hlmsPbs = OGRE_NEW Ogre::HlmsPbs( archivePbs, &library );
        mRoot->getHlmsManager()->registerHlms( hlmsPbs );
        library.pop_back();

        if( renderSystem->getName() == "Direct3D11 Rendering Subsystem" )
        {
            //Set lower limits 512kb instead of the default 4MB per Hlms in D3D 11.0
            //and below to avoid saturating AMD's discard limit (8MB) or
            //saturate the PCIE bus in some low end machines.
            bool supportsNoOverwriteOnTextureBuffers;
            renderSystem->getCustomAttribute( "MapNoOverwriteOnDynamicBufferSRV",
                                              &supportsNoOverwriteOnTextureBuffers );

            if( !supportsNoOverwriteOnTextureBuffers )
            {
                hlmsPbs->setTextureBufferDefaultSize( 512 * 1024 );
                hlmsUnlit->setTextureBufferDefaultSize( 512 * 1024 );
            }
        }
    }
Exemplo n.º 10
0
//-----------------------------------------------------------------------------------------
void CPGInstanceManager::_onLoad()
{
    Ogre::String filename;

    if(mTempModified->get())
    {
        if(mTempFileName.empty())
            mTempFileName = OgitorsUtils::QualifyPath(mOgitorsRoot->GetProjectOptions()->ProjectDir + "/Temp/tmp" + Ogre::StringConverter::toString(mObjectID->get()) + ".instance");

        filename = mTempFileName;
    }
    else
    {
        Ogre::String name = mName->get();
        std::replace(name.begin(), name.end(), '<', ' ');
        std::replace(name.begin(), name.end(), '>', ' ');
        std::replace(name.begin(), name.end(), '#', ' ');

        name = Ogre::StringConverter::toString(mObjectID->get()) + "_" + name;

        filename = OgitorsUtils::QualifyPath(mOgitorsRoot->GetProjectOptions()->ProjectDir + "/PGInstances/" + name + ".instance");
    }

    std::ifstream stream(filename.c_str());

    if(!stream.is_open())
        return;

    if(!mTempModified->get())
        mLastFileName = filename;

    Ogre::StringVector list;

    char res[128];

    while(!stream.eof())
    {
        stream.getline(res, 128);
        Ogre::String resStr(res);
        OgitorsUtils::ParseStringVector(resStr, list);

        if(list.size() == 3)
        {
            PGInstanceInfo info;
            
            info.pos = Ogre::StringConverter::parseVector3(list[0]);
            info.scale = Ogre::StringConverter::parseReal(list[1]);
            info.yaw = Ogre::StringConverter::parseReal(list[2]);

            mInstanceList[mNextInstanceIndex++] = info;
        }
        else if(list.size() == 4)
        {
            PGInstanceInfo info;
            
            int index = Ogre::StringConverter::parseInt(list[0]);
            info.pos = Ogre::StringConverter::parseVector3(list[1]);
            info.scale = Ogre::StringConverter::parseReal(list[2]);
            info.yaw = Ogre::StringConverter::parseReal(list[3]);
            info.instance = 0;

            mInstanceList[index] = info;

            if(index >= mNextInstanceIndex)
                mNextInstanceIndex = index + 1;
        }
    }

    stream.close();
}
Exemplo n.º 11
0
//-----------------------------------------------------------------------------------------
void CPGInstanceManager::_onLoad()
{
    Ogre::String filename;

    if(mTempModified->get())
    {
        if(mTempFileName.empty())
            mTempFileName = "/Temp/tmp" + Ogre::StringConverter::toString(mObjectID->get()) + ".instance";

        filename = mTempFileName;
    }
    else
    {
        Ogre::String name = mName->get();
        std::replace(name.begin(), name.end(), '<', ' ');
        std::replace(name.begin(), name.end(), '>', ' ');
        std::replace(name.begin(), name.end(), '#', ' ');

        filename = "/PGInstances/" + Ogre::StringConverter::toString(mObjectID->get()) + "_" + name + ".instance";
    }

    OFS::OFSHANDLE handle;

    OFS::OfsPtr& mFile = mOgitorsRoot->GetProjectFile();

    OFS::OfsResult ret = mFile->openFile(handle, filename.c_str());

    if(ret != OFS::OFS_OK)
        return;

    OFS::ofs64 file_size = 0;

    mFile->getFileSize(handle, file_size);

    if(file_size == 0)
    {
        mFile->closeFile(handle);
        return;
    }

    char *buffer = new char[(unsigned int)file_size];
    mFile->read(handle, buffer, (unsigned int)file_size);

    std::stringstream stream;
    stream << buffer;

    delete [] buffer;

    if(!mTempModified->get())
        mLastFileName = filename;

    Ogre::StringVector list;

    char res[128];

    while(!stream.eof())
    {
        stream.getline(res, 128);
        Ogre::String resStr(res);
        OgitorsUtils::ParseStringVector(resStr, list);

        if(list.size() == 3)
        {
            PGInstanceInfo info;

            info.pos = Ogre::StringConverter::parseVector3(list[0]);
            info.scale = Ogre::StringConverter::parseReal(list[1]);
            info.yaw = Ogre::StringConverter::parseReal(list[2]);

            mInstanceList[mNextInstanceIndex++] = info;
        }
        else if(list.size() == 4)
        {
            PGInstanceInfo info;

            int index = Ogre::StringConverter::parseInt(list[0]);
            info.pos = Ogre::StringConverter::parseVector3(list[1]);
            info.scale = Ogre::StringConverter::parseReal(list[2]);
            info.yaw = Ogre::StringConverter::parseReal(list[3]);
            info.instance = 0;

            mInstanceList[index] = info;

            if(index >= mNextInstanceIndex)
                mNextInstanceIndex = index + 1;
        }
    }
}