Example #1
0
bool FArchiveXML::LoadTransformSkew(FCDObject* object, xmlNode* skewNode)
{
	FCDTSkew* tSkew = (FCDTSkew*)object;

	const char* content = FUDaeParser::ReadNodeContentDirect(skewNode);
	FloatList factors;
	factors.reserve(7);
	FUStringConversion::ToFloatList(content, factors);
	if (factors.size() != 7) return false;

	tSkew->SetAngle(factors[0]);
	tSkew->SetRotateAxis(FMVector3(factors[1], factors[2], factors[3]));
	tSkew->SetAroundAxis(FMVector3(factors[4], factors[5], factors[6]));

	// Check and pre-process the axises
	if (IsEquivalent(tSkew->GetRotateAxis(), FMVector3::Origin) || IsEquivalent(tSkew->GetAroundAxis(), FMVector3::Origin)) return false;
	tSkew->SetRotateAxis(tSkew->GetRotateAxis().Normalize());
	tSkew->SetAroundAxis(tSkew->GetAroundAxis().Normalize());

	// Register the animated values
	FArchiveXML::LoadAnimatable(&tSkew->GetSkew(), skewNode);

	tSkew->SetDirtyFlag();
	return true;
}
Example #2
0
	Mode FromString(const char* value)
	{
		if (IsEquivalent(value,	DAE_FX_STATE_POLYMODE_POINT)) return POINT;
		else if (IsEquivalent(value, DAE_FX_STATE_POLYMODE_LINE)) return LINE;
		else if (IsEquivalent(value, DAE_FX_STATE_POLYMODE_FILL)) return FILL;
		else return INVALID;
	}
Example #3
0
	// Returns a list of parameter names and nodes held by a given XML node
	void FindParameters(xmlNode* parent, StringList& parameterNames, xmlNodeList& parameterNodes)
	{
		if (parent == NULL || parameterNames.size() != parameterNodes.size()) return;

		size_t originalCount = parameterNodes.size();
		for (xmlNode* child = parent->children; child != NULL; child = child->next)
		{
			if (child->type != XML_ELEMENT_NODE) continue;

			// Drop the technique and exta elements that may be found
			if (IsEquivalent(child->name, DAE_TECHNIQUE_ELEMENT) ||
				IsEquivalent(child->name, DAE_EXTRA_ELEMENT)) continue;

			// Buffer this parameter node
			parameterNodes.push_back(child);
		}

		// Retrieve all the parameter's names
		size_t parameterNodeCount = parameterNodes.size();
		parameterNames.resize(parameterNodeCount);
		for (size_t i = originalCount; i < parameterNodeCount; ++i)
		{
			xmlNode* node = parameterNodes[i];
			parameterNames[i] = (const char*) node->name;
		}
	}
Example #4
0
	bool CheckExtraTree(FULogFile& fileOut, FCDExtra* extra, bool hasTypes)
	{
		FailIf(extra == NULL);

		// Find and verify the one technique
		FailIf(extra->GetDefaultType()->GetTechniqueCount() < 1); // note that FCDLight adds some <extra> elements of its own.
		FCDETechnique* technique = extra->GetDefaultType()->FindTechnique("FCTEI_TestProfile");
		FailIf(technique == NULL);

		// Find and verify the base parameter tree node
		FailIf(technique->GetChildNodeCount() != 1);
		FCDENode* baseNode = technique->GetChildNode(0);
		PassIf(baseNode != NULL);
		PassIf(extra->GetDefaultType()->FindRootNode("MainParameterTree") == baseNode);

		// Verify the base node attributes
		PassIf(baseNode->GetAttributeCount() == 2);
		FCDEAttribute* a1 = baseNode->FindAttribute("Vicious");
		FCDEAttribute* a2 = baseNode->FindAttribute("Gross");
		FailIf(a1 == NULL);
		FailIf(a2 == NULL);
		FailIf(a1 == a2);
		PassIf(IsEquivalent(a1->GetValue(), FC("Squirrel")));
		PassIf(IsEquivalent(FUStringConversion::ToUInt32(a2->GetValue()), (uint32)1002));

		// Identify the base node leaves
		PassIf(baseNode->GetChildNodeCount() == 2);
		FCDENode* leaf0 = NULL,* leaf3 = NULL;
		for (size_t i = 0; i < 2; ++i)
		{
			FCDENode* leaf = baseNode->GetChildNode(i);
			PassIf(IsEquivalent(leaf->GetName(), "SomeParameter"));
			FCDEAttribute* guts = leaf->FindAttribute("Guts");
			FailIf(guts == NULL || guts->GetValue().empty());
			uint32 gutsIndex = FUStringConversion::ToUInt32(guts->GetValue());
			if (gutsIndex == 0) { FailIf(leaf0 != NULL); leaf0 = leaf; }
			else if (gutsIndex == 3) { FailIf(leaf3 != NULL); leaf3 = leaf; }
			else Fail;
		}
		FailIf(leaf0 == NULL || leaf3 == NULL);

		// Verify the base node leaves
		PassIf(leaf0->GetChildNodeCount() == 0);
		PassIf(leaf3->GetChildNodeCount() == 0);
		PassIf(leaf0->GetAttributeCount() == 1);
		PassIf(leaf3->GetAttributeCount() == 1);
		PassIf(IsEquivalent(leaf0->GetContent(), FC("Test_SomeParameter")));
		PassIf(IsEquivalent(leaf3->GetContent(), FS("Test_ThatParameter!")));

		if (hasTypes)
		{
			// Verify the second extra type
			// Empty named-types should be imported without complaints or merging.
			FCDEType* secondType = extra->FindType("verificator");
			PassIf(secondType != NULL);
			PassIf(secondType != extra->GetDefaultType());
			PassIf(secondType->GetTechniqueCount() == 0);
		}
		return true;
	}
