CollisionShape3D *CollisionCylinderReaderWriter::loadFrom(std::shared_ptr<XmlChunk> shapeChunk, const XmlParser &xmlParser) const
	{
		std::shared_ptr<XmlChunk> orientationChunk = xmlParser.getUniqueChunk(true, ORIENTATION_TAG, XmlAttribute(), shapeChunk);
		std::string orientationValue = orientationChunk->getStringValue();
		CylinderShape<float>::CylinderOrientation orientation;
		if(orientationValue.compare(X_VALUE)==0)
		{
			orientation = CylinderShape<float>::CylinderOrientation::CYLINDER_X;
		}else if(orientationValue.compare(Y_VALUE)==0)
		{
			orientation = CylinderShape<float>::CylinderOrientation::CYLINDER_Y;
		}else if(orientationValue.compare(Z_VALUE)==0)
		{
			orientation = CylinderShape<float>::CylinderOrientation::CYLINDER_Z;
		}else
		{
			throw std::invalid_argument("Cylinder orientation type unknown: " + orientationValue);
		}

		std::shared_ptr<XmlChunk> radiusChunk = xmlParser.getUniqueChunk(true, RADIUS_TAG, XmlAttribute(), shapeChunk);
		float radius = radiusChunk->getFloatValue();

		std::shared_ptr<XmlChunk> heightChunk = xmlParser.getUniqueChunk(true, HEIGHT_TAG, XmlAttribute(), shapeChunk);
		float height = heightChunk->getFloatValue();

		CollisionShape3D *collisionShape = new CollisionCylinderShape(radius, height, orientation);
		return collisionShape;
	}
	void RigidBodyReaderWriter::writeBodyPropertiesOn(const std::shared_ptr<XmlChunk> &physicsChunk, const RigidBody *rigidBody, XmlWriter &xmlWriter) const
	{
		std::shared_ptr<XmlChunk> massChunk = xmlWriter.createChunk(MASS_TAG, XmlAttribute(), physicsChunk);
		massChunk->setFloatValue(rigidBody->getMass());

		std::shared_ptr<XmlChunk> restitutionChunk = xmlWriter.createChunk(RESTITUTION_TAG, XmlAttribute(), physicsChunk);
		restitutionChunk->setFloatValue(rigidBody->getRestitution());

		std::shared_ptr<XmlChunk> frictionChunk = xmlWriter.createChunk(FRICTION_TAG, XmlAttribute(), physicsChunk);
		frictionChunk->setFloatValue(rigidBody->getFriction());

		std::shared_ptr<XmlChunk> rollingFrictionChunk = xmlWriter.createChunk(ROLLING_FRICTION_TAG, XmlAttribute(), physicsChunk);
		rollingFrictionChunk->setFloatValue(rigidBody->getRollingFriction());

		std::shared_ptr<XmlChunk> linearDampingChunk = xmlWriter.createChunk(LINEAR_DAMPING_TAG, XmlAttribute(), physicsChunk);
		linearDampingChunk->setFloatValue(rigidBody->getLinearDamping());

		std::shared_ptr<XmlChunk> angularDampingChunk = xmlWriter.createChunk(ANGULAR_DAMPING_TAG, XmlAttribute(), physicsChunk);
		angularDampingChunk->setFloatValue(rigidBody->getAngularDamping());

		std::shared_ptr<XmlChunk> linearFactorChunk = xmlWriter.createChunk(LINEAR_FACTOR_TAG, XmlAttribute(), physicsChunk);
		linearFactorChunk->setVector3Value(rigidBody->getLinearFactor());

		std::shared_ptr<XmlChunk> angularFactorChunk = xmlWriter.createChunk(ANGULAR_FACTOR_TAG, XmlAttribute(), physicsChunk);
		angularFactorChunk->setVector3Value(rigidBody->getAngularFactor());
	}
