I'd have to say that in addition to all of the wonderful things Blender can do, I've come to realize that it has great potential as a children's learning tool for math, geometry, physics, and computer science, not to mention 3D modeling. My 10-year old son has really gotten into Blender, especially turning the physics engine loose on convoluted marble runs.

Unfortunately, he was disappointed to find that after putting a lot of effort into animating some static objects via actuators, that he could not record the motions of the objects in the same way that dynamic objects can easily be recorded. The simulation played out fine in the game engine, but only the motions of dynamic objects were recorded. So when he tried to render an animation using the recording, the motion of the static objects was lost.

I tried to find a solution on the web -- apparently this behavior existed by default in Blender 2.60 and earlier but mysteriously disappeared in recent releases, causing some consternation:

http://blenderartists.org/forum/showthread.php?246697-Recording-Motion-of-Static-Objects

Apparently the only known workaround for recent Blender releases to enable recording is to make all objects Dynamic (as discussed in thread above). This seems wrong, because in some cases you might want an object to be static so that you can control its motion without interference from the physics engine. In fact the game engine currently allows this, it just doesn't record the motion of the static objects, making it difficult to record such animation from the game engine for later high-quality renders. This seems wrong as well, that the the game engine, when run, would produce a different set of object motions than would be recorded as keyframes when Game>Record Animation is checked.

Anyway, I've written up a simple patch to restore recording of static objects. The attached patch (against trunk rev 56332) allows for easy recording of the motion of static objects via a checkbox on the Physics panel. All static objects are given a new checkbox called "Record Animation" that appears under the "Actor" and "Ghost" checkboxes on the Physics panel. This checkbox only appears for static objects. When checked, the motion of the static object will be recorded, whenever game-engine recording is enabled via Game>Record Animation.

So with this patch, we were finally able to render my son's animation. Here's the finished result:

http://youtu.be/yltDGgW4jd0

Is this something that can be considered for inclusion in Blender?

Thanks,
James
Index: release/scripts/startup/bl_ui/properties_game.py
===================================================================
--- release/scripts/startup/bl_ui/properties_game.py    (revision 56332)
+++ release/scripts/startup/bl_ui/properties_game.py    (working copy)
@@ -156,6 +156,7 @@
             col = layout.column()
             col.prop(game, "use_actor")
             col.prop(game, "use_ghost")
+            col.prop(game, "record_static_animate")
             col.prop(ob, "hide_render", text="Invisible")
 
             layout.separator()
