Preparation to VideoTexture: everything but the VideoTexture module itself.
authorBenoit Bolsee <benoit.bolsee@online.be>
Fri, 31 Oct 2008 21:06:48 +0000 (21:06 +0000)
committerBenoit Bolsee <benoit.bolsee@online.be>
Fri, 31 Oct 2008 21:06:48 +0000 (21:06 +0000)
Rename PHY_GetActiveScene() to KX_GetActiveScene(): more logical name
Add KX_GetActiveEngine()

new KX_KetsjiEngine::GetClockTime(void) to return current
render frame time: if the CPU does not keep up with the
frame rate, up to 5 consecutive logic frames are processed
between each render frame, so that the logic system stays
accurate even if the graphic system is slow. For the video
texture module, it is important to stay in sync with the
render frame: no need to update the texture for logic frame.

BL_Texture::swapTexture(): texture id manipulation
BL_Texture::getTex() : return material texture

Enable video support in ffmpeg for Linux.

12 files changed:
projectfiles_vc7/blender/blender.vcproj
source/blender/imbuf/intern/util.c
source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
source/gameengine/Ketsji/BL_Texture.h
source/gameengine/Ketsji/KX_BlenderMaterial.h
source/gameengine/Ketsji/KX_Camera.cpp
source/gameengine/Ketsji/KX_GameObject.cpp
source/gameengine/Ketsji/KX_KetsjiEngine.cpp
source/gameengine/Ketsji/KX_KetsjiEngine.h
source/gameengine/Ketsji/KX_ParentActuator.cpp
source/gameengine/Ketsji/KX_PythonInit.cpp
source/gameengine/Ketsji/KX_PythonInit.h

index 26cb3fb79e189b70cd59c204a9cc2ed47c36f1db..ef6900b7b75cd563eab4f8eb5eb4be74acb6d4f5 100644 (file)
@@ -124,7 +124,7 @@ ECHO Done
                                Name="VCLinkerTool"
                                AdditionalOptions="/MACHINE:I386
 "
-                               AdditionalDependencies="SDL.lib freetype2ST.lib ftgl_static.lib gnu_gettext.lib qtmlClient.lib openal_static.lib libsoundsystem.lib libopenalsoundsystem.lib libdummysoundsystem.lib libguardedalloc.lib libbsp.lib libbmfont.lib libghost.lib libstring.lib ws2_32.lib dxguid.lib opengl32.lib libjpeg.lib glu32.lib vfw32.lib winmm.lib libdecimation.lib libiksolver.lib libpng_st.lib zlib.lib libmoto.lib solid.lib qhull.lib libopennl.lib Bullet.lib python25_d.lib libelbeem.lib libboolop.lib pthreadVSE2.lib pthreadVC2.lib libtiff.lib broad.lib complex.lib convex.lib memutil.lib verse.lib Half.lib Iex.lib Imath.lib IlmImf.lib IlmThread.lib avcodec-51.lib avformat-52.lib avutil-49.lib swscale-0.lib glew.lib"
+                               AdditionalDependencies="SDL.lib freetype2ST.lib ftgl_static.lib gnu_gettext.lib qtmlClient.lib openal_static.lib libsoundsystem.lib libopenalsoundsystem.lib libdummysoundsystem.lib libguardedalloc.lib libbsp.lib libbmfont.lib libghost.lib libstring.lib ws2_32.lib dxguid.lib opengl32.lib libjpeg.lib glu32.lib vfw32.lib winmm.lib libdecimation.lib libiksolver.lib libpng_st.lib zlib.lib libmoto.lib solid.lib qhull.lib libopennl.lib Bullet.lib python25_d.lib libelbeem.lib libboolop.lib pthreadVSE2.lib pthreadVC2.lib libtiff.lib broad.lib complex.lib convex.lib memutil.lib verse.lib Half.lib Iex.lib Imath.lib IlmImf.lib IlmThread.lib avcodec-51.lib avformat-52.lib avdevice-52.lib avutil-49.lib swscale-0.lib glew.lib"
                                ShowProgress="0"
                                OutputFile="..\..\bin\debug\blender.exe"
                                LinkIncremental="2"
index 4f6730db1f1efe7f9872dc098dca2e51f12dc3f8..70a02d72b01081f60dc4bcfed397721e502f5284 100644 (file)
@@ -64,6 +64,7 @@
 #ifdef WITH_FFMPEG
 #include <ffmpeg/avcodec.h>
 #include <ffmpeg/avformat.h>