void ExeComponent::Load(TiXmlElement * node)
{
    executable = node->Attribute("executable");
    executable_silent = node->Attribute("executable_silent");
    executable_basic = node->Attribute("executable_basic");
    install_directory = node->Attribute("install_directory");
    responsefile_source = node->Attribute("responsefile_source");
    responsefile_target = node->Attribute("responsefile_target");
    responsefile_format = node->Attribute("responsefile_format");
    exeparameters = node->Attribute("exeparameters");
    exeparameters_silent = node->Attribute("exeparameters_silent");
    exeparameters_basic = node->Attribute("exeparameters_basic");
    uninstall_responsefile_source = node->Attribute("uninstall_responsefile_source");
    uninstall_responsefile_target = node->Attribute("uninstall_responsefile_target");
    uninstall_executable = node->Attribute("uninstall_executable");
    uninstall_executable_silent = node->Attribute("uninstall_executable_silent");
    uninstall_executable_basic = node->Attribute("uninstall_executable_basic");
    uninstall_exeparameters = node->Attribute("uninstall_exeparameters");
    uninstall_exeparameters_silent = node->Attribute("uninstall_exeparameters_silent");
    uninstall_exeparameters_basic = node->Attribute("uninstall_exeparameters_basic");
    returncodes_success = node->Attribute("returncodes_success");
    returncodes_reboot = node->Attribute("returncodes_reboot");
    disable_wow64_fs_redirection = XmlAttribute(node->Attribute("disable_wow64_fs_redirection")).GetBoolValue(false);
    execution_method = DVLib::wstring2cem(XmlAttribute(node->Attribute("execution_method")).GetValue());
    Component::Load(node);
}
	void CollisionCylinderReaderWriter::writeOn(std::shared_ptr<XmlChunk> shapeChunk, const CollisionShape3D *collisionShape, XmlWriter &xmlWriter) const
	{
		shapeChunk->setAttribute(XmlAttribute(TYPE_ATTR, CYLINDER_VALUE));

		const CollisionCylinderShape *cylinderShape = static_cast<const CollisionCylinderShape *>(collisionShape);

		std::shared_ptr<XmlChunk> orientationChunk = xmlWriter.createChunk(ORIENTATION_TAG, XmlAttribute(), shapeChunk);
		CylinderShape<float>::CylinderOrientation orientationValue = cylinderShape->getCylinderOrientation();
		if(orientationValue==CylinderShape<float>::CylinderOrientation::CYLINDER_X)
		{
			orientationChunk->setStringValue(X_VALUE);
		}else if(orientationValue==CylinderShape<float>::CylinderOrientation::CYLINDER_Y)
		{
			orientationChunk->setStringValue(Y_VALUE);
		}else if(orientationValue==CylinderShape<float>::CylinderOrientation::CYLINDER_Z)
		{
			orientationChunk->setStringValue(Z_VALUE);
		}else
		{
			throw std::invalid_argument("Cylinder orientation type unknown: " + orientationValue);
		}

		std::shared_ptr<XmlChunk> radiusChunk = xmlWriter.createChunk(RADIUS_TAG, XmlAttribute(), shapeChunk);
		radiusChunk->setFloatValue(cylinderShape->getRadius());

		std::shared_ptr<XmlChunk> heightChunk = xmlWriter.createChunk(HEIGHT_TAG, XmlAttribute(), shapeChunk);
		heightChunk->setFloatValue(cylinderShape->getHeight());
	}
void MsuComponent::Load(TiXmlElement * node)
{
	package = node->Attribute("package");
	cmdparameters = node->Attribute("cmdparameters");
	cmdparameters_silent = node->Attribute("cmdparameters_silent");
	cmdparameters_basic = node->Attribute("cmdparameters_basic");
    disable_wow64_fs_redirection = XmlAttribute(node->Attribute("disable_wow64_fs_redirection")).GetBoolValue(false);
	execution_method = DVLib::wstring2cem(XmlAttribute(node->Attribute("execution_method")).GetValue());
	Component::Load(node);
}
示例#6
0
	void Map::writeSceneObjectsOn(const std::shared_ptr<XmlChunk> &chunk, XmlWriter &xmlWriter) const
	{
		std::shared_ptr<XmlChunk> objectsListChunk = xmlWriter.createChunk(OBJECTS_TAG, XmlAttribute(), chunk);

		for (auto sceneObject : sceneObjects)
		{
			std::shared_ptr<XmlChunk> objectsChunk = xmlWriter.createChunk(OBJECT_TAG, XmlAttribute(), objectsListChunk);
			sceneObject->writeOn(objectsChunk, xmlWriter);
		}
	}
