Пример #1
0
void ObjectManager::loadFactories(const String& factoriesfile)
{
	String pluginDir;
	Ogre::StringVector pluginList;	
	Ogre::ConfigFile cfg;
	
	try {
		cfg.load( factoriesfile );
	}
	catch (Ogre::Exception)
	{
		Ogre::LogManager::getSingleton().logMessage(factoriesfile + " not found, automatic object factories loading disabled.");
		return;
	}

	pluginDir = cfg.getSetting("ObjectFactoryFolder"); // Ignored on Mac OS X, uses Resources/ directory
	pluginList = cfg.getMultiSetting("ObjectFactory");

	char last_char = pluginDir[pluginDir.length()-1];
	if (last_char != '/' && last_char != '\\')
	{
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
		pluginDir += "\\";
#elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
		pluginDir += "/";
#endif
	}

	for( Ogre::StringVector::iterator it = pluginList.begin(); it != pluginList.end(); ++it )
	{
		this->loadFactory(pluginDir + (*it));
	}

}
Пример #2
0
    void SoundManager::startRandomTitle()
    {
        Ogre::StringVector filelist;
        if (mMusicFiles.find(mCurrentPlaylist) == mMusicFiles.end())
        {
            Ogre::StringVector groups = Ogre::ResourceGroupManager::getSingleton().getResourceGroups ();
            for (Ogre::StringVector::iterator it = groups.begin(); it != groups.end(); ++it)
            {
                Ogre::StringVectorPtr resourcesInThisGroup = mResourceMgr.findResourceNames(*it,
                                                                                            "Music/"+mCurrentPlaylist+"/*");
                filelist.insert(filelist.end(), resourcesInThisGroup->begin(), resourcesInThisGroup->end());
            }
            mMusicFiles[mCurrentPlaylist] = filelist;
        }
        else
            filelist = mMusicFiles[mCurrentPlaylist];

        if(!filelist.size())
            return;

        int i = rand()%filelist.size();

        // Don't play the same music track twice in a row
        if (filelist[i] == mLastPlayedMusic)
        {
            i = (i+1) % filelist.size();
        }

        streamMusicFull(filelist[i]);
    }
Пример #3
0
//!
//! Destroy the node's Ogre resource group.
//!
void OgreTools::destroyResourceGroup ( const QString &name )
{
	Ogre::StringVector groupNames = Ogre::ResourceGroupManager::getSingleton().getResourceGroups();
	if (std::find(groupNames.begin(), groupNames.end(), name.toStdString()) != groupNames.end()) {
		Ogre::ResourceGroupManager::getSingleton().destroyResourceGroup(name.toStdString());
	}
}
Пример #4
0
//--------------------------------------------------------------------------------
void CMultiSelEditor::add(const Ogre::StringVector& newselection)
{
    if(mDeletionInProgress)
        return;

    Ogre::StringVector::const_iterator it = newselection.begin();
    
    while(it != newselection.end())
    {
        CBaseEditor *object = mOgitorsRoot->FindObject(*it);
       
        if(object && object != this)
        {
            if(mSelectedObjects.find(object->getName()) == mSelectedObjects.end())
            {
                mSelectedObjects.insert(NameObjectPairList::value_type(object->getName(), object));

                object->setSelected(true);
            }
        }

        it++;
    }

    _createModifyList();
}
Пример #5
0
//--------------------------------------------------------------------------------
void CMultiSelEditor::remove(const Ogre::StringVector& newselection)
{
    if(mDeletionInProgress)
        return;

    Ogre::StringVector::const_iterator it = newselection.begin();
    NameObjectPairList::iterator dit;
    
    while(it != newselection.end())
    {
        CBaseEditor *object = mOgitorsRoot->FindObject(*it);
       
        if(object)
        {
            if((dit = mSelectedObjects.find(object->getName())) != mSelectedObjects.end())
            {
                mSelectedObjects.erase(dit);

                object->setSelected(false);
            }
        }

        it++;
    }

    _createModifyList();
}
Пример #6
0
void LogMessageWindow::trimDisplayArea(const char* aMsg)
{
	m_displaylog.append(Ogre::UTFString(CharToWchar(aMsg)));
	m_displaylog.append("\n");
	Ogre::StringVector v = Ogre::StringUtil::split(m_displaylog,"\n");
	while(v.size()>m_displaylinenum)
	{
		v.erase(v.begin());
		m_displaylog.clear();
		for (Ogre::StringVector::iterator i = v.begin(); i != v.end(); ++i)
		{
			m_displaylog.append(i->c_str());
			m_displaylog.append("\n");
		}
		v = Ogre::StringUtil::split(m_displaylog,"\n");
	}
}
Пример #7
0
void OgreResourceLoader::unloadUnusedResources()
{
	TimedLog l("Unload unused resources.");
	Ogre::ResourceGroupManager& resourceGroupManager(Ogre::ResourceGroupManager::getSingleton());

	Ogre::StringVector resourceGroups = resourceGroupManager.getResourceGroups();
	for (Ogre::StringVector::const_iterator I = resourceGroups.begin(); I != resourceGroups.end(); ++I) {
		resourceGroupManager.unloadUnreferencedResourcesInGroup(*I, false);
	}
}
Пример #8
0
 void FontLoader::loadAllFonts(bool exportToFile)
 {
     Ogre::StringVector groups = Ogre::ResourceGroupManager::getSingleton().getResourceGroups ();
     for (Ogre::StringVector::iterator it = groups.begin(); it != groups.end(); ++it)
     {
         Ogre::StringVectorPtr resourcesInThisGroup = Ogre::ResourceGroupManager::getSingleton ().findResourceNames (*it, "*.fnt");
         for (Ogre::StringVector::iterator resource = resourcesInThisGroup->begin(); resource != resourcesInThisGroup->end(); ++resource)
         {
             loadFont(*resource, exportToFile);
         }
     }
 }
Пример #9
0
	void MeshMergeTool::doInvoke(const OptionList& toolOptions,
			const Ogre::StringVector& inFileNames,
			const Ogre::StringVector& outFileNames)
	{
		if (outFileNames.size() != 1)
		{
			fail("Exactly one output file must be specified.");
			return;
		}
		else if (inFileNames.size() == 0)
		{
			fail("No input files specified.");
			return;
		}

		StatefulMeshSerializer* meshSer = OgreEnvironment::getSingleton().getMeshSerializer();
		StatefulSkeletonSerializer* skelSer =
			OgreEnvironment::getSingleton().getSkeletonSerializer();
		for (Ogre::StringVector::const_iterator it = inFileNames.begin();
			it != inFileNames.end(); ++it)
		{
			MeshPtr curMesh = meshSer->loadMesh(*it);
			if (!curMesh.isNull())
			{
				if (curMesh->hasSkeleton() && SkeletonManager::getSingleton().getByName(
					curMesh->getSkeletonName()).isNull())
				{
					skelSer->loadSkeleton(curMesh->getSkeletonName());
				}
				addMesh(curMesh);
			}
			else
			{
				warn("Skipped: Mesh " + *it + " cannnot be loaded.");
			}
		}
		Ogre::String outputfile = *outFileNames.begin();
		meshSer->exportMesh(merge(outputfile).getPointer(), outputfile);
	}
Пример #10
0
CSMWorld::Resources::Resources (const std::string& baseDirectory, UniversalId::Type type,
    const char * const *extensions)
: mBaseDirectory (baseDirectory), mType (type)
{
    int baseSize = mBaseDirectory.size();

    Ogre::StringVector resourcesGroups =
        Ogre::ResourceGroupManager::getSingleton().getResourceGroups();

    for (Ogre::StringVector::iterator iter (resourcesGroups.begin());
        iter!=resourcesGroups.end(); ++iter)
    {
        if (*iter=="General" || *iter=="Internal" || *iter=="Autodetect")
            continue;

        Ogre::StringVectorPtr resources =
            Ogre::ResourceGroupManager::getSingleton().listResourceNames (*iter);

        for (Ogre::StringVector::const_iterator iter (resources->begin());
            iter!=resources->end(); ++iter)
        {
            if (static_cast<int> (iter->size())<baseSize+1 ||
                iter->substr (0, baseSize)!=mBaseDirectory ||
                ((*iter)[baseSize]!='/' && (*iter)[baseSize]!='\\'))
                continue;

            if (extensions)
            {
                std::string::size_type index = iter->find_last_of ('.');

                if (index==std::string::npos)
                    continue;

                std::string extension = iter->substr (index+1);

                int i = 0;

                for (; extensions[i]; ++i)
                    if (extensions[i]==extension)
                        break;

                if (!extensions[i])
                    continue;
            }

            std::string file = iter->substr (baseSize+1);
            mFiles.push_back (file);
            mIndex.insert (std::make_pair (file, static_cast<int> (mFiles.size())-1));
        }
    }
}
Пример #11
0
/*-----------------------------------------------------------------------------
 | Initialize the RT Shader system.	
 -----------------------------------------------------------------------------*/