+#include <ffmpeg/avdevice.h>
 
 #if LIBAVFORMAT_VERSION_INT < (49 << 16)
 #define FFMPEG_OLD_FRAME_RATE 1
@@ -236,6 +237,7 @@ void do_init_ffmpeg()
        if (!ffmpeg_init) {
                ffmpeg_init = 1;
                av_register_all();
+               avdevice_register_all();
        }
 }
 
index 9fbdc3fa1c9c454b662b15282f6146c99bc3c2fe..2b3ef1b31e3aa5123c02a9c2f1089d479c944b02 100644 (file)
@@ -364,6 +364,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
                        initGameKeys();
                        initPythonConstraintBinding();
                        initMathutils();
+                       //initVideoTexture();
 
                        if (sceneconverter)
                        {
index 0d0c7a277f291775ae09f0c06b3af480d2646c00..830ffceb0f78c151d478d0b89f6d5bceeba4c911 100644 (file)
@@ -59,6 +59,14 @@ public:
        void SetMapping(int mode);
        void DisableUnit();
        void setTexEnv(BL_Material *mat, bool modulate=false);
+       unsigned int swapTexture (unsigned int newTex) {
+               // swap texture codes
+               unsigned int tmp = mTexture;
+               mTexture = newTex;
+               // return original texture code
+               return tmp;
+       }
+
 };
 
 #endif//__BL_TEXTURE_H__
index 4ddf5a924df21f3260cefbbda92487df57bd2e4c..b858fa3754cc92866d0738b814d110b6de0680c7 100644 (file)
@@ -67,6 +67,9 @@ public:
 
        MTFace* GetMTFace(void) const;
        unsigned int* GetMCol(void) const;