bool FArchiveXML::LoadPASSphere(FCDObject* object, xmlNode* node)
{
	FCDPASSphere* pASSphere = (FCDPASSphere*)object;

	bool status = true;

	if (!IsEquivalent(node->name, DAE_SPHERE_ELEMENT))
	{
		FUError::Error(FUError::WARNING_LEVEL, FUError::WARNING_INVALID_SPHERE_TYPE, node->line);
		return status;
	}

	for (xmlNode* child = node->children; child != NULL; child = child->next)
	{
		if (child->type != XML_ELEMENT_NODE) continue;

		if (IsEquivalent(child->name, DAE_RADIUS_ELEMENT))
		{
			pASSphere->radius = FUStringConversion::ToFloat(ReadNodeContentDirect(child));
		}
	}

	pASSphere->SetDirtyFlag();
	return status;
}
bool FArchiveXML::LoadPASCylinder(FCDObject* object, xmlNode* node)
{
	FCDPASCylinder* pASCylinder = (FCDPASCylinder*)object;

	bool status = true;

	if (!IsEquivalent(node->name, DAE_CYLINDER_ELEMENT))
	{
		FUError::Error(FUError::WARNING_LEVEL, FUError::WARNING_INVALID_SPHERE_TYPE, node->line);
		return status;
	}

	for (xmlNode* child = node->children; child != NULL; child = child->next)
	{
		if (child->type != XML_ELEMENT_NODE) continue;

		if (IsEquivalent(child->name, DAE_HEIGHT_ELEMENT))
		{
			pASCylinder->height = FUStringConversion::ToFloat(ReadNodeContentDirect(child));
		}
		else if (IsEquivalent(child->name, DAE_RADIUS_ELEMENT))
		{
			const char* stringRadius = ReadNodeContentDirect(child);
			pASCylinder->radius.x = FUStringConversion::ToFloat(&stringRadius);
			pASCylinder->radius.y = FUStringConversion::ToFloat(&stringRadius);
		}
	}

	pASCylinder->SetDirtyFlag();
	return status;
}
bool FArchiveXML::LoadPASPlane(FCDObject* object, xmlNode* node)
{
	FCDPASPlane* pASPlane = (FCDPASPlane*)object;

	bool status = true;

	if (!IsEquivalent(node->name, DAE_PLANE_ELEMENT))
	{
		FUError::Error(FUError::WARNING_LEVEL, FUError::WARNING_INVALID_PLANE_TYPE, node->line);
		return status;
	}

	for (xmlNode* child = node->children; child != NULL; child = child->next)
	{
		if (child->type != XML_ELEMENT_NODE) continue;

		if (IsEquivalent(child->name, DAE_EQUATION_ELEMENT))
		{
			const char* eq = ReadNodeContentDirect(child);
			pASPlane->normal.x = FUStringConversion::ToFloat(&eq);
			pASPlane->normal.y = FUStringConversion::ToFloat(&eq);
			pASPlane->normal.z = FUStringConversion::ToFloat(&eq);
			pASPlane->d = FUStringConversion::ToFloat(&eq);
		}
	}

	pASPlane->SetDirtyFlag();
	return status;
}
Example #8
0
	Type FromString(const char* value)
	{
		if (IsEquivalent(value, DAE_FX_STATE_FACETYPE_FRONT)) return FRONT;
		else if (IsEquivalent(value, DAE_FX_STATE_FACETYPE_BACK)) return BACK;
		else if (IsEquivalent(value, DAE_FX_STATE_FACETYPE_FRONT_AND_BACK)) return FRONT_AND_BACK;
		else return INVALID;
	}