bool DemoApp::initializeRTShaderSystem(Ogre::SceneManager* sceneMgr)
{			
    if (Ogre::RTShader::ShaderGenerator::initialize())
    {
        mShaderGenerator = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
        
        mShaderGenerator->addSceneManager(sceneMgr);
        
        // Setup core libraries and shader cache path.
        Ogre::StringVector groupVector = Ogre::ResourceGroupManager::getSingleton().getResourceGroups();
        Ogre::StringVector::iterator itGroup = groupVector.begin();
        Ogre::StringVector::iterator itGroupEnd = groupVector.end();
        Ogre::String shaderCoreLibsPath;
        Ogre::String shaderCachePath;
        
        for (; itGroup != itGroupEnd; ++itGroup)
        {
            Ogre::ResourceGroupManager::LocationList resLocationsList = Ogre::ResourceGroupManager::getSingleton().getResourceLocationList(*itGroup);
            Ogre::ResourceGroupManager::LocationList::iterator it = resLocationsList.begin();
            Ogre::ResourceGroupManager::LocationList::iterator itEnd = resLocationsList.end();
            bool coreLibsFound = false;
            
            // Try to find the location of the core shader lib functions and use it
            // as shader cache path as well - this will reduce the number of generated files
            // when running from different directories.
            for (; it != itEnd; ++it)
            {
                if ((*it)->archive->getName().find("RTShaderLib") != Ogre::String::npos)
                {
                    shaderCoreLibsPath = (*it)->archive->getName() + "/";
                    shaderCachePath = shaderCoreLibsPath;
                    coreLibsFound = true;
                    break;
                }
            }
            // Core libs path found in the current group.
            if (coreLibsFound) 
                break; 
        }
        
        // Core shader libs not found -> shader generating will fail.
        if (shaderCoreLibsPath.empty())			
            return false;			
        
        // Create and register the material manager listener.
        mMaterialMgrListener = new ShaderGeneratorTechniqueResolverListener(mShaderGenerator);				
        Ogre::MaterialManager::getSingleton().addListener(mMaterialMgrListener);
    }
    
    return true;
}
Пример #12
0
bool OgreSubsystem::LoadOgrePlugins(Ogre::String const & pluginsfile)
{
	Ogre::StringVector pluginList;
	Ogre::String pluginDir;
	Ogre::ConfigFile cfg;

	try
	{
		cfg.load( pluginsfile );
	}
	catch (Ogre::Exception)
	{
		Ogre::LogManager::getSingleton().logMessage(pluginsfile + " not found, automatic plugin loading disabled.");
		return false;
	}

	pluginDir = cfg.getSetting("PluginFolder"); // Ignored on Mac OS X, uses Resources/ directory
	pluginList = cfg.getMultiSetting("Plugin");

#if OGRE_PLATFORM != OGRE_PLATFORM_APPLE && OGRE_PLATFORM != OGRE_PLATFORM_IPHONE
	if (pluginDir.empty())
	{
		// User didn't specify plugins folder, try current one
		pluginDir = ".";
	}
#endif

	char last_char = pluginDir[pluginDir.length()-1];
	if (last_char != '/' && last_char != '\\')
	{
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
		pluginDir += "\\";
#elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
		pluginDir += "/";
#endif
	}

	for ( Ogre::StringVector::iterator it = pluginList.begin(); it != pluginList.end(); ++it )
	{
		Ogre::String pluginFilename = pluginDir + (*it);
		try
		{
			m_ogre_root->loadPlugin(pluginFilename);
		} 
		catch(Ogre::Exception &e)
		{
			LOG("failed to load plugin: " + pluginFilename + ": " + e.getFullDescription());
		}
	}
	return true;
}
bool ResourceGroupReloader::resourceGroupExist(const std::string& pResourceGroupName)
{
	bool lIsPresent = false;
	Ogre::ResourceGroupManager& resGroupMgr = Ogre::ResourceGroupManager::getSingleton();
	Ogre::StringVector lAllResourceGroups = resGroupMgr.getResourceGroups();
	Ogre::StringVector::iterator iter = lAllResourceGroups.begin();
	Ogre::StringVector::iterator iterEnd = lAllResourceGroups.end();
	for(;iter!=iterEnd;iter++)
	{
		if((*iter) == pResourceGroupName)
		{
			lIsPresent = true;
		}
	}
	return lIsPresent;
}
Пример #14
0
    void SoundManager::startRandomTitle()
    {
        Ogre::StringVector filelist;

        Ogre::StringVector groups = Ogre::ResourceGroupManager::getSingleton().getResourceGroups ();
        for (Ogre::StringVector::iterator it = groups.begin(); it != groups.end(); ++it)
        {
            Ogre::StringVectorPtr resourcesInThisGroup = mResourceMgr.findResourceNames(*it,
                                                                                        "Music/"+mCurrentPlaylist+"/*");
            filelist.insert(filelist.end(), resourcesInThisGroup->begin(), resourcesInThisGroup->end());
        }

        if(!filelist.size())
            return;

        int i = rand()%filelist.size();
        streamMusicFull(filelist[i]);
    }
Пример #15
0
void OgreSample8App::loadResources()
{
    BaseApp::loadResources();

#ifdef USE_RTSHADER_SYSTEM
    ResourceGroupManager& rgm = ResourceGroupManager::getSingleton();
    Ogre::StringVector groupVector = Ogre::ResourceGroupManager::getSingleton().getResourceGroups();
    Ogre::StringVector::iterator itGroup = groupVector.begin();
    Ogre::StringVector::iterator itGroupEnd = groupVector.end();
    Ogre::String shaderCoreLibsPath;

    for (; itGroup != itGroupEnd ; ++itGroup)
    {
        Ogre::ResourceGroupManager::LocationList resLocationList = Ogre::ResourceGroupManager::getSingleton().getResourceLocationList(*itGroup);
        Ogre::ResourceGroupManager::LocationList::iterator it = resLocationList.begin();
        Ogre::ResourceGroupManager::LocationList::iterator itEnd = resLocationList.end();
        bool coreLibsFound = false;

        for (; it != itEnd; it++)
        {
            if ((*it)->archive->getName().find("RTShaderLib") != Ogre::String::npos)
            {
                shaderCoreLibsPath = (*it)->archive->getName() + "/";
                coreLibsFound = true;
                break;
            }
        }

        if (coreLibsFound)
        {
            break;
        }

        rgm.createResourceGroup("RTShaderSystemMaterialsGroup");
        rgm.addResourceLocation(shaderCoreLibsPath + "materials","FileSystem","RTShaderSystemMaterialGroup");
        rgm.initialiseResourceGroup("RTShaderSystemMaterialsGroup");
        rgm.loadResourceGroup("RTShaderSystemMaterialsGroup",true);
    }
#endif
}
Пример #16
0
    void LoadingScreen::changeWallpaper ()
    {
        if (mResources.empty())
        {
            Ogre::StringVector groups = Ogre::ResourceGroupManager::getSingleton().getResourceGroups ();
            for (Ogre::StringVector::iterator it = groups.begin(); it != groups.end(); ++it)
            {
                Ogre::StringVectorPtr resourcesInThisGroup = Ogre::ResourceGroupManager::getSingleton ().findResourceNames (*it, "Splash_*.tga");
                mResources.insert(mResources.end(), resourcesInThisGroup->begin(), resourcesInThisGroup->end());
            }
        }

        if (!mResources.empty())
        {
            std::string const & randomSplash = mResources.at (rand() % mResources.size());

            Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton ().load (randomSplash, Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);

            mBackgroundImage->setImageTexture (randomSplash);
        }
        else
            std::cerr << "No loading screens found!" << std::endl;
    }
	void ScriptWriter::writeDefinition(std::fstream& stream, ScriptDefinition* d, int level)
	{
		// Write the definition header
		stream << getSpaces(level * mNumSpacesPerLevel) + d->getType() + " " + d->getID() << std::endl;
		// Write opening curly brace
		stream << getSpaces(level * mNumSpacesPerLevel) + "{" << std::endl;
		// Write out properties
		std::list<DefinitionProperty*> propList = d->getProperties();
		for(std::list<DefinitionProperty*>::iterator it = propList.begin(); it != propList.end(); ++it)
		{
			DefinitionProperty* p = (*it);
			stream << getSpaces((level + 1) * mNumSpacesPerLevel) + p->getPropertyName();

			Ogre::StringVector sv = p->getValues();
			for(Ogre::StringVector::iterator propertyIter = sv.begin(); propertyIter != sv.end(); ++propertyIter)
			{
				stream << " " + (*propertyIter);
			}

			stream << std::endl;
		}
		// Write out sub Definitions
		std::list<ScriptDefinition*> subDefList = d->getDefinitions();
		if(!subDefList.empty())
		{
			if(!propList.empty())
				stream << std::endl;

			for(std::list<ScriptDefinition*>::iterator it = subDefList.begin(); it != subDefList.end(); ++it)
			{
				writeDefinition(stream,(*it),(level + 1));
				stream << std::endl;
			}
		}
		// Write closing curly brace
		stream << getSpaces(level * mNumSpacesPerLevel) + "}" << std::endl;
	}
Пример #18
0
bool OgreSubsystem::LoadOgrePlugins(Ogre::String const & pluginsfile)
{
    Ogre::ConfigFile cfg;

    try
    {
        cfg.load( pluginsfile );
    }
    catch (Ogre::Exception e)
    {
        Ogre::LogManager::getSingleton().logMessage(pluginsfile + " not found, automatic plugin loading disabled. Message: " + e.getFullDescription());
        return false;
    }

    Ogre::String pluginDir = cfg.getSetting("PluginFolder");
    Ogre::StringVector pluginList = cfg.getMultiSetting("Plugin");

    if (pluginDir.empty())
    {
        pluginDir = RoR::App::sys_process_dir.GetActive();
    }

    for ( Ogre::StringVector::iterator it = pluginList.begin(); it != pluginList.end(); ++it )
    {
        Ogre::String pluginFilename = pluginDir + PATH_SLASH + (*it);
        try
        {
            m_ogre_root->loadPlugin(pluginFilename);
        }
        catch (Ogre::Exception &e)
        {
            LOG("failed to load plugin: " + pluginFilename + ": " + e.getFullDescription());
        }
    }
    return true;
}
Пример #19
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 GOODS 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
#include "constants.h"
#include "hlms_builder.h"
#include <QFile>
#include <QTextStream>
#include "OgreResourceGroupManager.h"
#include "OgreHlmsManager.h"
#include "OgreHlmsJson.h"

//****************************************************************************/
HlmsBuilder::HlmsBuilder(void)
{
}

//****************************************************************************/
HlmsBuilder::~HlmsBuilder(void)
{
}

//****************************************************************************/
HlmsNodeSamplerblock* HlmsBuilder::createSamplerNode(Magus::QtNodeEditor* nodeEditor)
{
    HlmsNodeSamplerblock* node = new HlmsNodeSamplerblock(NODE_TITLE_SAMPLERBLOCK);
    node->setType(NODE_TYPE_SAMPLERBLOCK);
    nodeEditor->addNode(node);
    return node;
}

