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>2012-01-22 22:04:35 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-01-22 22:04:35 +0400
commit4966982a5aa7715e6bd67dcef1babdf8ca3d02e9 (patch)
treecf96f67b83f89336e3fe2f64aa58345dca818430 /source/gameengine
parent0198df7956125180d5b9c50638a0778a3236d88f (diff)
parentdf51fd74cf826c42a90212082abb27e99484257a (diff)
svn merge ^/trunk/blender -r43564:43609
Diffstat (limited to 'source/gameengine')
-rw-r--r--source/gameengine/Converter/KX_ConvertActuators.cpp2
-rw-r--r--source/gameengine/GameLogic/SCA_PythonKeyboard.cpp18
-rw-r--r--source/gameengine/GameLogic/SCA_PythonKeyboard.h1
-rw-r--r--source/gameengine/GameLogic/SCA_PythonMouse.cpp17
-rw-r--r--source/gameengine/GameLogic/SCA_PythonMouse.h1
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp125
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.h6
-rw-r--r--source/gameengine/VideoTexture/blendVideoTex.cpp6
8 files changed, 174 insertions, 2 deletions
diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp
index be14400f33a..e577a5e5f99 100644
--- a/source/gameengine/Converter/KX_ConvertActuators.cpp
+++ b/source/gameengine/Converter/KX_ConvertActuators.cpp
@@ -83,7 +83,7 @@
#include "BLI_blenlib.h"
#include "BLI_math_base.h"
-#define FILE_MAX 240 // repeated here to avoid dependency from BKE_utildefines.h
+#define FILE_MAX 1024 // repeated here to avoid dependency from BKE_utildefines.h
#include "KX_NetworkMessageActuator.h"
diff --git a/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp b/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp
index 9c7f3831567..46c43b5e339 100644
--- a/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp
+++ b/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp
@@ -84,6 +84,7 @@ PyMethodDef SCA_PythonKeyboard::Methods[] = {
PyAttributeDef SCA_PythonKeyboard::Attributes[] = {
KX_PYATTRIBUTE_RO_FUNCTION("events", SCA_PythonKeyboard, pyattr_get_events),
+ KX_PYATTRIBUTE_RO_FUNCTION("active_events", SCA_PythonKeyboard, pyattr_get_active_events),
{ NULL } //Sentinel
};
@@ -101,4 +102,21 @@ PyObject* SCA_PythonKeyboard::pyattr_get_events(void *self_v, const KX_PYATTRIBU
return self->m_event_dict;
}
+PyObject* SCA_PythonKeyboard::pyattr_get_active_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ SCA_PythonKeyboard* self = static_cast<SCA_PythonKeyboard*>(self_v);
+
+ PyDict_Clear(self->m_event_dict);
+
+ for (int i=SCA_IInputDevice::KX_BEGINKEY; i<=SCA_IInputDevice::KX_ENDKEY; i++)
+ {
+ const SCA_InputEvent & inevent = self->m_keyboard->GetEventValue((SCA_IInputDevice::KX_EnumInputs)i);
+
+ if (inevent.m_status != SCA_InputEvent::KX_NO_INPUTSTATUS)
+ PyDict_SetItem(self->m_event_dict, PyLong_FromSsize_t(i), PyLong_FromSsize_t(inevent.m_status));
+ }
+ Py_INCREF(self->m_event_dict);
+ return self->m_event_dict;
+}
+
#endif
diff --git a/source/gameengine/GameLogic/SCA_PythonKeyboard.h b/source/gameengine/GameLogic/SCA_PythonKeyboard.h
index 7ecf76d1581..f44bb40e13c 100644
--- a/source/gameengine/GameLogic/SCA_PythonKeyboard.h
+++ b/source/gameengine/GameLogic/SCA_PythonKeyboard.h
@@ -43,6 +43,7 @@ public:
#ifdef WITH_PYTHON
static PyObject* pyattr_get_events(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static PyObject* pyattr_get_active_events(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
#endif
};
diff --git a/source/gameengine/GameLogic/SCA_PythonMouse.cpp b/source/gameengine/GameLogic/SCA_PythonMouse.cpp
index 4f06445a79f..cdbeaba2235 100644
--- a/source/gameengine/GameLogic/SCA_PythonMouse.cpp
+++ b/source/gameengine/GameLogic/SCA_PythonMouse.cpp
@@ -86,6 +86,7 @@ PyMethodDef SCA_PythonMouse::Methods[] = {
PyAttributeDef SCA_PythonMouse::Attributes[] = {
KX_PYATTRIBUTE_RO_FUNCTION("events", SCA_PythonMouse, pyattr_get_events),
+ KX_PYATTRIBUTE_RO_FUNCTION("active_events", SCA_PythonMouse, pyattr_get_active_events),
KX_PYATTRIBUTE_RW_FUNCTION("position", SCA_PythonMouse, pyattr_get_position, pyattr_set_position),
KX_PYATTRIBUTE_RW_FUNCTION("visible", SCA_PythonMouse, pyattr_get_visible, pyattr_set_visible),
{ NULL } //Sentinel
@@ -105,6 +106,22 @@ PyObject* SCA_PythonMouse::pyattr_get_events(void *self_v, const KX_PYATTRIBUTE_
return self->m_event_dict;
}
+PyObject* SCA_PythonMouse::pyattr_get_active_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ SCA_PythonMouse* self = static_cast<SCA_PythonMouse*>(self_v);
+
+ PyDict_Clear(self->m_event_dict);
+
+ for (int i=SCA_IInputDevice::KX_BEGINMOUSE; i<=SCA_IInputDevice::KX_ENDMOUSE; i++)
+ {
+ const SCA_InputEvent & inevent = self->m_mouse->GetEventValue((SCA_IInputDevice::KX_EnumInputs)i);
+
+ if (inevent.m_status != SCA_InputEvent::KX_NO_INPUTSTATUS)
+ PyDict_SetItem(self->m_event_dict, PyLong_FromSsize_t(i), PyLong_FromSsize_t(inevent.m_status));
+ }
+ Py_INCREF(self->m_event_dict);
+ return self->m_event_dict;
+}
PyObject* SCA_PythonMouse::pyattr_get_position(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
diff --git a/source/gameengine/GameLogic/SCA_PythonMouse.h b/source/gameengine/GameLogic/SCA_PythonMouse.h
index 4ad655dce8f..41d286a8048 100644
--- a/source/gameengine/GameLogic/SCA_PythonMouse.h
+++ b/source/gameengine/GameLogic/SCA_PythonMouse.h
@@ -48,6 +48,7 @@ public:
KX_PYMETHOD_DOC(SCA_PythonMouse, show);
static PyObject* pyattr_get_events(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static PyObject* pyattr_get_active_events(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static PyObject* pyattr_get_position(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_position(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject* value);
static PyObject* pyattr_get_visible(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 18b8c0d533d..023c3dcbfc9 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -1153,6 +1153,36 @@ void KX_GameObject::NodeSetRelativeScale(const MT_Vector3& scale)
}
}
+void KX_GameObject::NodeSetWorldScale(const MT_Vector3& scale)
+{
+ if (!GetSGNode())
+ return;
+ SG_Node* parent = GetSGNode()->GetSGParent();
+ if (parent != NULL)
+ {
+ // Make sure the objects have some scale
+ MT_Vector3 p_scale = parent->GetWorldScaling();
+ if (fabs(p_scale[0]) < FLT_EPSILON ||
+ fabs(p_scale[1]) < FLT_EPSILON ||
+ fabs(p_scale[2]) < FLT_EPSILON)
+ {
+ return;
+ }
+
+ MT_Vector3 *local = new MT_Vector3(scale);
+
+ p_scale[0] = 1/p_scale[0];
+ p_scale[1] = 1/p_scale[1];
+ p_scale[2] = 1/p_scale[2];
+
+ NodeSetLocalScale(scale * p_scale);
+ }
+ else
+ {
+ NodeSetLocalScale(scale);
+ }
+}
+
void KX_GameObject::NodeSetWorldPosition(const MT_Point3& trans)
{
if (!GetSGNode())
@@ -1620,7 +1650,9 @@ PyAttributeDef KX_GameObject::Attributes[] = {
KX_PYATTRIBUTE_RW_FUNCTION("localPosition", KX_GameObject, pyattr_get_localPosition, pyattr_set_localPosition),
KX_PYATTRIBUTE_RW_FUNCTION("worldPosition", KX_GameObject, pyattr_get_worldPosition, pyattr_set_worldPosition),
KX_PYATTRIBUTE_RW_FUNCTION("localScale", KX_GameObject, pyattr_get_localScaling, pyattr_set_localScaling),
- KX_PYATTRIBUTE_RO_FUNCTION("worldScale", KX_GameObject, pyattr_get_worldScaling),
+ KX_PYATTRIBUTE_RW_FUNCTION("worldScale", KX_GameObject, pyattr_get_worldScaling, pyattr_set_worldScaling),
+ KX_PYATTRIBUTE_RW_FUNCTION("localTransform", KX_GameObject, pyattr_get_localTransform, pyattr_set_localTransform),
+ KX_PYATTRIBUTE_RW_FUNCTION("worldTransform", KX_GameObject, pyattr_get_worldTransform, pyattr_set_worldTransform),
KX_PYATTRIBUTE_RW_FUNCTION("linearVelocity", KX_GameObject, pyattr_get_localLinearVelocity, pyattr_set_worldLinearVelocity),
KX_PYATTRIBUTE_RW_FUNCTION("localLinearVelocity", KX_GameObject, pyattr_get_localLinearVelocity, pyattr_set_localLinearVelocity),
KX_PYATTRIBUTE_RW_FUNCTION("worldLinearVelocity", KX_GameObject, pyattr_get_worldLinearVelocity, pyattr_set_worldLinearVelocity),
@@ -2112,6 +2144,18 @@ PyObject* KX_GameObject::pyattr_get_worldScaling(void *self_v, const KX_PYATTRIB
#endif
}
+int KX_GameObject::pyattr_set_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
+{
+ KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
+ MT_Vector3 scale;
+ if (!PyVecTo(value, scale))
+ return PY_SET_ATTR_FAIL;
+
+ self->NodeSetWorldScale(scale);
+ self->NodeUpdateGS(0.f);
+ return PY_SET_ATTR_SUCCESS;
+}
+
PyObject* KX_GameObject::pyattr_get_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
#ifdef USE_MATHUTILS
@@ -2134,6 +2178,85 @@ int KX_GameObject::pyattr_set_localScaling(void *self_v, const KX_PYATTRIBUTE_DE
return PY_SET_ATTR_SUCCESS;
}
+PyObject* KX_GameObject::pyattr_get_localTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
+
+ double *mat = MT_CmMatrix4x4().getPointer();
+
+ MT_Transform trans;
+
+ trans.setOrigin(self->GetSGNode()->GetLocalPosition());
+ trans.setBasis(self->GetSGNode()->GetLocalOrientation());
+
+ MT_Vector3 scaling = self->GetSGNode()->GetLocalScale();
+ trans.scale(scaling[0], scaling[1], scaling[2]);
+
+ trans.getValue(mat);
+
+ return PyObjectFrom(MT_Matrix4x4(mat));
+}
+
+int KX_GameObject::pyattr_set_localTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
+{
+ KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
+ MT_Matrix4x4 temp;
+ if (!PyMatTo(value, temp))
+ return PY_SET_ATTR_FAIL;
+
+ float transform[4][4];
+ float loc[3], size[3];
+ float rot[3][3];
+ MT_Matrix3x3 orientation;
+
+ temp.getValue(*transform);
+ mat4_to_loc_rot_size(loc, rot, size, transform);
+
+ self->NodeSetLocalPosition(MT_Point3(loc));
+
+ //MT_Matrix3x3's constructor expects a 4x4 matrix
+ orientation = MT_Matrix3x3();
+ orientation.setValue3x3(*rot);
+ self->NodeSetLocalOrientation(orientation);
+
+ self->NodeSetLocalScale(MT_Vector3(size));
+
+ return PY_SET_ATTR_SUCCESS;
+}
+
+PyObject* KX_GameObject::pyattr_get_worldTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
+
+ return PyObjectFrom(MT_Matrix4x4(self->GetOpenGLMatrix()));
+}
+
+int KX_GameObject::pyattr_set_worldTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
+{
+ KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
+ MT_Matrix4x4 temp;
+ if (!PyMatTo(value, temp))
+ return PY_SET_ATTR_FAIL;
+
+ float transform[4][4];
+ float loc[3], size[3];
+ float rot[3][3];
+ MT_Matrix3x3 orientation;
+
+ temp.getValue(*transform);
+ mat4_to_loc_rot_size(loc, rot, size, transform);
+
+ self->NodeSetWorldPosition(MT_Point3(loc));
+
+ //MT_Matrix3x3's constructor expects a 4x4 matrix
+ orientation = MT_Matrix3x3();
+ orientation.setValue3x3(*rot);
+ self->NodeSetGlobalOrientation(orientation);
+
+ self->NodeSetWorldScale(MT_Vector3(size));
+
+ return PY_SET_ATTR_SUCCESS;
+}
PyObject* KX_GameObject::pyattr_get_worldLinearVelocity(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 cc078e96e64..a35e6f1b2cd 100644
--- a/source/gameengine/Ketsji/KX_GameObject.h
+++ b/source/gameengine/Ketsji/KX_GameObject.h
@@ -475,6 +475,7 @@ public:
void NodeSetGlobalOrientation(const MT_Matrix3x3& rot );
void NodeSetLocalScale( const MT_Vector3& scale );
+ void NodeSetWorldScale( const MT_Vector3& scale );
void NodeSetRelativeScale( const MT_Vector3& scale );
@@ -968,8 +969,13 @@ public:
static PyObject* pyattr_get_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
static PyObject* pyattr_get_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static int pyattr_set_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
static PyObject* pyattr_get_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
+ static PyObject* pyattr_get_localTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static int pyattr_set_localTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
+ static PyObject* pyattr_get_worldTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static int pyattr_set_worldTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
static PyObject* pyattr_get_worldLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_worldLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
static PyObject* pyattr_get_localLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp
index abfd0ed49b7..8410e9350d0 100644
--- a/source/gameengine/VideoTexture/blendVideoTex.cpp
+++ b/source/gameengine/VideoTexture/blendVideoTex.cpp
@@ -38,6 +38,7 @@ http://www.gnu.org/copyleft/lesser.txt.
//#include "TexPlayerGL.h"
#include "ImageBase.h"
+#include "VideoBase.h"
#include "FilterBase.h"
#include "Texture.h"
@@ -208,6 +209,11 @@ PyObject* initVideoTexture(void)
Py_INCREF(&TextureType);
PyModule_AddObject(m, (char*)"Texture", (PyObject*)&TextureType);
+ PyModule_AddIntConstant(m, (char*)"SOURCE_ERROR", SourceError);
+ PyModule_AddIntConstant(m, (char*)"SOURCE_EMPTY", SourceEmpty);
+ PyModule_AddIntConstant(m, (char*)"SOURCE_READY", SourceReady);
+ PyModule_AddIntConstant(m, (char*)"SOURCE_PLAYING", SourcePlaying);
+ PyModule_AddIntConstant(m, (char*)"SOURCE_STOPPED", SourceStopped);
// init last error description
Exception::m_lastError = "";