applied patch from snailrose, related to multi-platform OpenGL extensions.
[blender.git] / source / gameengine / Ketsji / KX_BlenderMaterial.h
1 #ifndef __KX_BLENDER_MATERIAL_H__
2 #define __KX_BLENDER_MATERIAL_H__
3
4 #include <vector>
5
6
7 #include "RAS_IPolygonMaterial.h"
8 #include "BL_Material.h"
9 #include "BL_Texture.h"
10 #include "BL_Shader.h"
11
12 #include "PyObjectPlus.h"
13
14 #include "MT_Vector3.h"
15 #include "MT_Vector4.h"
16
17 struct TFace;
18 class KX_Scene;
19
20 class KX_BlenderMaterial :  public PyObjectPlus, public RAS_IPolyMaterial
21 {
22         Py_Header;
23 public:
24         // --------------------------------
25         KX_BlenderMaterial(
26                 class KX_Scene* scene, // light/obj list
27                 BL_Material*    mat,
28                 bool                    skin,
29                 int                             lightlayer,
30                 void*                   clientobject,
31                 PyTypeObject*   T=&Type
32         );
33
34         virtual ~KX_BlenderMaterial();
35
36         // --------------------------------
37         virtual TCachingInfo GetCachingInfo(void) const
38         {
39                 // --
40                 return (void*) this;
41         }
42
43         // --------------------------------
44         virtual bool Activate(
45                 RAS_IRasterizer* rasty, 
46                 TCachingInfo& cachingInfo) const;
47         
48         void ActivateMat(
49                 RAS_IRasterizer* rasty, 
50                 TCachingInfo& cachingInfo)const;
51                 
52         void ActivatShaders(
53                 RAS_IRasterizer* rasty, 
54                 TCachingInfo& cachingInfo)const;
55         // --------------------------------
56
57         TFace* GetTFace(void) const;
58
59         // for ipos
60         void UpdateIPO(
61                 MT_Vector4 rgba, MT_Vector3 specrgb,
62                 MT_Scalar hard, MT_Scalar spec,
63                 MT_Scalar ref, MT_Scalar emit, MT_Scalar alpha
64         );
65         
66         // --------------------------------
67         virtual PyObject* _getattr(const STR_String& attr);
68         virtual int       _setattr(const STR_String& attr, PyObject *pyvalue);
69
70         KX_PYMETHOD_DOC( KX_BlenderMaterial, getShader );
71         KX_PYMETHOD_DOC( KX_BlenderMaterial, getMaterialIndex );
72         KX_PYMETHOD_DOC( KX_BlenderMaterial, getTexture );
73         KX_PYMETHOD_DOC( KX_BlenderMaterial, setTexture );
74
75         // --------------------------------
76         // pre calculate to avoid pops/lag at startup
77         virtual void OnConstruction( );
78
79 private:
80         BL_Material*    mMaterial;
81         BL_Shader*              mShader;
82         KX_Scene*               mScene;
83         BL_Texture              mTextures[MAXTEX];              // texture array
84         
85         // message centers
86         void    setTexData( bool enable );
87         void    setShaderData( bool enable );
88
89         void    setTextureEnvironment( int textureIndex );
90         void    setEnvMap( bool val, bool cube=false);
91         void    setTexMatrixData(int i);
92         bool    setDefaultBlending();
93         bool    setBlending( int ind, bool enable=false );
94         void    setObjectMatrixData(int i);
95
96         // cleanup stuff
97         void    DisableTexData();
98         void    OnExit();
99
100         //void  DisableNonEnabled();
101         // --
102         mutable int     mPass;
103 };
104
105
106 #endif