示例#7
0
	void Map::writeSceneWatersOn(const std::shared_ptr<XmlChunk> &chunk, XmlWriter &xmlWriter) const
	{
		std::shared_ptr<XmlChunk> watersListChunk = xmlWriter.createChunk(WATERS_TAG, XmlAttribute(), chunk);

		for (auto sceneWater : sceneWaters)
		{
			std::shared_ptr<XmlChunk> watersChunk = xmlWriter.createChunk(WATER_TAG, XmlAttribute(), watersListChunk);
			sceneWater->writeOn(watersChunk, xmlWriter);
		}
	}
示例#8
0
	void Map::writeSceneLightsOn(const std::shared_ptr<XmlChunk> &chunk, XmlWriter &xmlWriter) const
	{
		std::shared_ptr<XmlChunk> lightsListChunk = xmlWriter.createChunk(LIGHTS_TAG, XmlAttribute(), chunk);

		for (auto sceneLight : sceneLights)
		{
			std::shared_ptr<XmlChunk> lightsChunk = xmlWriter.createChunk(LIGHT_TAG, XmlAttribute(), lightsListChunk);
			sceneLight->writeOn(lightsChunk, xmlWriter);
		}
	}
示例#9
0
	void Map::writeSceneTerrainsOn(const std::shared_ptr<XmlChunk> &chunk, XmlWriter &xmlWriter) const
	{
		std::shared_ptr<XmlChunk> terrainsListChunk = xmlWriter.createChunk(TERRAINS_TAG, XmlAttribute(), chunk);

		for (auto sceneTerrain : sceneTerrains)
		{
			std::shared_ptr<XmlChunk> terrainsChunk = xmlWriter.createChunk(TERRAIN_TAG, XmlAttribute(), terrainsListChunk);
			sceneTerrain->writeOn(terrainsChunk, xmlWriter);
		}
	}
	SoundShape *SoundSphereReaderWriter::loadFrom(std::shared_ptr<XmlChunk> shapeChunk, const XmlParser &xmlParser) const
	{
		std::shared_ptr<XmlChunk> radiusChunk = xmlParser.getUniqueChunk(true, RADIUS_TAG, XmlAttribute(), shapeChunk);
		float radius = radiusChunk->getFloatValue();

		std::shared_ptr<XmlChunk> positionChunk = xmlParser.getUniqueChunk(true, POSITION_TAG, XmlAttribute(), shapeChunk);
		Point3<float> position = positionChunk->getPoint3Value();

		std::shared_ptr<XmlChunk> marginChunk = xmlParser.getUniqueChunk(true, MARGIN_TAG, XmlAttribute(), shapeChunk);
		float margin = marginChunk->getFloatValue();

		return new SoundSphere(radius, position, margin);
	}
