当前位置: 首页>>代码示例>>C++>>正文


C++ Wall::addDoor方法代码示例

本文整理汇总了C++中Wall::addDoor方法的典型用法代码示例。如果您正苦于以下问题:C++ Wall::addDoor方法的具体用法?C++ Wall::addDoor怎么用?C++ Wall::addDoor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Wall的用法示例。


在下文中一共展示了Wall::addDoor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: drawObject

void GLBox::drawObject(const QDomDocument &doc)
{
	QDomElement root = doc.documentElement().toElement();

	QDomElement texture1 = root.elementsByTagName("textures").item(0).toElement();

	for (QDomNode i = texture1.firstChild(); !i.isNull(); i = i.nextSibling())
	{
		QDomElement e = i.toElement();

		QString name = e.attribute("name");
		QString file = e.attribute("file");
		QString color = e.attribute("color", "0xFFFFFF");
		QString xscale = e.attribute("xscale", "1.0");
		QString yscale = e.attribute("yscale", "1.0");

		qDebug()<<"Adding Texture:"<<name<<color<<file<<xscale<<yscale;
		textures[name] = Texture(color.toUInt(0, 16), file, xscale.toFloat(), yscale.toFloat());
	}

	QDomElement item = root.elementsByTagName("items").item(0).toElement();

	for (QDomNode i = item.firstChild(); !i.isNull(); i = i.nextSibling())
	{
		QDomElement e = i.toElement();

		QString x = e.attribute("x");
		QString y = e.attribute("y");
		QString z = e.attribute("z");
		QString rotation = e.attribute("rotation", "0.0");
		QString type = e.attribute("type");

		if (type == "wall")
		{
			QString length = e.attribute("length");
			QString innerTexture = e.attribute("innerTexture");
			QString outerTexture = e.attribute("outerTexture");
			QString height = e.attribute("height", "10.0");
			QString thickness = e.attribute("thickness", "0.5");

			qDebug()<<"Adding Wall:"<<x<<y<<z<<rotation<<length<<innerTexture<<outerTexture<<height<<thickness;

			Wall *wall = new Wall(x.toFloat(), y.toFloat(), z.toFloat(), rotation.toFloat(), length.toFloat(), textures[innerTexture], textures[outerTexture], height.toFloat(), thickness.toFloat());

			// now we start parsing the windows
			for (QDomNode w = e.firstChild(); !w.isNull(); w = w.nextSibling()) {
				QDomElement tmp = w.toElement();

				if (tmp.tagName() == "window") {
					QString position = tmp.attribute("position");
					QString length = tmp.attribute("length");
					QString texture = tmp.attribute("texture");
					QString lowerHeight = tmp.attribute("lowerHeight", "3.0");
					QString upperHeight = tmp.attribute("upperHeight", "7.0");
					wall->addWindow(position.toFloat(), length.toFloat(), textures[texture], lowerHeight.toFloat(), upperHeight.toFloat());
					qDebug()<<"Added Window:"<<position<<length<<texture<<lowerHeight<<upperHeight;
				}
				else if (tmp.tagName() == "door") {
					QString position = tmp.attribute("position");
					QString length = tmp.attribute("length");
					QString texture = tmp.attribute("texture");
					QString height = tmp.attribute("height", "7.0");
					wall->addDoor(position.toFloat(), length.toFloat(), textures[texture], height.toFloat());
					qDebug()<<"Added Door:"<<position<<length<<texture<<height;
				}
			}

			addObject(wall);
		} else if (type == "floor") {
			QString texture = e.attribute("texture");
			qDebug()<<"Adding Floor:"<<x<<y<<z<<rotation;
			Floor *floor = new Floor(x.toFloat(), y.toFloat(), z.toFloat(), rotation.toFloat(), textures[texture]);

			// now we start parsing the windows
			for (QDomNode w = e.firstChild(); !w.isNull(); w = w.nextSibling()) {
				QDomElement tmp = w.toElement();

				if (tmp.tagName() == "point") {
					QString x = tmp.attribute("x");
					QString y = tmp.attribute("y");
					floor->addPoint(x.toFloat(), y.toFloat());

					qDebug()<<"Added Point:"<<x<<y;
				}
			}

			addObject(floor);
		}
	}
}
开发者ID:sourav87,项目名称:lblock,代码行数:90,代码来源:drawobject.cpp


注:本文中的Wall::addDoor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。