bool FArchiveXML::LoadPASBox(FCDObject* object, xmlNode* node)
{
	FCDPASBox* pASBox = (FCDPASBox*)object;

	bool status = true;

	if (!IsEquivalent(node->name, DAE_BOX_ELEMENT))
	{
		FUError::Error(FUError::WARNING_LEVEL, FUError::WARNING_INVALID_BOX_TYPE, node->line);
		return status;
	}

	for (xmlNode* child = node->children; child != NULL; child = child->next)
	{
		if (child->type != XML_ELEMENT_NODE) continue;

		if (IsEquivalent(child->name, DAE_HALF_EXTENTS_ELEMENT))
		{
			const char* halfExt = ReadNodeContentDirect(child);
			pASBox->halfExtents.x = FUStringConversion::ToFloat(&halfExt);
			pASBox->halfExtents.y = FUStringConversion::ToFloat(&halfExt);
			pASBox->halfExtents.z = FUStringConversion::ToFloat(&halfExt);
		}
	}

	pASBox->SetDirtyFlag();
	return status;
}
Example #10
0
	Type FromString(const char* value)
	{
		if (IsEquivalent(value, DAE_FX_STATE_FOGTYPE_LINEAR)) return LINEAR;
		else if (IsEquivalent(value, DAE_FX_STATE_FOGTYPE_EXP)) return EXP;
		else if (IsEquivalent(value, DAE_FX_STATE_FOGTYPE_EXP2)) return EXP2;
		else return INVALID;
	}
Example #11
0
	Type FromString(const fm::string& value)
	{
		if (IsEquivalent(value, DAE_LINEAR_SPLINE_TYPE)) return LINEAR;
		else if (IsEquivalent(value, DAE_BEZIER_SPLINE_TYPE)) return BEZIER;
		else if (IsEquivalent(value, DAE_NURBS_SPLINE_TYPE)) return NURBS;
		else return UNKNOWN;
	}
Example #12
0
bool FCDTRotation::IsInverse(const FCDTransform* transform) const
{
	return transform->GetType() == FCDTransform::ROTATION
		&& ((IsEquivalent(angleAxis->axis, ((const FCDTRotation*)transform)->angleAxis->axis)
		&& IsEquivalent(-angleAxis->angle, ((const FCDTRotation*)transform)->angleAxis->angle))
		|| (IsEquivalent(-angleAxis->axis, ((const FCDTRotation*)transform)->angleAxis->axis)
		&& IsEquivalent(angleAxis->angle, ((const FCDTRotation*)transform)->angleAxis->angle)));
}
Example #13
0
	Infinity FromString(const char* value)
	{
		if (IsEquivalent(value, DAEMAYA_CONSTANT_INFINITY)) return CONSTANT;
		else if (IsEquivalent(value, DAEMAYA_LINEAR_INFINITY)) return LINEAR;
		else if (IsEquivalent(value, DAEMAYA_CYCLE_INFINITY)) return CYCLE;
		else if (IsEquivalent(value, DAEMAYA_CYCLE_RELATIVE_INFINITY)) return CYCLE_RELATIVE;
		else if (IsEquivalent(value, DAEMAYA_OSCILLATE_INFINITY)) return OSCILLATE;
		else return DEFAULT;
	}
Example #14
0
	WrapMode FromString(const char* value)
	{
		if (IsEquivalent(value, DAE_TEXTURE_WRAP_NONE)) return NONE;
		else if (IsEquivalent(value, DAE_TEXTURE_WRAP_WRAP)) return WRAP;
		else if (IsEquivalent(value, DAE_TEXTURE_WRAP_MIRROR)) return MIRROR;
		else if (IsEquivalent(value, DAE_TEXTURE_WRAP_CLAMP)) return CLAMP;
		else if (IsEquivalent(value, DAE_TEXTURE_WRAP_BORDER)) return BORDER;
		else return UNKNOWN;
	}