void CmdComponent::Load(TiXmlElement * node)
{
	command = node->Attribute("command");
    command_silent = node->Attribute("command_silent");
	command_basic = node->Attribute("command_basic");	
	uninstall_command = node->Attribute("uninstall_command");
    uninstall_command_silent = node->Attribute("uninstall_command_silent");
	uninstall_command_basic = node->Attribute("uninstall_command_basic");	
	returncodes_success = node->Attribute("returncodes_success");
	returncodes_reboot = node->Attribute("returncodes_reboot");
	hide_window = XmlAttribute(node->Attribute("hide_window")).GetBoolValue(false);
    disable_wow64_fs_redirection = XmlAttribute(node->Attribute("disable_wow64_fs_redirection")).GetBoolValue(false);
	execution_method = DVLib::wstring2cem(XmlAttribute(node->Attribute("execution_method")).GetValue());
	Component::Load(node);
}
	void SoundSphereReaderWriter::writeOn(std::shared_ptr<XmlChunk> shapeChunk, const SoundShape *soundShape, XmlWriter &xmlWriter) const
	{
		shapeChunk->setAttribute(XmlAttribute(TYPE_ATTR, SPHERE_VALUE));

		const SoundSphere *sphereShape = static_cast<const SoundSphere *>(soundShape);

		std::shared_ptr<XmlChunk> radiusChunk = xmlWriter.createChunk(RADIUS_TAG, XmlAttribute(), shapeChunk);
		radiusChunk->setFloatValue(sphereShape->getRadius());

		std::shared_ptr<XmlChunk> positionChunk = xmlWriter.createChunk(POSITION_TAG, XmlAttribute(), shapeChunk);
		positionChunk->setPoint3Value(sphereShape->getPosition());

		std::shared_ptr<XmlChunk> marginChunk = xmlWriter.createChunk(MARGIN_TAG, XmlAttribute(), shapeChunk);
		marginChunk->setFloatValue(sphereShape->getMargin());
	}
	CollisionShape3D *CollisionCompoundShapeReaderWriter::loadFrom(std::shared_ptr<XmlChunk> shapeChunk, const XmlParser &xmlParser) const
	{
		std::shared_ptr<XmlChunk> localizedShapesListChunk = xmlParser.getUniqueChunk(true, LOCALIZED_SHAPES, XmlAttribute(), shapeChunk);
		std::vector<std::shared_ptr<XmlChunk>> localizedShapesChunk = xmlParser.getChunks(LOCALIZED_SHAPE, XmlAttribute(), localizedShapesListChunk);

		std::vector<std::shared_ptr<const LocalizedCollisionShape>> compoundShapes;
		for(unsigned int i=0; i<localizedShapesChunk.size(); ++i)
		{
			std::shared_ptr<LocalizedCollisionShape> localizedBox(new LocalizedCollisionShape());

			localizedBox->position = i;

			std::shared_ptr<XmlChunk> translationChunk = xmlParser.getUniqueChunk(true, TRANSLATION, XmlAttribute(), localizedShapesChunk[i]);
			localizedBox->translation = translationChunk->getVector3Value();

			std::shared_ptr<XmlChunk> shapeChunk = xmlParser.getUniqueChunk(true, SHAPE, XmlAttribute(), localizedShapesChunk[i]);
			CollisionShape3D *embeddedCollisionShape = CollisionShapeReaderWriterRetriever::retrieveShapeReaderWriter(shapeChunk)->loadFrom(shapeChunk, xmlParser);
			localizedBox->shape = std::shared_ptr<CollisionShape3D>(embeddedCollisionShape);

			compoundShapes.push_back(localizedBox);
		}

		CollisionShape3D *collisionShape = new CollisionCompoundShape(compoundShapes);
		return collisionShape;
	}
void ControlImage::Load(TiXmlElement * node)
{
	resource_id = node->Attribute("resource_id");
	image_file = node->Attribute("image_file");
	center = XmlAttribute(node->Attribute("center")).GetBoolValue(false);
	Control::Load(node);
}
void ControlText::Load(TiXmlElement * node)
{
	text = node->Attribute("text");
	font_name = node->Attribute("font_name");
	font_size = XmlAttribute(node->Attribute("font_size")).GetLongValue();
	Control::Load(node);
}
	void RigidBodyReaderWriter::loadBodyPropertiesOn(RigidBody *rigidBody, const std::shared_ptr<XmlChunk> &physicsChunk, const XmlParser &xmlParser) const
	{
		std::shared_ptr<XmlChunk> massChunk = xmlParser.getUniqueChunk(true, MASS_TAG, XmlAttribute(), physicsChunk);
		float bodyMass = massChunk->getFloatValue();
		rigidBody->setMass(bodyMass);

		std::shared_ptr<XmlChunk> restitutionChunk = xmlParser.getUniqueChunk(true, RESTITUTION_TAG, XmlAttribute(), physicsChunk);
		rigidBody->setRestitution(restitutionChunk->getFloatValue());

		std::shared_ptr<XmlChunk> frictionChunk = xmlParser.getUniqueChunk(true, FRICTION_TAG, XmlAttribute(), physicsChunk);
		rigidBody->setFriction(frictionChunk->getFloatValue());

		std::shared_ptr<XmlChunk> rollingFrictionChunk = xmlParser.getUniqueChunk(true, ROLLING_FRICTION_TAG, XmlAttribute(), physicsChunk);
		rigidBody->setRollingFriction(rollingFrictionChunk->getFloatValue());

		std::shared_ptr<XmlChunk> linearDampingChunk = xmlParser.getUniqueChunk(true, LINEAR_DAMPING_TAG, XmlAttribute(), physicsChunk);
		std::shared_ptr<XmlChunk> angularDampingChunk = xmlParser.getUniqueChunk(true, ANGULAR_DAMPING_TAG, XmlAttribute(), physicsChunk);
		rigidBody->setDamping(linearDampingChunk->getFloatValue(), angularDampingChunk->getFloatValue());

		std::shared_ptr<XmlChunk> linearFactorChunk = xmlParser.getUniqueChunk(true, LINEAR_FACTOR_TAG, XmlAttribute(), physicsChunk);
		rigidBody->setLinearFactor(linearFactorChunk->getVector3Value());

		std::shared_ptr<XmlChunk> angularFactorChunk = xmlParser.getUniqueChunk(true, ANGULAR_FACTOR_TAG, XmlAttribute(), physicsChunk);
		rigidBody->setAngularFactor(angularFactorChunk->getVector3Value());
	}
