Beispiel #1
0
//---------------------------------------------------------------------------------------------------------
Vehicle::Vehicle(const std::string &fileName,Ogre::SceneManager* sm,
				 Ogre::RenderWindow* win, NxScene* ns, 
				 const Ogre::Vector3 pos, const Ogre::Quaternion ori):
                 mSpeed(0), mAngle(0),mAngleDelta(0),mTurnLeft(0),mTurnRight(0),mRollAngle(0)
{

	//初始化各种变量
	mSceneMgr		= sm;
	mWindow			= win;
	mOriginalPos	= pos;
	mOriginalQuat	= ori;
	mNxScene		= ns;
	//mVehicleInfo.loadFromFile("carinfo.cfg");	
	mDecalShadow = NULL;

	VehicleWheel vw;
	mWheels.push_back(vw);
	mWheels.push_back(vw);
	mWheels.push_back(vw);
	mWheels.push_back(vw);

	loadScene(fileName);

	//load parameter data from file
	Ogre::FileInfoListPtr fp = 
		Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo("Popular", fileName + ".vpf");
	Ogre::String total = fp->back().archive->getName() + "\\" + fileName + ".vpf";
	mVehicleParam.loadFromFile(total);
	refreshParameter();

	mCarNode = mBaseCarNode;

	//创建摄像机节点
	mCameraDerivedNode = mCarNode->createChildSceneNode(Ogre::Vector3(0.0f, mBoundingBox.getSize().y, -mBoundingBox.getSize().z*2));
	mVehicleCamer = new VehicleCamera(fileName + "VehicleCamera", mWindow, mSceneMgr);
	mVehicleCamer->setTarget(mCameraDerivedNode, mCarNode);
	mVehicleCamer->setTightness(2.5f);

	//获取VehicleCamera计算后得到的CameraNode
	mCameraNode = mVehicleCamer->getCameraNode();

	//创建车的附加物体外设
	createPeriphery();

	CompositorManager::getSingleton().addCompositor(mWindow->getViewport(0), "Radial Blur");
	CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0), "Radial Blur", false);

	tforce = ttortue = NxVec3(0, 0, 0);
	isJet = false;
}
OgreNetworkReply::OgreNetworkReply(const QNetworkRequest &request)
{
    setOperation(QNetworkAccessManager::GetOperation);
    setRequest(request);
    setUrl(request.url());

    QString path = request.url().toString(QUrl::RemoveScheme);

    // Remote slashes at the beginning
    while (path.startsWith('/'))
        path = path.mid(1);

    qDebug() << "Opening" << path << "from ogre resource.";

    Ogre::ResourceGroupManager &resourceManager = Ogre::ResourceGroupManager::getSingleton();

    qRegisterMetaType<QNetworkReply::NetworkError>("QNetworkReply::NetworkError");

    /* Is it a directory? */
    Ogre::FileInfoListPtr fileInfo = resourceManager.findResourceFileInfo("General", path.toStdString(), true);
    if (fileInfo->size() > 0) {
        QString msg = QString("Cannot open %1: Path is a directory").arg(path);
        setError(ContentOperationNotPermittedError, msg);
        QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
                                  Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ContentOperationNotPermittedError));
        QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
        return;
    }

    try {
        mDataStream = resourceManager.openResource(path.toStdString());
    } catch (Ogre::FileNotFoundException &e) {
        qWarning("Couldn't find %s: %s", qPrintable(path), e.getFullDescription().c_str());
        setError(ContentNotFoundError, "Couldn't find " + path);
        QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
                                  Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ContentNotFoundError));
        QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
        return;
    }

    open(QIODevice::ReadOnly);

    setHeader(QNetworkRequest::ContentLengthHeader, mDataStream->size());

    QMetaObject::invokeMethod(this, "metaDataChanged", Qt::QueuedConnection);
    QMetaObject::invokeMethod(this, "downloadProgress", Qt::QueuedConnection,
                              Q_ARG(qint64, mDataStream->size()), Q_ARG(qint64, mDataStream->size()));
    QMetaObject::invokeMethod(this, "readyRead", Qt::QueuedConnection);
    QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
}
	const VectorString& Ogre2DataManager::getDataListNames(const std::string& _pattern, bool _fullpath)
	{
		static VectorString result;
		result.clear();

		VectorString search;
		if (mAllGroups)
		{
			Ogre::StringVector sp = Ogre::ResourceGroupManager::getSingleton().getResourceGroups();
			search.reserve(sp.size());
			for (size_t i = 0; i < sp.size(); i++)
				search.push_back(sp[i]);
		}
		else
			search.push_back(mGroup);

		std::vector<Ogre::FileInfoListPtr> pFileInfos;

		int resultSize = 0;
		for (size_t i = 0; i < search.size(); i++)
		{
			Ogre::FileInfoListPtr pFileInfo = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(search[i], _pattern);
			resultSize += pFileInfo->size();
			if (!pFileInfo->empty())
				pFileInfos.push_back(pFileInfo);
			else
				pFileInfo.setNull();
		}

		result.reserve(resultSize);

		for (size_t i = 0; i < pFileInfos.size(); i++)
		{
			Ogre::FileInfoListPtr pFileInfo = pFileInfos[i];
			for (Ogre::FileInfoList::iterator fi = pFileInfo->begin(); fi != pFileInfo->end(); ++fi )
			{
				if (fi->path.empty())
				{
					bool found = false;
					for (VectorString::iterator iter = result.begin(); iter != result.end(); ++iter)
					{
						if (*iter == fi->filename)
						{
							found = true;
							break;
						}
					}
					if (!found)
					{
						result.push_back(_fullpath ? fi->archive->getName() + "/" + fi->filename : fi->filename);
					}
				}
			}

			pFileInfo.setNull();
		}

		return result;
	}
void
ObjectPropertyEditor::onSelectObject(const Fairy::ObjectPtr& object)
{
    mPropertiesViewer->GetGrid()->Clear();
    mCurrentObject = object;

	if (mObjNameList.GetCount()<=0)
	{
		Ogre::FileInfoListPtr fileInfoList =
			Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
			Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
			"*.obj");

		for(Ogre::FileInfoList::const_iterator it = fileInfoList->begin(); it != fileInfoList->end(); ++it)
		{	
			const Ogre::String name = it->filename;
			mObjNameList.AddString(name.c_str());
		}
	}

    const Fairy::PropertyList& properties = object->getProperties();
    for (Fairy::PropertyList::const_iterator it = properties.begin(); it != properties.end(); ++it)
    {
        const Fairy::PropertyDef& propertyDef = *it;
        Fairy::uint propertyFlags = object->getPropertyFlags(propertyDef.name);	
		wxPGId id;
		if (propertyDef.name == "actor name")
		{
			wxPGProperty* property = NULL;
			wxString name = propertyDef.name.c_str();
			property = wxEnumProperty(name, name, mObjNameList);
			property->SetValueFromString(propertyDef.defaultValue.c_str(),0);
			id = AddPropertyRecursive(property);
		}
		else
		{
			id = AddPropertyRecursive(mPropertyManager->CreateProperty(propertyDef));
		}
			
		wxPGIdToPtr(id)->SetValueFromString(AS_STRING(object->getPropertyAsString(propertyDef.name)), wxPG_FULL_VALUE);
		
		if (propertyFlags & Fairy::PF_READONLY)
        {
            mPropertiesViewer->DisableProperty(id);
        }
    }

    mPropertiesViewer->Refresh();
}
Beispiel #5
0
std::vector<std::wstring> ManipulatorEffect::GetAttachEffectMeshNames()
{
	std::vector<std::wstring> ret;

	Ogre::FileInfoListPtr fileinfo = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
		"Effect", "*.mesh");

	for(auto iter=fileinfo->begin(); iter!=fileinfo->end(); ++iter)
	{
		const Ogre::FileInfo& info = *iter;
		ret.push_back(Utility::EngineToUnicode(info.basename));
	}

	return std::move(ret);
}
Beispiel #6
0
    /* Always get the actual pointers, because they may change. That is the reason why the datablock pointer cannot be cached.
     * The same seems to apply to the texture pointer.
     */
    Ogre::HlmsDatablock* datablock;
    Ogre::HlmsPbsDatablock* datablockPbs;
    Ogre::TexturePtr texture;
    Ogre::HlmsManager* hlmsManager = Ogre::Root::getSingletonPtr()->getHlmsManager();
    Ogre::HlmsPbs* hlmsPbs = static_cast<Ogre::HlmsPbs*>(hlmsManager->getHlms(Ogre::HLMS_PBS));
    datablock = hlmsPbs->getDatablock(mDatablockId);
    if (!datablock)
        return;

    datablockPbs = static_cast<Ogre::HlmsPbsDatablock*>(datablock);
    try
    {
        // Get texture on GPU
        if (!datablockPbs->getTexture(mTextureType).isNull())
        {
            texture = datablockPbs->getTexture(mTextureType); // TextureType MUST exist, otherwise the application crashes
            mNumMipMaps = texture->getNumMipmaps();
        }
    }
    catch (Ogre::Exception e){}

    if (texture.isNull())
        return;

    Ogre::uint8 maxMipMaps = mNumMipMaps + 1; // Increase with one, because there is always one image to blit
    maxMipMaps = maxMipMaps > PAINT_MAX_MIP_MAPS ? PAINT_MAX_MIP_MAPS : maxMipMaps; // Just paint a few mipmaps (not all)
    Ogre::Image textureOnWhichIsPaintedScaled = mTextureOnWhichIsPainted; // Temporary image must be used, otherwise painting doesn't work
    size_t w = mTextureOnWhichIsPaintedWidth;
    size_t h = mTextureOnWhichIsPaintedHeight;
    Ogre::v1::HardwarePixelBuffer* buffer;
    for (Ogre::uint8 i = 0; i < maxMipMaps; ++i)
    {
        buffer = texture->getBuffer(0, i).getPointer();
        buffer->blitFromMemory(textureOnWhichIsPaintedScaled.getPixelBox(0, 0), Ogre::Box(0, 0, 0, w, h, 1));
        w*=0.5f; // Mipmaps always are half of the previous one
        h*=0.5f;
        if (w < 1.0f || h < 1.0f)
            break; // Stop when the mipmaps are too small

        textureOnWhichIsPaintedScaled.resize(w, h);

    }
    textureOnWhichIsPaintedScaled.freeMemory();
}

