Exemple #1
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++];
		}
	}
	//------------------------------
	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++];
		}
	}