forked from bartvdbraak/blender
Game Engine: Option to record static objects animation
This commit is contained in:
parent
964252cdda
commit
1831c930a5
@ -151,11 +151,17 @@ base class --- :class:`SCA_IObject`
|
||||
visibility flag.
|
||||
|
||||
:type: boolean
|
||||
|
||||
|
||||
.. note::
|
||||
|
||||
|
||||
Game logic will still run for invisible objects.
|
||||
|
||||
.. attribute:: record_animation
|
||||
|
||||
Record animation for this object.
|
||||
|
||||
:type: boolean
|
||||
|
||||
.. attribute:: color
|
||||
|
||||
The object color of the object. [r, g, b, a]
|
||||
|
@ -156,6 +156,7 @@ class PHYSICS_PT_game_physics(PhysicsButtonsPanel, Panel):
|
||||
col = layout.column()
|
||||
col.prop(game, "use_actor")
|
||||
col.prop(game, "use_ghost")
|
||||
col.prop(game, "use_record_animation")
|
||||
col.prop(ob, "hide_render", text="Invisible")
|
||||
|
||||
layout.separator()
|
||||
|
@ -542,6 +542,8 @@ enum {
|
||||
OB_NAVMESH = 1 << 20,
|
||||
OB_HASOBSTACLE = 1 << 21,
|
||||
OB_CHARACTER = 1 << 22,
|
||||
|
||||
OB_RECORD_ANIMATION = 1 << 23,
|
||||
};
|
||||
|
||||
/* ob->gameflag2 */
|
||||
|
@ -1646,6 +1646,10 @@ static void rna_def_object_game_settings(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(prop, "Physics Type", "Select the type of physical representation");
|
||||
RNA_def_property_update(prop, NC_LOGIC, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "use_record_animation", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_RECORD_ANIMATION);
|
||||
RNA_def_property_ui_text(prop, "Record Animation", "Record animation objects without physics");
|
||||
|
||||
prop = RNA_def_property(srna, "use_actor", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_ACTOR);
|
||||
RNA_def_property_ui_text(prop, "Actor", "Object is detected by the Near and Radar sensor");
|
||||
|
@ -1513,6 +1513,7 @@ static void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
|
||||
objprop.m_softbody = (blenderobject->gameflag & OB_SOFT_BODY) != 0;
|
||||
objprop.m_angular_rigidbody = (blenderobject->gameflag & OB_RIGID_BODY) != 0;
|
||||
objprop.m_character = (blenderobject->gameflag & OB_CHARACTER) != 0;
|
||||
objprop.m_record_animation = (blenderobject->gameflag & OB_RECORD_ANIMATION) != 0;
|
||||
|
||||
///contact processing threshold is only for rigid bodies and static geometry, not 'dynamic'
|
||||
if (objprop.m_angular_rigidbody || !objprop.m_dyna )
|
||||
|
@ -706,8 +706,7 @@ void KX_BlenderSceneConverter::ResetPhysicsObjectsAnimationIpo(bool clearIpo)
|
||||
for (g=0;g<numObjects;g++)
|
||||
{
|
||||
KX_GameObject* gameObj = (KX_GameObject*)parentList->GetValue(g);
|
||||
if (gameObj->IsDynamic())
|
||||
{
|
||||
if (gameObj->IsRecordAnimation()) {
|
||||
|
||||
Object* blenderObject = gameObj->GetBlenderObject();
|
||||
if (blenderObject)
|
||||
@ -769,7 +768,7 @@ void KX_BlenderSceneConverter::resetNoneDynamicObjectToIpo()
|
||||
CListValue* parentList = scene->GetRootParentList();
|
||||
for (int ix=0;ix<parentList->GetCount();ix++) {
|
||||
KX_GameObject* gameobj = (KX_GameObject*)parentList->GetValue(ix);
|
||||
if (!gameobj->IsDynamic()) {
|
||||
if (!gameobj->IsRecordAnimation()) {
|
||||
Object* blenderobject = gameobj->GetBlenderObject();
|
||||
if (!blenderobject)
|
||||
continue;
|
||||
@ -821,8 +820,7 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber)
|
||||
{
|
||||
KX_GameObject* gameObj = (KX_GameObject*)parentList->GetValue(g);
|
||||
Object* blenderObject = gameObj->GetBlenderObject();
|
||||
if (blenderObject && blenderObject->parent==NULL && gameObj->IsDynamic())
|
||||
{
|
||||
if (blenderObject && blenderObject->parent==NULL && gameObj->IsRecordAnimation()) {
|
||||
|
||||
if (blenderObject->adt==NULL)
|
||||
BKE_id_add_animdata(&blenderObject->id);
|
||||
@ -939,9 +937,7 @@ void KX_BlenderSceneConverter::TestHandlesPhysicsObjectToAnimationIpo()
|
||||
for (g=0;g<numObjects;g++)
|
||||
{
|
||||
KX_GameObject* gameObj = (KX_GameObject*)parentList->GetValue(g);
|
||||
if (gameObj->IsDynamic())
|
||||
{
|
||||
|
||||
if (gameObj->IsRecordAnimation()) {
|
||||
#if 0
|
||||
Object* blenderObject = gameObj->GetBlenderObject();
|
||||
if (blenderObject && blenderObject->ipo)
|
||||
|
@ -71,6 +71,7 @@ struct KX_ObjectProperties
|
||||
bool m_ghost;
|
||||
class KX_GameObject* m_dynamic_parent;
|
||||
bool m_isactor;
|
||||
bool m_record_animation;
|
||||
bool m_sensor;
|
||||
bool m_character;
|
||||
bool m_concave;
|
||||
|
@ -435,6 +435,11 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
|
||||
shapeInfo->Release();
|
||||
|
||||
gameobj->SetPhysicsController(physicscontroller,isbulletdyna);
|
||||
|
||||
// record animation for dynamic objects
|
||||
if (isbulletdyna)
|
||||
gameobj->SetRecordAnimation(true);
|
||||
|
||||
// don't add automatically sensor object, they are added when a collision sensor is registered
|
||||
if (!isbulletsensor && objprop->m_in_active_layer)
|
||||
{
|
||||
@ -493,6 +498,11 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
|
||||
gameobj->getClientInfo()->m_type =
|
||||
(isbulletsensor) ? ((isActor) ? KX_ClientObjectInfo::OBACTORSENSOR : KX_ClientObjectInfo::OBSENSOR) :
|
||||
(isActor) ? KX_ClientObjectInfo::ACTOR : KX_ClientObjectInfo::STATIC;
|
||||
|
||||
// should we record animation for this object?
|
||||
if (objprop->m_record_animation)
|
||||
gameobj->SetRecordAnimation(true);
|
||||
|
||||
// store materialname in auxinfo, needed for touchsensors
|
||||
if (meshobj)
|
||||
{
|
||||
|
@ -112,6 +112,7 @@ KX_GameObject::KX_GameObject(
|
||||
m_pInstanceObjects(NULL),
|
||||
m_pDupliGroupObject(NULL),
|
||||
m_actionManager(NULL),
|
||||
m_bRecordAnimation(false),
|
||||
m_isDeformable(false)
|
||||
|
||||
#ifdef WITH_PYTHON
|
||||
@ -1791,6 +1792,7 @@ PyAttributeDef KX_GameObject::Attributes[] = {
|
||||
KX_PYATTRIBUTE_RW_FUNCTION("linVelocityMin", KX_GameObject, pyattr_get_lin_vel_min, pyattr_set_lin_vel_min),
|
||||
KX_PYATTRIBUTE_RW_FUNCTION("linVelocityMax", KX_GameObject, pyattr_get_lin_vel_max, pyattr_set_lin_vel_max),
|
||||
KX_PYATTRIBUTE_RW_FUNCTION("visible", KX_GameObject, pyattr_get_visible, pyattr_set_visible),
|
||||
KX_PYATTRIBUTE_RW_FUNCTION("record_animation", KX_GameObject, pyattr_get_record_animation, pyattr_set_record_animation),
|
||||
KX_PYATTRIBUTE_BOOL_RW ("occlusion", KX_GameObject, m_bOccluder),
|
||||
KX_PYATTRIBUTE_RW_FUNCTION("position", KX_GameObject, pyattr_get_worldPosition, pyattr_set_localPosition),
|
||||
KX_PYATTRIBUTE_RO_FUNCTION("localInertia", KX_GameObject, pyattr_get_localInertia),
|
||||
@ -2258,6 +2260,28 @@ int KX_GameObject::pyattr_set_visible(void *self_v, const KX_PYATTRIBUTE_DEF *at
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
|
||||
PyObject *KX_GameObject::pyattr_get_record_animation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
|
||||
return PyBool_FromLong(self->IsRecordAnimation());
|
||||
}
|
||||
|
||||
int KX_GameObject::pyattr_set_record_animation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
||||
{
|
||||
KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
|
||||
int param = PyObject_IsTrue(value);
|
||||
if (param == -1) {
|
||||
PyErr_SetString(PyExc_AttributeError, "gameOb.record_animation = bool: KX_GameObject, expected boolean");
|
||||
return PY_SET_ATTR_FAIL;
|
||||
}
|
||||
|
||||
self->SetRecordAnimation(param);
|
||||
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PyObject *KX_GameObject::pyattr_get_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
#ifdef USE_MATHUTILS
|
||||
|
@ -126,6 +126,7 @@ protected:
|
||||
|
||||
BL_ActionManager* GetActionManager();
|
||||
|
||||
bool m_bRecordAnimation;
|
||||
public:
|
||||
bool m_isDeformable;
|
||||
|
||||
@ -599,6 +600,20 @@ public:
|
||||
return m_bDyna;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should we record animation for this object?
|
||||
*/
|
||||
|
||||
void SetRecordAnimation(bool recordAnimation)
|
||||
{
|
||||
m_bRecordAnimation = recordAnimation;
|
||||
}
|
||||
|
||||
bool IsRecordAnimation() const
|
||||
{
|
||||
return m_bRecordAnimation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this object has a vertex parent relationship
|
||||
*/
|
||||
@ -981,6 +996,8 @@ public:
|
||||
static int pyattr_set_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
||||
static PyObject* pyattr_get_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static int pyattr_set_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
||||
static PyObject* pyattr_get_record_animation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static int pyattr_set_record_animation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
||||
static PyObject* pyattr_get_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static int pyattr_set_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
||||
static PyObject* pyattr_get_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
|
Loading…
Reference in New Issue
Block a user