void ControlCheckBox::Load(TiXmlElement * node)
{
	checked = XmlAttribute(node->Attribute("checked")).GetBoolValue(false);
	id = node->Attribute("id");
	checked_value = node->Attribute("checked_value");
	unchecked_value = node->Attribute("unchecked_value");
	ControlText::Load(node);
}
	void RigidBodyReaderWriter::writeOn(const std::shared_ptr<XmlChunk> &physicsChunk, const RigidBody *rigidBody, XmlWriter &xmlWriter) const
	{
		std::shared_ptr<XmlChunk> shapeChunk = xmlWriter.createChunk(SHAPE_TAG, XmlAttribute(), physicsChunk);
		std::shared_ptr<CollisionShapeReaderWriter> shapeReaderWriter = CollisionShapeReaderWriterRetriever::retrieveShapeReaderWriter(rigidBody->getOriginalShape().get());

		shapeReaderWriter->writeOn(shapeChunk, rigidBody->getOriginalShape().get(), xmlWriter);
		writeBodyPropertiesOn(physicsChunk, rigidBody, xmlWriter);
	}
示例#19
0
void MsuComponent::Load(TiXmlElement * node)
{
	package = node->Attribute("package");
	cmdparameters = node->Attribute("cmdparameters");
	cmdparameters_silent = node->Attribute("cmdparameters_silent");
	cmdparameters_basic = node->Attribute("cmdparameters_basic");
    disable_wow64_fs_redirection = XmlAttribute(node->Attribute("disable_wow64_fs_redirection")).GetBoolValue(false);
	Component::Load(node);
}
	void CollisionCompoundShapeReaderWriter::writeOn(std::shared_ptr<XmlChunk> shapeChunk, const CollisionShape3D *collisionShape, XmlWriter &xmlWriter) const
	{
		shapeChunk->setAttribute(XmlAttribute(TYPE_ATTR, COMPOUND_SHAPE_VALUE));

		const CollisionCompoundShape *compoundShape = static_cast<const CollisionCompoundShape *>(collisionShape);

		std::shared_ptr<XmlChunk> localizedShapesListChunk = xmlWriter.createChunk(LOCALIZED_SHAPES, XmlAttribute(), shapeChunk);
		const std::vector<std::shared_ptr<const LocalizedCollisionShape>> &shapes = compoundShape->getLocalizedShapes();
		for(unsigned int i=0; i<shapes.size(); ++i)
		{
			std::shared_ptr<XmlChunk> localizedShapeChunk = xmlWriter.createChunk(LOCALIZED_SHAPE, XmlAttribute(), localizedShapesListChunk);

			std::shared_ptr<XmlChunk> translationChunk = xmlWriter.createChunk(TRANSLATION, XmlAttribute(), localizedShapeChunk);
			translationChunk->setVector3Value(shapes[i]->translation);

			std::shared_ptr<XmlChunk> shapeChunk = xmlWriter.createChunk(SHAPE, XmlAttribute(), localizedShapeChunk);
			const CollisionShape3D *collisionShape = shapes[i]->shape.get();
			CollisionShapeReaderWriterRetriever::retrieveShapeReaderWriter(collisionShape)->writeOn(shapeChunk, collisionShape, xmlWriter);
		}
	}
