コード例 #1
0
ファイル: FCDEffectTools.cpp プロジェクト: Marlinc/0ad
	FCDParameterAnimatableFloat* GetAnimatedFloat(FCDGeometryInstance* geometryInstance, FCDMaterial* material, const fm::string& semantic)
	{
		//Find the different classes that are needed.
		//FCDMaterial* material = materialInstance->GetMaterial();
		if (material == NULL) return NULL;
		FCDEffect* effect = material->GetEffect();
		if (effect == NULL) return NULL;
		FCDEffectProfile* effectProfile = effect->FindProfile(FUDaeProfileType::COMMON);
		if (effectProfile == NULL) return NULL;
		FCDEffectStandard* effectStandard = (FCDEffectStandard*) effectProfile;
		bool isFloat = true;

		//Find out if the parameter is animated
		FCDEffectParameter* effectStandardParam = effectStandard->GetParam(semantic, &isFloat);
		if (!effectStandardParam) return NULL; 
		const fm::string& reference = effectStandardParam->GetReference();
		if (reference.empty())
		{
			if (isFloat) return &(((FCDEffectParameterFloat*)effectStandardParam)->GetValue());
			else return NULL;
		}
		FCDEffectParameter* geometryParam = geometryInstance != NULL ? FindEffectParameterBySemantic(geometryInstance, semantic) : NULL;
		FCDEffectParameter* materialParam = FindEffectParameterByReference(material, reference, true);
		FCDEffectParameter* effectParam = FindEffectParameterByReference(effect, reference, true);
		FCDEffectParameter* effectProfileParam = FindEffectParameterByReference(effectProfile, reference, false);

		if (isFloat)
		{
			if (geometryParam)
			{
				if (geometryParam->GetType() != FCDEffectParameter::FLOAT) return NULL;
				else return &((FCDEffectParameterFloat*)geometryParam)->GetValue();
			}
			//From this on out, could call GetDefaultFloat... and return that?
			else if (materialParam)
			{
				if (materialParam->GetType() != FCDEffectParameter::FLOAT) return NULL;
				else return &((FCDEffectParameterFloat*)materialParam)->GetValue();
			}
			else if (effectParam)
			{
				if (effectParam->GetType() != FCDEffectParameter::FLOAT) return NULL;
				else return &((FCDEffectParameterFloat*)effectParam)->GetValue();
			}
			else if (effectProfileParam)
			{
				if (effectProfileParam->GetType() != FCDEffectParameter::FLOAT) return NULL;
				else return &((FCDEffectParameterFloat*)effectProfileParam)->GetValue();
			}
			else return &((FCDEffectParameterFloat*)effectStandardParam)->GetValue();
		}
		else return NULL;
	}
コード例 #2
0
ファイル: FCDEffectTools.cpp プロジェクト: Marlinc/0ad
	float* GetDefaultFloat(FCDMaterial* material, const fm::string& semantic)
	{
		//Find the different classes that are needed.
		FCDEffect* effect = material->GetEffect();
		FCDEffectProfile* effectProfile = effect->FindProfile(FUDaeProfileType::COMMON);
		FCDEffectStandard* effectStandard = (FCDEffectStandard*) effectProfile;
		bool isFloat = true;

		//Find out if the parameter is animated
		FCDEffectParameter* effectStandardParam = effectStandard->GetParam(semantic, &isFloat);
		if (!effectStandardParam) return NULL; 
		const fm::string& reference = effectStandardParam->GetReference();
		if (reference.empty())
		{
			if (isFloat) return &(float&) ((FCDEffectParameterFloat*)effectStandardParam)->GetValue();
			else return NULL;
		}
		FCDEffectParameter* materialParam = FindEffectParameterByReference(material, reference, true);
		FCDEffectParameter* effectParam = FindEffectParameterByReference(effect, reference, true);
		FCDEffectParameter* effectProfileParam = FindEffectParameterByReference(effectProfile, reference, false);

		if (isFloat)
		{
			if (materialParam)
			{
				if (materialParam->GetType() != FCDEffectParameter::FLOAT) return NULL;
				else return &(float&) ((FCDEffectParameterFloat*)materialParam)->GetValue();
			}
			else if (effectParam)
			{
				if (effectParam->GetType() != FCDEffectParameter::FLOAT) return NULL;
				else return &(float&) ((FCDEffectParameterFloat*)effectParam)->GetValue();
			}
			else if (effectProfileParam)
			{
				if (effectProfileParam->GetType() != FCDEffectParameter::FLOAT) return NULL;
				else return &(float&) ((FCDEffectParameterFloat*)effectProfileParam)->GetValue();
			}
			else return &(float&) ((FCDEffectParameterFloat*)effectStandardParam)->GetValue();
		}
		else return NULL;
	}
