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 26cb3fb..ef6900b 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 4f6730d..70a02d7 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 9fbdc3f..2b3ef1b 100644 (file)
@@ -364,6 +364,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
                        initGameKeys();
                        initPythonConstraintBinding();
                        initMathutils();
+                       //initVideoTexture();
 
                        if (sceneconverter)
                        {
index 0d0c7a2..830ffce 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 4ddf5a9..b858fa3 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 3830d42..53b3e34 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 739c122..a168beb 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 b1ab8e3..8bcda44 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 1aa067a..4184202 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 eb56e8d..89549ca 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 a30d9f4..0032d83 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 36e3db6..57ee0be 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);