2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* $Id$
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
2009-09-29 21:42:40 +00:00
|
|
|
#ifndef DISABLE_PYTHON
|
|
|
|
|
2002-11-25 15:29:57 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2004-07-17 05:28:23 +00:00
|
|
|
#include "KX_VertexProxy.h"
|
|
|
|
#include "KX_MeshProxy.h"
|
|
|
|
#include "RAS_TexVert.h"
|
|
|
|
|
2004-05-30 11:09:46 +00:00
|
|
|
#include "KX_PyMath.h"
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
PyTypeObject KX_VertexProxy::Type = {
|
2009-06-08 20:08:19 +00:00
|
|
|
PyVarObject_HEAD_INIT(NULL, 0)
|
2002-10-12 11:37:38 +00:00
|
|
|
"KX_VertexProxy",
|
2009-04-20 15:06:46 +00:00
|
|
|
sizeof(PyObjectPlus_Proxy),
|
2002-10-12 11:37:38 +00:00
|
|
|
0,
|
2009-04-20 15:06:46 +00:00
|
|
|
py_base_dealloc,
|
2002-10-12 11:37:38 +00:00
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
2009-04-20 15:06:46 +00:00
|
|
|
py_base_repr,
|
2009-06-29 12:06:46 +00:00
|
|
|
0,0,0,0,0,0,0,0,0,
|
2009-06-28 11:22:26 +00:00
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
|
|
|
|
0,0,0,0,0,0,0,
|
|
|
|
Methods,
|
|
|
|
0,
|
|
|
|
0,
|
2009-06-29 12:06:46 +00:00
|
|
|
&CValue::Type,
|
|
|
|
0,0,0,0,0,0,
|
|
|
|
py_base_new
|
2002-10-12 11:37:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
PyMethodDef KX_VertexProxy::Methods[] = {
|
2009-02-23 06:41:10 +00:00
|
|
|
{"getXYZ", (PyCFunction)KX_VertexProxy::sPyGetXYZ,METH_NOARGS},
|
|
|
|
{"setXYZ", (PyCFunction)KX_VertexProxy::sPySetXYZ,METH_O},
|
|
|
|
{"getUV", (PyCFunction)KX_VertexProxy::sPyGetUV,METH_NOARGS},
|
|
|
|
{"setUV", (PyCFunction)KX_VertexProxy::sPySetUV,METH_O},
|
2006-01-06 03:46:54 +00:00
|
|
|
|
2009-02-23 06:41:10 +00:00
|
|
|
{"getUV2", (PyCFunction)KX_VertexProxy::sPyGetUV2,METH_NOARGS},
|
2006-01-06 03:46:54 +00:00
|
|
|
{"setUV2", (PyCFunction)KX_VertexProxy::sPySetUV2,METH_VARARGS},
|
|
|
|
|
2009-02-23 06:41:10 +00:00
|
|
|
{"getRGBA", (PyCFunction)KX_VertexProxy::sPyGetRGBA,METH_NOARGS},
|
|
|
|
{"setRGBA", (PyCFunction)KX_VertexProxy::sPySetRGBA,METH_O},
|
|
|
|
{"getNormal", (PyCFunction)KX_VertexProxy::sPyGetNormal,METH_NOARGS},
|
|
|
|
{"setNormal", (PyCFunction)KX_VertexProxy::sPySetNormal,METH_O},
|
2002-10-12 11:37:38 +00:00
|
|
|
{NULL,NULL} //Sentinel
|
|
|
|
};
|
|
|
|
|
2009-02-26 09:04:06 +00:00
|
|
|
PyAttributeDef KX_VertexProxy::Attributes[] = {
|
2009-06-08 20:08:19 +00:00
|
|
|
//KX_PYATTRIBUTE_TODO("DummyProps"),
|
2009-06-28 11:22:26 +00:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
KX_PYATTRIBUTE_DUMMY("x"),
|
|
|
|
KX_PYATTRIBUTE_DUMMY("y"),
|
|
|
|
KX_PYATTRIBUTE_DUMMY("z"),
|
2009-06-28 11:22:26 +00:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
KX_PYATTRIBUTE_DUMMY("r"),
|
|
|
|
KX_PYATTRIBUTE_DUMMY("g"),
|
|
|
|
KX_PYATTRIBUTE_DUMMY("b"),
|
|
|
|
KX_PYATTRIBUTE_DUMMY("a"),
|
2009-06-28 11:22:26 +00:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
KX_PYATTRIBUTE_DUMMY("u"),
|
|
|
|
KX_PYATTRIBUTE_DUMMY("v"),
|
2009-06-28 11:22:26 +00:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
KX_PYATTRIBUTE_DUMMY("u2"),
|
|
|
|
KX_PYATTRIBUTE_DUMMY("v2"),
|
2009-06-28 11:22:26 +00:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
KX_PYATTRIBUTE_DUMMY("XYZ"),
|
|
|
|
KX_PYATTRIBUTE_DUMMY("UV"),
|
2009-06-28 11:22:26 +00:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
KX_PYATTRIBUTE_DUMMY("color"),
|
|
|
|
KX_PYATTRIBUTE_DUMMY("colour"),
|
2009-06-28 11:22:26 +00:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
KX_PYATTRIBUTE_DUMMY("normal"),
|
2009-06-28 11:22:26 +00:00
|
|
|
|
2009-02-26 09:04:06 +00:00
|
|
|
{ NULL } //Sentinel
|
|
|
|
};
|
|
|
|
|
2009-06-28 11:22:26 +00:00
|
|
|
#if 0
|
2002-10-12 11:37:38 +00:00
|
|
|
PyObject*
|
2009-04-20 15:06:46 +00:00
|
|
|
KX_VertexProxy::py_getattro(PyObject *attr)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2009-06-29 02:25:54 +00:00
|
|
|
char *attr_str= _PyUnicode_AsString(attr);
|
2009-04-20 15:06:46 +00:00
|
|
|
if (attr_str[1]=='\0') { // Group single letters
|
2009-02-19 13:42:07 +00:00
|
|
|
// pos
|
2009-04-20 15:06:46 +00:00
|
|
|
if (attr_str[0]=='x')
|
2009-02-19 13:42:07 +00:00
|
|
|
return PyFloat_FromDouble(m_vertex->getXYZ()[0]);
|
2009-04-20 15:06:46 +00:00
|
|
|
if (attr_str[0]=='y')
|
2009-02-19 13:42:07 +00:00
|
|
|
return PyFloat_FromDouble(m_vertex->getXYZ()[1]);
|
2009-04-20 15:06:46 +00:00
|
|
|
if (attr_str[0]=='z')
|
2009-02-19 13:42:07 +00:00
|
|
|
return PyFloat_FromDouble(m_vertex->getXYZ()[2]);
|
|
|
|
|
|
|
|
// Col
|
2009-04-20 15:06:46 +00:00
|
|
|
if (attr_str[0]=='r')
|
2009-02-19 13:42:07 +00:00
|
|
|
return PyFloat_FromDouble(m_vertex->getRGBA()[0]/255.0);
|
2009-04-20 15:06:46 +00:00
|
|
|
if (attr_str[0]=='g')
|
2009-02-19 13:42:07 +00:00
|
|
|
return PyFloat_FromDouble(m_vertex->getRGBA()[1]/255.0);
|
2009-04-20 15:06:46 +00:00
|
|
|
if (attr_str[0]=='b')
|
2009-02-19 13:42:07 +00:00
|
|
|
return PyFloat_FromDouble(m_vertex->getRGBA()[2]/255.0);
|
2009-04-20 15:06:46 +00:00
|
|
|
if (attr_str[0]=='a')
|
2009-02-19 13:42:07 +00:00
|
|
|
return PyFloat_FromDouble(m_vertex->getRGBA()[3]/255.0);
|
|
|
|
|
|
|
|
// UV
|
2009-04-20 15:06:46 +00:00
|
|
|
if (attr_str[0]=='u')
|
2009-02-19 13:42:07 +00:00
|
|
|
return PyFloat_FromDouble(m_vertex->getUV1()[0]);
|
2009-04-20 15:06:46 +00:00
|
|
|
if (attr_str[0]=='v')
|
2009-02-19 13:42:07 +00:00
|
|
|
return PyFloat_FromDouble(m_vertex->getUV1()[1]);
|
|
|
|
}
|
2009-06-28 11:22:26 +00:00
|
|
|
|
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
if (!strcmp(attr_str, "XYZ"))
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
return PyObjectFrom(MT_Vector3(m_vertex->getXYZ()));
|
2004-05-30 11:09:46 +00:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
if (!strcmp(attr_str, "UV"))
|
2004-07-17 05:28:23 +00:00
|
|
|
return PyObjectFrom(MT_Point2(m_vertex->getUV1()));
|
2004-05-30 11:09:46 +00:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
if (!strcmp(attr_str, "color") || !strcmp(attr_str, "colour"))
|
2004-05-30 11:09:46 +00:00
|
|
|
{
|
2004-07-17 05:28:23 +00:00
|
|
|
const unsigned char *colp = m_vertex->getRGBA();
|
2007-04-04 13:18:41 +00:00
|
|
|
MT_Vector4 color(colp[0], colp[1], colp[2], colp[3]);
|
|
|
|
color /= 255.0;
|
|
|
|
return PyObjectFrom(color);
|
2004-05-30 11:09:46 +00:00
|
|
|
}
|
2009-06-28 11:22:26 +00:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
if (!strcmp(attr_str, "normal"))
|
2004-05-30 11:09:46 +00:00
|
|
|
{
|
2004-07-17 05:28:23 +00:00
|
|
|
return PyObjectFrom(MT_Vector3(m_vertex->getNormal()));
|
2004-05-30 11:09:46 +00:00
|
|
|
}
|
2009-06-28 11:22:26 +00:00
|
|
|
|
2009-06-08 20:08:19 +00:00
|
|
|
py_getattro_up(CValue);
|
|
|
|
}
|
2009-06-28 11:22:26 +00:00
|
|
|
#endif
|
2009-06-08 20:08:19 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-06-28 11:22:26 +00:00
|
|
|
#if 0
|
2009-04-20 15:06:46 +00:00
|
|
|
int KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue)
|
2004-05-30 11:09:46 +00:00
|
|
|
{
|
2009-06-29 02:25:54 +00:00
|
|
|
char *attr_str= _PyUnicode_AsString(attr);
|
2004-05-30 11:09:46 +00:00
|
|
|
if (PySequence_Check(pyvalue))
|
|
|
|
{
|
2009-04-20 15:06:46 +00:00
|
|
|
if (!strcmp(attr_str, "XYZ"))
|
2004-05-30 11:09:46 +00:00
|
|
|
{
|
2004-07-17 05:28:23 +00:00
|
|
|
MT_Point3 vec;
|
|
|
|
if (PyVecTo(pyvalue, vec))
|
|
|
|
{
|
|
|
|
m_vertex->SetXYZ(vec);
|
2006-04-02 21:04:20 +00:00
|
|
|
m_mesh->SetMeshModified(true);
|
2009-04-20 15:06:46 +00:00
|
|
|
return PY_SET_ATTR_SUCCESS;
|
2004-07-17 05:28:23 +00:00
|
|
|
}
|
2009-04-20 15:06:46 +00:00
|
|
|
return PY_SET_ATTR_FAIL;
|
2004-05-30 11:09:46 +00:00
|
|
|
}
|
2009-06-28 11:22:26 +00:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
if (!strcmp(attr_str, "UV"))
|
2004-05-30 11:09:46 +00:00
|
|
|
{
|
2004-07-17 05:28:23 +00:00
|
|
|
MT_Point2 vec;
|
|
|
|
if (PyVecTo(pyvalue, vec))
|
|
|
|
{
|
|
|
|
m_vertex->SetUV(vec);
|
2006-04-02 21:04:20 +00:00
|
|
|
m_mesh->SetMeshModified(true);
|
2009-04-20 15:06:46 +00:00
|
|
|
return PY_SET_ATTR_SUCCESS;
|
2004-07-17 05:28:23 +00:00
|
|
|
}
|
2009-04-20 15:06:46 +00:00
|
|
|
return PY_SET_ATTR_FAIL;
|
2004-05-30 11:09:46 +00:00
|
|
|
}
|
2009-06-28 11:22:26 +00:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
if (!strcmp(attr_str, "color") || !strcmp(attr_str, "colour"))
|
2004-05-30 11:09:46 +00:00
|
|
|
{
|
2004-07-17 05:28:23 +00:00
|
|
|
MT_Vector4 vec;
|
|
|
|
if (PyVecTo(pyvalue, vec))
|
|
|
|
{
|
|
|
|
m_vertex->SetRGBA(vec);
|
2006-04-02 21:04:20 +00:00
|
|
|
m_mesh->SetMeshModified(true);
|
2009-04-20 15:06:46 +00:00
|
|
|
return PY_SET_ATTR_SUCCESS;
|
2004-07-17 05:28:23 +00:00
|
|
|
}
|
2009-04-20 15:06:46 +00:00
|
|
|
return PY_SET_ATTR_FAIL;
|
2004-05-30 11:09:46 +00:00
|
|
|
}
|
2009-06-28 11:22:26 +00:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
if (!strcmp(attr_str, "normal"))
|
2004-05-30 11:09:46 +00:00
|
|
|
{
|
2004-07-17 05:28:23 +00:00
|
|
|
MT_Vector3 vec;
|
|
|
|
if (PyVecTo(pyvalue, vec))
|
|
|
|
{
|
|
|
|
m_vertex->SetNormal(vec);
|
2006-04-02 21:04:20 +00:00
|
|
|
m_mesh->SetMeshModified(true);
|
2009-04-20 15:06:46 +00:00
|
|
|
return PY_SET_ATTR_SUCCESS;
|
2004-07-17 05:28:23 +00:00
|
|
|
}
|
2009-04-20 15:06:46 +00:00
|
|
|
return PY_SET_ATTR_FAIL;
|
2004-05-30 11:09:46 +00:00
|
|
|
}
|
|
|
|
}
|
2009-06-28 11:22:26 +00:00
|
|
|
|
2004-05-30 11:09:46 +00:00
|
|
|
if (PyFloat_Check(pyvalue))
|
|
|
|
{
|
|
|
|
float val = PyFloat_AsDouble(pyvalue);
|
|
|
|
// pos
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
MT_Point3 pos(m_vertex->getXYZ());
|
2009-04-20 15:06:46 +00:00
|
|
|
if (!strcmp(attr_str, "x"))
|
2004-05-30 11:09:46 +00:00
|
|
|
{
|
|
|
|
pos.x() = val;
|
|
|
|
m_vertex->SetXYZ(pos);
|
2006-04-02 21:04:20 +00:00
|
|
|
m_mesh->SetMeshModified(true);
|
2009-04-20 15:06:46 +00:00
|
|
|
return PY_SET_ATTR_SUCCESS;
|
2004-05-30 11:09:46 +00:00
|
|
|
}
|
2009-06-28 11:22:26 +00:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
if (!strcmp(attr_str, "y"))
|
2004-05-30 11:09:46 +00:00
|
|
|
{
|
|
|
|
pos.y() = val;
|
|
|
|
m_vertex->SetXYZ(pos);
|
2006-04-02 21:04:20 +00:00
|
|
|
m_mesh->SetMeshModified(true);
|
2009-04-20 15:06:46 +00:00
|
|
|
return PY_SET_ATTR_SUCCESS;
|
2004-05-30 11:09:46 +00:00
|
|
|
}
|
2009-06-28 11:22:26 +00:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
if (!strcmp(attr_str, "z"))
|
2004-05-30 11:09:46 +00:00
|
|
|
{
|
|
|
|
pos.z() = val;
|
|
|
|
m_vertex->SetXYZ(pos);
|
2006-04-02 21:04:20 +00:00
|
|
|
m_mesh->SetMeshModified(true);
|
2009-04-20 15:06:46 +00:00
|
|
|
return PY_SET_ATTR_SUCCESS;
|
2004-05-30 11:09:46 +00:00
|
|
|
}
|
2009-06-28 11:22:26 +00:00
|
|
|
|
2004-05-30 11:09:46 +00:00
|
|
|
// uv
|
|
|
|
MT_Point2 uv = m_vertex->getUV1();
|
2009-04-20 15:06:46 +00:00
|
|
|
if (!strcmp(attr_str, "u"))
|
2004-05-30 11:09:46 +00:00
|
|
|
{
|
|
|
|
uv[0] = val;
|
|
|
|
m_vertex->SetUV(uv);
|
2006-04-02 21:04:20 +00:00
|
|
|
m_mesh->SetMeshModified(true);
|
2009-04-20 15:06:46 +00:00
|
|
|
return PY_SET_ATTR_SUCCESS;
|
2004-05-30 11:09:46 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
if (!strcmp(attr_str, "v"))
|
2004-05-30 11:09:46 +00:00
|
|
|
{
|
|
|
|
uv[1] = val;
|
|
|
|
m_vertex->SetUV(uv);
|
2006-04-02 21:04:20 +00:00
|
|
|
m_mesh->SetMeshModified(true);
|
2009-04-20 15:06:46 +00:00
|
|
|
return PY_SET_ATTR_SUCCESS;
|
2004-05-30 11:09:46 +00:00
|
|
|
}
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
// uv
|
|
|
|
MT_Point2 uv2 = m_vertex->getUV2();
|
2009-04-20 15:06:46 +00:00
|
|
|
if (!strcmp(attr_str, "u2"))
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
|
|
|
uv[0] = val;
|
|
|
|
m_vertex->SetUV2(uv);
|
2006-04-02 21:04:20 +00:00
|
|
|
m_mesh->SetMeshModified(true);
|
2006-01-06 03:46:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
if (!strcmp(attr_str, "v2"))
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
|
|
|
uv[1] = val;
|
|
|
|
m_vertex->SetUV2(uv);
|
2006-04-02 21:04:20 +00:00
|
|
|
m_mesh->SetMeshModified(true);
|
2009-04-20 15:06:46 +00:00
|
|
|
return PY_SET_ATTR_SUCCESS;
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
2009-06-28 11:22:26 +00:00
|
|
|
|
2004-05-30 11:09:46 +00:00
|
|
|
// col
|
2004-07-17 05:28:23 +00:00
|
|
|
unsigned int icol = *((const unsigned int *)m_vertex->getRGBA());
|
2004-05-30 11:09:46 +00:00
|
|
|
unsigned char *cp = (unsigned char*) &icol;
|
|
|
|
val *= 255.0;
|
2009-04-20 15:06:46 +00:00
|
|
|
if (!strcmp(attr_str, "r"))
|
2004-05-30 11:09:46 +00:00
|
|
|
{
|
|
|
|
cp[0] = (unsigned char) val;
|
|
|
|
m_vertex->SetRGBA(icol);
|
2006-04-02 21:04:20 +00:00
|
|
|
m_mesh->SetMeshModified(true);
|
2009-04-20 15:06:46 +00:00
|
|
|
return PY_SET_ATTR_SUCCESS;
|
2004-05-30 11:09:46 +00:00
|
|
|
}
|
2009-04-20 15:06:46 +00:00
|
|
|
if (!strcmp(attr_str, "g"))
|
2004-05-30 11:09:46 +00:00
|
|
|
{
|
|
|
|
cp[1] = (unsigned char) val;
|
|
|
|
m_vertex->SetRGBA(icol);
|
2006-04-02 21:04:20 +00:00
|
|
|
m_mesh->SetMeshModified(true);
|
2009-04-20 15:06:46 +00:00
|
|
|
return PY_SET_ATTR_SUCCESS;
|
2004-05-30 11:09:46 +00:00
|
|
|
}
|
2009-04-20 15:06:46 +00:00
|
|
|
if (!strcmp(attr_str, "b"))
|
2004-05-30 11:09:46 +00:00
|
|
|
{
|
|
|
|
cp[2] = (unsigned char) val;
|
|
|
|
m_vertex->SetRGBA(icol);
|
2006-04-02 21:04:20 +00:00
|
|
|
m_mesh->SetMeshModified(true);
|
2009-04-20 15:06:46 +00:00
|
|
|
return PY_SET_ATTR_SUCCESS;
|
2004-05-30 11:09:46 +00:00
|
|
|
}
|
2009-04-20 15:06:46 +00:00
|
|
|
if (!strcmp(attr_str, "a"))
|
2004-05-30 11:09:46 +00:00
|
|
|
{
|
|
|
|
cp[3] = (unsigned char) val;
|
|
|
|
m_vertex->SetRGBA(icol);
|
2006-04-02 21:04:20 +00:00
|
|
|
m_mesh->SetMeshModified(true);
|
2009-04-20 15:06:46 +00:00
|
|
|
return PY_SET_ATTR_SUCCESS;
|
2004-05-30 11:09:46 +00:00
|
|
|
}
|
|
|
|
}
|
2009-06-28 11:22:26 +00:00
|
|
|
|
2009-06-08 20:08:19 +00:00
|
|
|
return CValue::py_setattro(attr, pyvalue);
|
2004-05-30 11:09:46 +00:00
|
|
|
}
|
2009-06-28 11:22:26 +00:00
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-04-02 21:04:20 +00:00
|
|
|
KX_VertexProxy::KX_VertexProxy(KX_MeshProxy*mesh, RAS_TexVert* vertex)
|
|
|
|
: m_vertex(vertex),
|
|
|
|
m_mesh(mesh)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
KX_VertexProxy::~KX_VertexProxy()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// stuff for cvalue related things
|
2004-07-17 05:28:23 +00:00
|
|
|
CValue* KX_VertexProxy::Calc(VALUE_OPERATOR, CValue *) { return NULL;}
|
2009-06-28 11:22:26 +00:00
|
|
|
CValue* KX_VertexProxy::CalcFinal(VALUE_DATA_TYPE, VALUE_OPERATOR, CValue *) { return NULL;}
|
2002-10-12 11:37:38 +00:00
|
|
|
STR_String sVertexName="vertex";
|
|
|
|
const STR_String & KX_VertexProxy::GetText() {return sVertexName;};
|
2009-04-20 15:06:46 +00:00
|
|
|
double KX_VertexProxy::GetNumber() { return -1;}
|
2009-06-08 20:08:19 +00:00
|
|
|
STR_String& KX_VertexProxy::GetName() { return sVertexName;}
|
|
|
|
void KX_VertexProxy::SetName(const char *) { };
|
2002-10-12 11:37:38 +00:00
|
|
|
CValue* KX_VertexProxy::GetReplica() { return NULL;}
|
|
|
|
|
|
|
|
// stuff for python integration
|
2009-06-28 11:22:26 +00:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
PyObject* KX_VertexProxy::PyGetXYZ()
|
2004-07-17 05:28:23 +00:00
|
|
|
{
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
return PyObjectFrom(MT_Point3(m_vertex->getXYZ()));
|
2004-07-17 05:28:23 +00:00
|
|
|
}
|
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
PyObject* KX_VertexProxy::PySetXYZ(PyObject* value)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2004-07-17 05:28:23 +00:00
|
|
|
MT_Point3 vec;
|
2009-02-23 06:41:10 +00:00
|
|
|
if (!PyVecTo(value, vec))
|
|
|
|
return NULL;
|
2009-06-28 11:22:26 +00:00
|
|
|
|
2009-02-23 06:41:10 +00:00
|
|
|
m_vertex->SetXYZ(vec);
|
|
|
|
m_mesh->SetMeshModified(true);
|
|
|
|
Py_RETURN_NONE;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
PyObject* KX_VertexProxy::PyGetNormal()
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2004-07-17 05:28:23 +00:00
|
|
|
return PyObjectFrom(MT_Vector3(m_vertex->getNormal()));
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
PyObject* KX_VertexProxy::PySetNormal(PyObject* value)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2004-07-17 05:28:23 +00:00
|
|
|
MT_Vector3 vec;
|
2009-02-23 06:41:10 +00:00
|
|
|
if (!PyVecTo(value, vec))
|
|
|
|
return NULL;
|
2009-06-28 11:22:26 +00:00
|
|
|
|
2009-02-23 06:41:10 +00:00
|
|
|
m_vertex->SetNormal(vec);
|
|
|
|
m_mesh->SetMeshModified(true);
|
|
|
|
Py_RETURN_NONE;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
PyObject* KX_VertexProxy::PyGetRGBA()
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2004-07-17 05:28:23 +00:00
|
|
|
int *rgba = (int *) m_vertex->getRGBA();
|
2009-06-29 02:25:54 +00:00
|
|
|
return PyLong_FromSsize_t(*rgba);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
PyObject* KX_VertexProxy::PySetRGBA(PyObject* value)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2009-06-29 02:25:54 +00:00
|
|
|
if PyLong_Check(value) {
|
|
|
|
int rgba = PyLong_AsSsize_t(value);
|
2002-10-12 11:37:38 +00:00
|
|
|
m_vertex->SetRGBA(rgba);
|
2006-04-02 21:04:20 +00:00
|
|
|
m_mesh->SetMeshModified(true);
|
2009-02-21 12:43:24 +00:00
|
|
|
Py_RETURN_NONE;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2009-06-28 11:22:26 +00:00
|
|
|
else {
|
2009-02-23 06:41:10 +00:00
|
|
|
MT_Vector4 vec;
|
|
|
|
if (PyVecTo(value, vec))
|
|
|
|
{
|
|
|
|
m_vertex->SetRGBA(vec);
|
|
|
|
m_mesh->SetMeshModified(true);
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
}
|
|
|
|
}
|
2009-06-28 11:22:26 +00:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
PyErr_SetString(PyExc_TypeError, "vert.setRGBA(value): KX_VertexProxy, expected a 4D vector or an int");
|
2005-01-16 06:02:06 +00:00
|
|
|
return NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
PyObject* KX_VertexProxy::PyGetUV()
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2004-07-17 05:28:23 +00:00
|
|
|
return PyObjectFrom(MT_Vector2(m_vertex->getUV1()));
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
PyObject* KX_VertexProxy::PySetUV(PyObject* value)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2004-07-17 05:28:23 +00:00
|
|
|
MT_Point2 vec;
|
2009-02-23 06:41:10 +00:00
|
|
|
if (!PyVecTo(value, vec))
|
|
|
|
return NULL;
|
2009-06-28 11:22:26 +00:00
|
|
|
|
2009-02-23 06:41:10 +00:00
|
|
|
m_vertex->SetUV(vec);
|
|
|
|
m_mesh->SetMeshModified(true);
|
|
|
|
Py_RETURN_NONE;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
PyObject* KX_VertexProxy::PyGetUV2()
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
|
|
|
return PyObjectFrom(MT_Vector2(m_vertex->getUV2()));
|
|
|
|
}
|
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
PyObject* KX_VertexProxy::PySetUV2(PyObject* args)
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
|
|
|
MT_Point2 vec;
|
2009-06-08 20:08:19 +00:00
|
|
|
unsigned int unit= RAS_TexVert::SECOND_UV;
|
2009-06-28 11:22:26 +00:00
|
|
|
|
2009-02-23 06:41:10 +00:00
|
|
|
PyObject* list= NULL;
|
2009-06-08 20:08:19 +00:00
|
|
|
if(!PyArg_ParseTuple(args, "O|i:setUV2", &list, &unit))
|
2009-02-23 06:41:10 +00:00
|
|
|
return NULL;
|
2009-06-28 11:22:26 +00:00
|
|
|
|
2009-02-23 06:41:10 +00:00
|
|
|
if (!PyVecTo(list, vec))
|
|
|
|
return NULL;
|
2009-06-28 11:22:26 +00:00
|
|
|
|
2009-02-23 06:41:10 +00:00
|
|
|
m_vertex->SetFlag((m_vertex->getFlag()|RAS_TexVert::SECOND_UV));
|
|
|
|
m_vertex->SetUnit(unit);
|
|
|
|
m_vertex->SetUV2(vec);
|
|
|
|
m_mesh->SetMeshModified(true);
|
|
|
|
Py_RETURN_NONE;
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
2009-09-29 21:42:40 +00:00
|
|
|
|
|
|
|
#endif // DISABLE_PYTHON
|