/** Creates an material identifier for the first EffectCommon in @a effect. It is assumed, that there is at least
	one EffectCommon.*/
	MaterialCreator::MaterialIdentifier getMaterialIdentifier( const COLLADAFW::Effect& effect,
															   const COLLADAFW::MaterialBinding& materialBinding,
															   const DocumentImporter::SetMapChannelMap& setMapChannelMap)
	{
//		assert( !effect.getCommonEffects().empty() );
		MaterialCreator::MaterialIdentifier materialIdentifier;
		materialIdentifier.slotFlags = 0;

		const COLLADAFW::UniqueId& effectUniqueId = effect.getUniqueId();

		materialIdentifier.effectUniqueId = effect.getUniqueId();

		const COLLADAFW::CommonEffectPointerArray& commonEffects = effect.getCommonEffects();

		if ( !commonEffects.empty() )
		{
			const COLLADAFW::EffectCommon* commonEffect = effect.getCommonEffects()[0];

			const COLLADAFW::TextureCoordinateBindingArray& texCoordBindings =  materialBinding.getTextureCoordinateBindingArray();

			setMaterialIdentifierMapChannel( commonEffect->getAmbient(), texCoordBindings, setMapChannelMap, MaterialCreator::MaterialIdentifier::AMBIENT, materialIdentifier.slotFlags, materialIdentifier.ambientMapChannel);
			setMaterialIdentifierMapChannel( commonEffect->getDiffuse(), texCoordBindings, setMapChannelMap, MaterialCreator::MaterialIdentifier::DIFFUSE, materialIdentifier.slotFlags, materialIdentifier.diffuseMapChannel);
			setMaterialIdentifierMapChannel( commonEffect->getSpecular(), texCoordBindings, setMapChannelMap, MaterialCreator::MaterialIdentifier::SPECULAR, materialIdentifier.slotFlags, materialIdentifier.specularMapChannel);
	//		setMaterialIdentifierMapChannel( commonEffect->getShininess(), texCoordBindings, setMapChannelMap, MaterialCreator::MaterialIdentifier::SHININESS, materialIdentifier.slotFlags, materialIdentifier.shininessMapChannel);
			setMaterialIdentifierMapChannel( commonEffect->getEmission(), texCoordBindings, setMapChannelMap, MaterialCreator::MaterialIdentifier::EMISSION, materialIdentifier.slotFlags, materialIdentifier.emissionMapChannel);
			setMaterialIdentifierMapChannel( commonEffect->getOpacity(), texCoordBindings, setMapChannelMap, MaterialCreator::MaterialIdentifier::OPACITY, materialIdentifier.slotFlags, materialIdentifier.opacityMapChannel);
		}

		return materialIdentifier;
	}
예제 #2
0
    void ExtraDataHandler::determineBumpTextureSamplerAndTexCoord( const GeneratedSaxParser::xmlChar** attributes )
	{
        COLLADAFW::TextureAttributes *textureAttributes = nullptr;

        shared_ptr <JSONObject> bump = nullptr;
		if(mCurrentObject) {
			if( COLLADAFW::COLLADA_TYPE::EFFECT == mCurrentObject->getClassId()) {
                shared_ptr <JSONObject> extras = this->getExtras(mCurrentElementUniqueId);
                assert(extras);
                shared_ptr <JSONObject> textures = extras->createObjectIfNeeded("textures");
                bump = textures->createObjectIfNeeded("bump");
                
                COLLADAFW::Effect* effect = (COLLADAFW::Effect*)mCurrentObject;
                textureAttributes = effect->createExtraTextureAttributes();
			}
		}
        
        if ((bump == nullptr) || (textureAttributes == nullptr))
            return;
        
		size_t index = 0;
        
		const GeneratedSaxParser::xmlChar* attributeKey = attributes[index++];
		const GeneratedSaxParser::xmlChar* attributeValue = 0;
		while( attributeKey != 0 ) {
			attributeValue = attributes[index++];
			if( attributeValue != 0 ) {
                bump->setString(attributeKey, attributeValue);
			}
            
			if (strcmp(attributeKey, "texture") == 0) {
                textureAttributes->textureSampler = attributeValue;
            } else if (strcmp(attributeKey, "texcoord")) {
                textureAttributes->texCoord = attributeValue;
			}
			attributeKey = attributes[index++];
		}
	}
예제 #3
0
	//------------------------------
	void ExtraDataHandler::determineBumpTextureSamplerAndTexCoord( const GeneratedSaxParser::xmlChar** attributes )
	{
		mExtraParameters.bumpParameters.textureAttributes = 0;

		if( mCurrentObject )
		{
			if( COLLADAFW::COLLADA_TYPE::EFFECT == mCurrentObject->getClassId() )
			{
				COLLADAFW::Effect* effect = (COLLADAFW::Effect*)mCurrentObject;
				mExtraParameters.bumpParameters.textureAttributes = effect->createExtraTextureAttributes();
			}
		}

		if( mExtraParameters.bumpParameters.textureAttributes == 0 )
			return;

		size_t index = 0;

		const GeneratedSaxParser::xmlChar* attributeKey = attributes[index++];
		const GeneratedSaxParser::xmlChar* attributeValue = 0;
		while( attributeKey != 0 )
		{
			attributeValue = attributes[index++];
			if( strcmp(attributeKey, "texture") == 0 && attributeValue != 0 )
			{
				if( mExtraParameters.bumpParameters.textureAttributes )
					mExtraParameters.bumpParameters.textureAttributes->textureSampler = attributeValue;
			}
			else if( strcmp(attributeKey, "texcoord") == 0 && attributeValue != 0 )
			{
				if( mExtraParameters.bumpParameters.textureAttributes )
					mExtraParameters.bumpParameters.textureAttributes->texCoord = attributeValue;
			}

			attributeKey = attributes[index++];
		}
	}