Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-01-17 02:53:51 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-01-17 02:53:51 +0300
commit68c8054191560d68a9856e60311ed410cd32e5c7 (patch)
tree4bfd7a1f7d021b5b036697952afd9bdb681af775 /source/gameengine
parent9c9209f7e59d1561935ddeb7f5f42181ac965a86 (diff)
patch [#20560] [patch] KX_GameObject.obcolor
by Mitchell Stokes (moguri) * renamed attribute obcolor to color
Diffstat (limited to 'source/gameengine')
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp37
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.h5
2 files changed, 41 insertions, 1 deletions
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 6865f9f04a2..1b9c82b432c 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -811,6 +811,11 @@ void KX_GameObject::SetObjectColor(const MT_Vector4& rgbavec)
m_objectColor = rgbavec;
}
+const MT_Vector4& KX_GameObject::GetObjectColor()
+{
+ return m_objectColor;
+}
+
void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac)
{
MT_Matrix3x3 orimat;
@@ -1238,6 +1243,7 @@ void KX_GameObject::Relink(GEN_Map<GEN_HashedPtr, void*> *map_parameter)
#define MATHUTILS_VEC_CB_SCALE_LOCAL 3
#define MATHUTILS_VEC_CB_SCALE_GLOBAL 4
#define MATHUTILS_VEC_CB_INERTIA_LOCAL 5
+#define MATHUTILS_VEC_CB_OBJECT_COLOR 6
static int mathutils_kxgameob_vector_cb_index= -1; /* index for our callbacks */
@@ -1273,6 +1279,9 @@ static int mathutils_kxgameob_vector_get(PyObject *self_v, int subtype, float *v
if(!self->GetPhysicsController()) return 0;
self->GetPhysicsController()->GetLocalInertia().getValue(vec_from);
break;
+ case MATHUTILS_VEC_CB_OBJECT_COLOR:
+ self->GetObjectColor().getValue(vec_from);
+ break;
}
return 1;
@@ -1302,6 +1311,9 @@ static int mathutils_kxgameob_vector_set(PyObject *self_v, int subtype, float *v
case MATHUTILS_VEC_CB_INERTIA_LOCAL:
/* read only */
break;
+ case MATHUTILS_VEC_CB_OBJECT_COLOR:
+ self->SetObjectColor(MT_Vector4(vec_to));
+ break;
}
return 1;
@@ -1475,6 +1487,7 @@ PyAttributeDef KX_GameObject::Attributes[] = {
KX_PYATTRIBUTE_RO_FUNCTION("children", KX_GameObject, pyattr_get_children),
KX_PYATTRIBUTE_RO_FUNCTION("childrenRecursive", KX_GameObject, pyattr_get_children_recursive),
KX_PYATTRIBUTE_RO_FUNCTION("attrDict", KX_GameObject, pyattr_get_attrDict),
+ KX_PYATTRIBUTE_RW_FUNCTION("obcolor", KX_GameObject, pyattr_get_obcolor, pyattr_set_obcolor),
/* Experemental, dont rely on these yet */
KX_PYATTRIBUTE_RO_FUNCTION("sensors", KX_GameObject, pyattr_get_sensors),
@@ -2033,7 +2046,28 @@ PyObject* KX_GameObject::pyattr_get_meshes(void *self_v, const KX_PYATTRIBUTE_DE
return meshes;
}
-/* experemental! */
+PyObject* KX_GameObject::pyattr_get_obcolor(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+#ifdef USE_MATHUTILS
+ return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 4, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_OBJECT_COLOR);
+#else
+ KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
+ return PyObjectFrom(self->GetObjectColor());
+#endif
+}
+
+int KX_GameObject::pyattr_set_obcolor(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
+{
+ KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
+ MT_Vector4 obcolor;
+ if (!PyVecTo(value, obcolor))
+ return PY_SET_ATTR_FAIL;
+
+ self->SetObjectColor(obcolor);
+ return PY_SET_ATTR_SUCCESS;
+}
+
+/* These are experimental! */
PyObject* KX_GameObject::pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
return KX_PythonSeq_CreatePyObject((static_cast<KX_GameObject*>(self_v))->m_proxy, KX_PYGENSEQ_OB_TYPE_SENSORS);
@@ -2048,6 +2082,7 @@ PyObject* KX_GameObject::pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE
{
return KX_PythonSeq_CreatePyObject((static_cast<KX_GameObject*>(self_v))->m_proxy, KX_PYGENSEQ_OB_TYPE_ACTUATORS);
}
+/* End experimental */
PyObject* KX_GameObject::pyattr_get_children(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h
index 41e04eef91c..596e69f25b3 100644
--- a/source/gameengine/Ketsji/KX_GameObject.h
+++ b/source/gameengine/Ketsji/KX_GameObject.h
@@ -339,6 +339,9 @@ public:
const MT_Vector4& rgbavec
);
+ const MT_Vector4&
+ GetObjectColor();
+
void
ResolveCombinedVelocities(
@@ -882,6 +885,8 @@ public:
static PyObject* pyattr_get_children(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static PyObject* pyattr_get_children_recursive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static PyObject* pyattr_get_attrDict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static PyObject* pyattr_get_obcolor(void *selv_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static int pyattr_set_obcolor(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
/* Experemental! */
static PyObject* pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);