//****************************************************************************/
void TextureLayer::setFirstTextureGeneration (void)
{
    // Don't check on existence mTextureFileName, because it does exist
    loadTextureGeneration(mTextureFileName);
}

//****************************************************************************/
void TextureLayer::setLastTextureGeneration (void)
{
    Ogre::String textureFileNameGeneration = getTextureFileNameGeneration (mMaxSequence); // returns full qualified filename
    if (textureFileExists(textureFileNameGeneration))
        loadTextureGeneration(textureFileNameGeneration);
}

//****************************************************************************/
void TextureLayer::loadTextureGeneration (Ogre::ushort sequence)
{
    Ogre::String textureFileNameGeneration = getTextureFileNameGeneration (sequence); // returns full qualified filename
    if (sequence == 0)
        loadTextureGeneration(textureFileNameGeneration); // Don't check the filename if sequence is 0, because it is without path
    else if (textureFileExists(textureFileNameGeneration))
        loadTextureGeneration(textureFileNameGeneration);
}

//****************************************************************************/
void TextureLayer::loadTextureGeneration (const Ogre::String& filename)
{
    // Assume the filename exists
    mTextureOnWhichIsPainted.load(filename, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    mPixelboxTextureOnWhichIsPainted = mTextureOnWhichIsPainted.getPixelBox(0, 0);
    mTextureOnWhichIsPaintedHasAlpha = mTextureOnWhichIsPainted.getHasAlpha();
    mTextureOnWhichIsPaintedWidth = mPixelboxTextureOnWhichIsPainted.getWidth();
    mTextureOnWhichIsPaintedHeight = mPixelboxTextureOnWhichIsPainted.getHeight();
    // In theory, createCarbonCopyTexture() of all related paintlayers should be called,
    // but the texture size doesn't change in practice.

    blitTexture();
}

//****************************************************************************/
void TextureLayer::saveTextureGeneration (void)
{
    // Increase the sequence
    ++mMaxSequence;
    Ogre::String textureFileNameGeneration = getTextureFileNameGeneration (mMaxSequence); // returns full qualified filename

    // Saving the Image must be done in the background, otherwise the painting stutters
    QThread* thread = new QThread;
    TextureSaveWorker* textureSaveWorker = new TextureSaveWorker (mTextureOnWhichIsPainted, textureFileNameGeneration);
    textureSaveWorker->moveToThread(thread);
    connect(thread, SIGNAL(started()), textureSaveWorker, SLOT(saveImage()));
    connect(textureSaveWorker, SIGNAL(finished()), thread, SLOT(quit()));
    connect(textureSaveWorker, SIGNAL(finished()), textureSaveWorker, SLOT(deleteLater()));
    connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
    thread->start();
}

//****************************************************************************/
const Ogre::String& TextureLayer::saveTextureWithTimeStampToImportDir (void)
{
    Ogre::String strippedTextureFileName = mTextureFileName;
    Ogre::String extension = mTextureFileName;
    strippedTextureFileName.erase(strippedTextureFileName.find_last_of("."), Ogre::String::npos); // Remove extension
    if (strippedTextureFileName.find("_hlms") != Ogre::String::npos)
        strippedTextureFileName.erase(strippedTextureFileName.find("_hlms"), Ogre::String::npos); // Remove earlier hlms editor additions
    extension.erase(0, extension.find_last_of("."));
    mHelperString = strippedTextureFileName +
            "_hlms" +
            Ogre::StringConverter::toString((size_t)time(0)) +
            extension;

    mTextureOnWhichIsPainted.save(DEFAULT_IMPORT_PATH.toStdString() + mHelperString); // Saving to the import dir doesn't have to be in the background
    return mHelperString; // Return the basename
}

//****************************************************************************/
const Ogre::String& TextureLayer::getTextureFileNameGeneration (int sequence, bool fullQualified)
{
    mHelperString = mTextureFileName;

    // Do not go beyond the max sequence number
    sequence = sequence > mMaxSequence ? mMaxSequence : sequence;
    if (sequence > 0)
    {
        // Do not go below sequence number 1 (otherwise the original mTextureFileName (without path) is returned)
        Ogre::String strippedTextureFileName = mTextureFileName;
        Ogre::String extension = mTextureFileName;
        strippedTextureFileName.erase(strippedTextureFileName.find_last_of("."), Ogre::String::npos);
        extension.erase(0, extension.find_last_of("."));
        mHelperString = strippedTextureFileName +
                Ogre::StringConverter::toString(sequence) +
                extension;

        if (fullQualified)
            mHelperString = TEMP_PATH + mHelperString;
    }

    return mHelperString;
}

//****************************************************************************/
bool TextureLayer::isTextureFileNameDefinedAsResource (const Ogre::String& filename)
{
    Ogre::String path;
    Ogre::FileInfoListPtr list = Ogre::ResourceGroupManager::getSingleton().listResourceFileInfo(Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME) ;
    Ogre::FileInfoList::iterator it;
    Ogre::FileInfoList::iterator itStart = list->begin();
    Ogre::FileInfoList::iterator itEnd = list->end();
    for(it = itStart; it != itEnd; ++it)
    {
        Ogre::FileInfo& fileInfo = (*it);
        if (fileInfo.basename == filename || fileInfo.filename == filename)
            return true;
    }

    return false;
}
Beispiel #7
0
void
ReshapeDialog::ReloadTextureList(void)
{

	if (!Ogre::ResourceGroupManager::getSingletonPtr())
		return;

	Ogre::Codec::CodecIterator it = Ogre::Codec::getCodecIterator();
	while (it.hasMoreElements())
	{
		const Ogre::String& ext = it.peekNextKey();
		Ogre::Codec* codec = it.getNext();
		if (codec->getDataType() != "ImageData")
			continue;

		Ogre::FileInfoListPtr fileInfoList =
			Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
			AS_STRING(mResourceGroup),
			"*." + ext);
		for (Ogre::FileInfoList::const_iterator it = fileInfoList->begin(); it != fileInfoList->end(); ++it)
		{
			Ogre::String path, baseName;
			Ogre::StringUtil::splitFilename(it->filename, baseName, path);




			// 把相对路径的最后一个/去掉
			if (!path.empty() && path[path.length()-1] == '/')
				path.erase(path.length() - 1);

			Ogre::String value;
			if(path.empty())
			{
				value = baseName;
			}
			else
			{
				value = path + "/" + baseName;
			}

			mCmbTexture->AppendString( wxT(baseName) );

			pathNameMap.insert(make_pair(baseName,value));
		}
	}
}
Beispiel #8
0
const Ogre::StringVector& ManipulatorTerrain::GetAllLayerTexThumbnailNames()
{
	m_vecLayerTex.clear();

	Ogre::FileInfoListPtr fileinfo = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
		"TerrainTextures", "*.png");

	int i = 0;
	m_vecLayerTex.resize(fileinfo->size());
	for (auto iter=fileinfo->begin(); iter!=fileinfo->end(); ++iter)
	{
		const Ogre::FileInfo& info = (*iter);
		m_vecLayerTex[i++] = info.archive->getName() + "/" + info.filename;
	}

	return m_vecLayerTex;
}
Beispiel #9
0
std::vector<std::wstring> ManipulatorEffect::GetParticleTmpNames() const
{
	std::vector<std::wstring> ret;

	Ogre::FileInfoListPtr fileinfo = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
		"ParticleUniverse", "*.pu");

	for(auto iter=fileinfo->begin(); iter!=fileinfo->end(); ++iter)
	{
		const Ogre::FileInfo& info = *iter;
		STRING obasename, oextname;
		Ogre::StringUtil::splitBaseFilename(info.basename, obasename, oextname);
		ret.push_back(Utility::EngineToUnicode(obasename));
	}

	return std::move(ret);
}
Beispiel #10
0
std::string AssetsManager::resolveFilePathForMesh(Ogre::MeshPtr meshPtr)
{
	Ogre::ResourceGroupManager& manager = Ogre::ResourceGroupManager::getSingleton();
	const std::multimap<std::string, std::string>& locations = EmberOgre::getSingleton().getResourceLocations();

	for (std::multimap<std::string, std::string>::const_iterator I = locations.begin(); I != locations.end(); ++I) {
		std::string group = I->first;
		std::string fileName = meshPtr->getName();
		Ogre::FileInfoListPtr files = manager.findResourceFileInfo(group, fileName, false);
		for (Ogre::FileInfoList::const_iterator J = files->begin(); J != files->end(); ++J) {
			if (J->filename == fileName) {
				return I->second + J->filename;
			}
		}
	}
	return "";

}
Beispiel #11
0
void SoundBank::openFile(std::string path, std::string id, int index)
{
	std::string foundPath = path;
	Ogre::ResourceGroupManager* groupManager = Ogre::ResourceGroupManager::getSingletonPtr() ;
	Ogre::String group = groupManager->findGroupContainingResource(path) ;
	Ogre::FileInfoListPtr fileInfos = groupManager->findResourceFileInfo(group,foundPath);
	Ogre::FileInfoList::iterator it = fileInfos->begin();
	if(it != fileInfos->end())
	{
		foundPath = it->archive->getName() + "/" + foundPath;
	}
	else
	{
		foundPath = "";
	}

	this->addSound(new SoundChunk(foundPath), id, index);
}
        std::string findFilePath(const std::string& filename)
        {
          // on demand init
          Model::initRessources() ;
          
          std::string foundPath = filename;
          Ogre::ResourceGroupManager* groupManager = Ogre::ResourceGroupManager::getSingletonPtr() ;
          Ogre::String group = groupManager->findGroupContainingResource(filename) ;
          Ogre::FileInfoListPtr fileInfos = groupManager->findResourceFileInfo(group,foundPath);
          Ogre::FileInfoList::iterator it = fileInfos->begin();
          if(it != fileInfos->end())
          {
            foundPath = it->archive->getName() + "/" + foundPath;
            foundPath;
          }
          else
            foundPath = "";

          return foundPath;
        }