コード例 #3
0
ファイル: FCDEffectTools.cpp プロジェクト: Marlinc/0ad
	FMVector4* GetDefaultColor(FCDMaterial* material, const fm::string& semantic, bool* isFloat3)
	{
		//Find the different classes that are needed.
		FCDEffect* effect = material->GetEffect();
		FCDEffectProfile* effectProfile = effect->FindProfile(FUDaeProfileType::COMMON);
		FCDEffectStandard* effectStandard = (FCDEffectStandard*) effectProfile;
		bool isFloat = true;

		//Find out if the parameter is animated
		FCDEffectParameter* effectStandardParam = effectStandard->GetParam(semantic, &isFloat);
		if (!effectStandardParam) return NULL; 
		const fm::string& reference = effectStandardParam->GetReference();
		if (reference.empty())
		{
			if (isFloat) return NULL;
			else return &(FMVector4&)(((FCDEffectParameterColor4*)effectStandardParam)->GetValue());
		}
		FCDEffectParameter* materialParam = FindEffectParameterByReference(material, reference, true);
		FCDEffectParameter* effectParam = FindEffectParameterByReference(effect, reference, true);
		FCDEffectParameter* effectProfileParam = FindEffectParameterByReference(effectProfile, reference, false);

		//Do the figuring out .. ;)
		if (isFloat) return NULL;
		else
		{
			// Don't look at the geometry instance parameters: these are only used for animations!
			if (materialParam)
			{
				if (materialParam->GetType() == FCDEffectParameter::FLOAT3)
				{
					*isFloat3 = true;
					FCDEffectParameterFloat3* tempParam = (FCDEffectParameterFloat3*) materialParam;
					return (FMVector4*) &(FMVector3&) tempParam->GetValue();
				}
				else if (materialParam->GetType() == FCDEffectParameter::VECTOR)
				{
					*isFloat3 = false;
					return &(FMVector4&) ((FCDEffectParameterColor4*)materialParam)->GetValue();
				}
				else return NULL;
			}
			else if (effectParam)
			{
				if (effectParam->GetType() == FCDEffectParameter::FLOAT3)
				{
					*isFloat3 = true;
					FCDEffectParameterFloat3* tempParam = (FCDEffectParameterFloat3*) effectParam;
					return (FMVector4*) &(FMVector3&) tempParam->GetValue();
				}
				else if (effectParam->GetType() == FCDEffectParameter::VECTOR)
				{
					*isFloat3 = false;
					return &(FMVector4&) ((FCDEffectParameterColor4*)effectParam)->GetValue();
				}
				else return NULL;
			}
			else if (effectProfileParam)
			{
				if (effectProfileParam->GetType() == FCDEffectParameter::FLOAT3)
				{
					*isFloat3 = true;
					FCDEffectParameterFloat3* tempParam = (FCDEffectParameterFloat3*) effectProfileParam;
					return (FMVector4*) &(FMVector3&) tempParam->GetValue();
				}
				else if (effectProfileParam->GetType() == FCDEffectParameter::VECTOR)
				{
					*isFloat3 = false;
					return &(FMVector4&) ((FCDEffectParameterColor4*)effectProfileParam)->GetValue();
				}
				else return NULL;
			}
			else 
			{
				*isFloat3 = true;
				return &(FMVector4&) ((FCDEffectParameterColor4*)effectStandardParam)->GetValue();
			}
		}
	}
