Example #1
0
// Parse a primitive, apply defaults first, grab any base level
//	key pairs, then process any sub groups we may contain.
//------------------------------------------------------
bool CPrimitiveTemplate::ParsePrimitive( CGPGroup *grp )
{
	CGPGroup	*subGrp;
	CGPValue	*pairs;
	const char	*key; 
	const char	*val;

	// Lets work with the pairs first
	pairs = grp->GetPairs();

	while( pairs )
	{
		// the fields
		key = pairs->GetName();
		val = pairs->GetTopValue();

		// Huge stricmp lists suxor
		if ( !stricmp( key, "count" ))
		{
			ParseCount( val );
		}
		else if ( !stricmp( key, "shaders" ) || !stricmp( key, "shader" ))
		{
			ParseShaders( pairs );
		}
		else if ( !stricmp( key, "models" ) || !stricmp( key, "model" ))
		{
			ParseModels( pairs );
		}
		else if ( !stricmp( key, "sounds" ) || !stricmp( key, "sound" ))
		{
			ParseSounds( pairs );
		}
		else if ( !stricmp( key, "impactfx" ))
		{
			ParseImpactFxStrings( pairs );
		}
		else if ( !stricmp( key, "deathfx" ))
		{
			ParseDeathFxStrings( pairs );
		}
		else if ( !stricmp( key, "emitfx" ))
		{
			ParseEmitterFxStrings( pairs );
		}
		else if ( !stricmp( key, "playfx" ))
		{
			ParsePlayFxStrings( pairs );
		}
		else if ( !stricmp( key, "life" ))
		{
			ParseLife( val );
		}
		else if ( !stricmp( key, "cullrange" ))
		{
			mCullRange = atoi( val );
			mCullRange *= mCullRange; // Square
		}
		else if ( !stricmp( key, "delay" ))
		{
			ParseDelay( val );
		}
		else if ( !stricmp( key, "bounce" ) || !stricmp( key, "intensity" )) // me==bad for reusing this...but it shouldn't hurt anything)
		{
			ParseElasticity( val );
		}
		else if ( !stricmp( key, "min" ))
		{
			ParseMin( val );
		}
		else if ( !stricmp( key, "max" ))
		{
			ParseMax( val );
		}
		else if ( !stricmp( key, "angle" ) || !stricmp( key, "angles" ))
		{
			ParseAngle( val );
		}
		else if ( !stricmp( key, "angleDelta" ))
		{
			ParseAngleDelta( val );
		}
		else if ( !stricmp( key, "velocity" ) || !stricmp( key, "vel" ))
		{
			ParseVelocity( val );
		}
		else if ( !stricmp( key, "acceleration" ) || !stricmp( key, "accel" ))
		{
			ParseAcceleration( val );
		}
		else if ( !stricmp( key, "gravity" ))
		{
			ParseGravity( val );
		}
		else if ( !stricmp( key, "density" ))
		{
			ParseDensity( val );
		}
		else if ( !stricmp( key, "variance" ))
		{
			ParseVariance( val );
		}
		else if ( !stricmp( key, "origin" ))
		{
			ParseOrigin1( val );
		}
		else if ( !stricmp( key, "origin2" ))
		{
			ParseOrigin2( val );
		}
		else if ( !stricmp( key, "radius" )) // part of ellipse/cylinder calcs.
		{
			ParseRadius( val );
		}
		else if ( !stricmp( key, "height" )) // part of ellipse/cylinder calcs.
		{
			ParseHeight( val );
		}
		else if ( !stricmp( key, "rotation" ))
		{
			ParseRotation( val );
		}
		else if ( !Q_stricmp( key, "rotationDelta" ))
		{
			ParseRotationDelta( val );
		}
		else if ( !stricmp( key, "flags" ) || !stricmp( key, "flag" ))
		{ // these need to get passed on to the primitive
			ParseFlags( val );
		}
		else if ( !stricmp( key, "spawnFlags" ) || !stricmp( key, "spawnFlag" ))
		{ // these are used to spawn things in cool ways, but don't ever get passed on to prims.
			ParseSpawnFlags( val );
		}
		else if ( !stricmp( key, "name" ))
		{
			if ( val )
			{
				// just stash the descriptive name of the primitive
				strcpy( mName, val );
			}
		}
		else
		{
			theFxHelper.Print( "Unknown key parsing an effect primitive: %s\n", key );
		}

		pairs = (CGPValue *)pairs->GetNext();
	}

	subGrp = grp->GetSubGroups();

	// Lets chomp on the groups now
	while ( subGrp )
	{
		key = subGrp->GetName();

		if ( !stricmp( key, "rgb" ))
		{
			ParseRGB( subGrp );
		}
		else if ( !stricmp( key, "alpha" ))
		{
			ParseAlpha( subGrp );
		}
		else if ( !stricmp( key, "size" ) || !stricmp( key, "width" ))
		{
			ParseSize( subGrp );
		}
		else if ( !stricmp( key, "size2" ) || !stricmp( key, "width2" ))
		{
			ParseSize2( subGrp );
		}
		else if ( !stricmp( key, "length" ) || !stricmp( key, "height" ))
		{
			ParseLength( subGrp );
		}
		else
		{
			theFxHelper.Print( "Unknown group key parsing a particle: %s\n", key );
		}

		subGrp = (CGPGroup *)subGrp->GetNext();
	}

	return true;
}
//-------------------------------------------------------------------------------------------------
bool U2FrameXmlParser::Parse()
{
	TiXmlHandle docHandle(m_pXmlDoc);
	TiXmlElement* pFrameElem = docHandle.FirstChildElement("Frame").Element();
	U2ASSERT(pFrameElem);

	

	TiXmlElement* pChild;
	for(pChild = pFrameElem->FirstChildElement(); pChild; pChild = pChild->NextSiblingElement())
	{
#ifdef UNICODE 
		if(ToUnicode(pChild->Value()) == U2DynString(_T("Shaders")))
		{
			ParseShaders();
		}
		else if(ToUnicode(pChild->Value()) == U2DynString(_T("RenderTarget")))
		{
			ParseRenderTarget(pChild, m_pOwnerFrame);
		}
		else if(ToUnicode(pChild->Value()) == U2DynString(_T("Float")))
		{
			ParseGlobalVariable(U2Variable::Float, pChild, m_pOwnerFrame);
		}
		else if(ToUnicode(pChild->Value()) == U2DynString(_T("Float4")))
		{
			ParseGlobalVariable(U2Variable::Vector4, pChild, m_pOwnerFrame);
		}
		else if(ToUnicode(pChild->Value()) == U2DynString(_T("Int")))
		{
			ParseGlobalVariable(U2Variable::Int, pChild, m_pOwnerFrame);
		}
		else if(ToUnicode(pChild->Value()) == U2DynString(_T("Texture")))
		{
			ParseGlobalVariable(U2Variable::Object, pChild, m_pOwnerFrame);
		}
		else if(ToUnicode(pChild->Value()) == U2DynString(_T("RenderTarget")))	
		{
			ParseFrameSection(pChild, m_pOwnerFrame);
		}
#else 
		if(pChild->Value() == U2DynString(_T("Shaders")))

		{
			PROFILER_DECLARE(prof);
			PROFILER_START(prof);

			ParseShaders();

			PROFILER_STOP(prof);
			//FILE_LOG(logINFO) << _T("ParseShaders: ") << prof.GetTimeInSecs();
		}
		else if(pChild->Value() == U2DynString(_T("RenderTarget")))
		{
			PROFILER_DECLARE(prof);
			PROFILER_START(prof);

			ParseRenderTarget(pChild, m_pOwnerFrame);
			
			PROFILER_STOP(prof);
			//FILE_LOG(logINFO) << _T("ParseRenderTarget: ") << prof.GetTimeInSecs();
		}
		else if(pChild->Value() == U2DynString(_T("Float")))

		{
			PROFILER_DECLARE(prof);
			PROFILER_START(prof);
			ParseGlobalVariable(U2Variable::Float, pChild, m_pOwnerFrame);
			PROFILER_STOP(prof);
			//FILE_LOG(logINFO) << _T("ParseGlobalVariable Float: ") << prof.GetTimeInSecs();


		}
		else if(pChild->Value() == U2DynString(_T("Float4")))

		{
			PROFILER_DECLARE(prof);
			PROFILER_START(prof);
			ParseGlobalVariable(U2Variable::Vector4, pChild, m_pOwnerFrame);
			PROFILER_STOP(prof);

			//FILE_LOG(logINFO) << _T("ParseGlobalVariable Float4: ") << prof.GetTimeInSecs();


		}
		else if(pChild->Value() == U2DynString(_T("Int")))

		{
			PROFILER_DECLARE(prof);
			PROFILER_START(prof);
			ParseGlobalVariable(U2Variable::Int, pChild, m_pOwnerFrame);
			PROFILER_STOP(prof);
			//FILE_LOG(logINFO) << _T("ParseGlobalVariable Int: ") << prof.GetTimeInSecs();


		}
		else if(pChild->Value() == U2DynString(_T("Texture")))

		{
			PROFILER_DECLARE(prof);
			PROFILER_START(prof);
			ParseGlobalVariable(U2Variable::Object, pChild, m_pOwnerFrame);
			PROFILER_STOP(prof);
			//FILE_LOG(logINFO) << _T("ParseGlobalVariable Texture: ") << prof.GetTimeInSecs();


		}
		else if(pChild->Value() == U2DynString(_T("FrameSection")))
		{
			PROFILER_DECLARE(prof);
			PROFILER_START(prof);
			// Reset 에러... 2011/09/26 
			ParseFrameSection(pChild, m_pOwnerFrame);
			PROFILER_STOP(prof);
			//FILE_LOG(logINFO) << _T("ParseFrameSection: ") << prof.GetTimeInSecs();


		}
#endif 		
	}
	return true;
}