Beispiel #1
0
	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;
	}
void ColladaMeshFactory::LoadMaterialNew(
	int aSurfaceIndex,
	FCDMaterial* aMaterial,
	FCDocument* aDocument,
	RevTextures& aTextures)
{
	FCDEffect* fx = aMaterial->GetEffect();
	FCDEffectProfile* profile = fx->FindProfile(FUDaeProfileType::COMMON);
	FCDEffectStandard* standardProfile=dynamic_cast<FCDEffectStandard*>(profile);

	if (standardProfile->GetTextureCount(FUDaeTextureChannel::DIFFUSE)>0) 
	{
		FCDTexture* texture=standardProfile->GetTexture(FUDaeTextureChannel::DIFFUSE,0);
		FCDImage* image=texture->GetImage();
		std::string fileName=image->GetFilename();
		aTextures.AddShaderResource( "g_DiffuseTex", fileName.c_str(), true ); 

	}

	if (standardProfile->GetTextureCount(FUDaeTextureChannel::BUMP)>0) 
	{
		FCDTexture* texture=standardProfile->GetTexture(FUDaeTextureChannel::BUMP,0);	
		FCDImage* image=texture->GetImage();
		std::string fileName=image->GetFilename();
		aTextures.AddShaderResource( "g_NormalTex", fileName.c_str(), false ); 

	}
	if (standardProfile->GetTextureCount(FUDaeTextureChannel::AMBIENT)>0) 
	{
		FCDTexture* texture=standardProfile->GetTexture(FUDaeTextureChannel::AMBIENT,0);
		FCDImage* image=texture->GetImage();
		std::string fileName=image->GetFilename();
		aTextures.AddShaderResource("g_PixelRoughnessAOEmissive", fileName.c_str(), true);
	}


	if (standardProfile->GetTextureCount(FUDaeTextureChannel::SPECULAR) > 0)
	{
		FCDTexture* texture = standardProfile->GetTexture(FUDaeTextureChannel::SPECULAR, 0);
		FCDImage* image = texture->GetImage();
		std::string fileName = image->GetFilename();
		aTextures.AddShaderResource("g_SubstanceTexture", fileName.c_str(), false);
	}
}
Beispiel #3
0
	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;
	}
Beispiel #4
0
	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();
			}
		}
	}
Beispiel #5
0
	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();
			}
		}
	}