Example #15
0
	Type FromString(const char* value)
	{
		if (IsEquivalent(value, DAE_FX_PROFILE_COMMON_ELEMENT)) return COMMON;
		else if (IsEquivalent(value, DAE_FX_PROFILE_CG_ELEMENT)) return CG;
		else if (IsEquivalent(value, DAE_FX_PROFILE_HLSL_ELEMENT)) return HLSL;
		else if (IsEquivalent(value, DAE_FX_PROFILE_GLSL_ELEMENT)) return GLSL;
		else if (IsEquivalent(value, DAE_FX_PROFILE_GLES_ELEMENT)) return GLES;
		else return UNKNOWN;
	}
Example #16
0
	Equation FromString(const char* value)
	{
		if (IsEquivalent(value, DAE_FX_STATE_BLENDEQ_ADD)) return ADD;
		else if (IsEquivalent(value, DAE_FX_STATE_BLENDEQ_SUBTRACT)) return SUBTRACT;
		else if (IsEquivalent(value, DAE_FX_STATE_BLENDEQ_REVERSE_SUBTRACT)) return REVERSE_SUBTRACT;
		else if (IsEquivalent(value, DAE_FX_STATE_BLENDEQ_MIN)) return MIN;
		else if (IsEquivalent(value, DAE_FX_STATE_BLENDEQ_MAX)) return MAX;
		else return INVALID;
	}
Example #17
0
	Type FromString(const char* value)
	{
		if (IsEquivalent(value, DAE_FX_STATE_MATERIALTYPE_EMISSION)) return EMISSION;
		else if (IsEquivalent(value, DAE_FX_STATE_MATERIALTYPE_AMBIENT)) return AMBIENT;
		else if (IsEquivalent(value, DAE_FX_STATE_MATERIALTYPE_DIFFUSE)) return DIFFUSE;
		else if (IsEquivalent(value, DAE_FX_STATE_MATERIALTYPE_SPECULAR)) return SPECULAR;
		else if (IsEquivalent(value, DAE_FX_STATE_MATERIALTYPE_AMBDIFF)) return AMBIENT_AND_DIFFUSE;
		else return INVALID;
	}