//****************************************************************************/
HlmsNodeMacroblock* HlmsBuilder::createMacroNode(Magus::QtNodeEditor* nodeEditor)
{
    HlmsNodeMacroblock* node = new HlmsNodeMacroblock(NODE_TITLE_MACROBLOCK);
    node->setType(NODE_TYPE_MACROBLOCK);
    nodeEditor->addNode(node);
    return node;
}

//****************************************************************************/
HlmsNodeBlendblock* HlmsBuilder::createBlendNode(Magus::QtNodeEditor* nodeEditor)
{
    HlmsNodeBlendblock* node = new HlmsNodeBlendblock(NODE_TITLE_BLENDBLOCK);
    node->setType(NODE_TYPE_BLENDBLOCK);
    nodeEditor->addNode(node);
    return node;
}

//****************************************************************************/
void HlmsBuilder::enrichSamplerBlockGeneric (Ogre::HlmsSamplerblock* samplerblock,
                                             HlmsNodeSamplerblock* samplernode)
{
    // ******** Min filter ********
    samplerblock->mMinFilter = getFilterOptionFromIndex(samplernode->getTextureMinFilter());

    // ******** Mag filter ********
    samplerblock->mMagFilter = getFilterOptionFromIndex(samplernode->getTextureMagFilter());

    // ******** Mip filter ********
    samplerblock->mMipFilter = getFilterOptionFromIndex(samplernode->getTextureMipFilter());

    // ******** Texture addressing mode U ********
    samplerblock->mU = getTAMFromIndex(samplernode->getTextureAddressingModeU());

    // ******** Texture addressing mode V ********
    samplerblock->mV = getTAMFromIndex(samplernode->getTextureAddressingModeV());

    // ******** Texture addressing mode W ********
    samplerblock->mW = getTAMFromIndex(samplernode->getTextureAddressingModeW());

    // ******** Mip LOD Bias ********
    samplerblock->mMipLodBias = samplernode->getMipLodBias();

    // ******** Max Anisotropy ********
    samplerblock->mMaxAnisotropy = samplernode->getMaxAnisotropy();

    // ******** Compare Function ********
    samplerblock->mCompareFunction = getCompareFunctionFromIndex(samplernode->getCompareFunction());

    // ******** Min LOD ********
    samplerblock->mMinLod = samplernode->getMinLod();

    // ******** Max LOD ********
    samplerblock->mMaxLod = samplernode->getMaxLod();

    // ******** Border colour ********
    Ogre::ColourValue colour;
    colour.r = samplernode->getBorderColourRed() / 255.0f;
    colour.g = samplernode->getBorderColourGreen() / 255.0f;
    colour.b = samplernode->getBorderColourBlue() / 255.0f;
    samplerblock->mBorderColour = colour;
}

//****************************************************************************/
void HlmsBuilder::enrichSamplerNodeGeneric (HlmsNodeSamplerblock* samplernode,
                                            const Ogre::HlmsSamplerblock* samplerblock)
{
    // ******** Enabled ********
    samplernode->setSamplerblockEnabled(true); // default true when loaded

    // ******** Min filter ********
    samplernode->setTextureMinFilter(getIndexFromFilterOption(samplerblock->mMinFilter));

    // ******** Mag filter ********
    samplernode->setTextureMagFilter(getIndexFromFilterOption(samplerblock->mMagFilter));

    // ******** Mip filter ********
    samplernode->setTextureMipFilter(getIndexFromFilterOption(samplerblock->mMipFilter));

    // ******** Texture addressing mode U ********
    samplernode->setTextureAddressingModeU(getIndexFromTAM(samplerblock->mU));

    // ******** Texture addressing mode V ********
    samplernode->setTextureAddressingModeV(getIndexFromTAM(samplerblock->mV));

    // ******** Texture addressing mode W ********
    samplernode->setTextureAddressingModeW(getIndexFromTAM(samplerblock->mW));

    // ******** Mip LOD Bias ********
    samplernode->setMipLodBias(samplerblock->mMipLodBias);

    // ******** Max Anisotropy ********
    samplernode->setMaxAnisotropy(samplerblock->mMaxAnisotropy);

    // ******** Compare Function ********
    samplernode->setCompareFunction(getIndexFromCompareFunction(samplerblock->mCompareFunction));

    // ******** Min LOD ********
    if (samplerblock->mMinLod < -10000000.0f)
        samplernode->setMinLod(-10000000.0f);
    else
        samplernode->setMinLod(samplerblock->mMinLod);

    // ******** Max LOD ********
    if (samplerblock->mMaxLod > 10000000.0f)
        samplernode->setMaxLod(10000000.0f);
    else
        samplernode->setMaxLod(samplerblock->mMaxLod);

    // ******** Border colour ********
    samplernode->setBorderColourRed(255.0f * samplerblock->mBorderColour.r);
    samplernode->setBorderColourGreen(255.0f * samplerblock->mBorderColour.g);
    samplernode->setBorderColourBlue(255.0f * samplerblock->mBorderColour.b);
}

//****************************************************************************/
void HlmsBuilder::enrichMacroblock(HlmsNodeMacroblock* macronode, Ogre::HlmsMacroblock* macroblock)
{
    macroblock->mScissorTestEnabled = macronode->getScissorTestEnabled();
    macroblock->mDepthCheck = macronode->getDepthCheck();
    macroblock->mDepthWrite = macronode->getDepthWrite();
    macroblock->mDepthFunc = getCompareFunctionFromIndex(macronode->getDepthFunc());
    macroblock->mDepthBiasConstant = macronode->getDepthBiasConstant();
    macroblock->mDepthBiasSlopeScale = macronode->getDepthBiasSlopeScale();
    switch (macronode->getCullMode())
    {
        case 0:
            macroblock->mCullMode = Ogre::CULL_NONE;
        break;
        case 1:
            macroblock->mCullMode = Ogre::CULL_CLOCKWISE;
        break;
        case 2:
            macroblock->mCullMode = Ogre::CULL_ANTICLOCKWISE;
        break;
    }
    switch (macronode->getPolygonMode())
    {
        case 0:
            macroblock->mPolygonMode = Ogre::PM_POINTS;
        break;
        case 1:
            macroblock->mPolygonMode = Ogre::PM_WIREFRAME;
        break;
        case 2:
            macroblock->mPolygonMode = Ogre::PM_SOLID;
        break;
    }
}

//****************************************************************************/
void HlmsBuilder::enrichBlendblock(HlmsNodeBlendblock* blendnode, Ogre::HlmsBlendblock* blendblock)
{
    blendblock->mAlphaToCoverageEnabled = blendnode->getAlphaToCoverageEnabled();
    switch (blendnode->getBlendChannelMask())
    {
        case 0:
            blendblock->mBlendChannelMask = Ogre::HlmsBlendblock::BlendChannelRed;
        break;
        case 1:
            blendblock->mBlendChannelMask = Ogre::HlmsBlendblock::BlendChannelGreen;
        break;
        case 2:
            blendblock->mBlendChannelMask = Ogre::HlmsBlendblock::BlendChannelBlue;
        break;
        case 3:
            blendblock->mBlendChannelMask = Ogre::HlmsBlendblock::BlendChannelAlpha;
        break;
        case 4:
            blendblock->mBlendChannelMask = Ogre::HlmsBlendblock::BlendChannelAll;
        break;
    }
    blendblock->mIsTransparent = blendnode->getTransparent();
    blendblock->mSeparateBlend = blendnode->getSeparateBlend();
    blendblock->mSourceBlendFactor = getSceneBlendFactorFromIndex(blendnode->getSourceBlendFactor());
    blendblock->mDestBlendFactor = getSceneBlendFactorFromIndex(blendnode->getDestBlendFactor());
    blendblock->mSourceBlendFactorAlpha = getSceneBlendFactorFromIndex(blendnode->getSourceBlendFactorAlpha());
    blendblock->mDestBlendFactorAlpha = getSceneBlendFactorFromIndex(blendnode->getDestBlendFactorAlpha());
    blendblock->mBlendOperation = getSceneBlendOperationFromIndex(blendnode->getBlendOperation());
    blendblock->mBlendOperationAlpha = getSceneBlendOperationFromIndex(blendnode->getBlendOperationAlpha());
}

//****************************************************************************/
Ogre::CompareFunction HlmsBuilder::getCompareFunctionFromIndex(unsigned int index)
{
    switch (index)
    {
        case 0:
            return Ogre::CMPF_ALWAYS_FAIL;
        break;
        case 1:
            return Ogre::CMPF_ALWAYS_PASS;
        break;
        case 2:
            return Ogre::CMPF_LESS;
        break;
        case 3:
            return Ogre::CMPF_LESS_EQUAL;
        break;
        case 4:
            return Ogre::CMPF_EQUAL;
        break;
        case 5:
            return Ogre::CMPF_NOT_EQUAL;
        break;
        case 6:
            return Ogre::CMPF_GREATER_EQUAL;
        break;
        case 7:
            return Ogre::CMPF_GREATER;
        break;
        case 8:
            return Ogre::NUM_COMPARE_FUNCTIONS;
        break;
    }
}

//****************************************************************************/
unsigned int HlmsBuilder::getIndexFromCompareFunction(Ogre::CompareFunction compareFunction)
{
    switch(compareFunction)
    {
        case Ogre::CMPF_ALWAYS_FAIL:
            return 0;
        break;
        case Ogre::CMPF_ALWAYS_PASS:
            return 1;
        break;
        case Ogre::CMPF_LESS:
            return 2;
        break;
        case Ogre::CMPF_LESS_EQUAL:
            return 3;
        break;
        case Ogre::CMPF_EQUAL:
            return 4;
        break;
        case Ogre::CMPF_NOT_EQUAL:
            return 5;
        break;
        case Ogre::CMPF_GREATER_EQUAL:
            return 6;
        break;
        case Ogre::CMPF_GREATER:
            return 7;
        break;
        case Ogre::NUM_COMPARE_FUNCTIONS:
            return 8;
        break;
    }
}