Index: source/gameengine/Converter/KX_BlenderSceneConverter.cpp
===================================================================
--- source/gameengine/Converter/KX_BlenderSceneConverter.cpp    (revision 56332)
+++ source/gameengine/Converter/KX_BlenderSceneConverter.cpp    (working copy)
@@ -700,7 +700,7 @@
                for (g=0;g<numObjects;g++)
                {
                        KX_GameObject* gameObj = 
(KX_GameObject*)parentList->GetValue(g);
-                       if (gameObj->IsDynamic())
+                       if (gameObj->RecordAnimation())
                        {
                                //KX_IPhysicsController* physCtrl = 
gameObj->GetPhysicsController();
                                
@@ -764,7 +764,7 @@
                        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->RecordAnimation()) {
                                        Object* blenderobject = 
gameobj->GetBlenderObject();
                                        if (!blenderobject)
                                                continue;
@@ -816,7 +816,7 @@
                {
                        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->RecordAnimation())
                        {
                                //KX_IPhysicsController* physCtrl = 
gameObj->GetPhysicsController();
 
@@ -935,7 +935,7 @@
                for (g=0;g<numObjects;g++)
                {
                        KX_GameObject* gameObj = 
(KX_GameObject*)parentList->GetValue(g);
-                       if (gameObj->IsDynamic())
+                       if (gameObj->RecordAnimation())
                        {
                                //KX_IPhysicsController* physCtrl = 
gameObj->GetPhysicsController();
                                
Index: source/gameengine/Converter/BL_BlenderDataConversion.cpp
===================================================================
--- source/gameengine/Converter/BL_BlenderDataConversion.cpp    (revision 56332)
+++ source/gameengine/Converter/BL_BlenderDataConversion.cpp    (working copy)
@@ -1645,6 +1645,7 @@
        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_static_animate = (blenderobject->gameflag & 
OB_STATIC_ANIMATE) != 0;
        
        ///contact processing threshold is only for rigid bodies and static 
geometry, not 'dynamic'
        if (objprop.m_angular_rigidbody || !objprop.m_dyna )
Index: source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
===================================================================
--- source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp       (revision 56332)
+++ source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp       (working copy)
@@ -493,6 +493,10 @@
        gameobj->getClientInfo()->m_type = 
                (isbulletsensor) ? ((isActor) ? 
KX_ClientObjectInfo::OBACTORSENSOR : KX_ClientObjectInfo::OBSENSOR) :
                (isActor) ? KX_ClientObjectInfo::ACTOR : 
KX_ClientObjectInfo::STATIC;
+
+       // indicates that animation should be recorded for static object
+       gameobj->SetStaticAnimate(objprop->m_static_animate);
+
        // store materialname in auxinfo, needed for touchsensors
        if (meshobj)
        {
Index: source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
===================================================================
--- source/gameengine/Ketsji/KX_ConvertPhysicsObject.h  (revision 56332)
+++ source/gameengine/Ketsji/KX_ConvertPhysicsObject.h  (working copy)
@@ -71,6 +71,7 @@
        bool    m_ghost;
        class KX_GameObject*    m_dynamic_parent;
        bool    m_isactor;
+       bool    m_static_animate;        
        bool    m_sensor;
        bool    m_character;
        bool    m_concave;
Index: source/gameengine/Ketsji/KX_GameObject.cpp
===================================================================
--- source/gameengine/Ketsji/KX_GameObject.cpp  (revision 56332)
+++ source/gameengine/Ketsji/KX_GameObject.cpp  (working copy)
@@ -110,6 +110,7 @@
       m_pInstanceObjects(NULL),
       m_pDupliGroupObject(NULL),
       m_actionManager(NULL),
+      m_bStaticAnimate(false),
       m_isDeformable(false)
 #ifdef WITH_PYTHON
     , m_attr_dict(NULL)
Index: source/gameengine/Ketsji/KX_GameObject.h
===================================================================
--- source/gameengine/Ketsji/KX_GameObject.h    (revision 56332)
+++ source/gameengine/Ketsji/KX_GameObject.h    (working copy)
@@ -128,6 +128,7 @@
 
        BL_ActionManager* GetActionManager();
        
+       bool                                                            
m_bStaticAnimate;
 public:
        bool                                                            
m_isDeformable;
 
@@ -461,6 +462,14 @@
        );
 
        /**
+        * Indicate whether or not animation should be recorded for static 
object
+        */
+       void SetStaticAnimate(bool static_animate)
+       {
+         m_bStaticAnimate = static_animate;
+       }
+
+       /**
         * \return a pointer to the physics controller owned by this class.
         */
 
@@ -600,6 +609,14 @@
        }
 
        /**
+        * Should we record animation for this object?
+        */
+       bool    RecordAnimation() const 
+       { 
+               return IsDynamic() || m_bStaticAnimate; 
+       }
+
+       /**
         * Check if this object has a vertex parent relationship
         */
        bool IsVertexParent( )
Index: source/blender/makesdna/DNA_object_types.h
===================================================================
--- source/blender/makesdna/DNA_object_types.h  (revision 56332)
+++ source/blender/makesdna/DNA_object_types.h  (working copy)
@@ -516,6 +516,9 @@
 #define OB_HASOBSTACLE 0x200000
 #define OB_CHARACTER           0x400000
 
+/* Indicates that animation should be recorded for static object */
+#define OB_STATIC_ANIMATE 0x800000
+
 /* ob->gameflag2 */
 #define OB_NEVER_DO_ACTIVITY_CULLING   1
 #define OB_LOCK_RIGID_BODY_X_AXIS      4
Index: source/blender/makesrna/intern/rna_object.c
===================================================================
--- source/blender/makesrna/intern/rna_object.c (revision 56332)
+++ source/blender/makesrna/intern/rna_object.c (working copy)
@@ -1625,6 +1625,10 @@
        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, "record_static_animate", PROP_BOOLEAN, 
PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "gameflag", 
OB_STATIC_ANIMATE);
+       RNA_def_property_ui_text(prop, "Record Animation", "Record animation 
for static object");
+
        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");
_______________________________________________
Bf-committers mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-committers

Reply via email to