CBillboardAnimation::CBillboardAnimation ( CXMLTreeNode &_Node )
	: m_fTimePerImage	( 0.f )	
	, m_fCurrentTime	( 0.f )
	, m_uiImage			( 0 )
	, m_vColor			( Vect4f(0.f,0.f,0.f,0.f) )
	, m_fSize			( 0.f )
	, m_uiNumTextures	( 0 )
	, m_bLoop			( false )
{
	m_Name			= _Node.GetPszProperty ( "name", "" );
	m_vColor		= _Node.GetVect4fProperty( "color", Vect4f(0.f,0.f,0.f,0.f) );
	m_fSize			= _Node.GetFloatProperty("size", 1.f);
	m_fTimePerImage = _Node.GetFloatProperty("timePerImage", 1.f);
	m_bLoop			= _Node.GetBoolProperty("loop", false);				

	uint16 l_TotalAnimationNodes = _Node.GetNumChildren ();
	for ( uint16 i = 0; i < l_TotalAnimationNodes; ++i )
	{ 
		std::string l_Node = _Node(i).GetName();
		if ( l_Node == "Texture" )
		{
			std::string l_TextureName = _Node(i).GetPszProperty("file", "");
			CTexture *l_Tex = CORE->GetTextureManager()->GetTexture( l_TextureName );
			m_vTextures.push_back( l_Tex );
		}		
	}

	m_uiNumTextures = m_vTextures.size();
}
Beispiel #2
0
CLight::CLight(CXMLTreeNode &TreeNode) : CNamed(TreeNode)
{
	m_Type = GetLightTypeByName(TreeNode.GetPszProperty("type"));
	m_Position = TreeNode.GetVect3fProperty("pos", Vect3f(0.0f, 0.0f, 0.0f), true);
	m_Color = CColor(TreeNode.GetVect4fProperty("color", Vect4f(255.0f, 255.0f, 255.0f, 0.0f), true));
	m_StartRangeAttenuation = TreeNode.GetFloatProperty("att_start_range");
	m_EndRangeAttenuation = TreeNode.GetFloatProperty("att_end_range");
	m_Intensity = TreeNode.GetFloatProperty("intensity");
}
CBillboardAnimation::CBillboardAnimation( float _Time, const std::vector<CTexture *> & _vBillboardAnimation )
	: m_fTimePerImage	( _Time )	
	, m_fCurrentTime	( 0.f )
	, m_uiImage			( 0 )
	, m_vColor			( Vect4f(0.f,0.f,0.f,0.f) )
	, m_fSize			( 0.f )
	, m_fAngle			( 0.f )
	, m_uiNumTextures	( 0 )
	, m_bLoop			( false )
{}
// --------------------------------------------
//			CONSTRUCTOR/DESTRUCTOR
// --------------------------------------------
CLensFlareSceneRemdererCommand::CLensFlareSceneRemdererCommand( CXMLTreeNode &_Node )
	: CSceneRendererCommand ( _Node )
{	
	m_LightIndex = _Node.GetIntProperty("light_index", 0, true);
	Vect3f glowColor = _Node.GetVect3fProperty("glow_color", v3fZERO, true);


	m_LensFlare = new CLensFlarePostProcess();
	m_LensFlare->SetGlowColor(CColor(Vect4f(glowColor / 255.0f, 1.0f)));
	m_LensFlare->Init();
}
void CLanguageManager::LoadXML (const std::string& pathFile)
{
	CXMLTreeNode parser;
	if (!parser.LoadFile(pathFile.c_str()))
	{
		std::string msg_error = "LanguageManager::LoadXML->Error al intentar leer el archivo de lenguaje: " + pathFile;
		LOGGER->AddNewLog(ELL_ERROR, msg_error.c_str());
		throw CException(__FILE__, __LINE__, msg_error);
	}

	/*<Language id="english">
		<literal id="xfiles"  font="X-Files"  color="0.5 0.5 0.5 0.5" value="Hi World"/>
		<literal id="xfiles"  font="X-Files"  color="0.1 0.1 0.1 0.8" value="Exit"/>  
	</Language>*/

	LOGGER->AddNewLog(ELL_INFORMATION, "LanguageManager::LoadXML-> Parseando fichero de lenguaje: %s", pathFile.c_str());
	
	CXMLTreeNode  m = parser["Language"];
	std::string id_language	= m.GetPszProperty("id");
	TLanguage language;
	if (m.Exists())
	{
		int count = m.GetNumChildren();
    for (int i = 0; i < count; ++i)
    {
			//for each literal:
			SLiteral l_literal;
			
			std::string id			= m(i).GetPszProperty("id");
			l_literal.m_sFontId	= m(i).GetPszProperty("font");
			Vect4f vecColor			= m(i).GetVect4fProperty("color", Vect4f(0.f,0.f,0.f,0.f));	
			l_literal.m_value		= m(i).GetPszISOProperty("value", "nothing");	
			l_literal.m_cColor	= CColor(vecColor.x, vecColor.y, vecColor.z, vecColor.w);
			language.insert(std::pair<std::string,SLiteral>(id, l_literal));
			LOGGER->AddNewLog(ELL_INFORMATION, "LanguageManager::LoadXML-> Añadido literal(%s,%s,[%f,%f,%f,%f],%s)", 
																	id.c_str(), l_literal.m_sFontId.c_str(),vecColor.x,vecColor.y,vecColor.z,vecColor.w, l_literal.m_value.c_str());	
		}
	}
	if (m_Languages.find(id_language) != m_Languages.end())
	{
		//Ya está registrado el identificador id_language
		LOGGER->AddNewLog(ELL_WARNING, "LanguageManager::LoadXML-> EYa se ha registrado un language con identificador %s", id_language.c_str());
	}
	else
	{
		m_Languages.insert(std::pair<std::string, TLanguage>(id_language, language));
	}
	
}
///<summary>
/// CDrawQuadSceneEffect:: Constructor
///</summary>
///<param name="atts">Gestiona la lectura y escritura en ficheros XML</param>
CDrawQuadSceneEffect::CDrawQuadSceneEffect(CXMLTreeNode &atts)
: CSceneEffect (atts)
, m_Technique (NULL)
, m_Color (NULL)
{
	//<post_render type="draw_quad" name="glow_post_effect" technique="RenderGlowPostFXTechnique" active="true" color="1.0 1.0 1.0 1.0">
	//  <texture stage_id="0" file="GlowTexture"/>
	//</post_render>

	CEffectManager *effm = CORE->GetEffectManager();
	//TODO.. no devuelve la effectTechnique
	m_Technique = effm->GetEffectTechnique(atts.GetPszProperty("technique"));
	Vect4f l_vColor = atts.GetVect4fProperty("color", Vect4f(0.f,0.f,0.f,0.f));
	m_Color.SetArgb(l_vColor);
}
Beispiel #7
0
void CContextManager::PintarBuffer(EffectStruct shader)
{

	static CEffectParameters Parameters;

	Parameters.m_World.SetIdentity();
	Parameters.m_View.SetIdentity();
	Parameters.m_Projection.SetIdentity();
	Parameters.m_BaseColor = Vect4f(1, 1, 1, 1);
	UINT stride = sizeof(m_InitData.pSysMem);
	UINT offset = 0;

	m_DeviceContext->IASetVertexBuffers(0, 1, &shader.ConstantBuffer, &stride, &offset);//CREO BIEN
	m_DeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); // ESTA BIEN
	m_DeviceContext->IASetInputLayout(shader.VertexLayout);//BIEN SEGURAMENTE
	m_DeviceContext->VSSetShader(shader.VertexShader,0,0);//NOT SURE
	m_DeviceContext->UpdateSubresource(shader.ConstantBuffer, 0, NULL, &Parameters, 0, 0);//BIEN SEGURAMENTE
	m_DeviceContext->VSSetConstantBuffers(1,1,&shader.ConstantBuffer);//CREO BIEN
	m_DeviceContext->PSSetShader(shader.PixelShader,0,0);

	m_DeviceContext->Draw(3, 0);
}
Beispiel #8
0
//----------------------------------------------
void CBoxTrigger::ReadData( CXMLTreeNode &_Node )
{
	m_bIsActive		= _Node.GetBoolProperty("active", false);
	m_Name			= _Node.GetPszProperty("name", "");
	m_Position		= _Node.GetVect3fProperty("position", v3fZERO);
	m_Size			= _Node.GetVect3fProperty("size", v3fZERO);
	m_fYaw			= _Node.GetFloatProperty("yaw", 0.f);
	m_RenderColor	= CColor( _Node.GetVect4fProperty("color", Vect4f(1.f, 1.f, 1.f, 1.f)) );

	std::string l_ROName = _Node.GetPszProperty("renderable_object", "", false);
	std::string l_Layer = _Node.GetPszProperty("layer", "", false);

	CRenderableObjectsManager *l_pROM = CORE->GetRenderableObjectsLayersManager()->GetRenderableObjectManager(l_Layer);
	if( l_pROM != NULL )
	{
		m_pTriggerObject = l_pROM->GetInstance(l_ROName);
		if( m_pTriggerObject == NULL )
		{
			LOGGER->AddNewLog(ELL_WARNING, "CBoxTrigger::ReadData->No se ha podido obtener el objeto: %s de la capa Solid.", l_ROName.c_str());
		}
	}

	m_fYaw = mathUtils::Deg2Rad(m_fYaw);
}
///<summary>
/// CParticleManager:: LoadXML : Lectura de Particles.xml.
///</summary>
///<param name="fileName">Ruta del XML.</param>
///<returns name="result">Booleano que indica si la lectura se ha realizado con éxito.</returns>
bool CParticleManager::LoadXML (const std::string & fileName)
{
    bool l_bIsOk = true;
    CXMLTreeNode filexml;
    if (!filexml.LoadFile(fileName.c_str()))
    {
        LOGGER->AddNewLog(ELL_ERROR, "ParticleManager::LoadXML ---Error al cargar el XML---");
        l_bIsOk = false;
    }
    else
    {
        CXMLTreeNode l_pManager = filexml["ParticleManager"];
        if (l_pManager.Exists())
        {
            //<ParticleEmitter name="pEmitter1">
            //  <color color1="0.0 0.0 1.0 1.0" color2="0.0 1.0 0.0 1.0" time="0.0">
            //    <time t="2.0" col1="0.0 1.0 0.0 1.0" col2="0.0 1.0 0.0 1.0"/>
            //  </color>
            CXMLTreeNode l_pEmitters = l_pManager["ParticleEmitters"];
            int numNodes = l_pEmitters.GetNumChildren();
            for (int i = 0; i<numNodes; ++i)
            {
                CXMLTreeNode l_pEmitter = l_pEmitters(i)["ParticleEmitter"];
                if (l_pEmitter.Exists() && !l_pEmitter.IsComment())
                {
                    m_stInfo.sName = l_pEmitter.GetPszProperty("name");
                    CXMLTreeNode l_pColor = l_pEmitter["color"];

                    if (l_pColor.Exists() && !l_pColor.IsComment())
                    {
                        m_stColor.color1 = l_pColor.GetVect4fProperty("color1", Vect4f(0.f, 0.f, 0.f, 0.f));
                        m_stColor.color2 = l_pColor.GetVect4fProperty("color2", Vect4f(0.f, 0.f, 0.f, 0.f));
                        m_stColor.time	 = l_pColor.GetFloatProperty("time");

                        m_stInfo.vColor.push_back(m_stColor);
                    }
                    int num = l_pColor.GetNumChildren();
                    for (int j=0; j<num; ++j)
                    {
                        CXMLTreeNode l_pTime = l_pColor(j)["time"];
                        if (l_pTime.Exists() && !l_pTime.IsComment())
                        {
                            m_stColor.time   = l_pTime.GetFloatProperty("t");
                            m_stColor.color1 = l_pTime.GetVect4fProperty("col1", Vect4f(0.f, 0.f, 0.f, 0.f));
                            m_stColor.color2 = l_pTime.GetVect4fProperty("col2", Vect4f(0.f, 0.f, 0.f, 0.f));
                        }
                        m_stInfo.vColor.push_back(m_stColor);
                    }//end for color
                    //<direction d1="0.0 5.0 0.0" d2="0.0 6.0 0.0" time="0.0">
                    //	<time t="2.0" dir1="1.0 5.0 0.0" dir2="2.0 9.0 0.0"/>
                    //</direction>
                    CXMLTreeNode l_pDir = l_pEmitter["direction"];
                    if (l_pDir.Exists() && !l_pDir.IsComment())
                    {
                        m_stDir.dir1 = l_pDir.GetVect3fProperty("d1", Vect3f(0.f, 0.f, 0.f));
                        m_stDir.dir2 = l_pDir.GetVect3fProperty("d2", Vect3f(0.f, 0.f, 0.f));
                        m_stDir.time = l_pDir.GetFloatProperty("time");

                        m_stInfo.vDir.push_back(m_stDir);
                    }
                    int cont = l_pDir.GetNumChildren();
                    for (int k=0; k<cont; ++k)
                    {
                        CXMLTreeNode l_pTime = l_pDir(k)["time"];
                        if (l_pTime.Exists() && !l_pTime.IsComment())
                        {
                            m_stDir.time = l_pTime.GetFloatProperty("t");
                            m_stDir.dir1 = l_pTime.GetVect3fProperty("dir1", Vect3f(0.f, 0.f, 0.f));
                            m_stDir.dir2 = l_pTime.GetVect3fProperty("dir2", Vect3f(0.f, 0.f, 0.f));
                        }
                        m_stInfo.vDir.push_back(m_stDir);
                    }//end for direction
                    //<size mins="0.1" maxs="0.1" time="0.0">
                    //	<time t="0.5" siz1="0.3" siz2="0.3"/>
                    //</size>
                    CXMLTreeNode l_pSize = l_pEmitter["size"];
                    if (l_pSize.Exists() && !l_pSize.IsComment())
                    {
                        m_stSize.sizeMin = l_pSize.GetFloatProperty("mins");
                        m_stSize.sizeMax = l_pSize.GetFloatProperty("maxs");
                        m_stSize.time = l_pSize.GetFloatProperty("time");

                        m_stInfo.vSize.push_back(m_stSize);
                    }
                    int size = l_pSize.GetNumChildren();
                    for (int m=0; m<size; ++m)
                    {
                        CXMLTreeNode l_pTime = l_pSize(m)["time"];
                        if (l_pTime.Exists() && !l_pTime.IsComment())
                        {
                            m_stSize.time = l_pTime.GetFloatProperty("t");
                            m_stSize.sizeMin = l_pTime.GetFloatProperty("siz1");
                            m_stSize.sizeMax = l_pTime.GetFloatProperty("siz2");
                        }
                        m_stInfo.vSize.push_back(m_stSize);
                    }//end for size
                    //<life_time life1="1.0" life2="5.0"/>
                    CXMLTreeNode l_pLife = l_pEmitter["life_time"];
                    if (l_pLife.Exists() && !l_pLife.IsComment())
                    {
                        m_stInfo.fLifeMin = l_pLife.GetFloatProperty("life1");
                        m_stInfo.fLifeMax = l_pLife.GetFloatProperty("life2");
                    }
                    //<emit_rate er1="20.0" er2="30.0"/>
                    CXMLTreeNode l_pEmitRate = l_pEmitter["emit_rate"];
                    if (l_pEmitRate.Exists() && !l_pEmitRate.IsComment())
                    {
                        m_stInfo.fEmitRate1 = l_pEmitRate.GetFloatProperty("er1");
                        m_stInfo.fEmitRate2 = l_pEmitRate.GetFloatProperty("er2");
                    }
                    //<gravity gr="true"/>
                    CXMLTreeNode l_pGravity = l_pEmitter["gravity"];
                    if(l_pGravity.Exists() && !l_pGravity.IsComment())
                    {
                        m_stInfo.bGravity = l_pGravity.GetBoolProperty("gr");
                    }
                    //<velocity vel="1.0 1.0 1.0" time="0.0">
                    //	<time t="1.0" v="0.1 0.4 -0.2"/>
                    //</velocity>
                    CXMLTreeNode l_pVelocity = l_pEmitter["velocity"];
                    if(l_pVelocity.Exists() && !l_pVelocity.IsComment())
                    {
                        m_stVelocity.velocity = l_pVelocity.GetVect3fProperty("vel", (0.0f, 0.0f, 0.0f));
                        m_stVelocity.time = l_pVelocity.GetFloatProperty("time");

                        m_stInfo.vVelocity.push_back(m_stVelocity);
                    }
                    int tam = l_pVelocity.GetNumChildren();
                    for (int j=0; j<tam; ++j)
                    {
                        CXMLTreeNode l_pTime = l_pVelocity(j)["time"];
                        if (l_pTime.Exists() && !l_pTime.IsComment())
                        {
                            m_stVelocity.time = l_pTime.GetFloatProperty("t");
                            m_stVelocity.velocity = l_pTime.GetVect3fProperty("v",  (0.0f, 0.0f, 0.0f));
                        }
                        m_stInfo.vVelocity.push_back(m_stVelocity);
                    }//end for velocity
                    //<angle ang="0.5" time="0.0">
                    //	<time t="0.6" a="-0.5"/>
                    //</angle>
                    CXMLTreeNode l_pAngle = l_pEmitter["angle"];
                    if(l_pAngle.Exists() && !l_pAngle.IsComment())
                    {
                        m_stAngle.angle = l_pAngle.GetFloatProperty("ang");
                        m_stAngle.time = l_pAngle.GetFloatProperty("time");

                        m_stInfo.vAngle.push_back(m_stAngle);
                    }
                    int ang = l_pAngle.GetNumChildren();
                    for (int j=0; j<ang; ++j)
                    {
                        CXMLTreeNode l_pTime = l_pAngle(j)["time"];
                        if (l_pTime.Exists() && !l_pTime.IsComment())
                        {
                            m_stAngle.time = l_pTime.GetFloatProperty("t");
                            m_stAngle.angle = l_pTime.GetFloatProperty("a");
                        }
                        m_stInfo.vAngle.push_back(m_stAngle);
                    }//end for angle
                    //<texture tex="Data/Textures/Punto_Alfa.dds" />
                    CXMLTreeNode l_pText = l_pEmitter["texture"];
                    if (l_pText.Exists() && !l_pText.IsComment())
                    {
                        m_stInfo.pTexture = CORE->GetTextureManager()->GetTexture(l_pText.GetPszProperty("tex", ""));
                    }
                    m_vInfo.push_back(m_stInfo);
                    m_stInfo.vColor.clear();
                    m_stInfo.vDir.clear();
                    m_stInfo.vSize.clear();
                    m_stInfo.vVelocity.clear();
                    m_stInfo.vAngle.clear();
                }//end ParticleEmitter
            }
            //<Instance id="pEmitter1" pos1="0.0 0.0 0.0" pos2="8.0 0.0 0.0"/>
            CXMLTreeNode l_pInstance = l_pManager["Instances"];
            int numNodesInst = l_pInstance.GetNumChildren();
            for (int i = 0; i<numNodesInst; i++)
            {
                CXMLTreeNode l_pInst = l_pInstance(i)["Instance"];
                if (l_pInst.Exists() && !l_pInst.IsComment())
                {
                    m_stInstance.id = l_pInst.GetPszProperty("id",0);
                    m_stInstance.vPos1 = l_pInst.GetVect3fProperty("pos1", Vect3f(0.f,0.f,0.f));
                    m_stInstance.vPos2 = l_pInst.GetVect3fProperty("pos2", Vect3f(0.f,0.f,0.f));
                    m_stInfo.vInstance.push_back(m_stInstance);
                }
            }
            for (unsigned int c=0; c<m_vInfo.size(); c++)
            {
                int cont = -1;
                for (unsigned int i = 0; i<m_stInfo.vInstance.size(); i++)
                {
                    if (m_stInfo.vInstance[i].id == m_vInfo[c].sName)
                    {
                        cont++;
                        m_vInfo[c].vInstance.push_back(m_stInfo.vInstance[i]);
                        SetProperties(c,cont);
                    }
                }
            }
        }
    }
    LOGGER->AddNewLog(ELL_INFORMATION, "ParticleManager::LoadXML ---XML cargado correctamente---");
    SetPEmitterByInstance();
    return l_bIsOk;
}
Beispiel #10
0
void CRenderManager::Render()
{
	m_ContextManager->BeginRender();

	if (m_UseDebugCamera)
	{
		m_ContextManager->SetCamera(m_DebugCamera);
		UABEngine.GetEffectManager()->m_SceneParameters.m_CameraPosition=m_DebugCamera.GetPosition();
		UABEngine.GetEffectManager()->m_SceneParameters.m_CameraUpVector=m_DebugCamera.GetUp();
		UABEngine.GetEffectManager()->m_SceneParameters.m_CameraRightVector=Vect4f(1,1,1,1);
	}
	else
	{
		m_ContextManager->SetCamera(m_CurrentCamera);
	}
	//Mat44f view,proj;
	//view.SetIdentity();
	//proj.SetIdentity();
	//m_ContextManager->SetCamera(view,proj);
	// TODO crear un vector para objetos transparentes
	std::vector<BlendedSubmesh> l_SubmeshesWithBlend;

	UABEngine.GetRenderableObjectsManager()->Render(this);

	//for (size_t i = 0; i < m_CurrentRenderlistLength; ++i)
	//{
	//	
	//	Mat44f world;
	//	world.SetFromPosAndAnglesYXZ(l_Transform.Position, l_Transform.Yaw, l_Transform.Pitch, l_Transform.Roll);
	//	_Context->SetWorldMatrix(world);

	//	for (int j = 0; j < l_RenderableObject->GetNumSubmeshes(); ++j)
	//	{
	//		const CRenderableObject::SSubmesh& l_Submesh = l_RenderableObject->GetSubmesh(j);
	//		const CMaterial* l_Material = _MaterialManager->GetMaterial(l_Submesh.material);
	//		// TODO no pintar el objeto, sino añadirlo a la lista l_SubmeshesWithBlend si tiene blend
	//		if(l_Material->HasBlending())
	//		{
	//			struct BlendedSubmesh _BlendedSubmesh;
	//			_BlendedSubmesh.material = l_Material;
	//			_BlendedSubmesh.vertices = l_Submesh.vertices;
	//			_BlendedSubmesh.world = world;
	//			_BlendedSubmesh.position = l_Transform.Position;

	//			l_SubmeshesWithBlend.push_back(_BlendedSubmesh);
	//		}
	//		else
	//		{
	//			l_Material->SetShaderParameters(_Context);
	//			_Context->Draw(l_Submesh.vertices, l_Material->GetRasterizerState(), l_Material->GetDepthStencilState(), l_Material->GetBlendState());
	//		}
	//	}
	//}

	//// TODO: Ordenar objetos según la distáncia a la cámara
	//// NOTA: El quicksort es más rápido que el buble sort cuando la lista tiene más de ~100 objetos. NO OS MATÉIS SI NO HACE FALTA.
	//const Vect3f& l_CameraPosition = m_CurrentCamera.GetPosition();
	//for (int i = 0; i < l_SubmeshesWithBlend.size(); ++i)
	//{
	//	for (int j = 0; j < l_SubmeshesWithBlend.size()-i-1; ++j)
	//	{
	//		struct BlendedSubmesh _BlendedSubmeshAux;
	//		float l_DistanceSQ = l_SubmeshesWithBlend[j].position.SqDistance(l_CameraPosition);
	//		float l_DistanceSQ2 = l_SubmeshesWithBlend[j+1].position.SqDistance(l_CameraPosition);
	//		if(l_DistanceSQ<l_DistanceSQ2)
	//		{
	//			_BlendedSubmeshAux = l_SubmeshesWithBlend[j+1];
	//			l_SubmeshesWithBlend[j+1] = l_SubmeshesWithBlend[j];
	//			l_SubmeshesWithBlend[j] = _BlendedSubmeshAux;
	//		}
	//	}
	//}

	//// TODO: Pintar objetos translúcidos
	//for (int i = 0; i < l_SubmeshesWithBlend.size(); ++i)
	//{
	//	BlendedSubmesh l_BlendedSubmesh = l_SubmeshesWithBlend[i];
	//	l_BlendedSubmesh.material->SetShaderParameters(_Context);
	//	_Context->SetWorldMatrix(l_BlendedSubmesh.world);
	//	_Context->Draw(l_BlendedSubmesh.vertices, l_BlendedSubmesh.material->GetRasterizerState(), l_BlendedSubmesh.material->GetDepthStencilState(), l_BlendedSubmesh.material->GetBlendState());
	//
	//}

	m_CurrentRenderlistLength = 0;

	m_ContextManager->EndRender();
}
bool CParticleSettingsManager::Reload()
{
	CXMLTreeNode newFile;
	if (!newFile.LoadFile(m_Filename.c_str()))
	{
		std::string msg_error = "CParticleSettingsManager::Load->Error al intentar leer el archivo xml: " + m_Filename;
		LOGGER->AddNewLog(ELL_ERROR, msg_error.c_str());
		return false;
	}

	CXMLTreeNode l_xml = newFile["particle_settings"];
	if( l_xml.Exists() )
	{
		uint16 l_Count = l_xml.GetNumChildren();

		for(uint16 i=0; i<l_Count; ++i)
		{
			std::string l_Type = l_xml(i).GetName();

			if( l_Type == "settings" )
			{
				CXMLTreeNode child = l_xml(i);

				TParticleSystemSettings* settings = new TParticleSystemSettings();

				settings->m_Name = child.GetPszProperty("name", "", true);

				uint16 l_CountChild = child.GetNumChildren();
				for(uint16 j = 0; j < l_CountChild; ++j)
				{
					std::string l_TypeChild = child(j).GetName();

					if(l_TypeChild == "TextureName")
					{
						settings->m_TextureName = child(j).GetPszProperty("value", "", true);
					}
					else if(l_TypeChild == "MaxParticles")
					{
						uint32 maxPart = (uint32)child(j).GetIntProperty("value", 0, true) / CORE->GetConfig().particle_level;

						maxPart = maxPart == 0 ? 1 : maxPart;

						settings->m_MaxParticles = maxPart;
					}
					else if(l_TypeChild == "Duration")
					{
						settings->m_Duration = child(j).GetFloatProperty("value", 0, true);
					}
					else if(l_TypeChild == "DurationRandomness")
					{
						settings->m_DurationRandomness = child(j).GetFloatProperty("value", 0, true);
					}
					else if(l_TypeChild == "EmitterVelocitySensitivity")
					{
						settings->m_EmitterVelocitySensitivity = child(j).GetFloatProperty("value", 0, true);
					}
					else if(l_TypeChild == "MinHorizontalVelocity")
					{
						settings->m_MinHorizontalVelocity = child(j).GetFloatProperty("value", 0, true);
					}
					else if(l_TypeChild == "MaxHorizontalVelocity")
					{
						settings->m_MaxHorizontalVelocity = child(j).GetFloatProperty("value", 0, true);
					}
					else if(l_TypeChild == "MinVerticalVelocity")
					{
						settings->m_MinVerticalVelocity = child(j).GetFloatProperty("value", 0, true);
					}
					else if(l_TypeChild == "MaxVerticalVelocity")
					{
						settings->m_MaxVerticalVelocity = child(j).GetFloatProperty("value", 0, true);
					}
					else if(l_TypeChild == "Gravity")
					{
						settings->m_Gravity = child(j).GetVect3fProperty("value", Vect3f(0, 0, 0), true);
					}
					else if(l_TypeChild == "EndVelocity")
					{
						settings->m_EndVelocity = child(j).GetFloatProperty("value", 0, true);
					}
					else if(l_TypeChild == "MinColor")
					{
						Vect4f temp = child(j).GetVect4fProperty("value", Vect4f(0, 0, 0, 0), true) / 255.0f;
						settings->m_MinColor = CColor(temp);
					}
					else if(l_TypeChild == "MaxColor")
					{
						Vect4f temp = child(j).GetVect4fProperty("value", Vect4f(0, 0, 0, 0), true) / 255.0f;
						settings->m_MaxColor = CColor(temp);
					}
					else if(l_TypeChild == "MinRotateSpeed")
					{
						settings->m_MinRotateSpeed = child(j).GetFloatProperty("value", 0, true);
					}
					else if(l_TypeChild == "MaxRotateSpeed")
					{
						settings->m_MaxRotateSpeed = child(j).GetFloatProperty("value", 0, true);
					}
					else if(l_TypeChild == "MinStartSize")
					{
						settings->m_MinStartSize = child(j).GetFloatProperty("value", 0, true);
					}
					else if(l_TypeChild == "MaxStartSize")
					{
						settings->m_MaxStartSize = child(j).GetFloatProperty("value", 0, true);
					}
					else if(l_TypeChild == "MinEndSize")
					{
						settings->m_MinEndSize = child(j).GetFloatProperty("value", 0, true);
					}
					else if(l_TypeChild == "MaxEndSize")
					{
						settings->m_MaxEndSize = child(j).GetFloatProperty("value", 0, true);
					}
					else if(l_TypeChild == "BlendState")
					{
						std::string type = child(j).GetPszProperty("value", 0, true);
						settings->m_BlendName = type;

						if(type.compare("NonPremultiplied") == 0)
						{
							settings->m_BlendState = TGraphicBlendStates::NonPremultiplied;
						}
						else if (type.compare("Additive") == 0)
						{
							settings->m_BlendState = TGraphicBlendStates::Additive;
						} 
						else if (type.compare("DefaultState") == 0)
						{
							settings->m_BlendState = TGraphicBlendStates::DefaultState;
						}
					}
				}

				bool isOk = this->AddResource(settings->m_Name, settings);
				assert(isOk);
			}
		}
	}
	else
	{
		return false;
	}

	return true;
}
void CPostSceneRendererStep::Render(CRenderManager* _pRM)
{
    CEffectManager* l_pEM = CORE->GetEffectManager();

    l_pEM->SetAlphaFactor(m_fAlphaFactor);
    l_pEM->SetViewport(m_iPos.x, m_iPos.y, m_iSize.x, m_iSize.y);

    if(m_bUseTime)
    {
        l_pEM->SetTime(m_fTime);
    }

    if(m_bUseCenter)
    {
        l_pEM->SetCenterXY(m_vCenter.x,m_vCenter.y);
    }

    CEffect* l_pEffect = l_pEM->GetResource(m_szEffect);

    if(l_pEffect)
    {
        ActivateInputSamplers();

        l_pEM->LoadShaderData(l_pEffect);

        LPD3DXEFFECT l_pD3DEffect = l_pEffect->GetD3DEffect();

        if(l_pD3DEffect!=NULL)
        {
            UINT l_NumPasses;
            l_pD3DEffect->Begin(&l_NumPasses, 0);
            for (UINT iPass = 0; iPass < l_NumPasses; iPass++)
            {
                l_pD3DEffect->BeginPass(iPass);
                _pRM->DrawColoredTexturedQuad2D(m_iPos,m_iSize.x,m_iSize.y,m_Alignment,CColor(Vect4f(0,0,0,0)));
                l_pD3DEffect->EndPass();
            }
            l_pD3DEffect->End();
        }

        DeactivateInputSamplers();
    }
}
Beispiel #13
0
void CFont::DrawString(const std::string& text, const Rectf& bounds, bool overflowX /*= false*/)
{
    ustring str = GetUTF8String( text );
    Vect2f screenSz = m_gui->m_screen.size;
    Vect2f pos = bounds.position;

    pos.x = GetLineStartXPosition(str, bounds, 0);

    CEffectManager::m_SceneParameters.m_BaseColor = m_color;

    auto technique = m_material->getRenderableObjectTechique()->GetEffectTechnique();
    m_material->apply();
    m_pages[0]->Activate(0);

    for ( int b = 0; b < str.length(); b += MAX_GLYPHS_BATCH )
    {
        m_glyphs.clear();

        uchar lastChar = -1;
        for ( int i = b; (i - b < MAX_GLYPHS_BATCH) && (i < str.length()); ++i )
        {
            uchar c = str[i];
            if (c == '\n')
            {
                lastChar = -1;
                pos.x = GetLineStartXPosition(str, bounds, i+1);
                pos.y += m_lineHeight;
                continue;
            }
            auto descIt = m_chars.find( c );

            if ( descIt == m_chars.end() )
            {
                c = -1;
                descIt = m_chars.find( -1 );
            }

            if ( lastChar == -1 )
            {
                auto kernIt = m_kernings.find( std::make_pair( lastChar, c ) );
                if ( kernIt != m_kernings.end() )
                {
                    pos.x += kernIt->second;
                }
            }
            auto & desc = descIt->second;

            Rectf charR( pos, desc.size );

            charR.position += desc.offset;

            charR.x /= screenSz.x;
            charR.y /= screenSz.y;
            charR.w /= screenSz.x;
            charR.h /= screenSz.y;

            m_glyphs.push_back( {Vect4f(charR.x, charR.y, charR.w, charR.h), desc.uvRect.position, desc.uvRect.size } );


            pos.x += desc.xAdvance;

            lastChar = c;
        }

        m_glyphsVtxs->UpdateVertices(m_gui->m_contextManager->GetDeviceContext(), m_glyphs.data(), m_glyphs.size());

        m_glyphsVtxs->Render(m_gui->m_contextManager, technique);
    }
}
CMaterial::CMaterial(CXMLTreeNode &TreeNode)
	: CNamed(TreeNode)
{
	/*m_RenderableObjectTechnique = new CRenderableObjectTechnique(TreeNode.GetPszProperty("effect_technique"),
		CEngine::GetSingletonPtr()->getEffectsManager()->get(TreeNode.GetPszProperty("effect_technique")));*/

	std::string name;
	const char * rot = TreeNode.GetPszProperty("renderable_object_technique", 0, false);
	if (rot)
	{
		name = rot;
	}
	else
	{
		name = TreeNode.GetPszProperty("vertex_type", "", true);
		DEBUG_ASSERT( name != std::string("") );
	}

	m_RenderableObjectTechnique = CEngine::GetSingleton().getRenderableObjectTechniqueManager()->get(name);
	void *nextDir = &CEffectManager::m_MaterialEffectParameters.m_RawData[0];
	int l_NextStage = 0;
	for (int i = 0; i < TreeNode.GetNumChildren(); ++i)
	{
		CXMLTreeNode l_paramMat = TreeNode(i);
		if (l_paramMat.GetName() == std::string("texture"))
		{
			CXMLTreeNode l_Texture = l_paramMat;
			CTexture * Texture = CEngine::GetSingleton().getTextureManager()->GetTexture(l_Texture.GetPszProperty("filename"));
			int stage = GetTextureStage(l_Texture.GetPszProperty("type", "", false));
			if (stage < 0)
			{
				stage = l_paramMat.GetIntProperty("stage", -1, false);
			}
			if (stage < 0)
			{
				stage = l_NextStage;
			}
			m_textures.push_back(std::make_pair(stage,Texture));
			l_NextStage++;
		}
		else if (l_paramMat.GetName() == std::string("parameter"))
		{
			CMaterialParameter::TMaterialType type;
			if (l_paramMat.GetPszProperty("type") == std::string("float"))
			{
				type = CMaterialParameter::TMaterialType::FLOAT;
				CTemplatedMaterialParameter<float> *param = new CTemplatedMaterialParameter<float>(
					l_paramMat,
					nextDir,
					l_paramMat.GetFloatProperty("value"),
					type);
				m_Parameters.push_back(param);
			}
			else if (l_paramMat.GetPszProperty("type") == std::string("Vect2f"))
			{
				type = CMaterialParameter::TMaterialType::VECT2F;
				CTemplatedMaterialParameter<Vect2f> *param = new CTemplatedMaterialParameter<Vect2f>(
					l_paramMat,
					nextDir,
					l_paramMat.GetVect2fProperty("value", Vect2f(0, 0)),
					type);
				m_Parameters.push_back(param);
}
			else if (l_paramMat.GetPszProperty("type") == std::string("Vect3f"))
			{
				type = CMaterialParameter::TMaterialType::VECT3F;
				CTemplatedMaterialParameter<Vect3f> *param = new CTemplatedMaterialParameter<Vect3f>(
					l_paramMat,
					nextDir,
					l_paramMat.GetVect3fProperty("value", Vect3f(0, 0, 0)),
					type);
				m_Parameters.push_back(param);
			}
			else if (l_paramMat.GetPszProperty("type") == std::string("Vect4f"))
			{
				type = CMaterialParameter::TMaterialType::VECT4F;
				CTemplatedMaterialParameter<Vect4f> *param = new CTemplatedMaterialParameter<Vect4f>(
					l_paramMat,
					nextDir,
					l_paramMat.GetVect4fProperty("value", Vect4f(0, 0, 0, 0)),
					type);
				m_Parameters.push_back(param);
			}

			nextDir = reinterpret_cast<unsigned char*>(nextDir)+sizeof(Vect4f);
		}
	}
}
void CParticleEmitter::Load(CXMLTreeNode &parser)
{
	m_vColors.clear();
	m_vDirections.clear();
	m_vAcelerations.clear();
	m_vSizes.clear();

	//m_Type = parser.GetPszProperty("type", "point");
	m_bGravity = parser.GetBoolProperty("gravity");
	m_fMinTimeLife = parser.GetFloatProperty("life_time_min", 0.0f);
	m_fMaxTimeLife = parser.GetFloatProperty("life_time_max", 0.0f);
	m_fMinEmitRate = parser.GetFloatProperty("emit_rate_min", 1.0f);
	m_fMaxEmitRate = parser.GetFloatProperty("emit_rate_max", 1.0f);
	std::string l_texturePath = parser.GetPszProperty("tex", "");
	m_fAngle = parser.GetFloatProperty("angle", 0.0f);

	m_sTexture = CORE->GetTextureManager()->GetTexture(l_texturePath);

	//Variación de los colores
	CXMLTreeNode l_Node = parser["color"];
	m_vColors.push_back(SColor());
	//SColor l_color = new SColor();
	m_vColors[m_vColors.size()-1].time = l_Node.GetFloatProperty("time", 0.0f);
	m_vColors[m_vColors.size()-1].col1.SetArgb(l_Node.GetVect4fProperty("color1",Vect4f(1.0f,1.0f,1.0f,1.0f)));
	m_vColors[m_vColors.size()-1].col2.SetArgb(l_Node.GetVect4fProperty("color2",Vect4f(1.0f,1.0f,1.0f,1.0f)));
	//m_vColors.push_back(l_color);

	for(int i=0;i<l_Node.GetNumChildren();i++){
		m_vColors.push_back(SColor());
		m_vColors[m_vColors.size()-1].time = l_Node(i).GetFloatProperty("time", 0.0f);
		m_vColors[m_vColors.size()-1].col1.SetArgb(l_Node(i).GetVect4fProperty("color1",Vect4f(1.0f,1.0f,1.0f,1.0f)));
		m_vColors[m_vColors.size()-1].col2.SetArgb(l_Node(i).GetVect4fProperty("color2",Vect4f(1.0f,1.0f,1.0f,1.0f)));
	}

	//Variación de los vectores directores
	l_Node = parser["direction"];
	m_vDirections.push_back(SDirection());
	//SDirection* l_direction = new SDirection();
	m_vDirections[m_vDirections.size()-1].time = l_Node.GetFloatProperty("time", 0.0f);
	m_vDirections[m_vDirections.size()-1].dir1 = l_Node.GetVect3fProperty("dir1", Vect3f(0.0f,0.0f,0.0f));
	m_vDirections[m_vDirections.size()-1].dir2 = l_Node.GetVect3fProperty("dir2", Vect3f(0.0f,0.0f,0.0f));
	//m_vDirections.push_back(l_direction);

	for(int i=0;i<l_Node.GetNumChildren();i++){
		m_vDirections.push_back(SDirection());
		m_vDirections[m_vDirections.size()-1].time = l_Node(i).GetFloatProperty("time", 0.0f);
		m_vDirections[m_vDirections.size()-1].dir1 = l_Node(i).GetVect3fProperty("dir1",Vect3f(0.0f,0.0f,0.0f));
		m_vDirections[m_vDirections.size()-1].dir2 = l_Node(i).GetVect3fProperty("dir2",Vect3f(0.0f,0.0f,0.0f));
	}


	//Variación de los tamaños
	l_Node = parser["size"];
	m_vSizes.push_back(SSize());
	//SSize* l_size = new SSize();
	m_vSizes[m_vSizes.size()-1].time = l_Node.GetFloatProperty("time", 0.0f);
	m_vSizes[m_vSizes.size()-1].size1 = l_Node.GetFloatProperty("mins", 1.0f);
	m_vSizes[m_vSizes.size()-1].size2 = l_Node.GetFloatProperty("maxs", 1.0f);
	//m_vSizes.push_back(l_size);

	for(int i=0;i<l_Node.GetNumChildren();i++){
		m_vSizes.push_back(SSize());
		m_vSizes[m_vSizes.size()-1].time = l_Node(i).GetFloatProperty("time", 0.0f);
		m_vSizes[m_vSizes.size()-1].size1 = l_Node(i).GetFloatProperty("mins",1.0f);
		m_vSizes[m_vSizes.size()-1].size2 = l_Node(i).GetFloatProperty("maxs",1.0f);
	}

	//Variación de las aceleraciones
	l_Node = parser["aceleration"];
	m_vAcelerations.push_back(SAceleration());
	//SAceleration* l_aceleration = new SAceleration();
	m_vAcelerations[m_vAcelerations.size()-1].time = l_Node.GetFloatProperty("time", 0.0f);
	m_vAcelerations[m_vAcelerations.size()-1].acel1 = l_Node.GetVect3fProperty("acel1", Vect3f(0.0f,0.0f,0.0f));
	m_vAcelerations[m_vAcelerations.size()-1].acel2 = l_Node.GetVect3fProperty("acel2", Vect3f(0.0f,0.0f,0.0f));
	//m_vAcelerations.push_back(l_aceleration);

	for(int i=0;i<l_Node.GetNumChildren();i++){
		m_vAcelerations.push_back(SAceleration());
		m_vAcelerations[m_vAcelerations.size()-1].time = l_Node(i).GetFloatProperty("time", 0.0f);
		m_vAcelerations[m_vAcelerations.size()-1].acel1 = l_Node(i).GetVect3fProperty("acel1", Vect3f(0.0f,0.0f,0.0f));
		m_vAcelerations[m_vAcelerations.size()-1].acel1 = l_Node(i).GetVect3fProperty("acel2", Vect3f(0.0f,0.0f,0.0f));
	}

}