Ejemplo n.º 1
0
	const FCDEffectParameter* FindEffectParameterByReference(const FCDEffectProfile* profile, const char* reference, bool localOnly)
	{
		// Look within the local parameters.
		if (profile == NULL || reference == NULL || *reference == 0) return NULL;
		size_t count = profile->GetEffectParameterCount();
		for (size_t p = 0; p < count; ++p)
		{
			const FCDEffectParameter* effectParameter = profile->GetEffectParameter(p);
			if (IsEquivalent(effectParameter->GetReference(), reference)) return effectParameter;
		}

		if (profile->HasType(FCDEffectProfileFX::GetClassType()) && !localOnly)
		{
			// Look within the <technique> parameters.
			FCDEffectProfileFX* fx = (FCDEffectProfileFX*) profile;
			size_t techniqueCount = fx->GetTechniqueCount();
			for (size_t t = 0; t < techniqueCount; ++t)
			{
				const FCDEffectParameter* effectParameter = FindEffectParameterByReference(fx->GetTechnique(t), reference);
				if (effectParameter != NULL) return effectParameter;
			}
		}
		else if (profile->HasType(FCDEffectStandard::GetClassType()))
		{
			// Look within the textures which have their own parameters.
			FCDEffectStandard* std = (FCDEffectStandard*) profile;
			for (uint32 i = 0; i < FUDaeTextureChannel::COUNT; ++i)
			{
				size_t bucketSize = std->GetTextureCount(i);
				for (size_t t = 0; t < bucketSize; ++t)
				{
					FCDTexture* texture = std->GetTexture(i, t);
					if (IsEquivalent(texture->GetSet()->GetReference(), reference)) return texture->GetSet();
				}
			}
		}
		return NULL;
	}
Ejemplo n.º 2
0
	void FindEffectParametersBySemantic(const FCDEffectProfile* profile, const char* semantic, FCDEffectParameterList& parameters, bool localOnly)
	{
		// Look within the local parameters.
		if (profile == NULL || semantic == NULL || *semantic == 0) return;
		size_t count = profile->GetEffectParameterCount();
		for (size_t p = 0; p < count; ++p)
		{
			const FCDEffectParameter* effectParameter = profile->GetEffectParameter(p);
			if (IsEquivalent(effectParameter->GetSemantic(), semantic)) parameters.push_back(effectParameter);
		}

		if (profile->HasType(FCDEffectProfileFX::GetClassType()) && !localOnly)
		{
			// Look within the <technique> parameters.
			FCDEffectProfileFX* fx = (FCDEffectProfileFX*) profile;
			size_t techniqueCount = fx->GetTechniqueCount();
			for (size_t t = 0; t < techniqueCount; ++t)
			{
				FindEffectParametersBySemantic(fx->GetTechnique(t), semantic, parameters);
			}
		}
		else if (profile->HasType(FCDEffectStandard::GetClassType()))
		{
			// Look within the textures which have their own parameters.
			FCDEffectStandard* std = (FCDEffectStandard*) profile;
			for (uint32 i = 0; i < FUDaeTextureChannel::COUNT; ++i)
			{
				size_t bucketSize = std->GetTextureCount(i);
				for (size_t t = 0; t < bucketSize; ++t)
				{
					FCDTexture* texture = std->GetTexture(i, t);
					if (IsEquivalent(texture->GetSet()->GetSemantic(), semantic)) parameters.push_back(texture->GetSet());
				}
			}
		}
	}