//****************************************************************************/
Ogre::SceneBlendFactor HlmsBuilder::getSceneBlendFactorFromIndex(unsigned int index)
{
    switch (index)
    {
        case 0:
            return Ogre::SBF_ONE;
        break;
        case 1:
            return Ogre::SBF_ZERO;
        break;
        case 2:
            return Ogre::SBF_DEST_COLOUR;
        break;
        case 3:
            return Ogre::SBF_SOURCE_COLOUR;
        break;
        case 4:
            return Ogre::SBF_ONE_MINUS_DEST_COLOUR;
        break;
        case 5:
            return Ogre::SBF_ONE_MINUS_SOURCE_COLOUR;
        break;
        case 6:
            return Ogre::SBF_DEST_ALPHA;
        break;
        case 7:
            return Ogre::SBF_SOURCE_ALPHA;
        break;
        case 8:
            return Ogre::SBF_ONE_MINUS_DEST_ALPHA;
        break;
        case 9:
            return Ogre::SBF_ONE_MINUS_SOURCE_ALPHA;
        break;
    }
}

//****************************************************************************/
unsigned int HlmsBuilder::getIndexFromSceneBlendFactor(const Ogre::SceneBlendFactor& sceneBlendFactor)
{
    switch (sceneBlendFactor)
    {
        case Ogre::SBF_ONE:
            return 0;
        break;
        case Ogre::SBF_ZERO:
            return 1;
        break;
        case Ogre::SBF_DEST_COLOUR:
            return 2;
        break;
        case Ogre::SBF_SOURCE_COLOUR:
            return 3;
        break;
        case Ogre::SBF_ONE_MINUS_DEST_COLOUR:
            return 4;
        break;
        case Ogre::SBF_ONE_MINUS_SOURCE_COLOUR:
            return 5;
        break;
        case Ogre::SBF_DEST_ALPHA:
            return 6;
        break;
        case Ogre::SBF_SOURCE_ALPHA:
            return 7;
        break;
        case Ogre::SBF_ONE_MINUS_DEST_ALPHA:
            return 8;
        break;
        case Ogre::SBF_ONE_MINUS_SOURCE_ALPHA:
            return 9;
        break;
    }
}

//****************************************************************************/
Ogre::SceneBlendOperation HlmsBuilder::getSceneBlendOperationFromIndex(unsigned int index)
{
    switch (index)
    {
        case 0:
            return Ogre::SBO_ADD;
        break;
        case 1:
            return Ogre::SBO_SUBTRACT;
        break;
        case 2:
            return Ogre::SBO_REVERSE_SUBTRACT;
        break;
        case 3:
            return Ogre::SBO_MIN;
        break;
        case 4:
            return Ogre::SBO_MAX;
        break;
    }
}

//****************************************************************************/
unsigned int HlmsBuilder::getIndexFromSceneBlendOperation(const Ogre::SceneBlendOperation& sceneBlendOperation)
{
    switch (sceneBlendOperation)
    {
        case Ogre::SBO_ADD:
            return 0;
        break;
        case Ogre::SBO_SUBTRACT:
            return 1;
        break;
        case Ogre::SBO_REVERSE_SUBTRACT:
            return 2;
        break;
        case Ogre::SBO_MIN:
            return 3;
        break;
        case Ogre::SBO_MAX:
            return 4;
        break;
    }
}

//****************************************************************************/
unsigned int HlmsBuilder::getIndexFromTAM (Ogre::TextureAddressingMode textureAddressingMode)
{
    switch (textureAddressingMode)
    {
        case Ogre::TAM_WRAP:
            return 0;
        break;
        case Ogre::TAM_MIRROR:
            return 1;
        break;
        case Ogre::TAM_CLAMP:
            return 2;
        break;
        case Ogre::TAM_BORDER:
            return 3;
        break;
        case Ogre::TAM_UNKNOWN:
            return 0;
        break;
    }
    return 999;
}

//****************************************************************************/
Ogre::TextureAddressingMode HlmsBuilder::getTAMFromIndex (unsigned int index)
{
    switch (index)
    {
        case 0:
            return Ogre::TAM_WRAP;
        break;
        case 1:
            return Ogre::TAM_MIRROR;
        break;
        case 2:
            return Ogre::TAM_CLAMP;
        break;
        case 3:
            return Ogre::TAM_BORDER;
        break;
    }
    return Ogre::TAM_UNKNOWN;
}

//****************************************************************************/
unsigned int HlmsBuilder::getIndexFromFilterOption (Ogre::FilterOptions filterOption)
{
    switch (filterOption)
    {
        case Ogre::FO_NONE:
            return 0;
        break;
        case Ogre::FO_POINT:
            return 1;
        break;
        case Ogre::FO_LINEAR:
            return 2;
        break;
        case Ogre::FO_ANISOTROPIC:
            return 3;
        break;
    }

    return 999;
}

//****************************************************************************/
Ogre::FilterOptions HlmsBuilder::getFilterOptionFromIndex (unsigned int index)
{
    switch (index)
    {
        case 0:
            return Ogre::FO_NONE;
        break;
        case 1:
            return Ogre::FO_POINT;
        break;
        case 2:
            return Ogre::FO_LINEAR;
        break;
        case 3:
            return Ogre::FO_ANISOTROPIC;
        break;
    }
    return Ogre::FO_NONE;
}