Example #18
0
inline bool PlatformEquivalent(fstring& f, const fchar* check)
{
#ifdef WIN32
	return IsEquivalent(f, check);
#else
	fstring p = check;
	p.replace('\\', '/');
	return IsEquivalent(f, p);
#endif // WIN32
}
bool FArchiveXML::LoadPhysicsScene(FCDObject* object, xmlNode* sceneNode)
{
	if (!FArchiveXML::LoadEntity(object, sceneNode)) return false;

	bool status = true;
	FCDPhysicsScene* physicsScene = (FCDPhysicsScene*)object;
	if (IsEquivalent(sceneNode->name, DAE_PHYSICS_SCENE_ELEMENT))
	{
		for (xmlNode* child = sceneNode->children; child != NULL; child = child->next)
		{
			if (child->type != XML_ELEMENT_NODE) continue;

			// Look for instantiation elements
			if (IsEquivalent(child->name, DAE_INSTANCE_PHYSICS_MODEL_ELEMENT)) 
			{
				FCDPhysicsModelInstance* instance = physicsScene->AddPhysicsModelInstance(NULL);
				status &= (FArchiveXML::LoadPhysicsModelInstance(instance, child));
				continue; 
			}
			else if (IsEquivalent(child->name, DAE_TECHNIQUE_COMMON_ELEMENT))
			{
				xmlNode* gravityNode = FindChildByType(child, DAE_GRAVITY_ATTRIBUTE);
				if (gravityNode)
				{
					const char* gravityVal = ReadNodeContentDirect(gravityNode);
					FMVector3 gravity;
					gravity.x = FUStringConversion::ToFloat(&gravityVal);
					gravity.y = FUStringConversion::ToFloat(&gravityVal);
					gravity.z = FUStringConversion::ToFloat(&gravityVal);
					physicsScene->SetGravity(gravity);
				}
				xmlNode* timestepNode = FindChildByType(child, DAE_TIME_STEP_ATTRIBUTE);
				if (timestepNode)
				{
					physicsScene->SetTimestep(FUStringConversion::ToFloat(ReadNodeContentDirect(timestepNode)));
				}
			}
			else if (IsEquivalent(child->name, 
					DAE_INSTANCE_FORCE_FIELD_ELEMENT))
			{
				FCDPhysicsForceFieldInstance* instance = physicsScene->AddForceFieldInstance(NULL);
				status &= (FArchiveXML::LoadPhysicsForceFieldInstance(instance, child));
			}
			else if (IsEquivalent(child->name, DAE_EXTRA_ELEMENT))
			{
				// The extra information is loaded by the FCDEntity class.
			}
		}
	}

	physicsScene->SetDirtyFlag();
	return status;
}
Example #20
0
	bool CheckControllerSkin(FULogFile& fileOut, FCDSkinController* controller)
	{
		FailIf(controller == NULL);

		// Check the base target's identity
		FailIf(controller->GetTarget() == NULL);
		PassIf(controller->GetTarget()->GetType() == FCDEntity::GEOMETRY);
		PassIf(controller->GetTarget()->GetDaeId() == meshId);

		// Retrieve the two joints and verify their ids/bind-pose.
		PassIf(controller->GetJointCount() == 2);
		const FMMatrix44* joint1 = NULL,* joint2 = NULL;
		for (size_t i = 0; i < 2; ++i)
		{
			FCDSkinControllerJoint* joint = controller->GetJoint(i);
			if (joint->GetId() == jointId1) { FailIf(joint1 != NULL); joint1 = &joint->GetBindPoseInverse(); }
			else if (joint->GetId() == jointId2) { FailIf(joint2 != NULL); joint2 = &joint->GetBindPoseInverse(); }
			else Fail;
		}
		FailIf(joint1 == NULL || joint2 == NULL);
		PassIf(IsEquivalent(*joint1, FMMatrix44::Identity));
		FMMatrix44 sbp = FMMatrix44(sampleBindPose1).Inverted();
		PassIf(IsEquivalent(*joint2, FMMatrix44(sampleBindPose1).Inverted()));

		// Verify the influences
		PassIf(controller->GetInfluenceCount() == 4);
		FCDSkinControllerVertex* influence = controller->GetVertexInfluence(0);
		FailIf(influence == NULL);
		PassIf(influence->GetPairCount() == 2);
		PassIf(IsEquivalent(influence->GetPair(0)->jointIndex, 0));
		PassIf(IsEquivalent(influence->GetPair(0)->weight, 0.5f));
		PassIf(IsEquivalent(influence->GetPair(1)->jointIndex, 1));
		PassIf(IsEquivalent(influence->GetPair(1)->weight, 0.5f));

		influence = controller->GetVertexInfluence(1);
		FailIf(influence == NULL);
		PassIf(influence->GetPairCount() == 0);

		influence = controller->GetVertexInfluence(2);
		FailIf(influence == NULL);
		PassIf(influence->GetPairCount() == 1);
		PassIf(IsEquivalent(influence->GetPair(0)->jointIndex, 0));
		PassIf(IsEquivalent(influence->GetPair(0)->weight, 1.0f)); // the weight should have been normalized.

		influence = controller->GetVertexInfluence(3);
		FailIf(influence == NULL);
		PassIf(influence->GetPairCount() == 1);
		PassIf(IsEquivalent(influence->GetPair(0)->jointIndex, 1));
		PassIf(IsEquivalent(influence->GetPair(0)->weight, 1.0f));
		return true;
	}