Beispiel #13
0
KBOOL Kylin::PathwayLoader::Load( KCCHAR* pScene )
{
	Ogre::FileInfoListPtr resPtr = Ogre::ResourceGroupManager::getSingletonPtr()->findResourceFileInfo("General", pScene);
	Ogre::FileInfo fInfo = (*(resPtr->begin()));
	
	KSTR sName = StringUtils::replace(pScene,".xml","_pathway.xml");
	KSTR sPath = fInfo.archive->getName();
	sPath += "/" + sName;
	
	XmlStream kXml(sPath.data());
	if (!kXml.Open(XmlStream::Read))
		return false;

	KBOOL bScene = kXml.SetToFirstChild("pathway");
	while (bScene)
	{
		Pathway* pPathway = KNEW Pathway;

		KUINT id		= kXml.GetAttrInt("id");
		KBOOL bTurnback = kXml.GetAttrBool("turnback");

		KBOOL bPoint = kXml.SetToFirstChild("point");
		while (bPoint)
		{
			KFLOAT fX = kXml.GetAttrFloat("x");
			KFLOAT fZ = kXml.GetAttrFloat("z");
		
			pPathway->Add(KPoint3(fX,0,fZ));

			bPoint = kXml.SetToNextChild("point");
		}

		m_kPathwayMap.insert(std::pair<KUINT,Pathway*>(id,pPathway));

		bScene = kXml.SetToNextChild("pathway");
	}

	kXml.Close();

	return true;
}
void MaterialEditorDialog::InitMaterialCombo(void)
{
	typedef std::list<Ogre::String> MaterialFileNameList;
	MaterialFileNameList materialFileNameList;

	Ogre::FileInfoListPtr fileInfoList =
		Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
		Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
		"*.material");
	for (Ogre::FileInfoList::const_iterator it = fileInfoList->begin(); it != fileInfoList->end(); ++it)
	{
		if ( it->archive->getName() == EFFECT_PATH)
		{
			materialFileNameList.push_back(it->filename);
		}
	}

	Ogre::ResourceManager::ResourceMapIterator resourceMapIterator = Ogre::MaterialManager::getSingleton().getResourceIterator();

	while ( resourceMapIterator.hasMoreElements() )
	{				
		Ogre::String matName = resourceMapIterator.peekNextValue()->getName();

		for ( MaterialFileNameList::iterator i = materialFileNameList.begin();
			i != materialFileNameList.end(); ++i )
		{
			if ( *i == resourceMapIterator.peekNextValue()->getOrigin() )
			{
				mMaterialComboBox->Append(matName);

				break;

			}
		}

		resourceMapIterator.moveNext();
	}

}
    //-----------------------------------------------------------------------
    DataStreamPtr ZipArchive::open(const String& filename, bool readOnly)
    {
        // zziplib is not threadsafe
        OGRE_LOCK_AUTO_MUTEX;
        String lookUpFileName = filename;

        // Format not used here (always binary)
        ZZIP_FILE* zzipFile = 
            zzip_file_open(mZzipDir, lookUpFileName.c_str(), ZZIP_ONLYZIP | ZZIP_CASELESS);
        if (!zzipFile) // Try if we find the file
        {
            const Ogre::FileInfoListPtr fileNfo = findFileInfo(lookUpFileName, true);
            if (fileNfo->size() == 1) // If there are more files with the same do not open anyone
            {
                Ogre::FileInfo info = fileNfo->at(0);
                lookUpFileName = info.path + info.basename;
                zzipFile = zzip_file_open(mZzipDir, lookUpFileName.c_str(), ZZIP_ONLYZIP | ZZIP_CASELESS); // When an error happens here we will catch it below
            }
        }

        if (!zzipFile)
        {
            int zerr = zzip_error(mZzipDir);
            String zzDesc = getZzipErrorDescription((zzip_error_t)zerr);
            LogManager::getSingleton().logMessage(
                mName + " - Unable to open file " + lookUpFileName + ", error was '" + zzDesc + "'", LML_CRITICAL);
                
            // return null pointer
            return DataStreamPtr();
        }

        // Get uncompressed size too
        ZZIP_STAT zstat;
        zzip_dir_stat(mZzipDir, lookUpFileName.c_str(), &zstat, ZZIP_CASEINSENSITIVE);

        // Construct & return stream
        return DataStreamPtr(OGRE_NEW ZipDataStream(lookUpFileName, zzipFile, static_cast<size_t>(zstat.st_size)));

    }