//****************************************************************************/
bool HlmsBuilder::isResourceLocationExisting(const Ogre::String& path)
{
    Ogre::ResourceGroupManager::LocationList resourceLocations = Ogre::ResourceGroupManager::getSingletonPtr()->
            getResourceLocationList(Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    Ogre::ResourceGroupManager::LocationList::iterator it;
    Ogre::ResourceGroupManager::LocationList::iterator itStart = resourceLocations.begin();
    Ogre::ResourceGroupManager::LocationList::iterator itEnd = resourceLocations.end();
    for (it = itStart; it != itEnd; ++it)
    {
        Ogre::ResourceGroupManager::ResourceLocation* location = *it;
        Ogre::String name = location->archive->getName();
        if (name == path)
            return true;
    }
    return false;
}

//****************************************************************************/
void HlmsBuilder::saveAllResourcesLocations(void)
{
    // Also add the resource location to the resources.cfg / resources_d.cfg file (for next startup of the application)
    Ogre::StringVector resourceGroups = Ogre::ResourceGroupManager::getSingletonPtr()->getResourceGroups();
    Ogre::StringVector::iterator itGroup;
    Ogre::StringVector::iterator itGroupStart = resourceGroups.begin();
    Ogre::StringVector::iterator itGroupEnd = resourceGroups.end();
    Ogre::String group;
    Ogre::String resourceName;
    QFile file(getResourcesCfg());
    file.open(QFile::WriteOnly | QFile::Text);
    QTextStream writeFile(&file);

    for (itGroup = itGroupStart; itGroup != itGroupEnd; ++itGroup)
    {
        // Iterate through locations
        group = *itGroup;
        writeFile << "[" << group.c_str() << "]\n";
        Ogre::ResourceGroupManager::LocationList resourceLocations = Ogre::ResourceGroupManager::getSingletonPtr()->
                getResourceLocationList(group);
        Ogre::ResourceGroupManager::LocationList::iterator itLocation;
        Ogre::ResourceGroupManager::LocationList::iterator itLocationStart = resourceLocations.begin();
        Ogre::ResourceGroupManager::LocationList::iterator itLocationEnd = resourceLocations.end();
        for (itLocation = itLocationStart; itLocation != itLocationEnd; ++itLocation)
        {
            Ogre::ResourceGroupManager::ResourceLocation* location = *itLocation;
            resourceName = location->archive->getName();
            writeFile << "FileSystem = " << resourceName.c_str() << "\n";
        }
    }

    // Also add the Hlms settings
    writeFile << HLMS_GROUP;
    writeFile << HLMS_DO_NOT_USE_AS_RESOURCE;
    file.close();
}
Пример #20
0
void CLASS::UpdateControls()
{

	int valuecounter = 0; // Going to be usefull for selections

	//Lang (Still not done)
	if (!IsLoaded)
	{
		m_lang->addItem("English (U.S.)");
	}
	m_lang->setIndexSelected(0); //TODO

	if (!IsLoaded)
	{
		m_gearbox_mode->addItem("Automatic shift");
		m_gearbox_mode->addItem("Manual shift - Auto clutch");
		m_gearbox_mode->addItem("Fully Manual: sequential shift");
		m_gearbox_mode->addItem("Fully Manual: stick shift");
		m_gearbox_mode->addItem("Fully Manual: stick shift with ranges");
	}

	//Gearbox
	Ogre::String gearbox_mode = GameSettingsMap["GearboxMode"];
	if (gearbox_mode == "Manual shift - Auto clutch")
		m_gearbox_mode->setIndexSelected(1);
	else if (gearbox_mode == "Fully Manual: sequential shift")
		m_gearbox_mode->setIndexSelected(2);
	else if (gearbox_mode == "Fully Manual: stick shift")
		m_gearbox_mode->setIndexSelected(3);
	else if (gearbox_mode == "Fully Manual: stick shift with ranges")
		m_gearbox_mode->setIndexSelected(4);
	else
		m_gearbox_mode->setIndexSelected(0);


	Ogre::RenderSystem* rs = Ogre::Root::getSingleton().getRenderSystem();
	// add all rendersystems to the list
	if (m_render_sys->getItemCount() == 0)
	{
		const Ogre::RenderSystemList list = Application::GetOgreSubsystem()->GetOgreRoot()->getAvailableRenderers();
		int selection = 0;
		for (Ogre::RenderSystemList::const_iterator it = list.begin(); it != list.end(); it++, valuecounter++)
		{
			if (rs && rs->getName() == (*it)->getName())
			{
				ExOgreSettingsMap["Render System"] = rs->getName();
				selection = valuecounter;
			}
			else if (!rs) {
				LOG("Error: No Ogre Render System found");
			}
			if (!IsLoaded)
			{
				m_render_sys->addItem(Ogre::String((*it)->getName()));
			}
		}
		m_render_sys->setIndexSelected(selection);
	}

	Ogre::ConfigFile cfg;
	cfg.load(SSETTING("ogre.cfg", "ogre.cfg"));

	//Few GameSettingsMap
	Ogre::String bFullScreen = cfg.getSetting("Full Screen", rs->getName());
	if (bFullScreen == "Yes")
	{
		ExOgreSettingsMap["Full Screen"] = "Yes";
		m_fullscreen->setStateCheck(true);
	}
	else
	{
		ExOgreSettingsMap["Full Screen"] = "No";
		m_fullscreen->setStateCheck(false);
	}

	Ogre::String bVsync = cfg.getSetting("VSync", rs->getName());
	if (bVsync == "Yes")
	{
		ExOgreSettingsMap["VSync"] = "Yes";
		m_vsync->setStateCheck(true);
	}
	else
	{
		ExOgreSettingsMap["VSync"] = "No";
		m_vsync->setStateCheck(false);
	}
		
	// store available rendering devices and available resolutions
	Ogre::ConfigOptionMap& CurrentRendererOptions = rs->getConfigOptions();
	Ogre::ConfigOptionMap::iterator configItr = CurrentRendererOptions.begin();
	Ogre::StringVector mFoundResolutions;
	Ogre::StringVector mFoundFSAA;
	while (configItr != CurrentRendererOptions.end())
	{
		if ((configItr)->first == "Video Mode")
		{
			// Store Available Resolutions
			mFoundResolutions = ((configItr)->second.possibleValues);
		}
		if ((configItr)->first == "FSAA")
		{
			// Store Available Resolutions
			mFoundFSAA = ((configItr)->second.possibleValues);
		}
		configItr++;
	}

	//Loop thru the vector for the resolutions
	valuecounter = 0; //Back to default
	Ogre::StringVector::iterator iterRes = mFoundResolutions.begin();
	for (; iterRes != mFoundResolutions.end(); iterRes++)
	{
		if (!IsLoaded)
		{
			m_resolution->addItem(Ogre::String((iterRes)->c_str()));
		}
		if ((iterRes)->c_str() == cfg.getSetting("Video Mode", rs->getName()))
		{
			ExOgreSettingsMap["Video Mode"] = (iterRes)->c_str();
			m_resolution->setIndexSelected(valuecounter);
		}
		valuecounter++;
	}

	//Loop thru the vector for the FSAAs
	valuecounter = 0; //Back to default
	Ogre::StringVector::iterator iterFSAA = mFoundFSAA.begin();
	for (; iterFSAA != mFoundFSAA.end(); iterFSAA++)
	{
		if (!IsLoaded)
		{
			m_fsaa->addItem(Ogre::String((iterFSAA)->c_str()));
		}
		if ((iterFSAA)->c_str() == cfg.getSetting("FSAA", rs->getName()))
		{
			ExOgreSettingsMap["FSAA"] = (iterFSAA)->c_str();
			m_fsaa->setIndexSelected(valuecounter);
		}
		
		valuecounter++;
	}

	//Few GameSettingsMap
	if (GameSettingsMap["ArcadeControls"] == "Yes")
		m_arc_mode->setStateCheck(true);
	else
		m_arc_mode->setStateCheck(false);

	if (GameSettingsMap["External Camera Mode"] == "Static")
		m_d_cam_pitch->setStateCheck(true);
	else
		m_d_cam_pitch->setStateCheck(false);

	if (GameSettingsMap["Creak Sound"] == "No")
		m_d_creak_sound->setStateCheck(true);
	else
		m_d_creak_sound->setStateCheck(false);

	//Fov
	m_fovexternal->setCaption(GameSettingsMap["FOV External"]);
	m_fovinternal->setCaption(GameSettingsMap["FOV Internal"]);

	
	//Texture Filtering
	Ogre::String texfilter = GameSettingsMap["Texture Filtering"];
	if (texfilter == "Bilinear")
		m_tex_filter->setIndexSelected(1);
	else if (texfilter == "Trilinear")
		m_tex_filter->setIndexSelected(2);
	else if (texfilter == "Anisotropic (best looking)")
		m_tex_filter->setIndexSelected(3);
	else
		m_tex_filter->setIndexSelected(0);

	if (!IsLoaded)
	{
		m_water_type->addItem("Hydrax"); //It's working good enough to be here now. 
	}

	if (BSETTING("DevMode", false) && !IsLoaded)
	{
		//Things that aren't ready to be used yet.
		m_sky_type->addItem("SkyX (best looking, slower)");
		m_shadow_type->addItem("Parallel-split Shadow Maps");
	}

	//Sky effects
	Ogre::String skytype = GameSettingsMap["Sky effects"];
	if (skytype == "Caelum (best looking, slower)")
		m_sky_type->setIndexSelected(1);
	else if (skytype == "SkyX (best looking, slower)" && BSETTING("DevMode", false))
		m_sky_type->setIndexSelected(2);
	else
		m_sky_type->setIndexSelected(0);

	//Shadow technique
	Ogre::String shadowtype = GameSettingsMap["Shadow technique"];
	if (shadowtype == "Texture shadows")
		m_shadow_type->setIndexSelected(1);
	else if (shadowtype == "Stencil shadows (best looking)")
		m_shadow_type->setIndexSelected(2);
	else if (shadowtype == "Parallel-split Shadow Maps" && BSETTING("DevMode", false))
		m_shadow_type->setIndexSelected(3);
	else
		m_shadow_type->setIndexSelected(0);

	//Water effects
	Ogre::String watertype = GameSettingsMap["Water effects"];
	if (watertype == "Reflection")
		m_water_type->setIndexSelected(1);
	else if (watertype == "Reflection + refraction (speed optimized)")
		m_water_type->setIndexSelected(2);
	else if (watertype == "Reflection + refraction (quality optimized)")
		m_water_type->setIndexSelected(3);
	else if (watertype == "Hydrax")
		m_water_type->setIndexSelected(4);
	else
		m_water_type->setIndexSelected(0);
		
	//Vegetation
	Ogre::String vegetationtype = GameSettingsMap["Vegetation"];
	if (vegetationtype == "20%")
		m_vegetation->setIndexSelected(1);
	else if (vegetationtype == "50%")
		m_vegetation->setIndexSelected(2);
	else if (vegetationtype == "Full (best looking, slower)")
		m_vegetation->setIndexSelected(3);
	else
		m_vegetation->setIndexSelected(0);

	//Light source effects
	Ogre::String lightstype = GameSettingsMap["Lights"];
	if (lightstype == "Only current vehicle, main lights")
		m_light_source_effects->setIndexSelected(1);
	else if (lightstype == "All vehicles, main lights")
		m_light_source_effects->setIndexSelected(2);
	else if (lightstype == "All vehicles, all lights")
		m_light_source_effects->setIndexSelected(3);
	else
		m_light_source_effects->setIndexSelected(0);
	
	//Speed until selection
	Ogre::String speedunit = GameSettingsMap["SpeedUnit"];
	if (speedunit == "Metric")
		m_speed_unit->setIndexSelected(1);
	else
		m_speed_unit->setIndexSelected(0);

	//Other configs
	if (GameSettingsMap["DigitalSpeedo"] == "Yes")
		m_digital_speedo->setStateCheck(true);
	else
		m_digital_speedo->setStateCheck(false);

	if (GameSettingsMap["Particles"] == "Yes")
		m_psystem->setStateCheck(true);
	else
		m_psystem->setStateCheck(false);

	if (GameSettingsMap["HeatHaze"] == "Yes")
		m_heathaze->setStateCheck(true);
	else
		m_heathaze->setStateCheck(false);

	if (GameSettingsMap["Mirrors"] == "Yes")
		m_mirrors->setStateCheck(true);
	else
		m_mirrors->setStateCheck(false);

	if (GameSettingsMap["Sunburn"] == "Yes")
		m_sunburn->setStateCheck(true);
	else
		m_sunburn->setStateCheck(false);

	if (GameSettingsMap["HDR"] == "Yes")
		m_hdr->setStateCheck(true);
	else
		m_hdr->setStateCheck(false);

	if (GameSettingsMap["Motion blur"] == "Yes")
		m_mblur->setStateCheck(true);
	else
		m_mblur->setStateCheck(false);

	if (GameSettingsMap["Skidmarks"] == "Yes")
		m_skidmarks->setStateCheck(true);
	else
		m_skidmarks->setStateCheck(false);

	if (GameSettingsMap["Envmap"] == "Yes")
		m_hq_ref->setStateCheck(true);
	else
		m_hq_ref->setStateCheck(false);

	if (GameSettingsMap["Glow"] == "Yes")
		m_glow->setStateCheck(true);
	else
		m_glow->setStateCheck(false);

	if (GameSettingsMap["DOF"] == "Yes")
		m_dof->setStateCheck(true);
	else
		m_dof->setStateCheck(false);

	if (GameSettingsMap["Waves"] == "Yes")
		m_e_waves->setStateCheck(true);
	else
		m_e_waves->setStateCheck(false);

	if (GameSettingsMap["Shadow optimizations"] == "Yes")
		m_sh_pf_opti->setStateCheck(true);
	else
		m_sh_pf_opti->setStateCheck(false);

	if (GameSettingsMap["AsynchronousPhysics"] == "Yes")
		m_enable_async_physics->setStateCheck(true);
	else
		m_enable_async_physics->setStateCheck(false);

	if (GameSettingsMap["DisableCollisions"] == "Yes")
		m_disable_inter_collsion->setStateCheck(true);
	else
		m_disable_inter_collsion->setStateCheck(false);

	if (GameSettingsMap["DisableSelfCollisions"] == "Yes")
		m_disable_intra_collision->setStateCheck(true);
	else
		m_disable_intra_collision->setStateCheck(false);

	if (GameSettingsMap["Multi-threading"] == "No")
		m_disable_multithreading->setStateCheck(true);
	else
		m_disable_multithreading->setStateCheck(false);

	//Volume slider
	long sound_volume = Ogre::StringConverter::parseLong(GameSettingsMap["Sound Volume"], 100);
	m_volume_slider->setScrollRange(101);
	m_volume_slider->setScrollPosition(sound_volume -1);
	if (m_volume_slider->getScrollPosition() >= 100)
		m_volume_indicator->setCaption("100%");
	else
		m_volume_indicator->setCaption(Ogre::StringConverter::toString(sound_volume) + "%");

	//Audio Devices
	valuecounter = 0; //Back to default
	char *devices = (char *)alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER);
	while (devices && *devices != 0)
	{
		if (!IsLoaded)
		{
			m_audio_dev->addItem(Ogre::String(devices));
		}
		if (Ogre::String(devices) == GameSettingsMap["AudioDevice"])
			m_audio_dev->setIndexSelected(valuecounter);

		devices += strlen(devices) + 1; //next device
		valuecounter++;
	}

	//FPS Limiter slider
	long fps_limit = Ogre::StringConverter::parseLong(GameSettingsMap["FPS-Limiter"], 60);
	m_fps_limiter_slider->setScrollRange(200);
	m_fps_limiter_slider->setScrollPosition(fps_limit -1);


	if (fps_limit >= 199)
		m_fps_limiter_indicator->setCaption("Unlimited");
	else
		m_fps_limiter_indicator->setCaption(Ogre::StringConverter::toString(fps_limit) + " FPS");

	//SightRange slider
	long sight_range = Ogre::StringConverter::parseLong(GameSettingsMap["SightRange"], 5000);
	m_sightrange->setScrollRange(5000);
	m_sightrange->setScrollPosition(sight_range -1);
	if (sight_range >= 4999)
		m_sightrange_indicator->setCaption("Unlimited");
	else
		m_sightrange_indicator->setCaption(Ogre::StringConverter::toString(sight_range) + " m");		

	if (GameSettingsMap["Replay mode"] == "Yes")
		m_enable_replay->setStateCheck(true);
	else
		m_enable_replay->setStateCheck(false);

	if (GameSettingsMap["Screenshot Format"] == "png (bigger, no quality loss)")
		m_hq_screenshots->setStateCheck(true);
	else
		m_hq_screenshots->setStateCheck(false);

	if (GameSettingsMap["ChatAutoHide"] == "Yes")
		m_autohide_chatbox->setStateCheck(true);
	else
		m_autohide_chatbox->setStateCheck(false);
}
Пример #21
0
void QOgreWindow::initialize()
{
    // Initialize Ogre like normal
#ifdef _MSC_VER
    oRoot = new Ogre::Root(Ogre::String("plugins" OGRE_BUILD_SUFFIX ".cfg"));
#else
    oRoot = new Ogre::Root(Ogre::String("plugins.cfg"));
#endif
    Ogre::ConfigFile oConf;

    oConf.load(resConfig);

    Ogre::ConfigFile::SectionIterator seci = oConf.getSectionIterator();
    Ogre::String secName, typeName, archName;
    while (seci.hasMoreElements())
    {
        secName = seci.peekNextKey();
        Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
        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);
        }
    }

    /*Ogre::String name, locType;
    Ogre::ConfigFile::SectionIterator secIt = oConf.getSectionIterator();

    while(secIt.hasMoreElements())
    {
        Ogre::ConfigFile::SettingsMultiMap* _settings = secIt.getNext();
        Ogre::ConfigFile::SettingsMultiMap::iterator it;

        for (it = _settings->begin(); it != _settings->end(); ++it)
        {
            locType = it->first;
            name    = it->second;
        }

        Ogre::ResourceGroupManager::getSingleton().addResourceLocation(name,locType);
    }*/

    //if (!oRoot->restoreConfig() || oRoot->showConfigDialog()) return;

    const Ogre::RenderSystemList& rsList = oRoot->getAvailableRenderers();

    Ogre::RenderSystem* rs = rsList[0];

    // This list setup search order for used render system
    Ogre::StringVector renderOrder;
    renderOrder.push_back("OpenGL");
