Blender  V2.59
KX_VertexProxy.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: KX_VertexProxy.cpp 35171 2011-02-25 13:35:59Z jesterking $
00003  * ***** BEGIN GPL LICENSE BLOCK *****
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software Foundation,
00017  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018  *
00019  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00020  * All rights reserved.
00021  *
00022  * The Original Code is: all of this file.
00023  *
00024  * Contributor(s): none yet.
00025  *
00026  * ***** END GPL LICENSE BLOCK *****
00027  */
00028 
00034 #ifdef WITH_PYTHON
00035 
00036 #include "KX_VertexProxy.h"
00037 #include "KX_MeshProxy.h"
00038 #include "RAS_TexVert.h"
00039 
00040 #include "KX_PyMath.h"
00041 
00042 PyTypeObject KX_VertexProxy::Type = {
00043         PyVarObject_HEAD_INIT(NULL, 0)
00044         "KX_VertexProxy",
00045         sizeof(PyObjectPlus_Proxy),
00046         0,
00047         py_base_dealloc,
00048         0,
00049         0,
00050         0,
00051         0,
00052         py_base_repr,
00053         0,0,0,0,0,0,0,0,0,
00054         Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
00055         0,0,0,0,0,0,0,
00056         Methods,
00057         0,
00058         0,
00059         &CValue::Type,
00060         0,0,0,0,0,0,
00061         py_base_new
00062 };
00063 
00064 PyMethodDef KX_VertexProxy::Methods[] = {
00065 {"getXYZ", (PyCFunction)KX_VertexProxy::sPyGetXYZ,METH_NOARGS},
00066 {"setXYZ", (PyCFunction)KX_VertexProxy::sPySetXYZ,METH_O},
00067 {"getUV", (PyCFunction)KX_VertexProxy::sPyGetUV,METH_NOARGS},
00068 {"setUV", (PyCFunction)KX_VertexProxy::sPySetUV,METH_O},
00069 
00070 {"getUV2", (PyCFunction)KX_VertexProxy::sPyGetUV2,METH_NOARGS},
00071 {"setUV2", (PyCFunction)KX_VertexProxy::sPySetUV2,METH_VARARGS},
00072 
00073 {"getRGBA", (PyCFunction)KX_VertexProxy::sPyGetRGBA,METH_NOARGS},
00074 {"setRGBA", (PyCFunction)KX_VertexProxy::sPySetRGBA,METH_O},
00075 {"getNormal", (PyCFunction)KX_VertexProxy::sPyGetNormal,METH_NOARGS},
00076 {"setNormal", (PyCFunction)KX_VertexProxy::sPySetNormal,METH_O},
00077   {NULL,NULL} //Sentinel
00078 };
00079 
00080 PyAttributeDef KX_VertexProxy::Attributes[] = {
00081         KX_PYATTRIBUTE_RW_FUNCTION("x", KX_VertexProxy, pyattr_get_x, pyattr_set_x),
00082         KX_PYATTRIBUTE_RW_FUNCTION("y", KX_VertexProxy, pyattr_get_y, pyattr_set_y),
00083         KX_PYATTRIBUTE_RW_FUNCTION("z", KX_VertexProxy, pyattr_get_z, pyattr_set_z),
00084 
00085         KX_PYATTRIBUTE_RW_FUNCTION("r", KX_VertexProxy, pyattr_get_r, pyattr_set_r),
00086         KX_PYATTRIBUTE_RW_FUNCTION("g", KX_VertexProxy, pyattr_get_g, pyattr_set_g),
00087         KX_PYATTRIBUTE_RW_FUNCTION("b", KX_VertexProxy, pyattr_get_b, pyattr_set_b),
00088         KX_PYATTRIBUTE_RW_FUNCTION("a", KX_VertexProxy, pyattr_get_a, pyattr_set_a),
00089 
00090         KX_PYATTRIBUTE_RW_FUNCTION("u", KX_VertexProxy, pyattr_get_u, pyattr_set_u),
00091         KX_PYATTRIBUTE_RW_FUNCTION("v", KX_VertexProxy, pyattr_get_v, pyattr_set_v),
00092 
00093         KX_PYATTRIBUTE_RW_FUNCTION("u2", KX_VertexProxy, pyattr_get_u2, pyattr_set_u2),
00094         KX_PYATTRIBUTE_RW_FUNCTION("v2", KX_VertexProxy, pyattr_get_v2, pyattr_set_v2),
00095 
00096         KX_PYATTRIBUTE_RW_FUNCTION("XYZ", KX_VertexProxy, pyattr_get_XYZ, pyattr_set_XYZ),
00097         KX_PYATTRIBUTE_RW_FUNCTION("UV", KX_VertexProxy, pyattr_get_UV, pyattr_set_UV),
00098 
00099         KX_PYATTRIBUTE_RW_FUNCTION("color", KX_VertexProxy, pyattr_get_color, pyattr_set_color),
00100         KX_PYATTRIBUTE_RW_FUNCTION("normal", KX_VertexProxy, pyattr_get_normal, pyattr_set_normal),
00101 
00102         { NULL }        //Sentinel
00103 };
00104 
00105 PyObject* KX_VertexProxy::pyattr_get_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
00106 {
00107         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00108         return PyFloat_FromDouble(self->m_vertex->getXYZ()[0]);
00109 }
00110 
00111 PyObject* KX_VertexProxy::pyattr_get_y(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
00112 {
00113         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00114         return PyFloat_FromDouble(self->m_vertex->getXYZ()[1]);
00115 }
00116 
00117 PyObject* KX_VertexProxy::pyattr_get_z(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
00118 {
00119         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00120         return PyFloat_FromDouble(self->m_vertex->getXYZ()[2]);
00121 }
00122 
00123 PyObject* KX_VertexProxy::pyattr_get_r(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
00124 {
00125         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00126         return PyFloat_FromDouble(self->m_vertex->getRGBA()[0]/255.0);
00127 }
00128 
00129 PyObject* KX_VertexProxy::pyattr_get_g(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
00130 {
00131         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00132         return PyFloat_FromDouble(self->m_vertex->getRGBA()[1]/255.0);
00133 }
00134 
00135 PyObject* KX_VertexProxy::pyattr_get_b(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
00136 {
00137         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00138         return PyFloat_FromDouble(self->m_vertex->getRGBA()[2]/255.0);
00139 }
00140 
00141 PyObject* KX_VertexProxy::pyattr_get_a(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
00142 {
00143         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00144         return PyFloat_FromDouble(self->m_vertex->getRGBA()[3]/255.0);
00145 }
00146 
00147 PyObject* KX_VertexProxy::pyattr_get_u(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
00148 {
00149         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00150         return PyFloat_FromDouble(self->m_vertex->getUV1()[0]);
00151 }
00152 
00153 PyObject* KX_VertexProxy::pyattr_get_v(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
00154 {
00155         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00156         return PyFloat_FromDouble(self->m_vertex->getUV1()[1]);
00157 }
00158 
00159 PyObject* KX_VertexProxy::pyattr_get_u2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
00160 {
00161         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00162         return PyFloat_FromDouble(self->m_vertex->getUV2()[0]);
00163 }
00164 
00165 PyObject* KX_VertexProxy::pyattr_get_v2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
00166 {
00167         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00168         return PyFloat_FromDouble(self->m_vertex->getUV2()[1]);
00169 }
00170 
00171 PyObject* KX_VertexProxy::pyattr_get_XYZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
00172 {
00173         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00174         return PyObjectFrom(MT_Vector3(self->m_vertex->getXYZ()));
00175 }
00176 
00177 PyObject* KX_VertexProxy::pyattr_get_UV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
00178 {
00179         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00180         return PyObjectFrom(MT_Point2(self->m_vertex->getUV1()));
00181 }
00182 
00183 PyObject* KX_VertexProxy::pyattr_get_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
00184 {
00185         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00186         const unsigned char *colp = self->m_vertex->getRGBA();
00187         MT_Vector4 color(colp[0], colp[1], colp[2], colp[3]);
00188         color /= 255.0;
00189         return PyObjectFrom(color);
00190 }
00191 
00192 PyObject* KX_VertexProxy::pyattr_get_normal(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
00193 {
00194         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00195         return PyObjectFrom(MT_Vector3(self->m_vertex->getNormal()));
00196 }
00197 
00198 int KX_VertexProxy::pyattr_set_x(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
00199 {
00200         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00201         if (PyFloat_Check(value))
00202         {
00203                 float val = PyFloat_AsDouble(value);
00204                 MT_Point3 pos(self->m_vertex->getXYZ());
00205                 pos.x() = val;
00206                 self->m_vertex->SetXYZ(pos);
00207                 self->m_mesh->SetMeshModified(true);
00208                 return PY_SET_ATTR_SUCCESS;
00209         }
00210         return PY_SET_ATTR_FAIL;
00211 }
00212 
00213 int KX_VertexProxy::pyattr_set_y(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
00214 {
00215         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00216         if (PyFloat_Check(value))
00217         {
00218                 float val = PyFloat_AsDouble(value);
00219                 MT_Point3 pos(self->m_vertex->getXYZ());
00220                 pos.y() = val;
00221                 self->m_vertex->SetXYZ(pos);
00222                 self->m_mesh->SetMeshModified(true);
00223                 return PY_SET_ATTR_SUCCESS;
00224         }
00225         return PY_SET_ATTR_FAIL;
00226 }
00227 
00228 int KX_VertexProxy::pyattr_set_z(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
00229 {
00230         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00231         if (PyFloat_Check(value))
00232         {
00233                 float val = PyFloat_AsDouble(value);
00234                 MT_Point3 pos(self->m_vertex->getXYZ());
00235                 pos.z() = val;
00236                 self->m_vertex->SetXYZ(pos);
00237                 self->m_mesh->SetMeshModified(true);
00238                 return PY_SET_ATTR_SUCCESS;
00239         }
00240         return PY_SET_ATTR_FAIL;
00241 }
00242 
00243 int KX_VertexProxy::pyattr_set_u(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
00244 {
00245         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00246         if (PyFloat_Check(value))
00247         {
00248                 float val = PyFloat_AsDouble(value);
00249                 MT_Point2 uv = self->m_vertex->getUV1();
00250                 uv[0] = val;
00251                 self->m_vertex->SetUV(uv);
00252                 self->m_mesh->SetMeshModified(true);
00253                 return PY_SET_ATTR_SUCCESS;
00254         }
00255         return PY_SET_ATTR_FAIL;
00256 }
00257 
00258 int KX_VertexProxy::pyattr_set_v(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
00259 {
00260         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00261         if (PyFloat_Check(value))
00262         {
00263                 float val = PyFloat_AsDouble(value);
00264                 MT_Point2 uv = self->m_vertex->getUV1();
00265                 uv[1] = val;
00266                 self->m_vertex->SetUV(uv);
00267                 self->m_mesh->SetMeshModified(true);
00268                 return PY_SET_ATTR_SUCCESS;
00269         }
00270         return PY_SET_ATTR_FAIL;
00271 }
00272 
00273 int KX_VertexProxy::pyattr_set_u2(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
00274 {
00275         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00276         if (PyFloat_Check(value))
00277         {
00278                 float val = PyFloat_AsDouble(value);
00279                 MT_Point2 uv = self->m_vertex->getUV2();
00280                 uv[0] = val;
00281                 self->m_vertex->SetUV2(uv);
00282                 self->m_mesh->SetMeshModified(true);
00283                 return PY_SET_ATTR_SUCCESS;
00284         }
00285         return PY_SET_ATTR_FAIL;
00286 }
00287 
00288 int KX_VertexProxy::pyattr_set_v2(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
00289 {
00290         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00291         if (PyFloat_Check(value))
00292         {
00293                 float val = PyFloat_AsDouble(value);
00294                 MT_Point2 uv = self->m_vertex->getUV2();
00295                 uv[1] = val;
00296                 self->m_vertex->SetUV2(uv);
00297                 self->m_mesh->SetMeshModified(true);
00298                 return PY_SET_ATTR_SUCCESS;
00299         }
00300         return PY_SET_ATTR_FAIL;
00301 }
00302 
00303 int KX_VertexProxy::pyattr_set_r(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
00304 {
00305         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00306         if (PyFloat_Check(value))
00307         {
00308                 float val = PyFloat_AsDouble(value);
00309                 unsigned int icol = *((const unsigned int *)self->m_vertex->getRGBA());
00310                 unsigned char *cp = (unsigned char*) &icol;
00311                 val *= 255.0;
00312                 cp[0] = (unsigned char) val;
00313                 self->m_vertex->SetRGBA(icol);
00314                 self->m_mesh->SetMeshModified(true);
00315                 return PY_SET_ATTR_SUCCESS;
00316         }
00317         return PY_SET_ATTR_FAIL;
00318 }
00319 
00320 int KX_VertexProxy::pyattr_set_g(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
00321 {
00322         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00323         if (PyFloat_Check(value))
00324         {
00325                 float val = PyFloat_AsDouble(value);
00326                 unsigned int icol = *((const unsigned int *)self->m_vertex->getRGBA());
00327                 unsigned char *cp = (unsigned char*) &icol;
00328                 val *= 255.0;
00329                 cp[1] = (unsigned char) val;
00330                 self->m_vertex->SetRGBA(icol);
00331                 self->m_mesh->SetMeshModified(true);
00332                 return PY_SET_ATTR_SUCCESS;
00333         }
00334         return PY_SET_ATTR_FAIL;
00335 }
00336 
00337 int KX_VertexProxy::pyattr_set_b(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
00338 {
00339         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00340         if (PyFloat_Check(value))
00341         {
00342                 float val = PyFloat_AsDouble(value);
00343                 unsigned int icol = *((const unsigned int *)self->m_vertex->getRGBA());
00344                 unsigned char *cp = (unsigned char*) &icol;
00345                 val *= 255.0;
00346                 cp[2] = (unsigned char) val;
00347                 self->m_vertex->SetRGBA(icol);
00348                 self->m_mesh->SetMeshModified(true);
00349                 return PY_SET_ATTR_SUCCESS;
00350         }
00351         return PY_SET_ATTR_FAIL;
00352 }
00353 
00354 int KX_VertexProxy::pyattr_set_a(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
00355 {
00356         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00357         if (PyFloat_Check(value))
00358         {
00359                 float val = PyFloat_AsDouble(value);
00360                 unsigned int icol = *((const unsigned int *)self->m_vertex->getRGBA());
00361                 unsigned char *cp = (unsigned char*) &icol;
00362                 val *= 255.0;
00363                 cp[3] = (unsigned char) val;
00364                 self->m_vertex->SetRGBA(icol);
00365                 self->m_mesh->SetMeshModified(true);
00366                 return PY_SET_ATTR_SUCCESS;
00367         }
00368         return PY_SET_ATTR_FAIL;
00369 }
00370 
00371 int KX_VertexProxy::pyattr_set_XYZ(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
00372 {
00373         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00374         if (PySequence_Check(value))
00375         {
00376                 MT_Point3 vec;
00377                 if (PyVecTo(value, vec))
00378                 {
00379                         self->m_vertex->SetXYZ(vec);
00380                         self->m_mesh->SetMeshModified(true);
00381                         return PY_SET_ATTR_SUCCESS;
00382                 }
00383         }
00384         return PY_SET_ATTR_FAIL;
00385 }
00386 
00387 int KX_VertexProxy::pyattr_set_UV(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
00388 {
00389         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00390         if (PySequence_Check(value))
00391         {
00392                 MT_Point2 vec;
00393                 if (PyVecTo(value, vec))
00394                 {
00395                         self->m_vertex->SetUV(vec);
00396                         self->m_mesh->SetMeshModified(true);
00397                         return PY_SET_ATTR_SUCCESS;
00398                 }
00399         }
00400         return PY_SET_ATTR_FAIL;
00401 }
00402 
00403 int KX_VertexProxy::pyattr_set_color(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
00404 {
00405         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00406         if (PySequence_Check(value))
00407         {
00408                 MT_Vector4 vec;
00409                 if (PyVecTo(value, vec))
00410                 {
00411                         self->m_vertex->SetRGBA(vec);
00412                         self->m_mesh->SetMeshModified(true);
00413                         return PY_SET_ATTR_SUCCESS;
00414                 }
00415         }
00416         return PY_SET_ATTR_FAIL;
00417 }
00418 
00419 int KX_VertexProxy::pyattr_set_normal(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
00420 {
00421         KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
00422         if (PySequence_Check(value))
00423         {
00424                 MT_Vector3 vec;
00425                 if (PyVecTo(value, vec))
00426                 {
00427                         self->m_vertex->SetNormal(vec);
00428                         self->m_mesh->SetMeshModified(true);
00429                         return PY_SET_ATTR_SUCCESS;
00430                 }
00431         }
00432         return PY_SET_ATTR_FAIL;
00433 }
00434 
00435 KX_VertexProxy::KX_VertexProxy(KX_MeshProxy*mesh, RAS_TexVert* vertex)
00436 :       m_vertex(vertex),
00437         m_mesh(mesh)
00438 {
00439 }
00440 
00441 KX_VertexProxy::~KX_VertexProxy()
00442 {
00443 }
00444 
00445 
00446 
00447 // stuff for cvalue related things
00448 CValue*         KX_VertexProxy::Calc(VALUE_OPERATOR, CValue *) { return NULL;}
00449 CValue*         KX_VertexProxy::CalcFinal(VALUE_DATA_TYPE, VALUE_OPERATOR, CValue *) { return NULL;}
00450 STR_String      sVertexName="vertex";
00451 const STR_String &      KX_VertexProxy::GetText() {return sVertexName;};
00452 double          KX_VertexProxy::GetNumber() { return -1;}
00453 STR_String&     KX_VertexProxy::GetName() { return sVertexName;}
00454 void            KX_VertexProxy::SetName(const char *) { };
00455 CValue*         KX_VertexProxy::GetReplica() { return NULL;}
00456 
00457 // stuff for python integration
00458 
00459 PyObject* KX_VertexProxy::PyGetXYZ()
00460 {
00461         return PyObjectFrom(MT_Point3(m_vertex->getXYZ()));
00462 }
00463 
00464 PyObject* KX_VertexProxy::PySetXYZ(PyObject* value)
00465 {
00466         MT_Point3 vec;
00467         if (!PyVecTo(value, vec))
00468                 return NULL;
00469 
00470         m_vertex->SetXYZ(vec);
00471         m_mesh->SetMeshModified(true);
00472         Py_RETURN_NONE;
00473 }
00474 
00475 PyObject* KX_VertexProxy::PyGetNormal()
00476 {
00477         return PyObjectFrom(MT_Vector3(m_vertex->getNormal()));
00478 }
00479 
00480 PyObject* KX_VertexProxy::PySetNormal(PyObject* value)
00481 {
00482         MT_Vector3 vec;
00483         if (!PyVecTo(value, vec))
00484                 return NULL;
00485 
00486         m_vertex->SetNormal(vec);
00487         m_mesh->SetMeshModified(true);
00488         Py_RETURN_NONE;
00489 }
00490 
00491 
00492 PyObject* KX_VertexProxy::PyGetRGBA()
00493 {
00494         int *rgba = (int *) m_vertex->getRGBA();
00495         return PyLong_FromSsize_t(*rgba);
00496 }
00497 
00498 PyObject* KX_VertexProxy::PySetRGBA(PyObject* value)
00499 {
00500         if PyLong_Check(value) {
00501                 int rgba = PyLong_AsSsize_t(value);
00502                 m_vertex->SetRGBA(rgba);
00503                 m_mesh->SetMeshModified(true);
00504                 Py_RETURN_NONE;
00505         }
00506         else {
00507                 MT_Vector4 vec;
00508                 if (PyVecTo(value, vec))
00509                 {
00510                         m_vertex->SetRGBA(vec);
00511                         m_mesh->SetMeshModified(true);
00512                         Py_RETURN_NONE;
00513                 }
00514         }
00515 
00516         PyErr_SetString(PyExc_TypeError, "vert.setRGBA(value): KX_VertexProxy, expected a 4D vector or an int");
00517         return NULL;
00518 }
00519 
00520 
00521 PyObject* KX_VertexProxy::PyGetUV()
00522 {
00523         return PyObjectFrom(MT_Vector2(m_vertex->getUV1()));
00524 }
00525 
00526 PyObject* KX_VertexProxy::PySetUV(PyObject* value)
00527 {
00528         MT_Point2 vec;
00529         if (!PyVecTo(value, vec))
00530                 return NULL;
00531 
00532         m_vertex->SetUV(vec);
00533         m_mesh->SetMeshModified(true);
00534         Py_RETURN_NONE;
00535 }
00536 
00537 PyObject* KX_VertexProxy::PyGetUV2()
00538 {
00539         return PyObjectFrom(MT_Vector2(m_vertex->getUV2()));
00540 }
00541 
00542 PyObject* KX_VertexProxy::PySetUV2(PyObject* args)
00543 {
00544         MT_Point2 vec;
00545         unsigned int unit= RAS_TexVert::SECOND_UV;
00546 
00547         PyObject* list= NULL;
00548         if(!PyArg_ParseTuple(args, "O|i:setUV2", &list, &unit))
00549                 return NULL;
00550 
00551         if (!PyVecTo(list, vec))
00552                 return NULL;
00553 
00554         m_vertex->SetFlag((m_vertex->getFlag()|RAS_TexVert::SECOND_UV));
00555         m_vertex->SetUnit(unit);
00556         m_vertex->SetUV2(vec);
00557         m_mesh->SetMeshModified(true);
00558         Py_RETURN_NONE;
00559 }
00560 
00561 #endif // WITH_PYTHON