void OpenOfficeAction::_setDefaultLanguage()
{
	XmlParser parser;
	wstring file;
	bool bRslt;

	_getPreferencesFile(file);
	if (parser.Load(file) == false)
	{
		g_log.Log(L"OpenOfficeAction::_setDefaultLanguage. Could not open '%s'", (wchar_t *) file.c_str());
		return;
	}

	/*
		XML fragment to generate

		<item oor:path="/org.openoffice.Office.Linguistic/General">
			<prop oor:name="UILocale" oor:op="fuse">
				<value>DEFAULT_LANGUAGE</value>
			</prop>
		</item>
	*/

	XmlNode item(parser.getDocument()), prop(parser.getDocument()), value(parser.getDocument());
	value.SetName(wstring(L"value"));
	value.SetText(wstring(DEFAULT_LANGUAGE));
	
	prop.SetName(wstring(L"prop"));
	prop.AddAttribute(XmlAttribute(L"oor:name", L"UILocale"));
	prop.AddAttribute(XmlAttribute(L"oor:op", L"fuse"));
	prop.AddChildren(value);

	item.SetName(wstring(L"item"));
	item.AddAttribute(XmlAttribute(L"oor:path", L"/org.openoffice.Office.Linguistic/General"));	
	item.AddChildren(prop);

	parser.AppendNode(item);
	bRslt = parser.Save(file);

	g_log.Log(L"OpenOfficeAction::_setDefaultLanguage. Saved file '%s', result %u", (wchar_t *)file.c_str(), (wchar_t *) bRslt);
}
	RigidBody *RigidBodyReaderWriter::loadFrom(const std::shared_ptr<XmlChunk> &physicsChunk, const std::string &id,
			const Transform<float> &modelTransform, const XmlParser &xmlParser) const
	{
		std::shared_ptr<XmlChunk> shapeChunk = xmlParser.getUniqueChunk(true, SHAPE_TAG, XmlAttribute(), physicsChunk);
		std::shared_ptr<CollisionShapeReaderWriter> shapeReaderWriter = CollisionShapeReaderWriterRetriever::retrieveShapeReaderWriter(shapeChunk);
		CollisionShape3D *bodyShape = shapeReaderWriter->loadFrom(shapeChunk, xmlParser);

		RigidBody *rigidBody = new RigidBody(id, modelTransform, std::shared_ptr<const CollisionShape3D>(bodyShape));
		loadBodyPropertiesOn(rigidBody, physicsChunk, xmlParser);

		return rigidBody;
	}
	void LightReaderWriter::buildChunkFrom(std::shared_ptr<XmlChunk> lightChunk, const Light *light, XmlWriter &xmlWriter) const
	{
		if(light->getLightType()==Light::OMNIDIRECTIONAL)
		{
			const OmnidirectionalLight *omnidirectionalLight = static_cast<const OmnidirectionalLight *>(light);
			lightChunk->setAttribute(XmlAttribute(TYPE_ATTR, OMNIDIRECTIONAL_VALUE));

			std::shared_ptr<XmlChunk> positionChunk = xmlWriter.createChunk(POSITION_TAG, XmlAttribute(), lightChunk);
			positionChunk->setPoint3Value(omnidirectionalLight->getPosition());

			std::shared_ptr<XmlChunk> expenentialAttenuationChunk = xmlWriter.createChunk(EXPENENTIAL_ATTENUATION_TAG, XmlAttribute(), lightChunk);
			expenentialAttenuationChunk->setFloatValue(omnidirectionalLight->getExponentialAttenuation());
		}else if(light->getLightType()==Light::SUN)
		{
			const SunLight *sunLight = static_cast<const SunLight *>(light);
			lightChunk->setAttribute(XmlAttribute(TYPE_ATTR, SUN_VALUE));

			std::shared_ptr<XmlChunk> directionChunk = xmlWriter.createChunk(DIRECTION_TAG, XmlAttribute(), lightChunk);
			directionChunk->setVector3Value(sunLight->getDirections()[0]);
		}else
		{
			throw std::invalid_argument("Unknown light type to write in map: " + light->getLightType());
		}
	}