Beispiel #16
0
bool GameState::loadSceneFile(Ogre::String filename,NXU::NXU_FileType type)
{
	bool success = false;

	if (mPhysicsSDK)
	{
		Ogre::String totalname;

		//获得完整文件路径
		Ogre::FileInfoListPtr svp = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo("Popular", filename);
		totalname = svp->back().archive->getName() + "/" + filename;
		Ogre::StringVector sv = Ogre::StringUtil::split(totalname, "/");
		totalname = sv[0];
		for (unsigned int i = 1;i<sv.size();i++)
			totalname += "\\\\" + sv[i];

		//读取场景
		NXU::NxuPhysicsCollection *c = NXU::loadCollection(totalname.c_str(), type );
		if ( c )
		{
			if (mPhysicScene)
			{
				mPhysicsSDK->releaseScene(*mPhysicScene);
			}

			if (mPhysicsSDK)
			{
				success = NXU::instantiateCollection( c, *mPhysicsSDK, 0, 0, 0);
				mPhysicScene = mPhysicsSDK->getScene(0);
			}
			NXU::releaseCollection(c);
		}
		else
		{
		}
	}

	return success;
}
Beispiel #17
0
// Carga del recurso.
void Track::loadImpl() {
  Ogre::LogManager* pLogManager = Ogre::LogManager::getSingletonPtr();

  // Ruta al archivo.
  Ogre::FileInfoListPtr info;
  info = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(mGroup, mName);

  for (Ogre::FileInfoList::const_iterator i = info->begin(); i != info->end(); ++i) {
    _path = i->archive->getName() + "/" + i->filename;
  }
 
  // Archivo no encontrado...
  if (_path == "") {
    pLogManager->logMessage("Track::loadImpl() Imposible cargar el recurso de sonido.");
    throw (Ogre::Exception(Ogre::Exception::ERR_FILE_NOT_FOUND,
			   "Archivo no encontrado", "Track::loadImpl()"));
  }
    cout << "\n\nPath: " << _path << "\n\n" << endl;
    // Cargar el recurso de sonido.
    if ((_pTrack = Mix_LoadMUS(_path.c_str())) == NULL) {
      pLogManager->logMessage("Track::loadI() Imposible cargar el recurso de sonido.");
      throw (Ogre::Exception(Ogre::Exception::ERR_FILE_NOT_FOUND,
			     "Archivo no encontrado", "Track::loadI()"));
    }
    
    // Cálculo del tamaño del recurso de sonido.
    std::ifstream stream;
    char byteBuffer;
    stream.open(_path.c_str(), std::ios_base::binary);
 
    while (stream >> byteBuffer) {
      _size++;
    }
    
    stream.close();
}
void 
MaterialPreviewDialog::InitPreviewGrids(void)
{

	wxFlexGridSizer *item0 = new wxFlexGridSizer( 6, 0, 0 );

	typedef std::list<Ogre::String> MaterialFileNameList;
	MaterialFileNameList materialFileNameList;

	Ogre::FileInfoListPtr fileInfoList =
		Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
		Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
		"*.material");
	for (Ogre::FileInfoList::const_iterator it = fileInfoList->begin(); it != fileInfoList->end(); ++it)
	{
		if ( it->archive->getName() == EFFECT_PATH)
		{
			materialFileNameList.push_back(it->filename);
		}
	}

	wxComboBox *matCombo = mParentDialog->mMaterialComboBox;
	assert (matCombo);

	for ( int i=0; i<matCombo->GetCount(); ++i )
	{
		Ogre::String matName = matCombo->GetString(i);

		Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().getByName(matName);			

		if (mat.isNull())
		{
		}
		else
		{
			size_t numOfTex = mat->getTechnique(0)->getPass(0)->getNumTextureUnitStates();
			if (numOfTex > 0)
			{
				Ogre::String texName = mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->getTextureName();
				if (texName.empty() == false)
				{
					wxBoxSizer *item1 = new wxBoxSizer( wxVERTICAL );

					wxStaticBitmap *item2 = new wxStaticBitmap( this, ID_STATICBITMAP, TexturePreview( 0 ), wxDefaultPosition, wxSize(64,64) );
					item1->Add( item2, 0, wxALIGN_CENTER|wxALL, 5 );

					wxStaticText *item3 = new wxStaticText( this, ID_TEXT_MATERIAL_NAME, _("text"), wxDefaultPosition, wxDefaultSize, 0 );
					item1->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );

					wxButton *item4 = new wxButton( this, ID_BUTTON_USE, _("Use"), wxDefaultPosition, wxDefaultSize, 0 );
					item1->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );

					item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );

					buildPreviewBitmap( texName );
					item2->SetBitmap(mCurrentPreviewImage);
					item3->SetLabel(texName.c_str());
					item4->SetLabel(matName.c_str());
				}
			}
		}
	}

	this->SetSizer( item0 );
	item0->SetSizeHints( this );
}
void RoR::GUI::GameSettings::Draw()
{
    bool is_visible = true;
    const int flags = ImGuiWindowFlags_NoCollapse;
    ImGui::SetNextWindowSize(ImVec2(600.f, 400.f), ImGuiSetCond_FirstUseEver);
    ImGui::SetNextWindowPosCenter(ImGuiSetCond_Appearing);
    ImGui::Begin(_LC("GameSettings", "Game settings"), &is_visible, flags);
    if (! is_visible)
    {
        this->SetVisible(false);
        if (App::app_state.GetActive() == RoR::AppState::MAIN_MENU)
        {
            App::GetGuiManager()->SetVisible_GameMainMenu(true);
        }
        ImGui::End();
        return;
    }

    // 'Tabs' buttons
    ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4.f, 8.f));

    if (ImGui::Button(_LC("GameSettings", "Render System"))) { m_tab = SettingsTab::RENDER_SYSTEM; }
    ImGui::SameLine();
    if (ImGui::Button(_LC("GameSettings", "General")))       { m_tab = SettingsTab::GENERAL;       }
    ImGui::SameLine();
    if (ImGui::Button(_LC("GameSettings", "Graphics")))      { m_tab = SettingsTab::GRAPHICS;      }
    ImGui::SameLine();
#ifdef USE_OPENAL
    if (ImGui::Button(_LC("GameSettings", "Audio")))         { m_tab = SettingsTab::AUDIO;         }
    ImGui::SameLine();
#endif // USE_OPENAL
    if (ImGui::Button(_LC("GameSettings", "Controls")))      { m_tab = SettingsTab::CONTROL;       }
    ImGui::SameLine();
    if (ImGui::Button(_LC("GameSettings", "Diagnostic")))    { m_tab = SettingsTab::DIAG;          }
    ImGui::SameLine();
    if (ImGui::Button(_LC("GameSettings", "Update cache")))
    {
        App::app_force_cache_udpate.SetActive(true);
    }

    ImGui::PopStyleVar(1);

    ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 4.f);
    ImGui::Separator();

    if (m_tab == SettingsTab::RENDER_SYSTEM)
    {
        ImGui::TextDisabled(_LC("GameSettings", "Render system (changes require a restart)"));

        const auto ogre_root = App::GetOgreSubsystem()->GetOgreRoot();
        const auto render_systems = ogre_root->getAvailableRenderers();
        std::string render_system_names;
        for (auto rs : render_systems)
        {
            render_system_names += rs->getName() + '\0';
        }
        const auto ro = ogre_root->getRenderSystemByName(App::app_rendersys_override.GetActive());
        const auto rs = ro ? ro : ogre_root->getRenderSystem();
        const auto it = std::find(render_systems.begin(), render_systems.end(), rs);
        int render_id = it != render_systems.end() ? std::distance(render_systems.begin(), it) : 0;
        /* Combobox for selecting the Render System*/
        if (ImGui::Combo(_LC ("GameSettings", "Render System"), &render_id, render_system_names.c_str()))
        {
            App::app_rendersys_override.SetActive(render_systems[render_id]->getName().c_str());
        }

        const auto config_options = ogre_root->getRenderSystem()->getConfigOptions();
        std::set<std::string> filter = {"Allow NVPerfHUD", "Colour Depth", "Fixed Pipeline Enabled",
            "Floating-point mode", "Resource Creation Policy", "VSync Interval", "sRGB Gamma Conversion"};
        for (auto opt : config_options)
        {
            auto co = opt.second;
            if (co.immutable)
                continue;
            if (co.possibleValues.empty())
                continue;
            if (filter.find(co.name) != filter.end())
                continue;
            std::sort(co.possibleValues.rbegin(), co.possibleValues.rend());
            std::string option_values;
            for (auto value : co.possibleValues)
            {
                option_values += value + '\0';
            }
            const auto it = std::find(co.possibleValues.begin(), co.possibleValues.end(), opt.second.currentValue);
            int option_id = it != co.possibleValues.end() ? std::distance(co.possibleValues.begin(), it) : 0;
            if (ImGui::Combo(co.name.c_str(), &option_id, option_values.c_str()))
            {
                rs->setConfigOption(co.name, co.possibleValues[option_id]);
                if (rs->validateConfigOptions().empty())
                {
                    ogre_root->saveConfig();
                }
            }
        }
    }
    else if (m_tab == SettingsTab::GENERAL)
    {
        ImGui::TextDisabled(_LC("GameSettings", "Application settings"));

#ifndef NOLANG
        std::vector<std::pair<std::string, std::string>> languages = LanguageEngine::getSingleton().getLanguages();
        std::string lang_values;
        for (auto value : languages)
        {
            lang_values += value.first + '\0';
        }
        const auto it = std::find_if(languages.begin(), languages.end(),
                [](const std::pair<std::string, std::string>& l) { return l.second == App::app_language.GetActive(); });
        int lang_selection = it != languages.end() ? std::distance(languages.begin(), it) : 0;
        if (ImGui::Combo(_LC("GameSettings", "Language"), &lang_selection, lang_values.c_str()))
        {
            App::app_language.SetActive(languages[lang_selection].second.c_str());
            LanguageEngine::getSingleton().setup();
        }
#endif

        // Country selection
        static Ogre::FileInfoListPtr fl = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo("FlagsRG", "*");
        if (!fl->empty())
        {
            static std::vector<std::string> countries;
            if (countries.empty())
            {
                for (auto& file : *fl)
                {
                    std::string country = Ogre::StringUtil::replaceAll(file.filename, ".png", "");
                    if (country.size() == 2) // RoR protocol limitation
                    {
                        countries.push_back(country);
                    }
                }
                std::sort(countries.begin(), countries.end());
            }
            std::string country_values;
            for (auto value : countries)
            {
                country_values += value + '\0';
            }
            const auto it = std::find(countries.begin(), countries.end(), std::string(App::app_country.GetActive()));
            int country_selection = it != countries.end() ? std::distance(countries.begin(), it) : 0;
            if (ImGui::Combo(_LC("GameSettings", "Country"), &country_selection, country_values.c_str()))
            {
                App::app_country.SetActive(countries[country_selection].c_str());
            }
        }

        int sshot_select = (std::strcmp(App::app_screenshot_format.GetActive(),"jpg") == 0) ? 1 : 0; // Hardcoded; TODO: list available formats.

        /* Screenshot format: Can be png or jpg*/
        if (ImGui::Combo(_LC("GameSettings", "Screenshot format"), &sshot_select, "png\0jpg\0\0"))
        {
            App::app_screenshot_format.SetActive((sshot_select == 1) ? "jpg" : "png");
        }

        DrawGTextEdit(App::app_extra_mod_path, _LC("GameSettings", "Extra mod path"),  m_buf_app_extra_mod_dir);

        DrawGCheckbox(App::app_skip_main_menu, _LC("GameSettings", "Skip main menu"));
        DrawGCheckbox(App::app_async_physics, _LC("GameSettings", "Async physics"));
        DrawGCheckbox(App::app_disable_online_api, _LC("GameSettings", "Disable online api"));

        ImGui::Separator();
        ImGui::TextDisabled(_LC("GameSettings", "Simulation settings"));

        DrawGCombo(App::sim_gearbox_mode, _LC("GameSettings", "Gearbox mode"),
            "Automatic shift\0"
            "Manual shift - Auto clutch\0"
            "Fully Manual: sequential shift\0"
            "Fully manual: stick shift\0"
            "Fully Manual: stick shift with ranges\00");

        DrawGCheckbox(App::gfx_speedo_digital, _LC("GameSettings", "Digital speedometer"));
        DrawGCheckbox(App::gfx_speedo_imperial, _LC("GameSettings", "Imperial speedometer"));

        //DrawGCheckbox(App::gfx_flexbody_lods,      "Enable flexbody LODs");
        //DrawGCheckbox(App::gfx_flexbody_cache,     "Enable flexbody cache");

        DrawGCheckbox(App::sim_spawn_running, _LC("GameSettings", "Engines spawn running"));

        DrawGCheckbox(App::sim_replay_enabled, _LC("GameSettings", "Replay mode"));
        if (App::sim_replay_enabled.GetActive())
        {
            DrawGIntBox(App::sim_replay_length, _LC("GameSettings", "Replay length"));
            DrawGIntBox(App::sim_replay_stepping, _LC("GameSettings", "Replay stepping"));
        }

        DrawGCheckbox(App::sim_realistic_commands, _LC("GameSettings", "Realistic forward commands"));

        DrawGCheckbox(App::sim_races_enabled, _LC("GameSettings", "Enable races"));
        DrawGCheckbox(App::sim_direction_arrow, _LC("GameSettings", "Direction arrow"));

        DrawGCheckbox(App::sim_no_self_collisions, _LC("GameSettings", "No intra truck collisions"));
        DrawGCheckbox(App::sim_no_collisions, _LC("GameSettings", "No inter truck collisions"));
    }