#if PONY_PLATFORM == PLAT_WIN32 || PONY_PLATFORM == PLAT_WIN64
    renderOrder.push_back("Direct3D9");
    renderOrder.push_back("Direct3D11");
#endif
    //renderOrder.push_back("OpenGL 3+");

    for (Ogre::StringVector::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)
            {
                rs = *it;
                break;
            }
        }
        if (rs != NULL) break;
    }
    if (rs == NULL)
    {
        if (!oRoot->restoreConfig())
        {
            if (!oRoot->showConfigDialog())
            {
                OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "[PoneNgine][Ogre3D] Abort render system configuration.","QOgreWindow::initialize");
            }
        }
    }

    // Settings size on windows will solve a lot of problems
    // VSync... why is this praised by developers again? Becuase I hate it in games.
    // Soon, I'll make a settings class for the in-game settings.
    QString dimensions = QString("%1 x %2").arg(this->width()).arg(this->height());
    rs->setConfigOption("Video Mode", dimensions.toStdString());
    rs->setConfigOption("Full Screen", "No");
    rs->setConfigOption("VSync", "No");
    oRoot->setRenderSystem(rs);
    oRoot->initialise(false);

    Ogre::NameValuePairList parameters;

    if (rs->getName().find("GL") <= rs->getName().size())
        parameters["currentGLContext"] = Ogre::String("false");

#if PONY_PLATFORM == PLAT_WIN32 || PONY_PLATFORM == PLAT_WIN64 || PONY_PLATFORM == PLAT_MACOSX
    parameters["externalWindowHandle"] = Ogre::StringConverter::toString((size_t)(this->winId()));
    parameters["parentWindowHandle"]   = Ogre::StringConverter::toString((size_t)(this->winId()));
#else
    parameters["externalWindowHandle"] = Ogre::StringConverter::toString((unsigned long)(this->winId()));
    parameters["parentWindowHandle"] = Ogre::StringConverter::toString((unsigned long)(this->winId()));
#endif

#if PONY_PLATFORM == PLAT_MACOSX
    parameters["macAPI"] = "cocoa";
    parameters["macAPICocoaUseNSView"] = "true";
#endif

    oWin = oRoot->createRenderWindow("QOgreWindow Test | PoneNgine Version "+Ogre::String(PONENGINE_VERSION)+" Build "+Ogre::String(PONENGINE_BUILD), this->width(), this->height(), false, &parameters);
    oWin->setVisible(true);

    Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
    Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

#if OGRE_VERSION >= ((2 << 16) | (0 << 8) | 0)
    const size_t numThreads = std::max<int>(1, Ogre::PlatformInformation::getNumLogicalCores());
    Ogre::InstancingTheadedCullingMethod threadedCullingMethod = Ogre::INSTANCING_CULLING_SINGLETHREAD;
    if (numThreads > 1)threadedCullingMethod = Ogre::INSTANCING_CULLING_THREADED;
    oSceneMgr = oRoot->createSceneManager(Ogre::ST_GENERIC, numThreads, threadedCullingMethod);
#else
    oSceneMgr = oRoot->createSceneManager(Ogre::ST_GENERIC);
#endif

    oCam = oSceneMgr->createCamera("MainCamera");
    oCam->setPosition(Ogre::Vector3(0.0f,0.0f,10.0f));
    oCam->lookAt(Ogre::Vector3(0.0f,0.0f,-300.0f));
    oCam->setNearClipDistance(0.1f);
    oCam->setFarClipDistance(200.0f);
    camMan = new OgreQtBites::QtOgreSdkCameraMan(oCam);

#if OGRE_VERSION >= ((2 << 16) | (0 << 8) | 0)
    createCompositor();
#else
    Ogre::Viewport* oViewPort = oWin->addViewport(oCam);
    oViewPort->setBackgroundColour(oBgColor);
