//---------------------------------------------------------------------------- // 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 } } }
/// <summary> /// Carga el .xml de sonido. /// </summary> ///<param name="&FileName">Ubicación del archivo xml.</param> bool CSoundManager::Load(const std::string &FileName) { SSoundData soundData; bool l_bIsOk = true; m_FileName = FileName; CXMLTreeNode filexml; if (!filexml.LoadFile(m_FileName.c_str())) { // Guarda mensaje de error en el log std::string msg_error = "CSoundManager::Load->Error al intentar abrir el archivo: "; msg_error.append(m_FileName.c_str()); LOGGER->AddNewLog(ELL_ERROR, msg_error.c_str()); throw CException(__FILE__, __LINE__, msg_error); l_bIsOk = false; } else { CXMLTreeNode cores = filexml["sounds"]; if (cores.Exists()) { m_iMaxChannels = cores.GetIntProperty("maxChannels"); // Asignando número de canales de acuerdo al parametro extraído del .xml m_Channels.resize(m_iMaxChannels); if (!cores.IsComment()) { int32 numNodes = cores.GetNumChildren(); for(int i=0; i < numNodes; i++) { if (!cores(i).IsComment()) { // Recibe parametros de los sonidos std::string l_sCoreName = cores(i).GetPszProperty("name"); std::string l_sCoreType = cores(i).GetPszProperty("type"); std::string l_sCorePath = cores(i).GetPszProperty("path"); bool l_bCoreLoop = cores(i).GetBoolProperty("loop"); bool l_bCore3D = cores(i).GetBoolProperty("threeDimensional"); std::string l_sCorePriority = cores(i).GetPszProperty("priority"); std::string l_sCoreEffect = cores(i).GetPszProperty("effect"); float l_fCoreVolume = cores(i).GetFloatProperty("volume"); int iMask = 0; int PathLastCharacters = l_sCorePath.length() - 3; std::string substring = l_sCorePath.substr(PathLastCharacters,3); if (substring != "wav") { // Convert the sample (MP3/MP2/MP1 only) to mono, if it's not already. iMask = BASS_SAMPLE_MONO; } // Asigna propiedad de loop if (l_bCoreLoop) { iMask |= BASS_SAMPLE_LOOP; soundData.m_Loop = true; } else { soundData.m_Loop = false; } // Asigna propiedad 3D y posición 3D if (l_bCore3D) { iMask |= BASS_SAMPLE_3D; soundData.m_ThreeDimensional = true; soundData.m_Position = cores(i).GetVect3fProperty("position", Vect3f(0.0, 0.0, 0.0)); } else { soundData.m_ThreeDimensional = false; } if (l_sCoreType == "sample") { // Genera identificador para sonido soundData.m_type = SAMPLER; soundData.m_Id = BASS_SampleLoad(false, l_sCorePath.c_str(), 0, 0, m_iMaxChannels, iMask); } else { // Genera identificador para música soundData.m_Id = BASS_StreamCreateFile(false, l_sCorePath.c_str(), 0, 0, iMask); soundData.m_type = BGM; } // Añadiendo volumen soundData.m_Volume = l_fCoreVolume; // Añade sonido al mapa m_Resources[l_sCoreName] = soundData; } } } } else { l_bIsOk = false; } } return l_bIsOk; }
bool CSpirit::LoadXML(std::string fileName) { m_pFileName = fileName; CXMLTreeNode header; if(!header.LoadFile(fileName.c_str())) { //Guardar el mensaje de error en el LOGGER std::string msg_error = " CSpirit::Load->Error al intentar abrir el archivo: "; msg_error.append(fileName.c_str()); LOGGER->AddNewLog(ELL_ERROR, msg_error.c_str()); //throw CException(__FILE__, __LINE__, msg_error); return false; } else { //<spirit> //<parameters posini="3 2 -3" apertura="0.2" speedup="3.3" speeddown="0.5" heightflymax="3.0" heightflymin="1.9" //speedslow="1.0" speedfast="1.5" distnear="4.0" distfar="6.0" //timeidle="5.0" timechase="5.0" //numlaps="2" speedcontento="4.0" ///> //</spirit> //solo un spirit**** CXMLTreeNode tag = header["spirit"]; if(tag.Exists()) { if (!tag.IsComment()) { CXMLTreeNode params = tag(0)["parameters"]; if (params.Exists()) { m_V3PosIni = params.GetVect3fProperty("posini", Vect3f(3.0f, 1.5f, -3.8f)); // m_V3Pos = params.GetVect3fProperty("posini", Vect3f(3.0f, 1.5f, -3.8f)); //quitado para dejar estatico el espiritu m_fSpeed_YUp = params.GetFloatProperty("speedup",3.3f); m_fSpeed_YDown = params.GetFloatProperty("speeddown",0.5f); m_fPosYMax = params.GetFloatProperty("heightflymax",3.f); m_fPosYMin = params.GetFloatProperty("heightflymin",1.9f); m_fAperturaEmisor = params.GetFloatProperty("apertura",0.2f); m_fSpeedMax = params.GetFloatProperty("speedfast",1.5f); m_fSpeedMin = params.GetFloatProperty("speedslow",1.f); m_fDistFar = params.GetFloatProperty("distfar",6.f); m_fDistNear = params.GetFloatProperty("distnear",10.f); m_fDelayTimeIdle = params.GetFloatProperty("timeidle",5.f); m_fDelayTimeChase = params.GetFloatProperty("timechase",5.f); m_uiNumeroVueltasContento = params.GetIntProperty("numlaps",1); m_fSpeedRotationContento = params.GetFloatProperty("speedcontento",3.f); m_pLight = CORE->GetLigthManager()->GetResource(params.GetPszProperty("light", "")); } } } else { //Guardar el mensaje de error en el LOGGER std::string msg_error = " CSpirit::Load->Parametros mal configurados "; msg_error.append(fileName.c_str()); LOGGER->AddNewLog(ELL_ERROR, msg_error.c_str()); //throw CException(__FILE__, __LINE__, msg_error); return false; } } return true; }