#ifdef USE_OPENAL
    else if (m_tab == SettingsTab::AUDIO)
    {
        ImGui::TextDisabled(_LC("GameSettings", "Audio settings"));

        static const ALCchar *devices = alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER);
        const ALCchar *device = devices, *next = devices + 1;
        std::vector<std::string> audio_devices;

        while (device && *device != '\0' && next && *next != '\0')
        {
                audio_devices.push_back(device);
                size_t len = strlen(device);
                device += (len + 1);
                next += (len + 2);
        }

        const auto it = std::find(audio_devices.begin(), audio_devices.end(), App::audio_device_name.GetActive());
        int device_id = it != audio_devices.end() ? std::distance(audio_devices.begin(), it) : 0;
        if (ImGui::Combo(_LC("GameSettings", "Audio device"), &device_id, devices))
        {
            App::audio_device_name.SetActive(audio_devices[device_id].c_str());
        }

        DrawGCheckbox(App::audio_enable_creak,     _LC("GameSettings", "Creak sound"));
        DrawGCheckbox(App::audio_menu_music,       _LC("GameSettings", "Main menu music"));
        DrawGFloatSlider(App::audio_master_volume, _LC("GameSettings", "Master volume"), 0, 1);
    }
#endif // USE_OPENAL
    else if (m_tab == SettingsTab::GRAPHICS)
    {
        ImGui::TextDisabled(_LC("GameSettings", "Video settings"));

        DrawGCombo(App::gfx_flares_mode, _LC("GameSettings", "Lights"),
            "None (fastest)\0"
            "No light sources\0"
            "Only current vehicle, main lights\0"
            "All vehicles, main lights\0"
            "All vehicles, all lights\0\0");

        DrawGCombo(App::gfx_shadow_type, _LC("GameSettings", "Shadow type"),
            "Disabled\0"
            "Texture\0"
            "PSSM\0\0");

        if (App::gfx_shadow_type.GetActive() != GfxShadowType::NONE)
        {
            DrawGCheckbox(App::gfx_reduce_shadows, _LC("GameSettings", "Shadow optimizations"));
            if (App::gfx_shadow_type.GetActive() == GfxShadowType::PSSM)
            {
                DrawGIntSlider(App::gfx_shadow_quality, _LC("GameSettings", "Shadow quality"), 0, 3);
            }
        }

        DrawGCombo(App::gfx_sky_mode, "Sky gfx",
            "Sandstorm (fastest)\0"
            "Caelum (best looking, slower)\0"
            "SkyX (best looking, slower)\0\0");

        DrawGIntSlider(App::gfx_sight_range, _LC("GameSettings", "Sight range (meters)"), 100, 5000);

        DrawGCombo(App::gfx_texture_filter , _LC("GameSettings", "Texture filtering"),
            "None\0"
            "Bilinear\0"
            "Trilinear\0"
            "Anisotropic\0\0");

        if (App::gfx_texture_filter.GetActive() == GfxTexFilter::ANISOTROPIC)
        {
            int anisotropy = Ogre::Math::Clamp(App::gfx_anisotropy.GetActive(), 1, 16);
            int  selection = std::log2(anisotropy);
            if (ImGui::Combo(_LC("GameSettings", "Anisotropy"), &selection, "1\0""2\0""4\0""8\0""16\0\0"))
            {
                App::gfx_anisotropy.SetActive(std::pow(2, selection));
            }
        }

        DrawGCombo(App::gfx_vegetation_mode, _LC("GameSettings", "Vegetation density"),
            "None\0"
            "20%\0"
            "50%\0"
            "Full\0\0");

        DrawGCombo(App::gfx_water_mode, _LC("GameSettings", "Water gfx"),
            "None\0"
            "Basic (fastest)\0"
            "Reflection\0"
            "Reflection + refraction (speed optimized)\0"
            "Reflection + refraction (quality optimized)\0"
            "HydraX\0\0");

        DrawGIntSlider(App::gfx_fps_limit,       _LC("GameSettings", "FPS limit"), 0, 240);

        DrawGIntCheck(App::gfx_particles_mode,   _LC("GameSettings", "Enable particle gfx"));
        DrawGIntCheck(App::gfx_skidmarks_mode,   _LC("GameSettings", "Enable skidmarks"));

        DrawGCheckbox(App::gfx_envmap_enabled,   _LC("GameSettings", "Realtime reflections"));
        if (App::gfx_envmap_enabled.GetActive())
        {
            ImGui::PushItemWidth(125.f); // Width includes [+/-] buttons
            DrawGIntSlider(App::gfx_envmap_rate, _LC("GameSettings", "Realtime refl. update rate"), 0, 6);
            ImGui::PopItemWidth();
        }

        DrawGCheckbox(App::gfx_enable_videocams, _LC("GameSettings", "Render video cameras"));
        DrawGCheckbox(App::gfx_surveymap_icons,  _LC("GameSettings", "Overview map icons"));
        if (App::gfx_surveymap_icons.GetActive())
        {
            DrawGCheckbox(App::gfx_declutter_map,  _LC("GameSettings", "Declutter overview map"));
        }
        DrawGCheckbox(App::gfx_water_waves,      _LC("GameSettings", "Waves on water"));

        DrawGCombo(App::gfx_extcam_mode, "Exterior camera mode",
            "None\0"
            "Static\0"
            "Pitching\0\0");

        DrawGIntSlider(App::gfx_camera_height, _LC("GameSettings", "Static camera height (meters)"), 1, 50);
        DrawGIntSlider(App::gfx_fov_external, _LC("GameSettings", "Exterior field of view"), 10, 120);
        DrawGIntSlider(App::gfx_fov_internal, _LC("GameSettings", "Interior field of view"), 10, 120);
    }
    else if (m_tab == SettingsTab::DIAG)
    {
        ImGui::TextDisabled(_LC("GameSettings", "Diagnostic options"));

        int physics_fps = std::round(1.0f / App::diag_physics_dt.GetActive());
        if (ImGui::SliderInt(_LC("GameSettings", "Physics frames per second"), &physics_fps, 2000, 10000))
        {
            App::diag_physics_dt.SetActive(Ogre::Math::Clamp(1.0f / physics_fps, 0.0001f, 0.0005f));
        }
        DrawGTextEdit(App::diag_preset_terrain,      _LC("GameSettings", "Preselected terrain"),         m_buf_diag_preset_terrain, false);
        DrawGTextEdit(App::diag_preset_vehicle,      _LC("GameSettings", "Preselected vehicle"),         m_buf_diag_preset_vehicle, true);
        DrawGTextEdit(App::diag_preset_veh_config,   _LC("GameSettings", "Presel. veh. config"),         m_buf_diag_preset_veh_config);
        DrawGCheckbox(App::diag_preset_veh_enter,    _LC("GameSettings", "Enter preselected vehicle"));
        DrawGCheckbox(App::diag_auto_spawner_report, _LC("GameSettings", "Auto actor spawner report"));
        DrawGCheckbox(App::diag_rig_log_node_import, _LC("GameSettings", "Log node import (spawn)"));
        DrawGCheckbox(App::diag_rig_log_node_stats,  _LC("GameSettings", "Log node stats (spawn)"));
        DrawGCheckbox(App::diag_rig_log_messages,    _LC("GameSettings", "Log messages (spawn)"));
        DrawGCheckbox(App::diag_camera,              _LC("GameSettings", "Debug camera (rails)"));
        DrawGCheckbox(App::diag_collisions,          _LC("GameSettings", "Debug collisions"));
        DrawGCheckbox(App::diag_truck_mass,          _LC("GameSettings", "Debug actor mass"));
        DrawGCheckbox(App::diag_envmap,              _LC("GameSettings", "Debug realtime reflections"));
        DrawGCheckbox(App::diag_videocameras,        _LC("GameSettings", "Debug videocameras"));
        DrawGCheckbox(App::diag_warning_texture,     _LC("GameSettings", "Debug textures"));
        DrawGCheckbox(App::diag_hide_broken_beams,   _LC("GameSettings", "Hide broken beams"));
        DrawGCheckbox(App::diag_hide_wheel_info,     _LC("GameSettings", "Hide wheel info"));
        DrawGCheckbox(App::diag_hide_wheels,         _LC("GameSettings", "Hide wheels"));
        DrawGCheckbox(App::diag_hide_nodes,          _LC("GameSettings", "Hide nodes"));
        DrawGCheckbox(App::diag_log_console_echo,    _LC("GameSettings", "Echo log to console"));
        DrawGCheckbox(App::diag_log_beam_break,      _LC("GameSettings", "Log beam breaking"));
        DrawGCheckbox(App::diag_log_beam_deform,     _LC("GameSettings", "Log beam deforming"));
        DrawGCheckbox(App::diag_log_beam_trigger,    _LC("GameSettings", "Log beam triggers"));
        if (ImGui::Button(_LC("GameSettings", "Rebuild cache")))
        {
            App::app_force_cache_purge.SetActive(true);
        }
    }
    else if (m_tab == SettingsTab::CONTROL)
    {
        ImGui::TextDisabled(_LC("GameSettings", "Controller options"));

        DrawGCombo(App::io_input_grab_mode, _LC("GameSettings", "Input grab mode"),
            "None\0"
            "All\0"
            "Dynamic\0\0");

        DrawGFloatSlider(App::io_analog_smoothing,   _LC("GameSettings", "Analog Input Smoothing"),   0.5f, 2.0f);
        DrawGFloatSlider(App::io_analog_sensitivity, _LC("GameSettings", "Analog Input Sensitivity"), 0.5f, 2.0f);

        DrawGCheckbox(App::io_arcade_controls, _LC("GameSettings", "Use arcade controls"));

        DrawGCheckbox(App::io_ffb_enabled, _LC("GameSettings", "Enable ForceFeedback"));
        if (App::io_ffb_enabled.GetActive())
        {
            ImGui::PushItemWidth(125.f);
            DrawGFloatBox(App::io_ffb_camera_gain, _LC("GameSettings", "FFB camera gain"));
            DrawGFloatBox(App::io_ffb_center_gain, _LC("GameSettings", "FFB center gain"));
            DrawGFloatBox(App::io_ffb_master_gain, _LC("GameSettings", "FFB master gain"));
            DrawGFloatBox(App::io_ffb_stress_gain, _LC("GameSettings", "FFB stress gain"));
            ImGui::PopItemWidth();
        }

        DrawGIntCheck(App::io_outgauge_mode, _LC("GameSettings", "Enable OutGauge protocol"));
        if (App::io_outgauge_mode.GetActive())
        {
            DrawGTextEdit(App::io_outgauge_ip, _LC("GameSettings", "OutGauge IP"), m_buf_io_outgauge_ip);
            ImGui::PushItemWidth(125.f);
            DrawGIntBox(App::io_outgauge_port,    _LC("GameSettings", "OutGauge port"));
            DrawGIntBox(App::io_outgauge_id,      _LC("GameSettings", "OutGauge ID"));
            DrawGFloatBox(App::io_outgauge_delay, _LC("GameSettings", "OutGauge delay"));
            ImGui::PopItemWidth();
        }
    }

    ImGui::End();
}
Beispiel #20
0
void gkDebugScreen::initialize()
{
	if (m_isInit)
		return;

	try
	{

		m_font = new gkBuiltinFont;
		Ogre::FontPtr fp = Ogre::FontManager::getSingleton().create("<gkBuiltin/Font>", GK_BUILTIN_GROUP, true, m_font);
		fp->load();

#define  FONT_MATERIAL 1
#if FONT_MATERIAL

#ifndef OGREKIT_USE_OLD
		gkString ShareMaterail = "Examples/BumpMapping/MultiLight";
		static int Use_Init_Once = 0;
		if(Use_Init_Once < 2)
		{
			Ogre::FileInfoListPtr fileInfoList =
				Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
				"",
				"*.material");

			for (Ogre::FileInfoList::const_iterator cit=fileInfoList->begin();
				cit != fileInfoList->end();
				++cit) {
					const Ogre::String& name = cit->filename;
					const Ogre::String& basename = cit->basename;
					Ogre::String sType = cit->archive->getType();
					Ogre::String sPath = cit->archive->getName();
					if (sType=="Zip" || sType=="FileSystem") { 
						Ogre::DataStreamPtr pData=
							Ogre::ResourceGroupManager::getSingleton().openResource(
							basename,"");
						Ogre::MaterialManager::getSingleton().parseScript(
							pData, "");
						Ogre::MaterialManager::getSingleton().load(basename,"");
					}
			}
			Use_Init_Once++;
		}	
#endif

		Ogre::MaterialPtr ShareMaterailPtr = Ogre::MaterialManager::getSingleton().getByName(ShareMaterail, "");
		if (!ShareMaterailPtr.isNull())
		{
			ShareMaterailPtr->load();
			//ShareMaterailPtr->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("textureCount",1);
		}

		Ogre::MaterialPtr oma = Ogre::MaterialManager::getSingleton().getByName("Fonts/<gkBuiltin/Font>");

		if (!oma.isNull())
		{
			Ogre::Pass* pass1 = oma->getTechnique(0)->getPass(0);

			Ogre::GpuProgramPtr vsPtr = Ogre::HighLevelGpuProgramManager::getSingleton().getByName("FixVs");

			if (vsPtr.isNull())
			{
				LogManager::getSingleton().logMessage("GpuProgramPtr NULL");
			}

			gkString VertexProgramName = "FixVs";
			gkString FragmentProgramName ="FixPs";

			if (pass1)
			{
				pass1->setVertexProgram(VertexProgramName);
				pass1->setFragmentProgram(FragmentProgramName);
				Ogre::GpuProgramParametersSharedPtr vsParams = pass1->getVertexProgramParameters();
				vsParams->copyMatchingNamedConstantsFrom(*ShareMaterailPtr->getTechnique(0)->getPass(0)->getVertexProgramParameters().get());
				Ogre::GpuProgramParametersSharedPtr psParams = pass1->getFragmentProgramParameters();
				psParams->copyMatchingNamedConstantsFrom(*ShareMaterailPtr->getTechnique(0)->getPass(0)->getFragmentProgramParameters().get());
				//psParams->setNamedConstant("textureCount",1);
				//psParams->setNamedConstant("AlphaValue",0.0f);
				//vsParams->setNamedConstant("lightOpen",0);
				LogManager::getSingleton().logMessage("set font es2.0");
			}
		}
#endif

		Ogre::OverlayManager& mgr = Ogre::OverlayManager::getSingleton();
		m_over  = mgr.create("<gkBuiltin/gkDebugScreen>");
		m_ele   = mgr.createOverlayElement("TextArea", "<gkBuiltin/gkDebugScreen/TextArea>");

		Ogre::OverlayContainer* cont = (Ogre::OverlayContainer*)mgr.createOverlayElement("BorderPanel", "<gkBuiltin/gkDebugScreen/Containter>");
		cont->setMetricsMode(Ogre::GMM_PIXELS);
		cont->setVerticalAlignment(Ogre::GVA_TOP);

		const gkVector2& dims = gkWindowSystem::getSingleton().getMouse()->winsize;

		m_ele->setMetricsMode(Ogre::GMM_PIXELS);
		m_ele->setVerticalAlignment(Ogre::GVA_TOP);
		m_ele->setPosition(0, 0);
		m_ele->setDimensions(dims.x, dims.y);

		Ogre::TextAreaOverlayElement* textArea = static_cast<Ogre::TextAreaOverlayElement*>(m_ele);
		textArea->setFontName("<gkBuiltin/Font>");
		textArea->setCharHeight(SCREEN_SIZE);
		textArea->setColour(Ogre::ColourValue::White);

		m_over->setZOrder(500);
		cont->addChild(m_ele);
		m_over->add2D(cont);
	}
	catch (Ogre::Exception& e)
	{
		gkPrintf("%s", e.getDescription().c_str());
		return;
	}


	m_isInit = true;
	gConsole = this;
}
gkBlendListIterator::gkBlendListIterator(List* list)
	:	m_list(list),