コード例 #4
0
ファイル: FCDEffectTools.cpp プロジェクト: Marlinc/0ad
	FCDParameterAnimatableColor4* GetAnimatedColor(FCDGeometryInstance* geometryInstance, FCDMaterial* material, const fm::string& semantic, bool* isFloat3)
	{
		//Find the different classes that are needed.
		//FCDMaterial* material = materialInstance->GetMaterial();
		if (material == NULL) return NULL;
		FCDEffect* effect = material->GetEffect();
		if (effect == NULL) return NULL;
		FCDEffectProfile* effectProfile = effect->FindProfile(FUDaeProfileType::COMMON);
		if (effectProfile == NULL) return NULL;
		FCDEffectStandard* effectStandard = (FCDEffectStandard*) effectProfile;
		bool isFloat = true;

		//Find out if the parameter is animated
		FCDEffectParameter* effectStandardParam = effectStandard->GetParam(semantic, &isFloat);
		if (effectStandardParam == NULL) return NULL; 
		const fm::string& reference = effectStandardParam->GetReference();
		if (reference.empty())
		{
			if (isFloat) return NULL;
			else return &(((FCDEffectParameterColor4*)effectStandardParam)->GetValue());
		}
		FCDEffectParameter* geometryParam = geometryInstance != NULL ? FindEffectParameterBySemantic(geometryInstance, semantic) : NULL;
		FCDEffectParameter* materialParam = FindEffectParameterByReference(material, reference, true);
		FCDEffectParameter* effectParam = FindEffectParameterByReference(effect, reference, true);
		FCDEffectParameter* effectProfileParam = FindEffectParameterByReference(effectProfile, reference, false);

		//Do the figuring out .. ;)
		if (isFloat) return NULL;
		else
		{
			if (geometryParam)
			{
				if (geometryParam->GetType() == FCDEffectParameter::FLOAT3)
				{
					*isFloat3 = true;
					FCDEffectParameterFloat3* tempParam = (FCDEffectParameterFloat3*) geometryParam;
					return (FCDParameterAnimatableColor4*) &tempParam->GetValue();
				}
				else if (geometryParam->GetType() == FCDEffectParameter::VECTOR)
				{
					*isFloat3 = false;
					return &((FCDEffectParameterColor4*)geometryParam)->GetValue();
				}
				else return NULL;
			}
			//Could call GetDefaultColor from here on out...
			else if (materialParam)
			{
				if (materialParam->GetType() == FCDEffectParameter::FLOAT3)
				{
					*isFloat3 = true;
					FCDEffectParameterFloat3* tempParam = (FCDEffectParameterFloat3*) materialParam;
					return (FCDParameterAnimatableColor4*) &tempParam->GetValue();
				}
				else if (materialParam->GetType() == FCDEffectParameter::VECTOR)
				{
					*isFloat3 = false;
					return &((FCDEffectParameterColor4*)materialParam)->GetValue();
				}
				else return NULL;
			}
			else if (effectParam)
			{
				if (effectParam->GetType() == FCDEffectParameter::FLOAT3)
				{
					*isFloat3 = true;
					FCDEffectParameterFloat3* tempParam = (FCDEffectParameterFloat3*) effectParam;
					return (FCDParameterAnimatableColor4*) &tempParam->GetValue();
				}
				else if (effectParam->GetType() == FCDEffectParameter::VECTOR)
				{
					*isFloat3 = false;
					return &((FCDEffectParameterColor4*)effectParam)->GetValue();
				}
				else return NULL;
			}
			else if (effectProfileParam)
			{
				if (effectProfileParam->GetType() == FCDEffectParameter::FLOAT3)
				{
					*isFloat3 = true;
					FCDEffectParameterFloat3* tempParam = (FCDEffectParameterFloat3*) effectProfileParam;
					return (FCDParameterAnimatableColor4*) &tempParam->GetValue();
				}
				else if (effectProfileParam->GetType() == FCDEffectParameter::VECTOR)
				{
					*isFloat3 = false;
					return &((FCDEffectParameterColor4*)effectProfileParam)->GetValue();
				}
				else return NULL;
			}
			else 
			{
				*isFloat3 = true;
				return &((FCDEffectParameterColor4*)effectStandardParam)->GetValue();
			}
		}
	}