+       BL_Texture * getTex (unsigned int idx) { 
+               return (idx < MAXTEX) ? mTextures + idx : NULL; 
+       }
 
        // for ipos
        void UpdateIPO(
index 3830d42213866a941b8da300fa035c1367a742f4..53b3e348a36e3b6fbfddfe3e303e033e6457c467 100644 (file)
@@ -793,7 +793,7 @@ KX_PYMETHODDEF_DOC(KX_Camera, setOnTop,
 {
        class KX_Scene* scene;
        
-       scene = PHY_GetActiveScene();
+       scene = KX_GetActiveScene();
        MT_assert(scene);
        scene->SetCameraOnTop(this);
        Py_Return;
index 739c122a5ef52c1f8f1cc2cb553a5168d4c807eb..a168beb9a707a94119b9033430d4bfe23dcbf68d 100644 (file)
@@ -1027,7 +1027,7 @@ bool KX_GameObject::ConvertPythonVectorArgs(PyObject* args,
 
 PyObject* KX_GameObject::PyReplaceMesh(PyObject* self, PyObject* value)
 {
-       KX_Scene *scene = PHY_GetActiveScene();
+       KX_Scene *scene = KX_GetActiveScene();
        char* meshname;
        void* mesh_pt;
 
@@ -1050,7 +1050,7 @@ PyObject* KX_GameObject::PyReplaceMesh(PyObject* self, PyObject* value)
 PyObject* KX_GameObject::PyEndObject(PyObject* self)
 {
 
-       KX_Scene *scene = PHY_GetActiveScene();
+       KX_Scene *scene = KX_GetActiveScene();
        scene->DelayedRemoveObject(this);
        
        Py_RETURN_NONE;
@@ -1447,7 +1447,7 @@ PyObject* KX_GameObject::PySetParent(PyObject* self, PyObject* value)
        // The object we want to set as parent
        CValue *m_ob = (CValue*)value;
        KX_GameObject *obj = ((KX_GameObject*)m_ob);
-       KX_Scene *scene = PHY_GetActiveScene();
+       KX_Scene *scene = KX_GetActiveScene();
        
        this->SetParent(scene, obj);
                
@@ -1456,7 +1456,7 @@ PyObject* KX_GameObject::PySetParent(PyObject* self, PyObject* value)
 
 PyObject* KX_GameObject::PyRemoveParent(PyObject* self)
 {
-       KX_Scene *scene = PHY_GetActiveScene();
+       KX_Scene *scene = KX_GetActiveScene();
        this->RemoveParent(scene);
        Py_RETURN_NONE;
 }
index b1ab8e3e7def86b45319bf697404dc7394b2ba5e..8bcda4479e1dab9836202fc310f80a3e6e131a34 100644 (file)
@@ -470,7 +470,7 @@ else
                                m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true);
                                // set Python hooks for each scene
                                PHY_SetActiveEnvironment(scene->GetPhysicsEnvironment());
-                               PHY_SetActiveScene(scene);
+                               KX_SetActiveScene(scene);
        
                                scene->GetPhysicsEnvironment()->endFrame();
                                
@@ -568,7 +568,7 @@ else
                                
                                // set Python hooks for each scene
                                PHY_SetActiveEnvironment(scene->GetPhysicsEnvironment());
-                               PHY_SetActiveScene(scene);
+                               KX_SetActiveScene(scene);
                                
                                m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
                                scene->UpdateParents(m_clockTime);
@@ -1540,6 +1540,11 @@ double KX_KetsjiEngine::GetAnimFrameRate()
        return m_anim_framerate;
 }
 
+double KX_KetsjiEngine::GetClockTime(void) const
+{
+       return m_clockTime;
+}
+
 void KX_KetsjiEngine::SetAnimFrameRate(double framerate)
 {
        m_anim_framerate = framerate;
index 1aa067a99621dd536bc19aa25e39cfa9e01e5efd..4184202c51860265055a9840cf29224624a1e8ee 100644 (file)
@@ -253,6 +253,11 @@ public:
         */ 
        bool GetUseFixedTime(void) const;
 
+       /**
+        * Returns current render frame clock time
+        */
+       double GetClockTime(void) const;
+
        /**
         * Returns the difference between the local time of the scene (when it
         * was running and not suspended) and the "curtime"
index eb56e8de6790b06187cd4e4c441e17320b16ab8a..89549ca6b5798aee1116d49d6cb2380ddce0fc0b 100644 (file)
@@ -119,7 +119,7 @@ bool KX_ParentActuator::Update()
                return false; // do nothing on negative events
 
        KX_GameObject *obj = (KX_GameObject*) GetParent();
-       KX_Scene *scene = PHY_GetActiveScene();
+       KX_Scene *scene = KX_GetActiveScene();
        switch (m_mode) {
                case KX_PARENT_SET:
                        if (m_ob)
index a30d9f4022ded92f64a36615ec3c737c48405cc6..0032d83c2ff7c773737e1b649004ad3c46087845 100644 (file)
@@ -1461,16 +1461,21 @@ PyObject* initMathutils()
        return Mathutils_Init("Mathutils"); // Use as a top level module in BGE
 }
 
-void PHY_SetActiveScene(class KX_Scene* scene)
+void KX_SetActiveScene(class KX_Scene* scene)
 {
        gp_KetsjiScene = scene;
 }
 
-class KX_Scene* PHY_GetActiveScene()
+class KX_Scene* KX_GetActiveScene()
 {
        return gp_KetsjiScene;
 }
 
+class KX_KetsjiEngine* KX_GetActiveEngine()
+{
+       return gp_KetsjiEngine;
+}
+
 // utility function for loading and saving the globalDict
 int saveGamePythonConfig( char **marshal_buffer)
 {
index 36e3db6ec354cdf2d6b7fb18fbed2c738615a3c8..57ee0be9400310c001acfd80a69e405311681260 100644 (file)
@@ -45,6 +45,7 @@ PyObject*     initGameKeys();
 PyObject*      initRasterizer(class RAS_IRasterizer* rasty,class RAS_ICanvas* canvas);
 PyObject*      initGamePlayerPythonScripting(const STR_String& progname, TPythonSecurityLevel level);
 PyObject*      initMathutils();
+PyObject*      initVideoTexture(void); 
 void           exitGamePlayerPythonScripting();
 PyObject*      initGamePythonScripting(const STR_String& progname, TPythonSecurityLevel level);
 void           exitGamePythonScripting();
@@ -54,8 +55,12 @@ void         pathGamePythonConfig( char *path );
 int                    saveGamePythonConfig( char **marshal_buffer);
 int                    loadGamePythonConfig(char *marshal_buffer, int marshal_length);
 
-void PHY_SetActiveScene(class KX_Scene* scene);
-class KX_Scene* PHY_GetActiveScene();
+class KX_KetsjiEngine;
+class KX_Scene;
+
+void KX_SetActiveScene(class KX_Scene* scene);
+class KX_Scene* KX_GetActiveScene();
+class KX_KetsjiEngine* KX_GetActiveEngine();
 #include "MT_Vector3.h"
 
 void           KX_RasterizerDrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color);