Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00019 * All rights reserved. 00020 * 00021 * The Original Code is: all of this file. 00022 * 00023 * Contributor(s): none yet. 00024 * 00025 * ***** END GPL LICENSE BLOCK ***** 00026 */ 00027 00032 #ifndef __KX_POLYGONMATERIAL_H__ 00033 #define __KX_POLYGONMATERIAL_H__ 00034 00035 #include "PyObjectPlus.h" 00036 00037 #include "RAS_MaterialBucket.h" 00038 #include "RAS_IRasterizer.h" 00039 #include "DNA_ID.h" 00040 00041 #ifdef WITH_CXX_GUARDEDALLOC 00042 #include "MEM_guardedalloc.h" 00043 #endif 00044 00045 struct MTFace; 00046 struct Material; 00047 struct MTex; 00048 struct Image; 00049 00056 class KX_PolygonMaterial : public PyObjectPlus, public RAS_IPolyMaterial 00057 { 00058 Py_Header 00059 private: 00061 MTFace* m_tface; 00062 unsigned int* m_mcol; 00063 Material* m_material; 00064 00065 #ifdef WITH_PYTHON 00066 PyObject* m_pymaterial; 00067 #endif 00068 00069 mutable int m_pass; 00070 public: 00071 00072 KX_PolygonMaterial(); 00073 void Initialize(const STR_String &texname, 00074 Material* ma, 00075 int materialindex, 00076 int tile, 00077 int tilexrep, 00078 int tileyrep, 00079 int alphablend, 00080 bool alpha, 00081 bool zsort, 00082 bool light, 00083 int lightlayer, 00084 struct MTFace* tface, 00085 unsigned int* mcol); 00086 00087 virtual ~KX_PolygonMaterial(); 00088 00094 virtual TCachingInfo GetCachingInfo(void) const 00095 { 00096 return (void*) this; 00097 } 00098 00106 void DefaultActivate(RAS_IRasterizer* rasty, TCachingInfo& cachingInfo) const; 00107 virtual bool Activate(RAS_IRasterizer* rasty, TCachingInfo& cachingInfo) const; 00108 00109 Material *GetBlenderMaterial() const 00110 { 00111 return m_material; 00112 } 00113 00114 Image *GetBlenderImage() const; 00115 00120 MTFace* GetMTFace(void) const 00121 { 00122 return m_tface; 00123 } 00124 00125 unsigned int* GetMCol(void) const 00126 { 00127 return m_mcol; 00128 } 00129 virtual void GetMaterialRGBAColor(unsigned char *rgba) const; 00130 00131 #ifdef WITH_PYTHON 00132 KX_PYMETHOD_DOC(KX_PolygonMaterial, updateTexture); 00133 KX_PYMETHOD_DOC(KX_PolygonMaterial, setTexture); 00134 KX_PYMETHOD_DOC(KX_PolygonMaterial, activate); 00135 00136 KX_PYMETHOD_DOC(KX_PolygonMaterial, setCustomMaterial); 00137 KX_PYMETHOD_DOC(KX_PolygonMaterial, loadProgram); 00138 00139 virtual PyObject* py_repr(void) { return PyUnicode_FromString(m_material ? ((ID *)m_material)->name+2 : ""); } 00140 00141 static PyObject* pyattr_get_texture(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); 00142 static PyObject* pyattr_get_material(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); 00143 00144 static PyObject* pyattr_get_tface(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); 00145 static PyObject* pyattr_get_gl_texture(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); 00146 00147 static PyObject* pyattr_get_diffuse(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); 00148 static int pyattr_set_diffuse(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); 00149 static PyObject* pyattr_get_specular(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); 00150 static int pyattr_set_specular(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); 00151 #endif 00152 00153 }; 00154 00155 #endif // __KX_POLYGONMATERIAL_H__ 00156