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

Revision 11251, 1.6 kB (checked in by mplatings, 5 years ago)

Workaround for models with inverted transparency

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) {}
[11251]36
37    void checkInvertTransparency();
[11107]38private:
39    //Convert a texture fbx to an osg texture.
40    osg::ref_ptr<osg::Texture2D>
41    fbxTextureToOsgTexture(const KFbxTexture* pOsgTex);
42    KFbxMaterialMap       _kFbxMaterialMap;
43    ImageMap              _imageMap;
44    const osgDB::Options* _options;
45    const std::string     _dir;
46};
47
48
49#endif //FBXMATERIALTOOSGSTATESET_H
Note: See TracBrowser for help on using the browser.