Example #21
0
	bool CheckGeometryMesh(FULogFile& fileOut, FCDGeometryMesh* mesh)
	{
		// Verify the mesh and its sources
		PassIf(mesh->GetSourceCount() == 3);
		FCDGeometrySource* posSource = NULL,* colorSource = NULL,* dummySource = NULL;
		for (size_t i = 0; i < 3; ++i)
		{
			FCDGeometrySource* source = mesh->GetSource(i);
			FailIf(source == NULL);
			switch (source->GetType())
			{
			case FUDaeGeometryInput::POSITION: posSource = source; PassIf(source->GetName() == FC("TestPositionSource")); break;
			case FUDaeGeometryInput::COLOR: colorSource = source; PassIf(source->GetName() == FC("TestColorSource")); break;
			case FUDaeGeometryInput::EXTRA: dummySource = source; PassIf(source->GetName() == FC("TestDummySource")); break;
			default: Fail; break;
			}
		}
		FailIf(posSource == NULL || colorSource == NULL || dummySource == NULL);
		PassIf(IsEquivalent(posSource->GetData(), posSource->GetDataCount(), positionData, 12));
		PassIf(posSource->GetStride() == 3);
		PassIf(IsEquivalent(colorSource->GetData(), colorSource->GetDataCount(), colorData, 12));
		PassIf(colorSource->GetStride() == 4);
		PassIf(IsEquivalent(dummySource->GetData(), dummySource->GetDataCount(), dummyData, 10));
		PassIf(dummySource->GetStride() == 3);
		PassIf(CheckExtraTree(fileOut, dummySource->GetExtra(), false));

		// Find the non-empty polygon set and verify that one of the polygon set is, in fact, empty.
		FCDGeometryPolygons* polys1 = NULL,* polysEmpty = NULL;
		for (size_t i = 0; i < mesh->GetPolygonsCount(); ++i)
		{
			FCDGeometryPolygons* p = mesh->GetPolygons(i);
			if (p->GetFaceCount() == 0) { PassIf(polysEmpty == NULL); polysEmpty = p; }
			else { PassIf(polys1 == NULL); polys1 = p; }

			CheckExtraTree(fileOut, p->GetExtra(), true);
		}
		PassIf(polys1 != NULL && polysEmpty != NULL);

		// Check that we have the wanted tetrahedron in the non-empty polygon set.
		PassIf(polys1->GetFaceCount() == 4);
		PassIf(polys1->GetHoleCount() == 0);
		PassIf(polys1->GetFaceVertexCount(0) == 3 && polys1->GetFaceVertexCount(1) == 3 && polys1->GetFaceVertexCount(2) == 3 && polys1->GetFaceVertexCount(3) == 3);
		FCDGeometryPolygonsInput* posInput = polys1->FindInput(posSource);
		FailIf(posInput == NULL || posInput->GetIndexCount() != 12);
		FCDGeometryPolygonsInput* colorInput = polys1->FindInput(colorSource);
		FailIf(colorInput == NULL || colorInput == posInput || colorInput->GetIndexCount() != 12);
		PassIf(IsEquivalent(posInput->GetIndices(), 12, positionIndices, 12));
		PassIf(IsEquivalent(colorInput->GetIndices(), 12, colorIndices, 12));
		return true;
	}
