diff --git a/src/osgPlugins/fbx/fbxMaterialToOsgStateSet.h b/src/osgPlugins/fbx/fbxMaterialToOsgStateSet.h new file mode 100644 index 000000000..a9a4b83d6 --- /dev/null +++ b/src/osgPlugins/fbx/fbxMaterialToOsgStateSet.h @@ -0,0 +1,47 @@ +#ifndef FBXMATERIALTOOSGSTATESET_H +#define FBXMATERIALTOOSGSTATESET_H + +#include +#include +#include +#include +#include +#include + +#if defined(_MSC_VER) +#pragma warning( disable : 4505 ) +#endif +#include + +//The only things we need to create a new StateSet are texture and materials. So we store that in a pair. +//We Don't store directly in stateSet because getOrCreateStateSet function set some parameters. +typedef std::pair StateSetContent; + +//We use the pointers setted by the importer to not duplicate materials and textures. +typedef std::map KFbxMaterialMap; + +//This map is used to not load the same image more than 1 time. +typedef std::map ImageMap; + +class FbxMaterialToOsgStateSet +{ +public: + //Convert a KfbxSurfaceMaterial to a osgMaterial and an osgTexture. + StateSetContent convert(const KFbxSurfaceMaterial* pFbxMat); + + //dir is the directory where fbx is stored (for relative path). + FbxMaterialToOsgStateSet::FbxMaterialToOsgStateSet(const std::string& dir, const osgDB::Options* options) : + _options(options), + _dir(dir) {} +private: + //Convert a texture fbx to an osg texture. + osg::ref_ptr + fbxTextureToOsgTexture(const KFbxTexture* pOsgTex); + KFbxMaterialMap _kFbxMaterialMap; + ImageMap _imageMap; + const osgDB::Options* _options; + const std::string _dir; +}; + + +#endif //FBXMATERIALTOOSGSTATESET_H \ No newline at end of file