Merge from trunk 16122-16307
[blender.git] / source / gameengine / Ketsji / KX_BlenderMaterial.h
index 573481448908a495a6af5cc14d8eccf8736980f7..0d7657b8cdbaf7d1e388bb68d925bc7e1ff55e9a 100644 (file)
@@ -8,13 +8,14 @@
 #include "BL_Material.h"
 #include "BL_Texture.h"
 #include "BL_Shader.h"
+#include "BL_BlenderShader.h"
 
 #include "PyObjectPlus.h"
 
 #include "MT_Vector3.h"
 #include "MT_Vector4.h"
 
-struct TFace;
+struct MTFace;
 class KX_Scene;
 
 class KX_BlenderMaterial :  public PyObjectPlus, public RAS_IPolyMaterial
@@ -23,7 +24,7 @@ class KX_BlenderMaterial :  public PyObjectPlus, public RAS_IPolyMaterial
 public:
        // --------------------------------
        KX_BlenderMaterial(
-               class KX_Scene* scene, // light/obj list
+               class KX_Scene* scene,
                BL_Material*    mat,
                bool                    skin,
                int                             lightlayer,
@@ -34,27 +35,39 @@ public:
        virtual ~KX_BlenderMaterial();
 
        // --------------------------------
-       virtual TCachingInfo GetCachingInfo(void) const
-       {
-               // --
+       virtual TCachingInfo GetCachingInfo(void) const {
                return (void*) this;
        }
 
-       // --------------------------------
-       virtual bool Activate(
+       virtual 
+       bool Activate(
                RAS_IRasterizer* rasty, 
-               TCachingInfo& cachingInfo) const;
+               TCachingInfo& cachingInfo
+       ) const;
+       
+       virtual 
+       void ActivateMeshSlot(
+               const KX_MeshSlot & ms, 
+               RAS_IRasterizer* rasty 
+       ) const;
        
        void ActivateMat(
-               RAS_IRasterizer* rasty, 
-               TCachingInfo& cachingInfo)const;
-               
+               RAS_IRasterizer* rasty,
+               TCachingInfo& cachingInfo
+       )const;
+
        void ActivatShaders(
                RAS_IRasterizer* rasty, 
-               TCachingInfo& cachingInfo)const;
-       // --------------------------------
+               TCachingInfo& cachingInfo
+       )const;
+
+       void ActivateBlenderShaders(
+               RAS_IRasterizer* rasty, 
+               TCachingInfo& cachingInfo
+       )const;
 
-       TFace* GetTFace(void) const;
+       MTFace* GetMTFace(void) const;
+       unsigned int* GetMCol(void) const;
 
        // for ipos
        void UpdateIPO(
@@ -72,33 +85,49 @@ public:
        KX_PYMETHOD_DOC( KX_BlenderMaterial, getTexture );
        KX_PYMETHOD_DOC( KX_BlenderMaterial, setTexture );
 
+       KX_PYMETHOD_DOC( KX_BlenderMaterial, setBlending );
+
        // --------------------------------
        // pre calculate to avoid pops/lag at startup
        virtual void OnConstruction( );
 
+       static void     EndFrame();
+
 private:
-       BL_Material*    mMaterial;
-       BL_Shader*              mShader;
+       BL_Material*            mMaterial;
+       BL_Shader*                      mShader;
+       BL_BlenderShader*       mBlenderShader;
        KX_Scene*               mScene;
        BL_Texture              mTextures[MAXTEX];              // texture array
-       
+       bool                    mUserDefBlend;
+       unsigned int    mBlendFunc[2];
+       bool                    mModified;
+       bool                    mConstructed;                   // if false, don't clean on exit
+
+       void SetBlenderGLSLShader();
+
+       void ActivatGLMaterials( RAS_IRasterizer* rasty )const;
+       void ActivateTexGen( RAS_IRasterizer *ras ) const;
+
+       bool UsesLighting(RAS_IRasterizer *rasty) const;
+
        // message centers
-       void    setTexData( bool enable );
-       void    setShaderData( bool enable );
+       void    setTexData( bool enable,RAS_IRasterizer *ras);
+       void    setBlenderShaderData( bool enable, RAS_IRasterizer *ras);
+       void    setShaderData( bool enable, RAS_IRasterizer *ras);
 
-       void    setTextureEnvironment( int textureIndex );
-       void    setEnvMap( bool val, bool cube=false);
+       void    setObjectMatrixData(int i, RAS_IRasterizer *ras);
        void    setTexMatrixData(int i);
-       bool    setDefaultBlending();
-       bool    setBlending( int ind, bool enable=false );
-       void    setObjectMatrixData(int i);
+
+       void    setLightData();
 
        // cleanup stuff
-       void    DisableTexData();
        void    OnExit();
 
-       //void  DisableNonEnabled();
-       // --
+       // shader chacing
+       static BL_BlenderShader *mLastBlenderShader;
+       static BL_Shader                *mLastShader;
+
        mutable int     mPass;
 };