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