2006-01-06 03:46:54 +00:00
|
|
|
#ifndef __KX_BLENDER_MATERIAL_H__
|
|
|
|
#define __KX_BLENDER_MATERIAL_H__
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
|
|
#include "RAS_IPolygonMaterial.h"
|
|
|
|
#include "BL_Material.h"
|
|
|
|
#include "BL_Texture.h"
|
|
|
|
#include "BL_Shader.h"
|
|
|
|
|
|
|
|
#include "PyObjectPlus.h"
|
|
|
|
|
|
|
|
#include "MT_Vector3.h"
|
|
|
|
#include "MT_Vector4.h"
|
|
|
|
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
struct MTFace;
|
2006-01-06 03:46:54 +00:00
|
|
|
class KX_Scene;
|
|
|
|
|
|
|
|
class KX_BlenderMaterial : public PyObjectPlus, public RAS_IPolyMaterial
|
|
|
|
{
|
|
|
|
Py_Header;
|
|
|
|
public:
|
|
|
|
// --------------------------------
|
|
|
|
KX_BlenderMaterial(
|
2006-02-13 05:45:32 +00:00
|
|
|
class KX_Scene* scene,
|
2006-01-06 03:46:54 +00:00
|
|
|
BL_Material* mat,
|
|
|
|
bool skin,
|
|
|
|
int lightlayer,
|
|
|
|
void* clientobject,
|
|
|
|
PyTypeObject* T=&Type
|
|
|
|
);
|
|
|
|
|
|
|
|
virtual ~KX_BlenderMaterial();
|
|
|
|
|
|
|
|
// --------------------------------
|
2006-02-13 05:45:32 +00:00
|
|
|
virtual TCachingInfo GetCachingInfo(void) const {
|
2006-01-06 03:46:54 +00:00
|
|
|
return (void*) this;
|
|
|
|
}
|
|
|
|
|
2006-02-13 05:45:32 +00:00
|
|
|
virtual
|
|
|
|
bool Activate(
|
2006-01-06 03:46:54 +00:00
|
|
|
RAS_IRasterizer* rasty,
|
2006-02-13 05:45:32 +00:00
|
|
|
TCachingInfo& cachingInfo
|
|
|
|
) const;
|
|
|
|
|
|
|
|
virtual
|
|
|
|
void ActivateMeshSlot(
|
|
|
|
const KX_MeshSlot & ms,
|
|
|
|
RAS_IRasterizer* rasty
|
|
|
|
) const;
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
void ActivateMat(
|
2006-02-13 05:45:32 +00:00
|
|
|
RAS_IRasterizer* rasty,
|
|
|
|
TCachingInfo& cachingInfo
|
|
|
|
)const;
|
|
|
|
|
2006-01-06 03:46:54 +00:00
|
|
|
void ActivatShaders(
|
|
|
|
RAS_IRasterizer* rasty,
|
2006-02-13 05:45:32 +00:00
|
|
|
TCachingInfo& cachingInfo
|
|
|
|
)const;
|
|
|
|
|
2006-01-06 03:46:54 +00:00
|
|
|
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
MTFace* GetMTFace(void) const;
|
|
|
|
unsigned int* GetMCol(void) const;
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
// for ipos
|
|
|
|
void UpdateIPO(
|
|
|
|
MT_Vector4 rgba, MT_Vector3 specrgb,
|
|
|
|
MT_Scalar hard, MT_Scalar spec,
|
|
|
|
MT_Scalar ref, MT_Scalar emit, MT_Scalar alpha
|
|
|
|
);
|
|
|
|
|
|
|
|
// --------------------------------
|
|
|
|
virtual PyObject* _getattr(const STR_String& attr);
|
|
|
|
virtual int _setattr(const STR_String& attr, PyObject *pyvalue);
|
|
|
|
|
|
|
|
KX_PYMETHOD_DOC( KX_BlenderMaterial, getShader );
|
|
|
|
KX_PYMETHOD_DOC( KX_BlenderMaterial, getMaterialIndex );
|
|
|
|
KX_PYMETHOD_DOC( KX_BlenderMaterial, getTexture );
|
|
|
|
KX_PYMETHOD_DOC( KX_BlenderMaterial, setTexture );
|
|
|
|
|
2006-01-15 11:34:55 +00:00
|
|
|
KX_PYMETHOD_DOC( KX_BlenderMaterial, setBlending );
|
2006-02-13 05:45:32 +00:00
|
|
|
|
2006-01-06 03:46:54 +00:00
|
|
|
// --------------------------------
|
|
|
|
// pre calculate to avoid pops/lag at startup
|
|
|
|
virtual void OnConstruction( );
|
|
|
|
private:
|
|
|
|
BL_Material* mMaterial;
|
|
|
|
BL_Shader* mShader;
|
|
|
|
KX_Scene* mScene;
|
|
|
|
BL_Texture mTextures[MAXTEX]; // texture array
|
2006-01-15 11:34:55 +00:00
|
|
|
bool mUserDefBlend;
|
|
|
|
unsigned int mBlendFunc[2];
|
2006-01-18 06:04:11 +00:00
|
|
|
bool mModified;
|
2006-01-15 11:34:55 +00:00
|
|
|
|
2006-04-02 21:04:20 +00:00
|
|
|
void ActivatGLMaterials( RAS_IRasterizer* rasty )const;
|
|
|
|
void ActivateTexGen( RAS_IRasterizer *ras ) const;
|
|
|
|
|
2006-02-13 05:45:32 +00:00
|
|
|
|
2006-01-06 03:46:54 +00:00
|
|
|
// message centers
|
2006-02-13 05:45:32 +00:00
|
|
|
void setTexData( bool enable,RAS_IRasterizer *ras);
|
|
|
|
void setShaderData( bool enable, RAS_IRasterizer *ras);
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
bool setDefaultBlending();
|
2006-02-13 05:45:32 +00:00
|
|
|
void setObjectMatrixData(int i, RAS_IRasterizer *ras);
|
|
|
|
void setTexMatrixData(int i);
|
|
|
|
|
|
|
|
void setLightData();
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
// cleanup stuff
|
|
|
|
void OnExit();
|
|
|
|
|
|
|
|
mutable int mPass;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|