示例#24
0
bool XmlNodeReader::MoveToNextAttribute() const {
	if (!m_cur)
		return false;
	XmlNode anode = m_cur;
	if (m_cur.NodeType != XmlNodeType::Attribute) {
		XmlNode parent = m_cur.ParentNode;
		if (!parent || parent.NodeType != XmlNodeType::Attribute)
			return MoveToFirstAttribute();
		anode = parent;			
	}

	XmlAttributeCollection attrs = XmlAttribute(anode).OwnerElement.Attributes;	
	for (int i=0, count=attrs.Count; i<count-1; ++i) {
		XmlAttribute a = attrs[i];
		if (a == anode) {
			if (++i == count)
				return false;
			return m_cur = attrs[i];
		}
	}
	return false;
}
示例#25
0
//===========================================
// XmlNode::firstAttribute
//===========================================
inline XmlAttribute XmlNode::firstAttribute() const {
   if (isNull()) throw XmlException("Node is NULL", __FILE__, __LINE__);
   return XmlAttribute(m_doc, m_node->first_attribute(), m_file);
}
	void LightReaderWriter::writeFlagsOn(std::shared_ptr<XmlChunk> lightChunk, const Light *light, XmlWriter &xmlWriter) const
	{
		std::shared_ptr<XmlChunk> produceShadowChunk = xmlWriter.createChunk(PRODUCE_SHADOW_TAG, XmlAttribute(), lightChunk);
		produceShadowChunk->setBoolValue(light->isProduceShadow());
	}
	void LightReaderWriter::loadFlagsOn(Light *light, std::shared_ptr<XmlChunk> lightChunk, const XmlParser &xmlParser) const
	{
		std::shared_ptr<XmlChunk> produceShadowChunk = xmlParser.getUniqueChunk(true, PRODUCE_SHADOW_TAG, XmlAttribute(), lightChunk);
		light->setProduceShadow(produceShadowChunk->getBoolValue());
	}
	void LightReaderWriter::writePropertiesOn(std::shared_ptr<XmlChunk> lightChunk, const Light *light, XmlWriter &xmlWriter) const
	{
		std::shared_ptr<XmlChunk> ambientColorChunk = xmlWriter.createChunk(AMBIENT_COLOR_TAG, XmlAttribute(), lightChunk);
		ambientColorChunk->setPoint3Value(light->getAmbientColor());
	}
	void LightReaderWriter::loadPropertiesOn(Light *light, std::shared_ptr<XmlChunk> lightChunk, const XmlParser &xmlParser) const
	{
		std::shared_ptr<XmlChunk> ambientColorChunk = xmlParser.getUniqueChunk(true, AMBIENT_COLOR_TAG, XmlAttribute(), lightChunk);
		light->setAmbientColor(ambientColorChunk->getPoint3Value());
	}
	Light *LightReaderWriter::buildLightFrom(std::shared_ptr<XmlChunk> lightChunk, const XmlParser &xmlParser) const
	{
		std::string lightType = lightChunk->getAttributeValue(TYPE_ATTR);
		if(lightType.compare(OMNIDIRECTIONAL_VALUE)==0)
		{
			std::shared_ptr<XmlChunk> positionChunk = xmlParser.getUniqueChunk(true, POSITION_TAG, XmlAttribute(), lightChunk);
			OmnidirectionalLight *omnidirectional = new OmnidirectionalLight(positionChunk->getPoint3Value());

			std::shared_ptr<XmlChunk> expenentialAttenuationChunk = xmlParser.getUniqueChunk(true, EXPENENTIAL_ATTENUATION_TAG, XmlAttribute(), lightChunk);
			omnidirectional->setAttenuation(expenentialAttenuationChunk->getFloatValue());

			return omnidirectional;
		}else if(lightType.compare(SUN_VALUE)==0)
		{
			std::shared_ptr<XmlChunk> directionChunk = xmlParser.getUniqueChunk(true, DIRECTION_TAG, XmlAttribute(), lightChunk);

			return new SunLight(directionChunk->getVector3Value());
		}

		throw std::invalid_argument("Unknown light type read from map: " + lightType);
	}