#if OGREKIT_USE_BPARSE
		m_index(0)
#else
		m_index(list ? list->first : 0)
#endif
{
}

bool gkBlendListIterator::hasMoreElements() const
{
	if (m_list == 0) return false;

#if OGREKIT_USE_BPARSE
	return m_index < m_list->size();
#else
	return m_index != 0;
#endif
}


gkBlendListIterator::ListItem* gkBlendListIterator::getNext(void)	 
{ 
#if OGREKIT_USE_BPARSE
	return m_list->at(m_index++);
#else
	ListItem* item = m_index;
	m_index = m_index->next;
	return item;
#endif
}

//--

gkBlendInternalFile::gkBlendInternalFile()
	:	m_file(0)
{
}

gkBlendInternalFile::~gkBlendInternalFile()
{
	delete m_file;
	m_file = 0;
}

bool gkBlendInternalFile::parse(const gkString& fname)
{

	if (fname.empty()) 
	{
		gkLogMessage("BlendFile: File " << fname << " loading failed. File name is empty.");
		return false;
	}

#if OGREKIT_USE_BPARSE

	utMemoryStream fs;
	fs.open(fname.c_str(), utStream::SM_READ);

	if (!fs.isOpen())
	{
		gkLogMessage("BlendFile: File " << fname << " loading failed. No such file.");
		return false;
	}

	// Write contents and inflate.
	utMemoryStream buffer(utStream::SM_WRITE);
	fs.inflate(buffer);

	m_file = new bParse::bBlenderFile((char*)buffer.ptr(), buffer.size());
	m_file->parse(false);

	if (!m_file->ok())
	{
		gkLogMessage("BlendFile: File " << fname << " loading failed. Data error.");
		return false;
	}

#else

	m_file = new fbtBlend();
	int status = m_file->parse(fname.c_str(), fbtFile::PM_COMPRESSED);
	if (status != fbtFile::FS_OK)
	{
		delete m_file;
		m_file = 0;
		gkLogMessage("BlendFile: File " << fname << " loading failed. code: " << status);
		//return false;
	}
	else 
	{
		 gkLogMessage("BlendFile: File " << fname << " loading end1" );
	    return true;
	}
	//gkLogMessage("BlendFile: File " << fname << " loading end" );
	m_file = new fbtBlend();
	Ogre::DataStreamPtr stream;
	Ogre::ArchiveManager::ArchiveMapIterator beginItera = Ogre::ArchiveManager::getSingleton().getArchiveIterator();
	while(beginItera.hasMoreElements())
	{
		typedef std::map<Ogre::String, Ogre::Archive*>::iterator ArchiveIterator;
		ArchiveIterator arch = beginItera.current();	
		if (arch->second)
		{
			 Ogre::FileInfoListPtr fileInfo = arch->second->findFileInfo(fname);
			 if (fileInfo->size() > 0)
			 {
				 stream = arch->second->open(fname);
				 gkLogMessage("BlendFile: File found create stream");
				 break;
			 }
		}
		beginItera.moveNext();
	}
	//gkLogMessage("malloc buffer");
	unsigned char * buffer = new unsigned char[stream->size()];
	//gkLogMessage(" stream->read ");
    long sizeCount = stream->read(buffer,stream->size());
    //gkLogMessage(" m_file->parse");
	if(m_file) m_file->parse(buffer,sizeCount);
	delete buffer;
	//gkLogMessage(" m_file->parse end");
#endif
	return true;
}


