root/OpenSceneGraph/trunk/src/osgPlugins/fbx/fbxMaterialToOsgStateSet.h @ 11107

Revision 11107, 1.6 kB (checked in by mplatings, 4 years ago)
RevLine 
[11107]1#ifndef FBXMATERIALTOOSGSTATESET_H
2#define FBXMATERIALTOOSGSTATESET_H
3
4#include <map>
5#include <memory>
6#include <osg/Material>
7#include <osg/StateSet>
8#include <osgDB/Options>
9#include <osg/Texture2D>
10
11#if defined(_MSC_VER)
12#pragma warning( disable : 4505 )
13#endif
14#include <fbxsdk.h>
15
16//The only things we need to create a new StateSet are texture and materials. So we store that in a pair.
17//We Don't store directly in stateSet because getOrCreateStateSet function set some parameters.
18typedef std::pair<osg::Material *, osg::Texture2D *> StateSetContent;
19
20//We use the pointers setted by the importer to not duplicate materials and textures.
21typedef std::map<const KFbxSurfaceMaterial *, StateSetContent> KFbxMaterialMap;
22
23//This map is used to not load the same image more than 1 time.
24typedef std::map<std::string, osg::Texture2D *> ImageMap;
25
26class FbxMaterialToOsgStateSet
27{
28public:
29    //Convert a KfbxSurfaceMaterial to a osgMaterial and an osgTexture.
30    StateSetContent convert(const KFbxSurfaceMaterial* pFbxMat);
31
32    //dir is the directory where fbx is stored (for relative path).
33    FbxMaterialToOsgStateSet::FbxMaterialToOsgStateSet(const std::string& dir, const osgDB::Options* options) :
34        _options(options),
35        _dir(dir) {}
36private:
37    //Convert a texture fbx to an osg texture.
38    osg::ref_ptr<osg::Texture2D>
39    fbxTextureToOsgTexture(const KFbxTexture* pOsgTex);
40    KFbxMaterialMap       _kFbxMaterialMap;
41    ImageMap              _imageMap;
42    const osgDB::Options* _options;
43    const std::string     _dir;
44};
45
46
47#endif //FBXMATERIALTOOSGSTATESET_H
Note: See TracBrowser for help on using the browser.