本文整理汇总了C++中TiXmlElement::QueryFloatAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlElement::QueryFloatAttribute方法的具体用法?C++ TiXmlElement::QueryFloatAttribute怎么用?C++ TiXmlElement::QueryFloatAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlElement
的用法示例。
在下文中一共展示了TiXmlElement::QueryFloatAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readStaticEntity
/**
* Lee el tag XML static y agrega al escenario la entidad correspondiente
* @param pStaticElement
* @param scenario
*/
logic::CEntity* CScenariosXmlDao::readStaticEntity(TiXmlElement* pStaticElement) {
TiXmlHandle hStatic(pStaticElement);
TiXmlElement* pPositionElement = hStatic.FirstChild("position").Element();
TiXmlElement* pOrientationElement = hStatic.FirstChild("orientation").Element();
string id = pStaticElement->Attribute("id");
bool reflect = false;
logic::tRGBAColor color;
if(pStaticElement->Attribute("reflect")){
TiXmlElement* pColorElement = hStatic.FirstChild("color").Element();
pColorElement->QueryFloatAttribute("r",&color.r);
pColorElement->QueryFloatAttribute("g",&color.g);
pColorElement->QueryFloatAttribute("b",&color.b);
pColorElement->QueryFloatAttribute("a",&color.a);
//cout<<"[ScenariosXmlDao::readScenario] Elemento: "<<id<<" REFLEJA!!\n";
reflect = true;
}
float x=0,y=0,z=0;
pPositionElement->QueryFloatAttribute("x",&x);
pPositionElement->QueryFloatAttribute("y",&y);
pPositionElement->QueryFloatAttribute("z",&z);
float orientation = 0;
pOrientationElement->QueryFloatAttribute("value",&orientation);
//cout<<"[ScenariosXmlDao::readScenario]Entidad "<<id<<", ["<<x<<", "<<y<<", "<<z<<"], "<<orientation<<"\n";
logic::CEntity* entity = new logic::CEntity(id, x, y, z, orientation, true);
entity->setReflection(reflect);
entity->setColor(color);
return entity;
}
示例2: readScreen
logic::CScreen* CScenariosXmlDao::readScreen(TiXmlElement* pScreenElement) {
TiXmlHandle hScreen(pScreenElement);
TiXmlElement* pPositionElement = hScreen.FirstChild("position").Element();
TiXmlElement* pOrientationElement = hScreen.FirstChild("orientation").Element();
TiXmlElement* pSkinsElement = hScreen.FirstChild("skins").Element();
string id = pScreenElement->Attribute("id");
float interval = 0;
pSkinsElement->QueryFloatAttribute("interval", &interval);
float x=0,y=0,z=0;
pPositionElement->QueryFloatAttribute("x",&x);
pPositionElement->QueryFloatAttribute("y",&y);
pPositionElement->QueryFloatAttribute("z",&z);
float orientation = 0;
pOrientationElement->QueryFloatAttribute("value",&orientation);
vector<string> skinList = readSkins(pSkinsElement);
//cout<<"[ScenariosXmlDao::readScreen]Entidad "<<id<<", ["<<x<<", "<<y<<", "<<z<<"], "<<orientation<<"\n";
logic::CScreen* screen = new logic::CScreen(id, x, y, z, orientation, true);
screen->setSkinList(skinList);
screen->setInterval(interval);
return screen;
}
示例3: readHost
logic::CQuizShowHost* CScenariosXmlDao::readHost(TiXmlElement* pHostElement) {
//cout<<"Etiqueta: "<<pHostElement->Value()<<"\n";
string id = pHostElement->Attribute("id");
string type = "";
if(pHostElement->Attribute("type"))
type = pHostElement->Attribute("type");
TiXmlHandle hHost(pHostElement);
TiXmlElement* pPositionElement = hHost.FirstChild("position").Element();
TiXmlElement* pOrientationElement = hHost.FirstChild("orientation").Element();
float x=0,y=0,z=0;
pPositionElement->QueryFloatAttribute("x",&x);
pPositionElement->QueryFloatAttribute("y",&y);
pPositionElement->QueryFloatAttribute("z",&z);
float orientation = 0;
pOrientationElement->QueryFloatAttribute("value",&orientation);
//cout<<"[ScenariosXmlDao::readScenario] Animado "<<id<<", ["<<x<<", "<<y<<", "<<z<<"], "<<orientation<<"\n";
logic::CQuizShowHost* host= new logic::CQuizShowHost(id, id, x, y, z, orientation, true, 9);
return host;
}
示例4: readAudience
logic::CAvatar* CScenariosXmlDao::readAudience(TiXmlElement* pPublicElement) {
//cout<<"Etiqueta: "<<pPublicElement->Value()<<"\n";
string id = pPublicElement->Attribute("id");
string type = "";
if(pPublicElement->Attribute("type"))
type = pPublicElement->Attribute("type");
TiXmlHandle hPublic(pPublicElement);
TiXmlElement* pPositionElement = hPublic.FirstChild("position").Element();
TiXmlElement* pOrientationElement = hPublic.FirstChild("orientation").Element();
float x=0,y=0,z=0;
pPositionElement->QueryFloatAttribute("x",&x);
pPositionElement->QueryFloatAttribute("y",&y);
pPositionElement->QueryFloatAttribute("z",&z);
float orientation = 0;
pOrientationElement->QueryFloatAttribute("value",&orientation);
//cout<<"[ScenariosXmlDao::readScenario] Animado "<<id<<", ["<<x<<", "<<y<<", "<<z<<"], "<<orientation<<"\n";
logic::CAvatar* audience= new logic::CAvatar("player", id, x, y, z, orientation, true, 10);
return audience;
}
示例5: ReadFromXMLFile
bool ETHSceneProperties::ReadFromXMLFile(TiXmlElement *pRoot)
{
TiXmlNode *pNode;
pNode = pRoot->FirstChild(GS_L("SceneProperties"));
if (pNode)
{
TiXmlElement *pElement = pNode->ToElement();
pElement->QueryFloatAttribute(GS_L("lightIntensity"), &lightIntensity);
pElement->QueryFloatAttribute(GS_L("parallaxIntensity"), ¶llaxIntensity);
TiXmlElement *pIter;
pNode = pElement->FirstChild(GS_L("Ambient"));
if (pNode)
{
pIter = pNode->ToElement();
if (pIter)
{
pIter->QueryFloatAttribute(GS_L("r"), &ambient.x);
pIter->QueryFloatAttribute(GS_L("g"), &ambient.y);
pIter->QueryFloatAttribute(GS_L("b"), &ambient.z);
}
}
pNode = pElement->FirstChild(GS_L("ZAxisDirection"));
if (pNode)
{
pIter = pNode->ToElement();
if (pIter)
{
pIter->QueryFloatAttribute(GS_L("x"), &zAxisDirection.x);
pIter->QueryFloatAttribute(GS_L("y"), &zAxisDirection.y);
}
}
}
return true;
}
示例6: Init
void File::Init(TiXmlNode *node)
{
TiXmlElement *element = node->ToElement();
if (element)
{
int intValue;
float floatValue;
if (element->QueryIntAttribute("id", &intValue) == TIXML_SUCCESS)
id = intValue;
else
id = 0;
name = element->Attribute("name");
if (element->QueryFloatAttribute("width", &floatValue) == TIXML_SUCCESS)
width = floatValue;
else
width = 0;
if (element->QueryFloatAttribute("height", &floatValue) == TIXML_SUCCESS)
height = floatValue;
else
height = 0;
if (name.size()>0)
{
sprite = CCSprite::createWithSpriteFrameName(name.c_str());
// sprite = CCSprite::create(name.c_str());
sprite->retain();
}
}
}
示例7: processLights
void YafFile::processLights(TiXmlElement* lights)
{
float location[4], ambient[4], diffuse[4], specular[4];
float angle = 0, exponent = 0, direction[3];
bool enabled;
string type;
char* id;
Light* light;
TiXmlElement* element = lights->FirstChildElement();
while(element!=NULL)
{
element->QueryBoolAttribute("enabled",&enabled);
id = (char*)element->Attribute("id");
read3Float("location", element, location[0], location[1], location[2]);
read4Float("ambient", element, ambient[0], ambient[1], ambient[2],
ambient[3]);
read4Float("diffuse", element, diffuse[0], diffuse[1], diffuse[2],
diffuse[3]);
read4Float("specular", element, specular[0], specular[1], specular[2],
specular[3]);
if(element->Attribute("angle")!=NULL)
{
type="spot";
element->QueryFloatAttribute("angle", &angle);
element->QueryFloatAttribute("exponent", &exponent);
read3Float("direction", element, direction[0], direction[1],
direction[2]);
}
light = new Light(id,enabled,type,location,ambient,diffuse,specular,angle,exponent,direction);
this->sceneLights.push_back(light);
element=element->NextSiblingElement();
}
}
示例8: doc
// A font is specified by two files: a TGA file with the rendered
// chars for the font, and a XML file which contains global info
// about the font and the texture coordinates and width of each char
// The parameter fontName is the filename without extension.
// It is assumed that the files are "fontName.xml" and "fontName.tga"
bool
VSFontLib::load(std::string fontName)
{
// Test if image file exists
FILE *fp;
std::string s;
s = fontName + ".tga";
fp = fopen(s.c_str(),"r");
if (fp == NULL) {
VSResourceLib::sLogError.addMessage("Unable to find font texture: %s", s.c_str());
return false;
}
mFontTex = loadRGBATexture(s);
s = fontName + ".xml";
TiXmlDocument doc(s.c_str());
bool loadOK = doc.LoadFile();
if (!loadOK) {
VSResourceLib::sLogError.addMessage("Problem reading the XML font definition file: %s", s.c_str());
return false;
}
TiXmlHandle hDoc(&doc);
TiXmlHandle hRoot(0);
TiXmlElement *pElem;
pElem = hDoc.FirstChildElement().Element();
if (0 == pElem)
return false;
hRoot = TiXmlHandle(pElem);
pElem->QueryIntAttribute("numchars",&mNumChars);
if (mNumChars == 0)
return false;
hRoot = hRoot.FirstChild("characters");
pElem = hRoot.FirstChild("chardata").Element();
if (pElem)
pElem->QueryIntAttribute("hgt",&mHeight);
VSFLChar aChar;
int charCode, numChars = 0;
for(; 0 != pElem; pElem = pElem->NextSiblingElement(), ++numChars) {
pElem->QueryIntAttribute("char",&charCode);
pElem->QueryIntAttribute("wid",&(aChar.width));
pElem->QueryFloatAttribute("X1", &(aChar.x1));
pElem->QueryFloatAttribute("X2", &(aChar.x2));
pElem->QueryFloatAttribute("Y1", &(aChar.y1));
pElem->QueryFloatAttribute("Y2", &(aChar.y2));
pElem->QueryIntAttribute("A", &(aChar.A));
pElem->QueryIntAttribute("C", &(aChar.C));
mChars[(unsigned char)charCode] = aChar;
}
VSResourceLib::sLogInfo.addMessage("Font has %d chars", numChars);
return true;
}
示例9: extractLights
/**
* Extract a light elements containing position (x, y, z) and colour (r, g, b) attributes
*/
void MapLoader::extractLights() {
Vector3f lightPos;
Vector3f lightColor;
float distance;
float energy;
TiXmlElement* lightElement = rootHandle.FirstChild("light").ToElement();
do {
XmlHelper::pushAttributeVertexToVector(lightElement, lightPos);
lightElement->QueryFloatAttribute("r", &lightColor.x);
lightElement->QueryFloatAttribute("g", &lightColor.y);
lightElement->QueryFloatAttribute("b", &lightColor.z);
lightElement->QueryFloatAttribute("distance", &distance);
lightElement->QueryFloatAttribute("energy", &energy);
scene->lights.emplace_back();
Light &light = scene->lights.back();
light.position.set(lightPos.x, lightPos.y, lightPos.z);
light.color.set(lightColor.x, lightColor.y, lightColor.z);
light.distance = distance;
light.energy = energy;
} while ((lightElement = lightElement->NextSiblingElement("light")) != nullptr);
}
示例10: extractButtons
void MapLoader::extractButtons() {
TiXmlElement *textureElement = rootHandle.FirstChild("texture").ToElement();
string texturePath("none");
string surfaceType("none");
Vector2f position;
Vector2f size;
if (textureElement) {
do {
textureElement->QueryStringAttribute("source", &texturePath);
textureElement->QueryStringAttribute("type", &surfaceType);
TiXmlElement *buttonElement = textureElement->FirstChildElement("GUIbutton");
if (buttonElement) {
do {
scene->buttons.emplace_back();
GUIButton &button = scene->buttons.back();
buttonElement->QueryFloatAttribute("x", &position.x);
buttonElement->QueryFloatAttribute("y", &position.y);
buttonElement->QueryFloatAttribute("w", &size.x);
buttonElement->QueryFloatAttribute("h", &size.y);
button.texture = TextureLoader::getTexture(texturePath);
button.texture.xTiling = 0.5f;
button.texture.yTiling = 0.5f;
} while ((buttonElement = buttonElement->NextSiblingElement("GUIbutton")) != nullptr);
}
texturePath = "none";
} while ((textureElement = textureElement->NextSiblingElement("texture")) != nullptr);
}
}
示例11: ReadFromXMLFile
bool ETHLight::ReadFromXMLFile(TiXmlElement *pElement)
{
int nActive;
pElement->QueryIntAttribute(GS_L("active"), &nActive);
active = static_cast<ETH_BOOL>(nActive);
int nStatic;
pElement->QueryIntAttribute(GS_L("static"), &nStatic);
staticLight = static_cast<ETH_BOOL>(nStatic);
int nCastShadows;
pElement->QueryIntAttribute(GS_L("castShadows"), &nCastShadows);
castShadows = static_cast<ETH_BOOL>(nCastShadows);
pElement->QueryFloatAttribute(GS_L("range"), &range);
pElement->QueryFloatAttribute(GS_L("haloBrightness"), &haloBrightness);
pElement->QueryFloatAttribute(GS_L("haloSize"), &haloSize);
TiXmlNode *pNode;
TiXmlElement *pIter;
pNode = pElement->FirstChild(GS_L("Position"));
if (pNode)
{
pIter = pNode->ToElement();
if (pIter)
{
pIter->QueryFloatAttribute(GS_L("x"), &pos.x);
pIter->QueryFloatAttribute(GS_L("y"), &pos.y);
pIter->QueryFloatAttribute(GS_L("z"), &pos.z);
}
}
pNode = pElement->FirstChild(GS_L("Color"));
if (pNode)
{
pIter = pNode->ToElement();
if (pIter)
{
pIter->QueryFloatAttribute(GS_L("r"), &color.x);
pIter->QueryFloatAttribute(GS_L("g"), &color.y);
pIter->QueryFloatAttribute(GS_L("b"), &color.z);
}
}
pNode = pElement->FirstChild(GS_L("HaloBitmap"));
if (pNode)
{
TiXmlElement *pStringElement = pNode->ToElement();
if (pStringElement)
{
haloBitmap = pStringElement->GetText();
}
}
return true;
}
示例12: loadXML
void ControlSuper::loadXML(TiXmlElement &root)
{
root.QueryBoolAttribute("enabled",&enabled);
root.QueryBoolAttribute("hidden",&hidden);
root.QueryFloatAttribute("left", &controlPos.left);
root.QueryFloatAttribute("right", &controlPos.right);
root.QueryFloatAttribute("top", &controlPos.top);
root.QueryFloatAttribute("bottom",&controlPos.bottom);
}
示例13: Load
bool CTextureAtlas::Load()
{
BEATS_ASSERT(!IsLoaded());
TString fileext = CFilePathTool::GetInstance()->Extension(GetFilePath().c_str());
if(fileext == _T(".xml"))
{
TiXmlDocument doc;
CSerializer serializer;
CFilePathTool::GetInstance()->LoadFile(&serializer, GetFilePath().c_str(), _T("rb"));
if (serializer.GetWritePos() != serializer.GetReadPos())
{
doc.Parse((char*)serializer.GetReadPtr());
}
TiXmlElement *root = doc.RootElement();
BEATS_ASSERT(root && strcmp(root->Value(), "Imageset") == 0,
_T("TextureAtlas file %s not found or incorrect!"), GetFilePath().c_str());
const char *textureFile = root->Attribute("Imagefile");
BEATS_ASSERT(textureFile);
TCHAR szNameBuffer[MAX_PATH];
CStringHelper::GetInstance()->ConvertToTCHAR(textureFile, szNameBuffer, MAX_PATH);
m_texture = CResourceManager::GetInstance()->GetResource<CTexture>(szNameBuffer);
kmVec2 size;
kmVec2 point;
TString strName;
for(TiXmlElement *elemImage = root->FirstChildElement("Image");
elemImage != nullptr; elemImage = elemImage->NextSiblingElement("Image"))
{
const char *name = elemImage->Attribute("Name");
BEATS_ASSERT(name);
kmVec2Fill(&point, 0.f, 0.f);
kmVec2Fill(&size, 0.f, 0.f);
elemImage->QueryFloatAttribute("XPos", &point.x);
elemImage->QueryFloatAttribute("YPos", &point.y);
elemImage->QueryFloatAttribute("Width", &size.x);
elemImage->QueryFloatAttribute("Height", &size.y);
CStringHelper::GetInstance()->ConvertToTCHAR(name, szNameBuffer, MAX_PATH);
strName.assign(szNameBuffer);
CreateTextureFrag(strName, point, size);
}
}
else
{
m_texture = CResourceManager::GetInstance()->GetResource<CTexture>(GetFilePath());
}
m_name = CFilePathTool::GetInstance()->FileName(GetFilePath().c_str());
super::Load();
return true;
}
示例14: loadLevel
/**
* @method PigManager::loadLevel()
* @desc parse the current level xml and instantiate the pigs in it
*/
void PigManager::loadLevel(TiXmlElement* levelPigElement)
{
if (numPigs > 0)
{
shutdown();
}
numPigs = 0;
TiXmlElement* levelPig = levelPigElement->FirstChildElement();
while (levelPig != NULL)
{
numPigs++;
levelPig = levelPig->NextSiblingElement();
}
pigList = new EnemyPig*[numPigs];
int i = 0;
int x, y;
float wid, ht;
levelPig = levelPigElement->FirstChildElement();
ObjectData currentPigData;
while (levelPig != NULL)
{
const char* currentBlockType = levelPig->Attribute("type");
int j;
for (j = 0; j < totalPossiblePigs; j++)
{
if (strcmp(currentBlockType, allPigsData[j].objectType) == 0)
{
currentPigData = allPigsData[j];
break;
}
}
assert(j < totalPossiblePigs);
levelPig->QueryIntAttribute("x", &x);
levelPig->QueryIntAttribute("y", &y);
levelPig->QueryFloatAttribute("wid", &wid);
levelPig->QueryFloatAttribute("ht", &ht);
pigList[i] = new EnemyPig();
pigList[i]->init(x, y, wid, currentPigData);
levelPig = levelPig->NextSiblingElement();
i++;
}
CGame::GetInstance()->setPigCount(numPigs);
}
示例15: doc
void
FontXMLLoader::loadFont (Font *aFont, std::string &aFilename)
{
File::FixSlashes(aFilename);
std::string s = aFilename;
int numChars,height;
TiXmlDocument doc(s.c_str());
bool loadOK = doc.LoadFile();
if (!loadOK) {
NAU_THROW("Parsing Error -%s- Line(%d) Column(%d) in file: %s", doc.ErrorDesc(), doc.ErrorRow(), doc.ErrorCol(),aFilename.c_str());
}
TiXmlHandle hDoc(&doc);
TiXmlHandle hRoot(0);
TiXmlElement *pElem;
pElem = hDoc.FirstChildElement().Element();
if (0 == pElem)
NAU_THROW("Not a XML file: %s", aFilename.c_str());
hRoot = TiXmlHandle(pElem);
pElem->QueryIntAttribute("numchars",&numChars);
if (numChars == 0)
NAU_THROW("Zero chars in file: %s", aFilename.c_str());
hRoot = hRoot.FirstChild("characters");
pElem = hRoot.FirstChild("chardata").Element();
if (pElem) {
pElem->QueryIntAttribute("hgt",&height);
if (pElem)
aFont->setFontHeight(height);
}
int code,width,A,C;
float x1,x2,y1,y2;
for(; 0 != pElem; pElem = pElem->NextSiblingElement()) {
pElem->QueryIntAttribute("char",&code);
pElem->QueryIntAttribute("wid",&(width));
pElem->QueryFloatAttribute("X1", &(x1));
pElem->QueryFloatAttribute("X2", &(x2));
pElem->QueryFloatAttribute("Y1", &(y1));
pElem->QueryFloatAttribute("Y2", &(y2));
pElem->QueryIntAttribute("A", &(A));
pElem->QueryIntAttribute("C", &(C));
aFont->addChar(code,width,x1,x2,y1,y2,A,C);
}
}