#endif

    oCam->setAspectRatio(Ogre::Real(oWin->getWidth()) / Ogre::Real(oWin->getHeight()));
    oCam->setAutoAspectRatio(true);

    createScene();

    oRoot->addFrameListener(this);
}
Пример #22
0
bool OgreWidget::initializeRTShaderSystem(Ogre::SceneManager* sceneMgr)
{
    if(Ogre::RTShader::ShaderGenerator::initialize())
    {
        loadResources();
        mShaderGenerator = Ogre::RTShader::ShaderGenerator::getSingletonPtr();

        mShaderGenerator->addSceneManager(sceneMgr);

        // Setup core libraries and shader cache path.
        qDebug() << "number of resource groups:" << Ogre::ResourceGroupManager::getSingleton().getResourceGroups().size();
        Ogre::StringVector groupVector = Ogre::ResourceGroupManager::getSingleton().getResourceGroups();
        Ogre::StringVector::iterator itGroup = groupVector.begin();
        Ogre::StringVector::iterator itGroupEnd = groupVector.end();
        Ogre::String shaderCoreLibsPath;
        Ogre::String shaderCachePath;

        for (; itGroup != itGroupEnd; ++itGroup)
        {
            qDebug() << "now looking in resource group" << QString::fromStdString(*itGroup);
            Ogre::ResourceGroupManager::LocationList resLocationsList = Ogre::ResourceGroupManager::getSingleton().getResourceLocationList(*itGroup);
            Ogre::ResourceGroupManager::LocationList::iterator it = resLocationsList.begin();
            Ogre::ResourceGroupManager::LocationList::iterator itEnd = resLocationsList.end();
            bool coreLibsFound = false;

            // Try to find the location of the core shader lib functions and use it
            // as shader cache path as well - this will reduce the number of generated files
            // when running from different directories.
            for (; it != itEnd; ++it)
            {
                std::string archiveName = (*it)->archive->getName();
                qDebug() << "Now looking for RTShaderLib in" << QString::fromStdString(archiveName);
                if((*it)->archive->getName().find("RTShaderLib") != Ogre::String::npos)
                {
                    shaderCoreLibsPath = (*it)->archive->getName() + "/";
                    shaderCachePath = shaderCoreLibsPath;
                    coreLibsFound = true;
                    break;
                }
            }
            // Core libs path found in the current group.
            if(coreLibsFound)
                break;
        }

        // Core shader libs not found -> shader generating will fail.
        if(shaderCoreLibsPath.empty())
        {
            qDebug() << "shaderCoreLibsPath.empty()!";
            return false;
        }

#ifdef _RTSS_WRITE_SHADERS_TO_DISK
        // Set shader cache path.
        mShaderGenerator->setShaderCachePath(shaderCachePath);
#endif
        // Create and register the material manager listener.
        mMaterialMgrListener = new ShaderGeneratorTechniqueResolverListener(mShaderGenerator);
        Ogre::MaterialManager::getSingleton().addListener(mMaterialMgrListener);
    }
    else
    {
        qDebug() << "Ogre::RTShader::ShaderGenerator::initialize() failed.";
    }

    return true;
}
Пример #23
0
int COFSSceneSerializer::Import(Ogre::String importfile)
{
    OgitorsRoot *ogRoot = OgitorsRoot::getSingletonPtr();
    OgitorsSystem *mSystem = OgitorsSystem::getSingletonPtr();
    OFS::OfsPtr& mFile = OgitorsRoot::getSingletonPtr()->GetProjectFile();

    if(importfile == "")
    {
        UTFStringVector extlist;
        extlist.push_back(OTR("Ogitor File System File"));
        extlist.push_back("*.ofs");
        extlist.push_back(OTR("Ogitor Scene File"));
        extlist.push_back("*" + Globals::OGSCENE_FORMAT_EXTENSION);

        importfile = mSystem->GetSetting("system", "oldOpenPath", "");
        importfile = mSystem->DisplayOpenDialog(OTR("Open"), extlist, importfile);
        if(importfile == "") 
            return SCF_CANCEL;

        mSystem->SetSetting("system", "oldOpenPath", importfile);
    }

    importfile = OgitorsUtils::QualifyPath(importfile);

    Ogre::String filePath = OgitorsUtils::ExtractFilePath(importfile);
    Ogre::String fileName = OgitorsUtils::ExtractFileName(importfile);

    bool testpassed = false;
    try
    {
        std::ofstream test((filePath + "test.dat").c_str());
        if(test.is_open())
            testpassed = true;
        test.close();
        mSystem->DeleteFile(filePath + "test.dat");
    }
    catch(...)
    {
        testpassed = false;
    }

    if(!testpassed)
    {
        mSystem->DisplayMessageDialog("The path is read-only. Ogitor can not work with read-only project paths!", DLGTYPE_OK);
        return SCF_CANCEL;
    }

    Ogre::UTFString loadmsg = "";

    int typepos = importfile.find_last_of(".");
    if(typepos != -1 && (importfile.substr(typepos, 4) != ".ofs"))
        importfile = filePath;
    

    OFS::OfsResult oRet;
    if((oRet = mFile.mount(importfile.c_str(), OFS::OFS_MOUNT_OPEN | OFS::OFS_MOUNT_RECOVER)) != OFS::OFS_OK)
    {
        if(oRet == OFS::OFS_PREVIOUS_VERSION)
        {
            mSystem->DisplayMessageDialog("The OFS file is a previous version, please use qtOFS to upgrade it to new file version.", DLGTYPE_OK);
        }

        loadmsg = mSystem->Translate("Please load a Scene File...");
        mSystem->UpdateLoadProgress(-1, loadmsg);
        return SCF_ERRPARSE;
    }

    OFS::FileSystemStats fsStats;

    mFile->getFileSystemStats(fsStats);

    PROJECTOPTIONS *pOpt = ogRoot->GetProjectOptions();
    pOpt->CreatedIn = "";

    pOpt->ProjectDir = filePath;
    typepos = fileName.find_last_of(".");
    if(typepos != -1)
        fileName.erase(typepos, fileName.length() - typepos);
    pOpt->ProjectName = fileName;

    fileName += Globals::OGSCENE_FORMAT_EXTENSION;

    OFS::ofs64 file_size = 0;

    if(mFile->getFileSize(fileName.c_str(), file_size) != OFS::OFS_OK)
	{		
        // OGSCENE file name needs to match OFS container file name. If the later was renamed, we 
        // need to automatically adapt the OGSCENE file name now.
        OFS::FileList files = mFile->listFiles("/", OFS::OFS_FILE);
        unsigned int ogsceneFileExtensionLength = strlen(Globals::OGSCENE_FORMAT_EXTENSION.c_str());

		for(OFS::FileList::iterator iter = files.begin(); iter != files.end(); iter++)
		{
			// Filter out too short names
            if(iter->name.size() <= ogsceneFileExtensionLength) 
                continue;

			if(stricmp(iter->name.c_str() + (iter->name.size() - (ogsceneFileExtensionLength)), Globals::OGSCENE_FORMAT_EXTENSION.c_str()) == 0)
			{
				mFile->renameFile(iter->name.c_str(), fileName.c_str());
				break;
			}
		}

		if(mFile->getFileSize(fileName.c_str(), file_size) != OFS::OFS_OK)
			return SCF_ERRFILE;
	}

    char *file_data = new char[(unsigned int)file_size + 1];

    OFS::OFSHANDLE projHandle;

    if(mFile->openFile(projHandle, fileName.c_str(), OFS::OFS_READ) != OFS::OFS_OK)
    {
        delete [] file_data;
        return SCF_ERRFILE;
    }

    mFile->read(projHandle, file_data, file_size);
    mFile->closeFile(projHandle);

    TiXmlDocument docImport;

    if(!docImport.LoadFromMemory(file_data, file_size))
    {
        delete [] file_data;
        return SCF_ERRFILE;
    }

    delete [] file_data;

    loadmsg = mSystem->Translate("Parsing Scene File");
    mSystem->UpdateLoadProgress(1, loadmsg);

    TiXmlNode* ogitorSceneNode = 0;
    TiXmlNode* projectNode;
    TiXmlElement* element = 0;
    bool upgradeExecuted = false;
    ogitorSceneNode = docImport.FirstChild("OGITORSCENE");

    if(!ogitorSceneNode)
        return SCF_ERRPARSE;

    element = ogitorSceneNode->ToElement();

    // Old OGSCENE version check and attempt to fix/update
    int version = Ogre::StringConverter::parseInt(ValidAttr(element->Attribute("version"), "0"));    
    if(Ogre::StringConverter::toString(version) < Globals::OGSCENE_FORMAT_VERSION)
    {
        mSystem->DisplayMessageDialog(mSystem->Translate("Old OGSCENE file version detected. Ogitor will now attempt to upgrade the format and will also create a backup version of your OFS file."), DLGTYPE_OK);

        loadmsg = mSystem->Translate("Upgrading OGSCENE file.");
        mSystem->UpdateLoadProgress(10, loadmsg);

        if(version == 0)
        {
            mSystem->DisplayMessageDialog(mSystem->Translate("OGSCENE files contains no version number set and therefore cannot be loaded."), DLGTYPE_OK);
            return SCF_ERRPARSE;
        }
        else if(version == 1)
        {
            mSystem->DisplayMessageDialog(mSystem->Translate("OGSCENE files with version 1 cannot be upgraded automatically. Please contact the Ogitor team for further details."), DLGTYPE_OK);
            return SCF_ERRPARSE;
        }

        if(version > 1)
        {
            if((mFile->getFileSystemType() == OFS::OFS_PACKED) && (!mSystem->CopyFile(importfile, importfile + ".backup")))
                mSystem->DisplayMessageDialog(mSystem->Translate("Error while trying to create backup file."), DLGTYPE_OK);
        }
        switch(version)
        {
         case 2:
            _upgradeOgsceneFileFrom2To3(ogitorSceneNode);
            _upgradeOgsceneFileFrom3To4(ogitorSceneNode);
            break;
         case 3:
            _upgradeOgsceneFileFrom3To4(ogitorSceneNode);
            break;
        }

        upgradeExecuted = true;
    }  

    projectNode = ogitorSceneNode->FirstChild("PROJECT");

    if(projectNode)
    {
        loadmsg = mSystem->Translate("Parsing project options");
        mSystem->UpdateLoadProgress(5, loadmsg);
        ogRoot->LoadProjectOptions(projectNode->ToElement());
        ogRoot->PrepareProjectResources();
    }

    element = ogitorSceneNode->FirstChildElement();

    loadmsg = mSystem->Translate("Creating scene objects");
    mSystem->UpdateLoadProgress(10, loadmsg);

    unsigned int obj_count = 0;
    Ogre::String objecttype;
    OgitorsPropertyValueMap params;
    OgitorsPropertyValue tmpPropVal;
    Ogre::String objAttValue;
    Ogre::String elementName;
    TiXmlElement* properties = 0;
    Ogre::String attID;
    Ogre::String attValue;
    CBaseEditor* result = 0;
    TiXmlElement* customprop = 0;
    Ogre::StringVector invalidEditorTypes;

    do
    {
        // Make sure its NON-ZERO
        if(pOpt->ObjectCount)
        {
            ++obj_count;
            mSystem->UpdateLoadProgress(10 + ((obj_count * 70) / pOpt->ObjectCount), loadmsg);
        }

        params.clear();       

        objAttValue = ValidAttr(element->Attribute("object_id"), "");
        if(objAttValue != "")
        {
            tmpPropVal.propType = PROP_UNSIGNED_INT;
            tmpPropVal.val = Ogre::Any(Ogre::StringConverter::parseUnsignedInt(objAttValue));
            params.insert(OgitorsPropertyValueMap::value_type("object_id", tmpPropVal));
        }

        objAttValue = ValidAttr(element->Attribute("parentnode"), "");
        if(objAttValue != "")
        {
            tmpPropVal.propType = PROP_STRING;
            tmpPropVal.val = Ogre::Any(objAttValue);
            params.insert(OgitorsPropertyValueMap::value_type("parentnode", tmpPropVal));
        }

        objAttValue = ValidAttr(element->Attribute("name"), "");
        if(objAttValue != "")
        {
            tmpPropVal.propType = PROP_STRING;
            tmpPropVal.val = Ogre::Any(objAttValue);
            params.insert(OgitorsPropertyValueMap::value_type("name", tmpPropVal));
        }
        else
            continue;

        objAttValue = ValidAttr(element->Attribute("typename"), "");
        if(objAttValue != "")
        {
            tmpPropVal.propType = PROP_STRING;
            tmpPropVal.val = Ogre::Any(objAttValue);
            params.insert(OgitorsPropertyValueMap::value_type("typename", tmpPropVal));
        }
        else
            continue;

        properties = element->FirstChildElement();
        if(properties)
        {            
            do
            {
                elementName = properties->Value();
                if(elementName != "PROPERTY")
                    continue;

                attID = ValidAttr(properties->Attribute("id"), "");
                int attType = Ogre::StringConverter::parseInt(ValidAttr(properties->Attribute("type"), ""));
                attValue = ValidAttr(properties->Attribute("value"), "");

                params.insert(OgitorsPropertyValueMap::value_type(attID, OgitorsPropertyValue::createFromString((OgitorsPropertyType)attType, attValue)));
            } while(properties = properties->NextSiblingElement());
        }

        objecttype = Ogre::any_cast<Ogre::String>(params["typename"].val);
        result = ogRoot->CreateEditorObject(0, objecttype, params, false, false);
        if(result)
        {
            customprop = element->FirstChildElement("CUSTOMPROPERTIES");
            if(customprop) 
            {
                OgitorsUtils::ReadCustomPropertySet(customprop, result->getCustomProperties());
            }
        }
        else
            invalidEditorTypes.push_back(objecttype);

    } while(element = element->NextSiblingElement());

    // Print out invalid/unsupported editor types (= types where no factory could be found)
    if(invalidEditorTypes.size() > 0)
    {
        std::sort(invalidEditorTypes.begin(), invalidEditorTypes.end());
        invalidEditorTypes.erase(std::unique(invalidEditorTypes.begin(), invalidEditorTypes.end()), invalidEditorTypes.end());
        Ogre::String invalidTypesResultString;
        for(unsigned int i = 0; i < invalidEditorTypes.size(); i++)
        {
            invalidTypesResultString += invalidEditorTypes.at(i) + "\n";
        }
        mSystem->DisplayMessageDialog(mSystem->Translate("Could not create objects of types:\n" + invalidTypesResultString), DLGTYPE_OK);
    }

    //// Save directly after upgrade
    //if(upgradeExecuted)
    //    Export(false, importfile);

    ogRoot->AfterLoadScene();

    return SCF_OK;
}
void CLASS::Export(RigEditor::RigProperties* data)
{
	data->m_title = m_editbox_title->getCaption();
	data->m_guid = m_editbox_guid->getCaption();

	bool has_uid = ! m_editbox_uid->getCaption().empty();
	if (has_uid)
	{
		data->m_fileinfo.unique_id = m_editbox_uid->getCaption();
	}
	data->m_fileinfo._has_unique_id = has_uid;

	bool has_category = ! m_textbox_category_id->getCaption().empty();
	if (has_category)
	{
		data->m_fileinfo.category_id = PARSEUINT(m_textbox_category_id->getCaption());
	}
	data->m_fileinfo._has_category_id = has_category;

	bool has_version = ! m_editbox_version->getCaption().empty();
	if (has_version)
	{
		data->m_fileinfo.file_version = PARSEUINT(m_editbox_version->getCaption());
	}
	data->m_fileinfo._has_file_version_set = has_version;

	// Description
	data->m_description.clear();
	Ogre::String description_str = m_editbox_description->getCaption();
	Ogre::StringUtil::trim(description_str);
	if (! description_str.empty())
	{
		Ogre::StringVector lines = Ogre::StringUtil::split(description_str, "\r\n"); // Split over CR or LF
		for (auto itor = lines.begin(); itor != lines.end(); ++itor)
		{
			if (! itor->empty()) // Empty line?
			{
				std::string line = RoR::Utils::TrimBlanksAndLinebreaks(*itor);
				if (! line.empty())
				{
					data->m_description.push_back(line);
				}
			}
		}
	}

	// Authors
	data->m_authors.clear();
	Ogre::String authors_str = m_editbox_authors->getCaption();
	Ogre::StringUtil::trim(authors_str);
	if (! authors_str.empty())
	{
		Ogre::StringVector lines = Ogre::StringUtil::split(authors_str, "\n");
		for (auto itor = lines.begin(); itor != lines.end(); ++itor)
		{
			Ogre::String line = *itor;
			Ogre::StringUtil::trim(line);
			if (line.empty())
			{
				continue;
			}
			Ogre::StringVector tokens = Ogre::StringUtil::split(line, " \t");
			RigDef::Author author;
			author.type = tokens[0];
			if (tokens.size() > 1)
			{
				int account_id = PARSEINT(tokens[1]);
				if (account_id > -1)
				{
					author.forum_account_id = static_cast<unsigned int>(account_id);
					author._has_forum_account = true;
				}

				if (tokens.size() > 2)
				{
					author.name = tokens[2];

					if (tokens.size() > 3)
					{
						author.email = tokens[3];
					}
				}
			}
			
			data->m_authors.push_back(author);
		}
	}

	// Checkboxes
	data->m_hide_in_chooser               = m_checkbox_hide_in_chooser->getStateSelected();
	data->m_forward_commands              = m_checkbox_forwardcommands->getStateSelected();
	data->m_import_commands               = m_checkbox_importcommands->getStateSelected();
	data->m_is_rescuer                    = m_checkbox_rescuer->getStateSelected();
	data->m_disable_default_sounds        = m_checkbox_disable_default_sounds->getStateSelected();
	data->m_enable_advanced_deformation   = m_checkbox_use_advanced_deform->getStateSelected();
	data->m_rollon                        = m_checkbox_rollon->getStateSelected();

	// Section 'extcamera'
	RigDef::ExtCamera::Mode extcamera_mode = RigDef::ExtCamera::MODE_CLASSIC;
	extcamera_mode = m_radio_camera_behaviour_classic->getStateSelected()   ? RigDef::ExtCamera::MODE_CLASSIC   : extcamera_mode;
	extcamera_mode = m_radio_camera_behaviour_cinecam->getStateSelected()   ? RigDef::ExtCamera::MODE_CINECAM   : extcamera_mode;
	extcamera_mode = m_radio_camera_behaviour_node->getStateSelected()      ? RigDef::ExtCamera::MODE_NODE      : extcamera_mode;
	data->m_extcamera.mode = extcamera_mode;
	if (extcamera_mode == RigDef::ExtCamera::MODE_NODE)
	{
        std::string node_ref_str = m_editbox_extcamera_node->getCaption();
        unsigned flags = Node::Ref::REGULAR_STATE_IS_VALID | Node::Ref::REGULAR_STATE_IS_NAMED; // Fileformatversion>=450 ~ Use named-only nodes
        data->m_extcamera.node = Node::Ref(node_ref_str, 0, flags, 0); 
	}

	// Section 'set_skeleton_settings'
	data->m_skeleton_settings.beam_thickness_meters     = PARSEREAL(m_editbox_beam_thickness_meters->getCaption());
	data->m_skeleton_settings.visibility_range_meters   = PARSEREAL(m_editbox_beam_visibility_range_meters->getCaption());

	data->m_help_panel_material_name    = m_editbox_help_panel_mat_name->getCaption();
	data->m_globals_cab_material_name   = m_editbox_cab_material_name->getCaption();
	data->m_globals_dry_mass            = PARSEREAL(m_editbox_dry_mass->getCaption());
	data->m_globals_load_mass           = PARSEREAL(m_editbox_load_mass->getCaption());
	data->m_minimass                    = PARSEREAL(m_editbox_minimass->getCaption());

	// Section 'guisettings'

	GuiSettings::MapMode minimap_mode = GuiSettings::MAP_MODE_OFF;
	minimap_mode = m_radio_guisettings_minimap_off->getStateSelected()     ? GuiSettings::MAP_MODE_OFF     : minimap_mode;
	minimap_mode = m_radio_guisettings_minimap_simple->getStateSelected()  ? GuiSettings::MAP_MODE_SIMPLE  : minimap_mode;
	minimap_mode = m_radio_guisettings_minimap_zoom->getStateSelected()    ? GuiSettings::MAP_MODE_ZOOM    : minimap_mode;
	data->m_gui_settings.interactive_overview_map_mode = minimap_mode;

	data->m_gui_settings.use_max_rpm         = m_checkbox_guisettings_speedo_use_engine_max_rpm->getStateSelected();
	data->m_gui_settings.help_material       = m_editbox_guisettings_help_mat->getCaption();
	data->m_gui_settings.speedo_highest_kph  = PARSEUINT(m_editbox_guisettings_speedo_max->getCaption());
	data->m_gui_settings.speedo_material     = m_editbox_guisettings_speedo->getCaption();
	data->m_gui_settings.tacho_material      = m_editbox_guisettings_tacho->getCaption();

	Ogre::String rtt_layouts_str = m_editbox_guisettings_rtt_dashboard_layout->getCaption();
	Ogre::StringUtil::trim(rtt_layouts_str);
	if (! rtt_layouts_str.empty())
	{
		Ogre::StringVector lines = Ogre::StringUtil::split(rtt_layouts_str, "\n");
		for (auto itor = lines.begin(); itor != lines.end(); ++itor)
		{
			data->m_gui_settings.rtt_dashboard_layouts.push_back(*itor);
		}
	}

	Ogre::String dash_layouts_str = m_editbox_guisettings_rtt_dashboard_layout->getCaption();
	Ogre::StringUtil::trim(dash_layouts_str);
	if (! dash_layouts_str.empty())
	{
		Ogre::StringVector lines = Ogre::StringUtil::split(dash_layouts_str, "\n");
		for (auto itor = lines.begin(); itor != lines.end(); ++itor)
		{
			data->m_gui_settings.dashboard_layouts.push_back(*itor);
		}
	}
}