root/OpenSceneGraph/branches/OpenSceneGraph-2.8/src/osgPlugins/fbx/fbxMaterialToOsgStateSet.h @ 11264

Revision 11264, 1.6 kB (checked in by paulmartz, 4 years ago)

2.8 branch: Mergine recent changes to FBX. Revisions in this commit: r11251, r11252, r11262.

  • Property svn:mime-type set to text/x-cpp
  • Property svn:eol-style set to native
Line 
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/ReaderWriter>
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::ReaderWriter::Options* options) :
34        _options(options),
35        _dir(dir) {}
36
37    void checkInvertTransparency();
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::ReaderWriter::Options* _options;
45    const std::string     _dir;
46};
47
48
49#endif //FBXMATERIALTOOSGSTATESET_H
Note: See TracBrowser for help on using the browser.