本文整理汇总了C++中BodyPart::addTexture方法的典型用法代码示例。如果您正苦于以下问题:C++ BodyPart::addTexture方法的具体用法?C++ BodyPart::addTexture怎么用?C++ BodyPart::addTexture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BodyPart
的用法示例。
在下文中一共展示了BodyPart::addTexture方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadBodyParts
void ResourceManager::loadBodyParts(const std::string &filename)
{
XMLFile file;
int size;
char *data = loadFile(filename, size);
if (data && file.parse(data))
{
// set size
file.setElement("size");
mBodyWidth = file.readInt("size", "width");
mBodyHeight = file.readInt("size", "height");
// set defaults
file.setElement("default");
mDefaultBody = file.readInt("default", "body");
mDefaultFemale = file.readInt("default", "female");
mDefaultHair = file.readInt("default", "hair");
mDefaultChest = file.readInt("default", "chest");
mDefaultLegs = file.readInt("default", "legs");
mDefaultFeet = file.readInt("default", "feet");
// add all the body parts
file.setElement("body");
do
{
file.setSubElement("image");
int id = file.readInt("body", "id");
std::string icon = file.readString("body", "icon");
int part = file.readInt("body", "part");
std::string colour = file.readString("body", "colour");
Texture *iconTex = NULL;
if (icon != "")
{
if (getDataPath(icon).find(".zip") == std::string::npos)
{
iconTex = graphicsEngine->loadTexture(getDataPath(icon));
}
else
{
int iconBufSize = 0;
char *buffer = loadFile(icon, iconBufSize);
iconTex = graphicsEngine->loadTexture(icon, buffer, iconBufSize);
free(buffer);
}
if (iconTex == NULL)
{
logger->logError("Unable to load icon: " + icon);
}
}
BodyPart *body = new BodyPart(id, part, iconTex);
do
{
int dir = -1;
// check if img is in a content update
std::string img = file.readString("image", "file");
std::string dirstr = file.readString("image", "dir");
if (dirstr == "SE")
dir = DIRECTION_SOUTHEAST;
else if (dirstr == "SW")
dir = DIRECTION_SOUTHWEST;
else if (dirstr == "NE")
dir = DIRECTION_NORTHEAST;
else if (dirstr == "NW")
dir = DIRECTION_NORTHWEST;
std::string path = getDataPath(img);
size_t found = path.find(".zip");
if (found == std::string::npos)
{
body->addTexture(dir, path);
}
else
{
int imgBufSize = 0;
char *buffer = loadFile(img, imgBufSize);
body->addTexture(dir, img, buffer, imgBufSize);
free(buffer);
}
} while (file.nextSubElement("image"));
mBodyParts.push_back(body);
file.clear("image");
} while (file.nextElement("body"));
}
}