Blender::FileGlobal* gkBlendInternalFile::getFileGlobal()
{
	GK_ASSERT(m_file);
	
#if OGREKIT_USE_BPARSE
	return (Blender::FileGlobal*)m_file->getFileGlobal();
#else
	return m_file->m_fg;
#endif
}

int gkBlendInternalFile::getVersion()
{
	GK_ASSERT(m_file);

#if OGREKIT_USE_BPARSE
	return m_file->getMain()->getVersion();
#else
	return m_file->getVersion();
#endif
}
Beispiel #22
0
void
BrushSelector::ReloadTextureList(void)
{
	CatalogMap catalogMap;
	mCatalogMap.clear();

    if (!Ogre::ResourceGroupManager::getSingletonPtr())
        return;

    mBrushesTree->Freeze();

    mBrushesTree->DeleteAllItems();

	wxTreeItemId rootId = mBrushesTree->AddRoot(/*_("Brushes")*/wxT("画刷列表"));
 
    // 重新解析定义文件
    GetSceneManipulator()->reloadPaintInfo();

    const Fairy::TerrainPaintInfoContainer *paintInfoContainer = GetSceneManipulator()->getTerrainPaintInfoContainer();

    assert (paintInfoContainer);

    const Fairy::TextureInfoMap &textureInfoMap = paintInfoContainer->getTextureInfoMap();

	OwnerTexs ownerTextures;

	Fairy::TextureInfoMap::const_iterator it = textureInfoMap.begin();	

    // 遍历画刷数组
    while ( it != textureInfoMap.end() )
    {
        const Fairy::TextureInfos &textureInfos = it->second;
        
        // 遍历该画刷下的所有纹理
        for ( size_t i=0; i<textureInfos.size(); ++i )
        {
            // 取出所属的大纹理的名称
            Ogre::String ownerTexName = textureInfos[i].ownerTextureName;

			// 记录大纹理的名称
			ownerTextures.insert(OwnerTexs::value_type(ownerTexName, ownerTexName));

            // 如果该纹理名称中包含了/,说明它是在一个文件夹中的
            size_t pos = ownerTexName.find_last_of('/');

            // 在文件夹中
            if (pos != Ogre::String::npos)
            {
                // 先去除纹理文件名,剩下路径名
                ownerTexName.erase(pos+1);
                // 加上画刷的名称
                ownerTexName.append(textureInfos[i].brushName);
                wxTreeItemId id = mBrushesTree->AppendItem( GetParentId(ownerTexName, catalogMap), wxT(textureInfos[i].textureName) );
				
				mCatalogMap.insert(CatalogMap::value_type( textureInfos[i].textureName, id ));
            }
            else
            {
                Ogre::String brushName = textureInfos[i].brushName;
                // 如果是在根目录下,就直接用画刷名称来作为路径名
                wxTreeItemId id = mBrushesTree->AppendItem( GetParentId(brushName, catalogMap), wxT(textureInfos[i].textureName) );
				mCatalogMap.insert(CatalogMap::value_type( textureInfos[i].textureName, id ));
			}				
        }
        ++it;
    }

	wxString lostTexNames = wxEmptyString;
	for (OwnerTexs::iterator ownerIt = ownerTextures.begin(); ownerIt != ownerTextures.end(); ++ownerIt)
	{
		Ogre::String texName = ownerIt->first;

		Ogre::FileInfoListPtr fileInfoList =
			Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo("Brushes",texName);
		
		Ogre::FileInfoList::const_iterator itBegin = fileInfoList->begin();
		Ogre::FileInfoList::const_iterator itEnd = fileInfoList->end(); 
		if (itBegin == itEnd)
		{
			lostTexNames+=wxT("\n");
			lostTexNames+=texName.c_str();
			 continue;
		}

		Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().getByName(texName);

		if (!texture.isNull())
		{
			Ogre::TextureManager::getSingleton().remove(texName);
			Ogre::Image image;
			image.load(texName, Fairy::BRUSH_RESOURCE_GROUP_NAME);
			texture = Ogre::TextureManager::getSingleton()
				.loadImage(texName, Fairy::BRUSH_RESOURCE_GROUP_NAME, image);
		}
	}	

	if (!lostTexNames.empty())
	{
		wxMessageBox(wxT("以下贴图无法找到:")+lostTexNames);
	}

    mBrushesTree->Thaw();
}
Beispiel #23
0
wxPGConstants * WXEffectEditDialog::PopulateConstants(const Ogre::String& type)
{
	size_t id = reinterpret_cast<size_t>(&type);
	wxPGConstants* constants = wxPropertyGrid::GetConstantsArray(id);

	if (constants)
	{
		for (std::list<wxPGConstants*>::iterator it = mConstantList.begin(); it != mConstantList.end(); ++it)
		{
			if (constants == *it)
			{
				if (constants->UnRef())
					delete constants;

				mConstantList.erase(it);

				break;
			}
		}
	}
//	if (!constants)
//	{
		constants = wxPropertyGrid::CreateConstantsArray(id);

		if ( type == "Material" )
		{
			typedef std::list<Ogre::String> MaterialFileNameList;
			MaterialFileNameList materialFileNameList;

			Ogre::FileInfoListPtr fileInfoList =
				Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
				Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
				"*.material");
			for (Ogre::FileInfoList::const_iterator it = fileInfoList->begin(); it != fileInfoList->end(); ++it)
			{
				if ( it->archive->getName() == EFFECT_PATH)
				{
					materialFileNameList.push_back(it->filename);
				}
			}
			// 第一个为空,表示设置这个元素的材质是用原mesh的材质
			constants->Add("none");

			Ogre::ResourceManager::ResourceMapIterator resourceMapIterator = Ogre::MaterialManager::getSingleton().getResourceIterator();

			while ( resourceMapIterator.hasMoreElements() )
			{				
				Ogre::String matName = resourceMapIterator.peekNextValue()->getName();

				for ( MaterialFileNameList::iterator i = materialFileNameList.begin();
					i != materialFileNameList.end(); ++i )
				{
					if ( *i == resourceMapIterator.peekNextValue()->getOrigin() )
					{
						constants->Add(matName.c_str());
						break;
					}
				}

				resourceMapIterator.moveNext();
			}
		}
		else if ( type == "MeshName" )
		{			
			constants->Add("none");

			Ogre::FileInfoListPtr fileInfoList =
				Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
				Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
				"*.mesh");
			for (Ogre::FileInfoList::const_iterator it = fileInfoList->begin(); it != fileInfoList->end(); ++it)
			{
				if ( it->archive->getName() == EFFECT_PATH)
				{
					const Fairy::String& name = it->filename;
					constants->Add(name.c_str());
				}
			}
		}	
		else if ( type == "ParticleSystem" )
		{
			Ogre::ParticleSystemManager::ParticleSystemTemplateIterator iterator = Ogre::ParticleSystemManager::getSingleton().getTemplateIterator();

			while ( iterator.hasMoreElements() )
			{
				// 获取到粒子系统的名称
				Ogre::String parName = iterator.peekNextKey();

				constants->Add(parName.c_str());

				// 使iterator往后移
				iterator.moveNext();
			}
		}

		registerConstants(constants);
