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