CElevatorAnimatedPhysicModel::CElevatorAnimatedPhysicModel(const CXMLTreeNode& XmlData, CAnimatedCoreModel* coreModel) : CAnimatedInstanceModel(XmlData) { Initialize(coreModel); std::string l_Name = XmlData.GetPszProperty("name",""); std::string l_Core = XmlData.GetPszProperty("core",""); std::string l_Type = XmlData.GetPszProperty("physics_type",""); CStaticMesh* l_StaticMesh = CORE->GetStaticMeshManager()->GetResource(l_Name); if (l_StaticMesh!=NULL) { m_PhysicElement= new CPhysicElement(l_Core,l_Type); m_PhysicElement->m_UserData->SetPaint(true); m_PhysicElement->m_UserData->SetColor(colBLUE); if (l_Type=="triangle_mesh") { m_PhysicElement->m_PhysicActor->CreateBody(100.0f); CORE->GetPhysicsManager()->GetCookingMesh()->CreatePhysicMesh(l_StaticMesh->getVB(),l_StaticMesh->getIB(),l_Name); NxTriangleMesh* l_TriangleMesh= CORE->GetPhysicsManager()->GetCookingMesh()->GetPhysicMesh(l_Name); m_PhysicElement->m_PhysicActor->AddMeshShape(l_TriangleMesh,m_Position); CORE->GetPhysicsManager()->AddPhysicActor(m_PhysicElement->m_PhysicActor); m_PhysicElement->m_PhysicActor->SetKinematic(true); } } }
CStaticMesh::CStaticMesh(const CXMLTreeNode &TreeNode) : CNamed(TreeNode) , m_NumFaces(0) , m_NumVertexs(0) { Load(TreeNode.GetPszProperty("filename")); }
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(); }
//---------------------------------------------------------------------------- // Init data //---------------------------------------------------------------------------- bool CZombie::Init(const CXMLTreeNode &m) { m_bIsOk = Inherited::Init(m); if (!m_bIsOk) { LOGGER->AddNewLog(ELL_WARNING,"a CCZombie instace couldnt allocate memory"); } SetState( IDLE ); m_movIA = new CEjeMovimiento(); assert (m_movIA); m_bIsOk = m_movIA->Init(); if (!m_bIsOk) { LOGGER->AddNewLog(ELL_WARNING,"a CEjeMovimiento instace couldnt allocate memory"); } std::string l_sType = m.GetPszProperty("type", ""); if((l_sType.compare("ZOMBIE_BOSS"))&&(l_sType.compare("ZOMBIE_VOMITADOR"))) { if(m_bIsOk) { m_bIsOk = GeneraManoIzquierda(); } } if(l_sType.compare("ZOMBIE_VOMITADOR")) { if(m_bIsOk) { m_bIsOk = GeneraManoDerecha (); } } return m_bIsOk; }
CEffectVertexShader::CEffectVertexShader(const CXMLTreeNode &TreeNode) : CEffectShader(TreeNode) , m_VertexShader(nullptr) , m_VertexLayout(nullptr) { m_VertexType = TreeNode.GetPszProperty("vertex_type"); }
CAnimatedInstanceModel::CAnimatedInstanceModel(CXMLTreeNode &TreeNode):CRenderableObject(TreeNode) { Initialize(UABEngine.GetAnimatedModelsManager()->GetResource(TreeNode.GetPszProperty("core_name"))); /*m_AnimatedCoreModel = UABEngine.GetAnimatedModelsManager()->GetResource(l_Element.GetPszProperty("core_model_name")); m_CalModel = new CalModel(m_AnimatedCoreModel->GetCalCoreModel()); m_CalHardwareModel = new CalHardwareModel(m_AnimatedCoreModel->GetCalCoreModel());*/ }
C3DElement::C3DElement(const CXMLTreeNode &XMLTreeNode) { const char *l_Pos=XMLTreeNode.GetPszProperty("pos", "0.0 0.0 0.0"); sscanf_s(l_Pos, "%f %f %f", m_Position[0], m_Position[1], m_Position[2]); m_Yaw=XMLTreeNode.GetFloatProperty("yaw", 0.0f); m_Pitch=XMLTreeNode.GetFloatProperty("pitch", 0.0f); m_Roll=XMLTreeNode.GetFloatProperty("roll", 0.0f); }
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"); }
CRenderableObjectTechniquesSceneRendererCommand::CRenderableObjectTechniquesSceneRendererCommand(CXMLTreeNode &atts) : CSceneRendererCommand(atts) { std::string l_PROTName = atts.GetPszProperty("pool",""); if (l_PROTName!="") { m_PoolRenderableObjectTechnique = CORE->GetRenderableObjectsTechniqueManager()->GetPoolRenderableObjectTechniques().GetResource(l_PROTName); } }
void CGUIWindow::LoadEditableTextBox (CEditableTextBox** editableTextBox_aux, CXMLTreeNode& pNewNode, const Vect2i& screenResolution, CTextureManager* tm) { //<EditableTextBox name="debug_fps" posx="0" posy="2" height="10" width="10" visible="true" active="true" // texture_quad="blabla" id_font="0" color_font_r="0" color_font_g="0" color_font_b="0" // buffer="" OnSaveValue="blabla" OnLoadValue="blabla" Literal="blabla" widthOffset="" heightOffset="" // Literal="blabla" widthOffset="" heightOffset=""/> CEditableTextBox* editableTextBox; std::string name = pNewNode.GetPszProperty("name", "defaultGuiElement"); float posx = pNewNode.GetFloatProperty("posx", 0.f); float posy = pNewNode.GetFloatProperty("posy", 0.f); float w = pNewNode.GetFloatProperty("width", 50.f); float h = pNewNode.GetFloatProperty("height", 50.f); bool visible = pNewNode.GetBoolProperty("visible", true); bool activated = pNewNode.GetBoolProperty("active", true); std::string quad = pNewNode.GetPszProperty("texture_quad", ""); std::string OnSaveValue = pNewNode.GetPszProperty("OnSaveValue", ""); std::string OnLoadValue = pNewNode.GetPszProperty("OnLoadValue", ""); uint32 idFont = pNewNode.GetIntProperty("id_font", 0); float color_font_r = pNewNode.GetFloatProperty("color_font_r", 0.f); float color_font_g = pNewNode.GetFloatProperty("color_font_g", 0.f); float color_font_b = pNewNode.GetFloatProperty("color_font_b", 0.f); std::string buffer = pNewNode.GetPszProperty("buffer", ""); std::string l_literal = pNewNode.GetPszProperty("Literal", ""); float widthOffsetPercent = pNewNode.GetFloatProperty("widthOffset", 0.f); float heightOffsetPercent = pNewNode.GetFloatProperty("heightOffset", 0.f); uint32 widthOffset = (uint32) (screenResolution.x * 0.01f * widthOffsetPercent ); uint32 heightOffset = (uint32) (screenResolution.y * 0.01f * heightOffsetPercent ); CTexture* quad_texture = tm->GetTexture(quad); editableTextBox = new CEditableTextBox( screenResolution.y,screenResolution.x,h, w, Vect2f(posx,posy), CColor(color_font_r,color_font_g,color_font_b),idFont, l_literal, heightOffset, widthOffset, visible, activated); editableTextBox->SetName(name); editableTextBox->SetBackGroundTexture(quad_texture); editableTextBox->SetBuffer(buffer); editableTextBox->SetOnLoadValueAction(OnSaveValue); editableTextBox->SetOnSaveValueAction(OnLoadValue); *editableTextBox_aux = editableTextBox; }
void CGUIWindow::LoadCheckButton (CCheckButton** checkButton_aux, CXMLTreeNode& pNewNode, const Vect2i& screenResolution, CTextureManager* tm) { //<CheckButton name="debug_thps" posx="0" posy="2" height="10" width="10" visible="true" active="true" isOn="true" // texture_on="blabla" texture_off="bla" texture_deactivated"bla" // OnCheckOn="blabla" OnCheckOff="blabla" OnOverButton="blabla" // OnSaveValue="blabl" OnLoadValue="" Literal="blabla" widthOffset="" heightOffset=""/> CCheckButton* checkButton; std::string name = pNewNode.GetPszProperty("name", "defaultGuiElement"); float posx = pNewNode.GetFloatProperty("posx", 0.f); float posy = pNewNode.GetFloatProperty("posy", 0.f); float w = pNewNode.GetFloatProperty("width", 50.f); float h = pNewNode.GetFloatProperty("height", 50.f); bool visible = pNewNode.GetBoolProperty("visible", true); bool activated = pNewNode.GetBoolProperty("active", true); bool isOn = pNewNode.GetBoolProperty("isOn", ""); std::string texture_on = pNewNode.GetPszProperty("texture_on", ""); std::string texture_off = pNewNode.GetPszProperty("texture_off", ""); std::string texture_deactivated = pNewNode.GetPszProperty("texture_deactivated", ""); std::string OnCheckOn = pNewNode.GetPszProperty("OnCheckOn", ""); std::string OnCheckOff = pNewNode.GetPszProperty("OnCheckOff", ""); std::string OnOverButton = pNewNode.GetPszProperty("OnOverButton", ""); std::string OnSaveValue = pNewNode.GetPszProperty("OnSaveValue", ""); std::string OnLoadValue = pNewNode.GetPszProperty("OnLoadValue", ""); std::string l_literal = pNewNode.GetPszProperty("Literal", ""); float widthOffsetPercent = pNewNode.GetFloatProperty("widthOffset", 0.f); float heightOffsetPercent = pNewNode.GetFloatProperty("heightOffset", 0.f); CTexture* on = tm->GetTexture(texture_on); CTexture* off = tm->GetTexture(texture_off); CTexture* deactivated = tm->GetTexture(texture_deactivated); uint32 widthOffset = (uint32) (screenResolution.x * 0.01f * widthOffsetPercent ); uint32 heightOffset = (uint32) (screenResolution.y * 0.01f * heightOffsetPercent ); checkButton = new CCheckButton(screenResolution.y,screenResolution.x, h, w, Vect2f(posx,posy), isOn, l_literal, heightOffset, widthOffset, visible, activated); checkButton->SetName(name); checkButton->SetTextures(on, off, deactivated); checkButton->SetOnCheckOnAction(OnCheckOn); checkButton->SetOnCheckOffAction(OnCheckOff); checkButton->SetOnLoadValueAction(OnLoadValue); checkButton->SetOnSaveValueAction(OnSaveValue); checkButton->SetOnOverAction(OnOverButton); *checkButton_aux = checkButton; }
void CGUIWindow::LoadStaticText(CStaticText** staticText_aux, CXMLTreeNode& pNewNode, const Vect2i& screenResolution, CTextureManager* tm) { //<StaticText name="pepito" posx="0" posy="2" literal="blabla" visible="true" active="true"/> CStaticText* staticText; std::string name = pNewNode.GetPszProperty("name", "defaultGuiElement"); float posx = pNewNode.GetFloatProperty("posx", 0.f); float posy = pNewNode.GetFloatProperty("posy", 0.f); float w = pNewNode.GetFloatProperty("width", 50.f); float h = pNewNode.GetFloatProperty("height", 50.f); bool visible = pNewNode.GetBoolProperty("visible", true); bool activated = pNewNode.GetBoolProperty("active", true); std::string l_literal = pNewNode.GetPszProperty("Literal", ""); staticText = new CStaticText(screenResolution.y, screenResolution.x, h, w, Vect2f(posx,posy), l_literal, visible, activated); staticText->SetName(name); *staticText_aux = staticText; }
void CGUIWindow::LoadProgressBar(CProgressBar** progressBar_aux, CXMLTreeNode& pNewNode, const Vect2i& screenResolution, CTextureManager* tm) { //<ProgressBar name="progressBar1" posx="200" posy="600" height="10" width="100" visible="true" active="true" // texture_back="hola" texture_bar="hola2" id_font="0" color_font_r="0" color_font_g="0" color_font_b="0" // Literal="blabla" widthOffset="" heightOffset="" OnComplete="blabla"/> CProgressBar* progressBar; std::string name = pNewNode.GetPszProperty("name", "defaultGuiElement"); float posx = pNewNode.GetFloatProperty("posx", 0.f); float posy = pNewNode.GetFloatProperty("posy", 0.f); float w = pNewNode.GetFloatProperty("width", 50.f); float h = pNewNode.GetFloatProperty("height", 50.f); bool visible = pNewNode.GetBoolProperty("visible", true); bool activated = pNewNode.GetBoolProperty("active", true); std::string texture_bar = pNewNode.GetPszProperty("texture_bar", ""); std::string texture_back = pNewNode.GetPszProperty("texture_back", ""); std::string OnComplete = pNewNode.GetPszProperty("OnComplete", ""); uint32 idFont = pNewNode.GetIntProperty("id_font", 0); float color_font_r = pNewNode.GetFloatProperty("color_font_r", 0.f); float color_font_g = pNewNode.GetFloatProperty("color_font_g", 0.f); float color_font_b = pNewNode.GetFloatProperty("color_font_b", 0.f); std::string l_literal = pNewNode.GetPszProperty("Literal", ""); float widthOffsetPercent = pNewNode.GetFloatProperty("widthOffset", 0.f); float heightOffsetPercent = pNewNode.GetFloatProperty("heightOffset", 0.f); CTexture* bar = tm->GetTexture(texture_bar); CTexture* back = tm->GetTexture(texture_back); uint32 widthOffset = (uint32) (screenResolution.x * 0.01f * widthOffsetPercent ); uint32 heightOffset = (uint32) (screenResolution.y * 0.01f * heightOffsetPercent ); progressBar = new CProgressBar( screenResolution.y,screenResolution.x, h, w, Vect2f(posx, posy), l_literal, heightOffset, widthOffset, visible, activated); progressBar->SetName(name); progressBar->SetTextures(back, bar); progressBar->SetFont(idFont, CColor(color_font_r,color_font_g,color_font_b)); progressBar->SetOnComplete(OnComplete); *progressBar_aux = progressBar; }
//---------------------------------------------------------------------------- // Init data //---------------------------------------------------------------------------- bool CZombieOlfateador::Init(const CXMLTreeNode &m){ SetDummyStart(m.GetPszProperty("dummy_start")); m_sNodoActual = GetDummyStart(); m_sNodoSiguiente = ""; m_AgentIA = new C_IA(); m_AgentIA->Init(); std::map<std::string,SNodo*> miApuntadorGrafo = m_AgentIA->GetGrafo(); std::map<std::string,SNodo*>::iterator l_iterGrafo = miApuntadorGrafo.find(GetDummyStart()); GetInstance()->SetPosition(l_iterGrafo->second->posicion); this->SetAgent(m_AgentIA); m_V3RotIni = m.GetVect3fProperty("rot",NULL); GetInstance()->SetYaw(m_V3RotIni.x); GetInstance()->SetPitch(m_V3RotIni.y); GetInstance()->SetRoll(m_V3RotIni.z); GetInstance()->SetName( m.GetPszProperty("name")); SetSiguiendoRuta(false); return true; }
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)); } }
//---------------------------------------------- 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> /// 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); }
CMaterial::CMaterial(CXMLTreeNode &TreeNode) : CNamed(TreeNode) { std::string l_EffectTechnique = TreeNode.GetPszProperty("effect_technique"); m_EffectTechnique = CEngine::GetSingletonPtr()->GetEffectManager()->GetResource(l_EffectTechnique); if (l_EffectTechnique == "diffuse_technique") { for (int i = 0; i < TreeNode.GetNumChildren(); ++i) { CXMLTreeNode l_Texture = TreeNode(i); CTexture * Texture = new CTexture(); Texture->Load(l_Texture.GetPszProperty("filename")); m_Textures.push_back(Texture); } } }
CSetRenderTargetSceneRendererCommand::CSetRenderTargetSceneRendererCommand(CXMLTreeNode &TreeNode) :CStagedTexturedSceneRendererCommand(TreeNode) { setName(TreeNode.GetPszProperty("name")); for (int i = 0; i < TreeNode.GetNumChildren(); i++){ CXMLTreeNode text = TreeNode(i); if (text.GetName()==std::string("dynamic_texture")) { //XML SceneRenderCommands: //<dynamic_texture name="DiffuseMapTexture" texture_width_as_frame_buffer="true" format_type="A8R8G8B8" create_depth_stencil_buffer="false"/> CDynamicTexture * dynText = new CDynamicTexture(text); m_DynamicTextures.push_back(dynText); CEngine::GetSingleton().getTextureManager()->add(dynText->getName(), dynText); } } CreateRenderTargetViewVector(); }
void CGUIWindow::LoadButton (CButton** button_aux, CXMLTreeNode& pNewNode, const Vect2i& screenResolution, CTextureManager* tm) { //<Button name="play" posx="0" posy="0" height="10" width="10" visible="true" activated="true" // texture_normal="blabla" texture_over="bla" texture_clicked="bla" texture_deactivated="bla" // OnClickedAction="blabla" OnOverAction="blabla" Literal="blabla" widthOffset="" heightOffset=""/> CButton* button; std::string name = pNewNode.GetPszProperty("name", "defaultGuiElement"); float posx = pNewNode.GetFloatProperty("posx", 0.f); float posy = pNewNode.GetFloatProperty("posy", 0.f); float w = pNewNode.GetFloatProperty("width", 50.f); float h = pNewNode.GetFloatProperty("height", 50.f); bool visible = pNewNode.GetBoolProperty("visible", true); bool activated = pNewNode.GetBoolProperty("active", true); std::string texture_normal = pNewNode.GetPszProperty("texture_normal", ""); std::string texture_over = pNewNode.GetPszProperty("texture_over", ""); std::string texture_clicked = pNewNode.GetPszProperty("texture_clicked", ""); std::string texture_deactivated = pNewNode.GetPszProperty("texture_deactivated", ""); std::string OnClickedAction = pNewNode.GetPszProperty("OnClickedAction", ""); std::string OnOverAction = pNewNode.GetPszProperty("OnOverAction", ""); std::string l_literal = pNewNode.GetPszProperty("Literal", ""); float widthOffsetPercent = pNewNode.GetFloatProperty("widthOffset", 0.f); float heightOffsetPercent = pNewNode.GetFloatProperty("heightOffset", 0.f); CTexture* normal = tm->GetTexture(texture_normal); CTexture* over = tm->GetTexture(texture_over); CTexture* clicked = tm->GetTexture(texture_clicked); CTexture* deactivated = tm->GetTexture(texture_deactivated); uint32 widthOffset = (uint32) (screenResolution.x * 0.01f * widthOffsetPercent ); uint32 heightOffset = (uint32) (screenResolution.y * 0.01f * heightOffsetPercent ); button = new CButton(screenResolution.y,screenResolution.x, h, w, Vect2f(posx,posy), l_literal, heightOffset, widthOffset, visible, activated); button->SetName(name); button->SetTextures(normal,over,clicked,deactivated); button->SetOnClickedAction(OnClickedAction); button->SetOnOverAction(OnOverAction); *button_aux = button; }
//---------------------------------------------------------------------------- // Constructor //---------------------------------------------------------------------------- CSceneEffect::CSceneEffect(CXMLTreeNode &atts):CActive(),CNamed() { CNamed::Init();//inicia CNamed SetName(atts.GetPszProperty("name")); SetActive(atts.GetBoolProperty("active")); CXMLTreeNode texture = atts["texture"]; if (texture.Exists()) { if (!texture.IsComment()) { int32 numNodes = atts.GetNumChildren(); for(int i=0; i < numNodes; i++) { int l_iStageId = atts(i).GetIntProperty("stage_id"); std::string l_sFile = atts(i).GetPszProperty("file"); bool l_bLoadFile = atts(i).GetBoolProperty("load_file"); CTexture * l_Texture = NULL; if(l_bLoadFile) { l_Texture=CORE->GetTextureManager()->GetTexture(l_sFile); if (l_Texture==NULL) { //Guardar el mensaje de warning en el LOGGER std::string msg_warning = "SceneEffect::Constructor->Error al intentar leer el archivo de efectos: " + l_sFile; LOGGER->AddNewLog(ELL_WARNING, msg_warning.c_str()); } } else { //la creas dinámicamente la textura l_Texture=CORE->GetTextureManager()->GetResource(l_sFile); } if(l_Texture!=NULL) AddStageTexture(l_iStageId, l_Texture); }//end for } } }
void CEnemyManager::AddEnemy(CXMLTreeNode &XMLTreeNode) { std::string l_Type=XMLTreeNode.GetPszProperty("type"); std::map<std::string, TEnemyFactory> l_Functions; l_Functions["boss"]=CEnemy::GetTemplatedEnemy<CBossEnemy>; l_Functions["fixed"]=CEnemy::GetTemplatedEnemy<CFixedEnemy>; l_Functions["patrol"]=CEnemy::GetTemplatedEnemy<CPatrolEnemy>; CEnemy *l_Enemy=NULL; std::map<std::string, TEnemyFactory>::iterator it=l_Functions.find(l_Type); if(it!=l_Functions.end()) l_Enemy=it->second(XMLTreeNode); /*if(EnemyType=="boss") l_Enemy=new CBossEnemy(); else if(EnemyType=="fixed") l_Enemy=new CFixedEnemy(); else if(EnemyType=="patrol") l_Enemy=new CPatrolEnemy();*/ if(l_Enemy!=NULL) m_Enemies.push_back(l_Enemy); }
CNamed::CNamed(const CXMLTreeNode &node) { m_name = node.GetPszProperty("name", "", false); }
CRenderLayerSceneRendererCommand::CRenderLayerSceneRendererCommand(CXMLTreeNode &TreeNode): CSceneRendererCommand(TreeNode),m_Layer(nullptr) { std::string l_LayerName = TreeNode.GetPszProperty("layer"); m_Layer = CEngine::GetSingleton().GetLayerManager()->GetResource(l_LayerName); }
bool CEnemyManager::Init(const char* _pcFile) { CXMLTreeNode FileXML; FileXML.LoadFile(_pcFile); //CXMLTreeNode Enemies = fileXML(0); { CXMLTreeNode Templates = FileXML["templates"]; int iNumChildren = Templates.GetNumChildren(); for(int i = 0; i < iNumChildren; i++) { CXMLTreeNode EnemyTemplate = Templates(i); const char* pcId = EnemyTemplate.GetPszProperty("id"); const char* pcMesh = EnemyTemplate.GetPszProperty("mesh"); CEnemyResource* pResource = new CEnemyResource(); std::string szId = pcId; //TODO comprovar errors pResource->Init(pcId,pcMesh); m_Resources[szId] = pResource; } } { Vect3f Default(0,0,0); CXMLTreeNode Instances = FileXML["instances"]; int iNumChildren = Instances.GetNumChildren(); for(int i = 0; i < iNumChildren; i++) { CXMLTreeNode EnemyInstance = Instances(i); const char* pcType = EnemyInstance.GetPszProperty("type"); const Vect3f vPos = EnemyInstance.GetVect3fProperty("pos",Default); const Vect3f vRot = EnemyInstance.GetVect3fProperty("rot",Default); const float fMoveSpeed = EnemyInstance.GetFloatProperty("move_speed"); const float fRotateSpeed = EnemyInstance.GetFloatProperty("rotate_speed"); const float fHealth = EnemyInstance.GetFloatProperty("health"); if(strcmp(pcType,"PATROLLER") == 0) { const char* pcPaths = EnemyInstance.GetPszProperty("paths"); CPatroller* pPatroller = new CPatroller(); pPatroller->Init(vPos,vRot,fMoveSpeed,fRotateSpeed,fHealth,pcPaths); m_Instances.push_back(pPatroller); } else if(strcmp(pcType,"SNIPER") == 0) { float fAimDistance = EnemyInstance.GetFloatProperty("aim_distance"); CSniper* pSniper = new CSniper(); pSniper->Init(vPos,vRot,fMoveSpeed,fRotateSpeed,fHealth,fAimDistance); m_Instances.push_back(pSniper); } else if(strcmp(pcType,"TURRET") == 0) { Vect3f vMaxAngle = EnemyInstance.GetVect3fProperty("max_angle",Default); Vect3f vMinAngle = EnemyInstance.GetVect3fProperty("min_angle",Default); CTurret* pTurret = new CTurret(); pTurret->Init(vPos,vRot,fMoveSpeed,fRotateSpeed,fHealth,vMaxAngle,vMinAngle); m_Instances.push_back(pTurret); } else if(strcmp(pcType,"CAMERA") == 0) { Vect3f vMaxAngle = EnemyInstance.GetVect3fProperty("max_angle",Default); Vect3f vMinAngle = EnemyInstance.GetVect3fProperty("min_angle",Default); CCamera* pCamera = new CCamera(); pCamera->Init(vPos,vRot,fMoveSpeed,fRotateSpeed,fHealth,vMaxAngle,vMinAngle); m_Instances.push_back(pCamera); } else { //TODO errors } } } return true; }
bool CWayPointManager::Reload() { CXMLTreeNode newFile; if (!newFile.LoadFile(m_Filename.c_str())) { std::string msg_error = "WayPointManager::Load->Error al intentar leer el archivo xml: " + m_Filename; LOGGER->AddNewLog(ELL_ERROR, msg_error.c_str()); return false; } CXMLTreeNode l_wps = newFile["waypoints"]; if( l_wps.Exists() ) { uint16 l_Count = l_wps.GetNumChildren(); for(uint16 i=0; i<l_Count; ++i) { std::string l_Type = l_wps(i).GetName(); if( l_Type == "group" ) { CXMLTreeNode groupChild = l_wps(i); std::string groupName = groupChild.GetPszProperty("name", "", true); if(m_WPGroups.find(groupName) == m_WPGroups.end()) { m_WPGroups[groupName] = WayPointList(); } uint16 l_CountGroup = groupChild.GetNumChildren(); for(uint16 j = 0; j < l_CountGroup; ++j) { std::string l_TypeChild = groupChild(j).GetName(); if(l_TypeChild == "waypoint") { std::string wpName = groupChild(j).GetPszProperty("name", "", true); Vect3f wpPos = groupChild(j).GetVect3fProperty("position", Vect3f(0.0f, 0.0f, 0.0f), true); CWayPoint* wp = new CWayPoint(wpName, wpPos); m_WPGroups[groupName].push_back(wp); } if(l_TypeChild == "Brothers") { CXMLTreeNode broChild = groupChild(j); uint16 broChildCount = broChild.GetNumChildren(); std::string wpName = broChild.GetPszProperty("wave_point_name", "", true); CWayPoint* wp = GetWayPoint(groupName, wpName); assert(wp); for (uint16 x = 0; x < broChildCount; ++x) { std::string l_TypeBroChild = broChild(x).GetName(); if(l_TypeBroChild == "Brother") { std::string broName = broChild(x).GetPszProperty("name", "", true); CWayPoint* wpBro = GetWayPoint(groupName, broName); assert(wpBro); wp->AddBrother(wpBro); } } } } } } } else { return false; } return true; }
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; }
CMaterial::CMaterial(CXMLTreeNode &TreeNode) :m_Textures(NULL) ,m_RenderableObjectTechnique(NULL) ,CNamed(TreeNode.GetPszProperty("name", "")) ,m_CurrentParameterData(0) ,m_Offset(0) ,m_StaticFriction(0.0f) ,m_DynamicFriction(0.0f) ,m_Restitution(0.0f) { std::string l_RenderableObjectTechniqueName=TreeNode.GetPszProperty("renderable_object_technique", ""); if(l_RenderableObjectTechniqueName!="") m_RenderableObjectTechnique=CEngine::GetSingleton().GetRenderableObjectTechniqueManager()->GetResource(l_RenderableObjectTechniqueName); for (int i = 0; i < TreeNode.GetNumChildren(); ++i) { CXMLTreeNode l_Element = TreeNode(i); if (l_Element.GetName() == std::string("texture")) { std::string l_Filename = l_Element.GetPszProperty("filename", ""); bool l_GuiTexture = l_Element.GetBoolProperty("gui_texture", false); CTexture *l_Texture = CEngine::GetSingleton().GetTextureManager()->GetTexture(l_Filename, l_GuiTexture); if (l_Texture!=nullptr) m_Textures.push_back(l_Texture); } else if (l_Element.GetName() == std::string("parameter")) { std::string l_Type = l_Element.GetPszProperty("type"); std::string l_Name = l_Element.GetPszProperty("name"); if (l_Name == "static_friction") { m_StaticFriction = l_Element.GetFloatProperty("value", 0.0f); } else if (l_Name == "dynamic_friction") { m_DynamicFriction = l_Element.GetFloatProperty("value", 0.0f); } else if (l_Name == "restitution") { m_Restitution = l_Element.GetFloatProperty("value", 0.0f); } else { CMaterialParameter* l_MaterialParameter; CMaterialParameter::TMaterialType l_MaterialType; if (l_Type == "float") { l_MaterialType = CMaterialParameter::FLOAT; l_MaterialParameter = new CTemplatedMaterialParameter<float>(this, l_Element, l_Element.GetFloatProperty("value", 0.0f), l_MaterialType); } else if (l_Type == "vect2f") { l_MaterialType = CMaterialParameter::VECT2F; l_MaterialParameter = new CTemplatedMaterialParameter<Vect2f>(this, l_Element, l_Element.GetVect2fProperty("value", v2fZERO), l_MaterialType); } else if (l_Type == "vect3f") { l_MaterialType = CMaterialParameter::VECT3F; l_MaterialParameter = new CTemplatedMaterialParameter<Vect3f>(this, l_Element, l_Element.GetVect3fProperty("value", v3fZERO), l_MaterialType); } else if (l_Type == "vect4f") { l_MaterialType = CMaterialParameter::VECT4F; l_MaterialParameter = new CTemplatedMaterialParameter<Vect4f>(this, l_Element, l_Element.GetVect4fProperty("value", v4fZERO), l_MaterialType); } m_Parameters.push_back(l_MaterialParameter); } } } }
CPoolRenderableObjectTechnique::CPoolRenderableObjectTechnique(CXMLTreeNode &TreeNode) { setName(TreeNode.GetPszProperty("name")); }
CEffect::CEffect(CXMLTreeNode &XMLNode) : m_Effect(NULL) , m_WorldMatrixParameter(NULL) , m_ViewMatrixParameter(NULL) , m_ProjectionMatrixParameter(NULL) , m_WorldViewMatrixParameter(NULL) , m_ViewProjectionMatrixParameter(NULL) , m_WorldViewProjectionMatrixParameter(NULL) , m_ShadowViewProjectionMatrixParameter(NULL) , m_ShadowWorldViewProjectionMatrixParameter(NULL) , m_ShadowCameraPositionParameter(NULL) , m_ViewInverseMatrixParameter(NULL) , m_WorldInverseMatrixParameter(NULL) , m_ProjInverseMatrixParameter(NULL) , m_LightsTypeParameter(NULL) , m_LightsPositionParameter(NULL) , m_LightsDirectionParameter(NULL) , m_LightsAngleParameter(NULL) , m_LightsColorParameter(NULL) , m_LightsFallOffParameter(NULL) , m_LightsStartRangeAttenuationParameter(NULL) , m_LightsEndRangeAttenuationParameter(NULL) , m_CameraPositionParameter(NULL) , m_BonesParameter(NULL) , m_TimeParameter(NULL) , m_NumLightsParameter(NULL) , m_ViewProjectionInverseMatrixParameter(NULL) , m_HalfPixelParameter(NULL) , m_RenderTargetSizeParameter(NULL) , m_LightShadowStaticEnableParameter(NULL) , m_LightShadowDynamicEnableParameter(NULL) , m_LightIntensityParameter(NULL) , m_ActiveLights(0) , m_LightLinNearFarParameter(NULL) , m_ShadowWorldViewMatrixParameter(NULL) , m_ShadowLightLinNearFarParameter(NULL) , m_ElapsedTimeParameter(NULL) , m_TotalElapsedTimeParameter(NULL) , m_TextureDimParameter(NULL) , m_ShadowViewParameter(NULL) , m_PrevViewMatrixParameter(NULL) , m_PrevProjectionMatrixParameter(NULL) , m_PrevViewProjectionMatrixParameter(NULL) , m_CascadeShadowViewProjectionParameter(NULL) , m_CascadeDistancesParameter(NULL) , m_CascadeShadowMapPixelSizeParameter(NULL) { m_EffectName = XMLNode.GetPszProperty("name", ""); m_FileName = XMLNode.GetPszProperty("file", ""); for(uint16 i=0; i<MAX_PARAMS_BY_EFFECT; ++i) { m_Parameters.push_back(NULL); } memset(m_StaticShadowMapSamplerParameter, 0, sizeof(D3DXHANDLE) * MAX_LIGHTS_BY_SHADER); memset(m_DynamicShadowMapSamplerParameter, 0, sizeof(D3DXHANDLE) * MAX_LIGHTS_BY_SHADER); memset(m_LightLinNearFar, 0, sizeof(Vect2f) * MAX_LIGHTS_BY_SHADER); memset(m_LightsIntensity, 0, sizeof(float) * MAX_LIGHTS_BY_SHADER); memset(m_LightShadowViewProjection, 0, sizeof(Mat44f) * MAX_LIGHTS_BY_SHADER); memset(m_LightsType, 0, sizeof(int) * MAX_LIGHTS_BY_SHADER); memset(m_LightsAngle, 0, sizeof(float) * MAX_LIGHTS_BY_SHADER); memset(m_LightsFallOff, 0, sizeof(float) * MAX_LIGHTS_BY_SHADER); memset(m_LightsStartRangeAttenuation, 0, sizeof(float) * MAX_LIGHTS_BY_SHADER); memset(m_LightsEndRangeAttenuation, 0, sizeof(float) * MAX_LIGHTS_BY_SHADER); memset(m_LightsPosition, 0, sizeof(Vect3f) * MAX_LIGHTS_BY_SHADER); memset(m_LightsDirection, 0, sizeof(Vect3f) * MAX_LIGHTS_BY_SHADER); memset(m_LightsColor, 0, sizeof(Vect3f) * MAX_LIGHTS_BY_SHADER); memset(m_LightsDynamicShadowMap, 0, sizeof(CTexture*) * MAX_LIGHTS_BY_SHADER); memset(m_LightsStaticShadowMap, 0, sizeof(CTexture*) * MAX_LIGHTS_BY_SHADER); memset(m_LightsDynamicShadowMapEnable, 0, sizeof(BOOL) * MAX_LIGHTS_BY_SHADER); memset(m_LightsStaticShadowMapEnable, 0, sizeof(BOOL) * MAX_LIGHTS_BY_SHADER); ZeroMemory(m_CascadeDistance, sizeof(Vect3f) * MAX_LIGHTS_BY_SHADER); ZeroMemory(m_CascadeShadowMapPixelSize, sizeof(Vect2f) * MAX_LIGHTS_BY_SHADER); ZeroMemory(m_CascadeShadowViewProjection, sizeof(Mat44f) * MAX_LIGHTS_BY_SHADER * NUM_CASCADES); }