//	}

	return constants;
}
wxPGConstants * FairySkillEditDialog::PopulateConstants(const Ogre::String& name)
{
	size_t id = reinterpret_cast<size_t>(&name);
	wxPGConstants* constants = wxPropertyGrid::GetConstantsArray(id);

	if (constants)
	{
		for (std::list<wxPGConstants*>::iterator it = mConstantList.begin(); it != mConstantList.end(); ++it)
		{
			if (constants == *it)
			{
				if (constants->UnRef())
					delete constants;

				mConstantList.erase(it);

				break;
			}
		}
	}

//	if (!constants)
//	{
		constants = wxPropertyGrid::CreateConstantsArray(id);

		if ( name == "Animation" )
		{
			// 第一个为空,表示设置这个元素的材质是用原mesh的材质
			for ( unsigned short i = 0; i < mDObject->getSkeletonAnimationCount(); ++i )
			{
				Ogre::Animation *anim = mDObject->getSkeletonAnimation(i);

				if ( anim )
				{
					constants->Add(anim->getName().c_str());
				}
			}			
		}
		else if ( name == "EffectTemplateName" )
		{
			WX::EffectManager::EffectTemplateIterator it = 
				WX::EffectManager::getSingleton().getEffectTemplateIterator();

			while ( it.hasMoreElements() )
			{
				constants->Add(it.peekNextKey().c_str());

				it.moveNext();
			}
		}
		else if ( name == "AttachPoint" )
		{
			for ( unsigned short i=0; i<mDObject->getNumBones(); ++i )
			{
				constants->Add(mDObject->getBoneName(i).c_str());
			}	

			Ogre::StringVector locatorNames;
			mDObject->getLocatorNames(locatorNames);

			for ( size_t i=0; i<locatorNames.size(); ++i )
			{
				constants->Add(locatorNames[i].c_str());
			}			
		}
		else if ( name == "Material" )
		{
			typedef std::list<Ogre::String> MaterialFileNameList;
			MaterialFileNameList materialFileNameList;

			Ogre::FileInfoListPtr fileInfoList =
				Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
				Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
				"*.material");
			for (Ogre::FileInfoList::const_iterator it = fileInfoList->begin(); it != fileInfoList->end(); ++it)
			{
				if ( it->archive->getName() == MATERIAL_PATH)
				{
					materialFileNameList.push_back(it->filename);
				}
			}

			Ogre::ResourceManager::ResourceMapIterator resourceMapIterator = Ogre::MaterialManager::getSingleton().getResourceIterator();

			while ( resourceMapIterator.hasMoreElements() )
			{				
				Ogre::String matName = resourceMapIterator.peekNextValue()->getName();

				for ( MaterialFileNameList::iterator i = materialFileNameList.begin();
					i != materialFileNameList.end(); ++i )
				{
					if ( *i == resourceMapIterator.peekNextValue()->getOrigin() )
					{
						constants->Add(matName.c_str());
						break;
					}
				}

				resourceMapIterator.moveNext();
			}
		}	
		else if ( name == "SoundName" )
		{
            constants->Add("NULL");
			//-----------------------------------
			//得到所有文件名
            if (wxGetApp().funcEnumSoundFile)
            {
			    int nIndex = 0;
			    do
			    {
				    char szTemp[100];

                    int id;

				    bool bHave = wxGetApp().funcEnumSoundFile(nIndex++, szTemp, 100, id);
				    if(!bHave) break;

				    constants->Add(szTemp);
			    }while(true);
            }
		}

		registerConstants(constants);
	//}

	return constants;
}
Beispiel #25
0
//-------------------------------------------------------------------------------------
void SceneLoader::load(std::string filename, Scene* scene)
{
  try
  {
    Ogre::FileInfoListPtr files = Ogre::ResourceGroupManager::getSingletonPtr()->findResourceFileInfo("Essential", filename);
    if(files->size() < 1) throw NHException("could not find the path to the specified scene");

    std::string filePath = files->front().archive->getName() + "/" + files->front().filename;

    std::ifstream streamfile(filePath);
    rapidxml::xml_document<> doc;

    std::vector<char> buffer((std::istreambuf_iterator<char>(streamfile)), std::istreambuf_iterator<char>());//streamfile)), std::istreambuf_iterator<char>());

    buffer.push_back('\0');//null terminating the buffer

    //std::cout << &buffer[0] << std::endl; //test the buffer

    doc.parse<0>(&buffer[0]);
    rapidxml::xml_node<>* root = doc.first_node(SCENE_STRING);//"scene");

    scene->getSceneGraphicsManager()->setAmbientLight(getXMLColour(root, AMBIENT_RED_STRING, AMBIENT_GREEN_STRING, AMBIENT_BLUE_STRING));

    //description attributes
    //north = boost::lexical_cast<float>(root->first_attribute(NORTH_STRING)->value());

    //Architecture
    rapidxml::xml_node<>* architectureNode = root->first_node(ARCHITECTURE_STRING);//"architecture");
    while(architectureNode != NULL)
    {
      int id = boost::lexical_cast<int>(architectureNode->first_attribute(ID_STRING)->value());
      try
      {
        scene->addArchitecture(id, getXMLPosition(architectureNode), getXMLRotation(architectureNode), getXMLScale(architectureNode));
      }
      catch(NHException e) 
      {
#ifdef _DEBUG
        std::cout << e.what() << std::endl;
#endif
      }
      
      architectureNode = architectureNode->next_sibling(ARCHITECTURE_STRING);
    }

    scene->build();//building static geometry - must do here else we can't use the navigation mesh for creature placement

    //Lights
    rapidxml::xml_node<>* lightNode = root->first_node(LIGHT_STRING);//"light");
    while(lightNode != NULL)
    {
      bool cast_shadows = boost::lexical_cast<bool>(lightNode->first_attribute(CAST_SHADOWS_STRING)->value());
      float range = boost::lexical_cast<float>(lightNode->first_attribute(RANGE_STRING)->value());
      Ogre::ColourValue colour = getXMLColour(lightNode);
      scene->addLight(-1, getXMLPosition(lightNode),cast_shadows,range);//TODO: use actual id rather than -1
      lightNode = lightNode->next_sibling(LIGHT_STRING);
    }

    //Items
    rapidxml::xml_node<>* itemNode = root->first_node(ITEM_STRING);
    while(itemNode != NULL)
    {
      int id = boost::lexical_cast<int>(itemNode->first_attribute(ID_STRING)->value());
      scene->addItem(id, getXMLPosition(itemNode), getXMLRotation(itemNode));
      itemNode = itemNode->next_sibling(ITEM_STRING);
    }

    //Creatures
    rapidxml::xml_node<>* creatureNode = root->first_node(CREATURE_STRING);
    while(creatureNode != NULL)
    {
      int id = boost::lexical_cast<int>(creatureNode->first_attribute(ID_STRING)->value());
      scene->addCreature(id, getXMLPosition(creatureNode));
      creatureNode = creatureNode->next_sibling(CREATURE_STRING);
    }

    //Portals
    rapidxml::xml_node<>* portalNode = root->first_node(PORTAL_STRING);
    while(portalNode != NULL)
    {
      int id = boost::lexical_cast<int>(portalNode->first_attribute(ID_STRING)->value());
      int targetSceneID = boost::lexical_cast<int>(portalNode->first_attribute(TARGET_SCENE_ID_STRING)->value());
      int targetPortalID = boost::lexical_cast<int>(portalNode->first_attribute(TARGET_PORTAL_ID_STRING)->value());
      scene->addPortal(id, getXMLPosition(portalNode), getXMLVector(portalNode, LOOK_AT_X_STRING, LOOK_AT_Y_STRING, LOOK_AT_Z_STRING), Id<Scene>(targetSceneID), Id<Portal>(targetPortalID), Id<Portal>(id));
      portalNode = portalNode->next_sibling(PORTAL_STRING);//"portal");
    }

    //Particles //TODO: change to emitter
    /*
    rapidxml::xml_node<>* particleNode = root->first_node(PARTICLE_STRING);//"particle");
    while(particleNode != NULL)
    {
      scene->addParticles(particleNode->first_attribute(NAME_STRING)->value(), particleNode->first_attribute(TEMPLATE_NAME_STRING)->value(),getXMLPosition(particleNode));
      particleNode = particleNode->next_sibling(PARTICLE_STRING);
    }
    */
  }
  catch (rapidxml::parse_error e)
  {
    std::stringstream ss;
    ss << "could not load the xml scene '" << filename << "': " << e.what() << std::endl;
    throw NHException(ss.str().c_str());
  }
}