Example #1
0
bool	FBXLoader::DisplayTextureNames( KFbxProperty &pProperty, KString& pConnectionString)
{
	int lLayeredTextureCount = pProperty.GetSrcObjectCount(KFbxLayeredTexture::ClassId);
	if (lLayeredTextureCount > 0)
	{
		for (int j=0; j<lLayeredTextureCount; ++j)
		{
			KFbxLayeredTexture *lLayeredTexture = KFbxCast <KFbxLayeredTexture>(pProperty.GetSrcObject(KFbxLayeredTexture::ClassId, j));
			int lNbTextures = lLayeredTexture->GetSrcObjectCount(KFbxTexture::ClassId);
			pConnectionString += " Texture ";

			for (int k =0; k<lNbTextures; ++k)
			{
				pConnectionString += "\"";
				pConnectionString += (char*)lLayeredTexture->GetName();
				pConnectionString += "\"";
				pConnectionString += " ";
			}
			pConnectionString += "of ";
			pConnectionString += pProperty.GetName();
			pConnectionString += " on layer ";
			pConnectionString += j;
		}
		pConnectionString += " |";
		return true;
	}
	else
	{
		int lNbTextures = pProperty.GetSrcObjectCount(KFbxTexture::ClassId);

		if (lNbTextures > 0)
		{
			pConnectionString += " Texture ";
			pConnectionString += " ";

			for (int j =0; j<lNbTextures; ++j)
			{
				KFbxTexture* lTexture = KFbxCast <KFbxTexture> (pProperty.GetSrcObject(KFbxTexture::ClassId,j));
				if (lTexture)
				{
					pConnectionString += "\"";
					pConnectionString += (char*)lTexture->GetName();
					pConnectionString += "\"";
					pConnectionString += " ";
				}
			}
			pConnectionString += "of ";
			pConnectionString += pProperty.GetName();
			pConnectionString += " |";
			return true;
		}
		return false;
	}
}
Example #2
0
bool	FBXLoader::FindTextureInfo(KFbxProperty prop, bool& disp, int mat_i, Object* o)
{
	if (prop.IsValid())
	{
		Texture*	t;

		t = new (std::nothrow) Texture;
		if (t == NULL)
		{
			std::cout << "[FbxLoader]{__FindTextureInfo} Error: Can not allocate memory\n";
			return (false);
		}
		int	t_count;
		int	i;

		t_count = prop.GetSrcObjectCount(KFbxTexture::ClassId);
		i = 0;
		while (i < t_count)
		{
			KFbxLayeredTexture*	lay_t;

			lay_t = KFbxCast <KFbxLayeredTexture>(prop.GetSrcObject(KFbxLayeredTexture::ClassId, i));
			if (lay_t)
			{
				KFbxLayeredTexture*	lay_t2;
				int			nb_text;
				int			j;

				lay_t2 = KFbxCast <KFbxLayeredTexture>(prop.GetSrcObject(KFbxLayeredTexture::ClassId, i));
				nb_text = lay_t2->GetSrcObjectCount(KFbxTexture::ClassId);
				j = 0;
				while (j < nb_text)
				{
					KFbxTexture*	_t;

					_t = KFbxCast <KFbxTexture> (lay_t2->GetSrcObject(KFbxTexture::ClassId, j));
					if (_t)
					{
						KFbxLayeredTexture::EBlendMode blend_mode;

						if (disp)
							disp = false;
						lay_t2->GetTextureBlendMode(j, blend_mode);
						this->TextureInfoFinded(_t, (int)blend_mode, t);
						o->GetMatList()->at(mat_i)->AddTexture(t);
					}
					++j;
				}
			}
			else
			{
				KFbxTexture*	_t;

				_t = KFbxCast <KFbxTexture> (prop.GetSrcObject(KFbxTexture::ClassId, i));
				if (_t)
				{
					if (disp)
						disp = false;
					if (strcmp(prop.GetName(), "DiffuseColor") == 0)
						t->SetTXTChanel(0);
					else if (strcmp(prop.GetName(), "SpecularColor") == 0)
						t->SetTXTChanel(3);
					this->TextureInfoFinded(_t, -1, t);
					o->GetMatList()->at(mat_i)->AddTexture(t);
				}
			}
			++i;
		}
	}
	return (true);
}