//-----------------------------------------------------------------------
	void CGUIParticleSystemManager::parseNewAffector(const CGUIString& type, DataStreamPtr& stream, CGUIParticleSystem* sys)
	{
		// Create new affector
		CGUIParticleAffector* pAff = sys->addAffector(type);
		// Parse affector details
		CGUIString line;

		while(!stream->eof())
		{
			line = stream->getLine();
			// Ignore comments & blanks
			if (!(line.length() == 0 || line.substr(0,2) == "//"))
			{
				if (line == "}")
				{
					// Finished affector
					break;
				}
				else
				{
					// Attribute
					StringUtil::toLowerCase(line);
					parseAffectorAttrib(line, pAff);
				}
			}
		}
	}
示例#2
0
	//------------------------------------------------------------------------------
	std::vector<CGUIString>	StringToVector(const CGUIString& rString )
	{
		std::vector<CGUIString> aListString;
		CGUIString::size_type idx = 0;

		while( idx < rString.size())
		{
			CGUIString::size_type ret = rString.find(",", idx);
			aListString.push_back(rString.substr(idx, ret));
			if( ret == CGUIString::npos )
			{
				break;
			}
			else
			{
				idx = ret+1;
			}
		}
		return aListString;
	}
	//-----------------------------------------------------------------------
	void CGUIParticleSystemManager::parseScript(DataStreamPtr& stream, const CGUIString& groupName)
	{
#if OGRE_USE_NEW_COMPILERS == 1
		ScriptCompilerManager::getSingleton().parseScript(stream, groupName);
#else // OGRE_USE_NEW_COMPILERS
		CGUIString line;
		CGUIParticleSystem* pSys;
		vector<CGUIString>::type vecparams;

		pSys = 0;

		while(!stream->eof())
		{
			line = stream->getLine();
			// Ignore comments & blanks
			if (!(line.length() == 0 || line.substr(0,2) == "//"))
			{
				if (pSys == 0)
				{
					// No current system
					// So first valid data should be a system name
					if (StringUtil::startsWith(line, "particle_system "))
					{
						// chop off the 'particle_system ' needed by new compilers
						line = line.substr(16);
					}
					pSys = createTemplate(line, groupName);
					pSys->_notifyOrigin(stream->getName());
					// Skip to and over next {
					skipToNextOpenBrace(stream);
				}
				else
				{
					// Already in a system
					if (line == "}")
					{
						// Finished system
						pSys = 0;
					}
					else if (line.substr(0,7) == "emitter")
					{
						// new emitter
						// Get typename
						vecparams = StringUtil::split(line, "\t ");
						if (vecparams.size() < 2)
						{
							// Oops, bad emitter
							LogManager::getSingleton().logMessage("Bad particle system emitter line: '"
								+ line + "' in " + pSys->getName());
							skipToNextCloseBrace(stream);

						}
						skipToNextOpenBrace(stream);
						parseNewEmitter(vecparams[1], stream, pSys);

					}
					else if (line.substr(0,8) == "affector")
					{
						// new affector
						// Get typename
						vecparams = StringUtil::split(line, "\t ");
						if (vecparams.size() < 2)
						{
							// Oops, bad affector
							LogManager::getSingleton().logMessage("Bad particle system affector line: '"
								+ line + "' in " + pSys->getName());
							skipToNextCloseBrace(stream);

						}
						skipToNextOpenBrace(stream);
						parseNewAffector(vecparams[1],stream, pSys);
					}
					else
					{
						// Attribute
						parseAttrib(line, pSys);
					}

				}

			}


		}
#endif // OGRE_USE_NEW_COMPILERS
	}