Example #22
0
FUUri::FUUri(const fstring uri, bool escape)
	:	scheme(FUUri::NONE),
		port(0),
		path(FC(""))
{
	if (uri.empty()) return;

	fstring _uri;

	if (escape)
	{
		_uri = Escape(uri);
	}
	else
	{
		_uri = uri;
	}

	// Replace all '\\' characters by '/' so the path is only using them
	//_uri.replace(FC('\\'), FC('/'));
	
	_uri = FixFuxedUpColladaPaths( _uri );

	// Find the scheme from its ':' delimiter
	size_t schemeDelimiterIndex = _uri.find(FC(':'));
	size_t hostIndex = 0;

	if (schemeDelimiterIndex != fstring::npos && schemeDelimiterIndex > 1)
	{
		fstring _scheme = _uri.substr(0, schemeDelimiterIndex);

		if (IsEquivalent(_scheme, FC("FILE")) || IsEquivalent(_scheme, FC("file")))
		{
			scheme = FUUri::FILE;
		}
		else if (IsEquivalent(_scheme, FC("FTP")) || IsEquivalent(_scheme, FC("ftp")))
		{
			scheme = FUUri::FTP;
		}
		else if (IsEquivalent(_scheme, FC("HTTP")) || IsEquivalent(_scheme, FC("http")))
		{
			scheme = FUUri::HTTP;
		}
		else if (IsEquivalent(_scheme, FC("HTTPS")) || IsEquivalent(_scheme, FC("https")))
		{
			scheme = FUUri::HTTPS;
		}
		else
		{
#ifdef WIN32
			// Scheme not supported (could be a NFS path)
			FUFail(return);
#endif // WIN32
		}

		schemeDelimiter = _uri.substr(schemeDelimiterIndex, 3);
		hostIndex = schemeDelimiterIndex + 3;
	}
Example #23
0
FMVector4 FMVector4::FromHSVColor(float hue, float saturation, float value)
{
	// [GLaforte - 15-04-2007]
	// Algorithm inspired from http://www.cs.rit.edu/~ncs/color/t_convert.html
	// Written by Nan C. Schaller, Rochester Institute of Technology, Computer Science Department
	if (!IsEquivalent(saturation, 0.0f)) 
	{
		hue *= 6.0f;						// sector 0 to 5
		float sector = floor(hue);
		float f = hue - sector;				// factorial part of h
		float p = value * (1.0f - saturation);
		float q = value * (1.0f - saturation * f);
		float t = value * (1.0f - saturation * (1.0f - f));
		switch ((uint32) sector)
		{
			case 0: return FMVector4(value, t, p, 1.0f);
			case 1: return FMVector4(q, value, p, 1.0f);
			case 2: return FMVector4(p, value, t, 1.0f);
			case 3: return FMVector4(p, q, value, 1.0f);
			case 4: return FMVector4(t, p, value, 1.0f);
			case 5:
			default: return FMVector4(value, p, q, 1.0f);
		}
	}
	else return FMVector4(value, value, value, 1.0f); // Achromatic (grey)
}
bool FArchiveXML::LoadPhysicsForceFieldInstance(FCDObject* object, xmlNode* instanceNode)
{
	if (!FArchiveXML::LoadEntityInstance(object, instanceNode)) return false;

	bool status = true;
	FCDPhysicsForceFieldInstance* physicsForceFieldInstance = (FCDPhysicsForceFieldInstance*)object;
	if (physicsForceFieldInstance->GetEntity() == NULL && !physicsForceFieldInstance->IsExternalReference())
	{
		FUError::Error(FUError::ERROR_LEVEL, FUError::ERROR_INVALID_URI, 
				instanceNode->line);
	}

	// Check for the expected instantiation node type
	if (!IsEquivalent(instanceNode->name, DAE_INSTANCE_FORCE_FIELD_ELEMENT))
	{
		FUError::Error(FUError::ERROR_LEVEL, FUError::ERROR_UNKNOWN_ELEMENT, 
				instanceNode->line);
		status = false;
	}

	// nothing interesting in force field instance to load

	physicsForceFieldInstance->SetDirtyFlag();
	return status;
}
bool FArchiveXML::LoadPhysicsRigidConstraintInstance(FCDObject* object, xmlNode* instanceNode)
{
	if (!FArchiveXML::LoadEntityInstance(object, instanceNode)) return false;

	bool status = true;
	FCDPhysicsRigidConstraintInstance* physicsRigidConstraintInstance = (FCDPhysicsRigidConstraintInstance*)object;

	// Check for the expected instantiation node type
	if (!IsEquivalent(instanceNode->name, DAE_INSTANCE_RIGID_CONSTRAINT_ELEMENT)
		|| physicsRigidConstraintInstance->GetModelParentInstance() == NULL 
		|| physicsRigidConstraintInstance->GetModelParentInstance()->GetEntity() == NULL)
	{
		FUError::Error(FUError::ERROR_LEVEL, FUError::ERROR_UNKNOWN_ELEMENT, instanceNode->line);
		status = false;
	}

	FCDPhysicsModel* model = (FCDPhysicsModel*) physicsRigidConstraintInstance->GetModelParentInstance()->GetEntity();
	fm::string physicsRigidConstraintSid = ReadNodeProperty(instanceNode, DAE_CONSTRAINT_ATTRIBUTE);
	FCDPhysicsRigidConstraint* rigidConstraint = model->FindRigidConstraintFromSid(physicsRigidConstraintSid);
	if (!rigidConstraint)
	{
		FUError::Error(FUError::WARNING_LEVEL, FUError::WARNING_RIGID_CONSTRAINT_MISSING, instanceNode->line);
		return status;
	}
	physicsRigidConstraintInstance->SetRigidConstraint(rigidConstraint);
	physicsRigidConstraintInstance->SetDirtyFlag();
	return status;
}
Example #26
0
void FCDENode::FindChildrenNodes(const char* name, FCDENodeList& nodes) const
{
	for (const FCDENode** itN = children.begin(); itN != children.end(); ++itN)
	{
		if (IsEquivalent((*itN)->GetName(), name)) nodes.push_back(const_cast<FCDENode*>(*itN));
	}
}
bool FArchiveXML::LoadPhysicsRigidBody(FCDObject* object, xmlNode* physicsRigidBodyNode)
{
	if (!FArchiveXML::LoadEntity(object, physicsRigidBodyNode)) return false;

	bool status = true;
	FCDPhysicsRigidBody* physicsRigidBody = (FCDPhysicsRigidBody*)object;
	if (!IsEquivalent(physicsRigidBodyNode->name, DAE_RIGID_BODY_ELEMENT)) 
	{
		FUError::Error(FUError::WARNING_LEVEL, FUError::WARNING_UNKNOWN_PRB_LIB_ELEMENT, physicsRigidBodyNode->line);
		return status;
	}

	physicsRigidBody->SetSubId(FUDaeParser::ReadNodeSid(physicsRigidBodyNode));

	xmlNode* techniqueNode = FindChildByType(physicsRigidBodyNode, 
			DAE_TECHNIQUE_COMMON_ELEMENT);
	if (techniqueNode != NULL)
	{
		FArchiveXML::LoadPhysicsRigidBodyParameters(physicsRigidBody->GetParameters(), techniqueNode);
	}
	else
	{
		FUError::Error(FUError::ERROR_LEVEL, FUError::ERROR_COMMON_TECHNIQUE_MISSING,
				physicsRigidBodyNode->line);
	}

	return status;
}
bool FArchiveXML::LoadGeometryInstance(FCDObject* object, xmlNode* instanceNode)
{
	if (!FArchiveXML::LoadEntityInstance(object, instanceNode)) return false;

	bool status = true;
	FCDGeometryInstance* geometryInstance = (FCDGeometryInstance*)object;

	// Look for the <bind_material> element. The others are discarded for now.
	xmlNode* bindMaterialNode = FindChildByType(instanceNode, DAE_BINDMATERIAL_ELEMENT);
	if (bindMaterialNode != NULL)
	{
		for (xmlNode* child = bindMaterialNode->children; child != NULL; child = child->next)
		{
			if (child->type != XML_ELEMENT_NODE) continue;

			if (IsEquivalent(child->name, DAE_PARAMETER_ELEMENT))
			{
				FCDEffectParameter* parameter = geometryInstance->AddEffectParameter(FArchiveXML::GetEffectParameterType(child));
				parameter->SetAnimator();
				status &= FArchiveXML::LoadSwitch(parameter, &parameter->GetObjectType(), child);
			}
		} 

		// Retrieve the list of the <technique_common><instance_material> elements.
		xmlNode* techniqueNode = FindChildByType(bindMaterialNode, DAE_TECHNIQUE_COMMON_ELEMENT);
		xmlNodeList materialNodes;
		FindChildrenByType(techniqueNode, DAE_INSTANCE_MATERIAL_ELEMENT, materialNodes);
		for (xmlNodeList::iterator itM = materialNodes.begin(); itM != materialNodes.end(); ++itM)
		{
			FCDMaterialInstance* material = geometryInstance->AddMaterialInstance();
			status &= (FArchiveXML::LoadMaterialInstance(material, *itM));
		}
	}
	else
	{
		// Blinding attempt to use the material semantic from the polygons as a material id.
		FCDGeometry* geometry = (FCDGeometry*) geometryInstance->GetEntity();
		if (geometry != NULL && geometry->HasType(FCDGeometry::GetClassType()) && geometry->IsMesh())
		{
			FCDGeometryMesh* mesh = geometry->GetMesh();
			size_t polyCount = mesh->GetPolygonsCount();
			for (size_t i = 0; i < polyCount; ++i)
			{
				FCDGeometryPolygons* polys = mesh->GetPolygons(i);
				const fstring& semantic = polys->GetMaterialSemantic();
				fm::string semanticUTF8 = TO_STRING(semantic);
				semanticUTF8 = FCDObjectWithId::CleanId(semanticUTF8.c_str());
				FCDMaterial* material = geometry->GetDocument()->FindMaterial(semanticUTF8);
				if (material != NULL)
				{
					geometryInstance->AddMaterialInstance(material, polys);
				}
			}
		}
	}

	geometryInstance->SetDirtyFlag();
	return status;
}
Example #29
0
// Search for a profile-specific type
const FCDEType* FCDExtra::FindType(const char* name) const
{
	for (const FCDEType** itT = types.begin(); itT != types.end(); ++itT)
	{
		if (IsEquivalent((*itT)->GetName(), name)) return *itT;
	}
	return NULL;
}
Example #30
0
bool FCDEffectParameterAnimatableT<PrimitiveType, Qualifiers>::IsValueEqual(FCDEffectParameter* parameter)
{
	if (!FCDEffectParameter::IsValueEqual(parameter)) return false;
	FCDEffectParameterAnimatableT<PrimitiveType, Qualifiers>* param = (FCDEffectParameterAnimatableT<PrimitiveType, Qualifiers>*) parameter;
	
	if (floatType != param->GetFloatType()) return false;
	return IsEquivalent(value, param->GetValue());
}