game engine support for recording animation back & some other minor changes.

This commit is contained in:
2010-02-22 12:25:58 +00:00
parent dd03793f4e
commit 4ef1fd1078
16 changed files with 121 additions and 338 deletions

View File

@@ -45,7 +45,7 @@ def main(context):
class DiscontFilterOp(bpy.types.Operator):
"""Fixes the most common causes of gimbal lock in the fcurves of the active bone"""
bl_idname = "graph.discont_filter"
bl_idname = "graph.euler_filter"
bl_label = "Filter out discontinuities in the active fcurves"
def poll(self, context):
@@ -63,4 +63,3 @@ def unregister():
if __name__ == "__main__":
register()

View File

@@ -357,13 +357,13 @@ class RENDER_PT_game_performance(RenderButtonsPanel):
col.prop(gs, "show_debug_properties", text="Debug Properties")
col.prop(gs, "show_framerate_profile", text="Framerate and Profile")
col.prop(gs, "show_physics_visualization", text="Physics Visualization")
col.prop(gs, "deprecation_warnings")
col.prop(gs, "use_deprecation_warnings")
if wide_ui:
col = split.column()
col.label(text="Render:")
col.prop(gs, "all_frames")
col.prop(gs, "display_lists")
col.prop(gs, "use_frame_rate")
col.prop(gs, "use_display_lists")
class RENDER_PT_game_sound(RenderButtonsPanel):

View File

@@ -148,7 +148,7 @@ class GRAPH_MT_channel(bpy.types.Menu):
layout.operator("anim.channels_collapse")
layout.separator()
layout.operator("graph.discont_filter", text="Discontinuity (Euler) Filter")
layout.operator("graph.euler_filter", text="Discontinuity (Euler) Filter")
class GRAPH_MT_key(bpy.types.Menu):

View File

@@ -253,7 +253,8 @@ class INFO_MT_game(bpy.types.Menu):
layout.prop(gs, "show_debug_properties")
layout.prop(gs, "show_framerate_profile")
layout.prop(gs, "show_physics_visualization")
layout.prop(gs, "deprecation_warnings")
layout.prop(gs, "use_deprecation_warnings")
layout.prop(gs, "use_animation_record")
class INFO_MT_render(bpy.types.Menu):

View File

@@ -1690,8 +1690,8 @@ void game_set_commmandline_options(GameData *gm)
test= (gm->flag & GAME_ENABLE_ALL_FRAMES);
SYS_WriteCommandLineInt(syshandle, "fixedtime", test);
// a= (G.fileflags & G_FILE_GAME_TO_IPO);
// SYS_WriteCommandLineInt(syshandle, "game2ipo", a);
test= (gm->flag & GAME_ENABLE_ANIMATION_RECORD);
SYS_WriteCommandLineInt(syshandle, "animation_record", test);
test= (gm->flag & GAME_IGNORE_DEPRECATION_WARNINGS);
SYS_WriteCommandLineInt(syshandle, "ignore_deprecation_warnings", test);

View File

@@ -487,6 +487,7 @@ typedef struct GameData {
#define GAME_GLSL_NO_NODES (1 << 10)
#define GAME_GLSL_NO_EXTRA_TEX (1 << 11)
#define GAME_IGNORE_DEPRECATION_WARNINGS (1 << 12)
#define GAME_ENABLE_ANIMATION_RECORD (1 << 13)
/* GameData.matmode */
#define GAME_MAT_TEXFACE 0

View File

@@ -1501,51 +1501,46 @@ static void rna_def_scene_game_data(BlenderRNA *brna)
prop= RNA_def_property(srna, "use_occlusion_culling", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", (1 << 5)); //XXX mode hardcoded // WO_DBVT_CULLING
RNA_def_property_ui_text(prop, "DBVT culling", "Use optimized Bullet DBVT tree for view frustrum and occlusion culling");
RNA_def_property_update(prop, NC_SCENE, NULL);
// not used // deprecated !!!!!!!!!!!!!
prop= RNA_def_property(srna, "activity_culling", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", (1 << 3)); //XXX mode hardcoded
RNA_def_property_ui_text(prop, "Activity Culling", "Activity culling is enabled");
RNA_def_property_update(prop, NC_SCENE, NULL);
// not used // deprecated !!!!!!!!!!!!!
prop= RNA_def_property(srna, "activity_culling_box_radius", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "activityBoxRadius");
RNA_def_property_range(prop, 0.0, 1000.0);
RNA_def_property_ui_text(prop, "box radius", "Radius of the activity bubble, in Manhattan length. Objects outside the box are activity-culled");
RNA_def_property_update(prop, NC_SCENE, NULL);
/* booleans */
prop= RNA_def_property(srna, "all_frames", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_ENABLE_ALL_FRAMES);
RNA_def_property_ui_text(prop, "All Frames", "Render as many frames as possible, rather than respecting framerate");
RNA_def_property_update(prop, NC_SCENE, NULL);
prop= RNA_def_property(srna, "show_debug_properties", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_SHOW_DEBUG_PROPS);
RNA_def_property_ui_text(prop, "Show Debug Properties", "Show properties marked for debugging while the game runs");
RNA_def_property_update(prop, NC_SCENE, NULL);
prop= RNA_def_property(srna, "show_framerate_profile", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_SHOW_FRAMERATE);
RNA_def_property_ui_text(prop, "Show Framerate and Profile", "Show framerate and profiling information while the game runs");
RNA_def_property_update(prop, NC_SCENE, NULL);
prop= RNA_def_property(srna, "show_physics_visualization", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_SHOW_PHYSICS);
RNA_def_property_ui_text(prop, "Show Physics Visualization", "Show a visualization of physics bounds and interactions");
RNA_def_property_update(prop, NC_SCENE, NULL);
prop= RNA_def_property(srna, "display_lists", PROP_BOOLEAN, PROP_NONE);
prop= RNA_def_property(srna, "use_frame_rate", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_ENABLE_ALL_FRAMES);
RNA_def_property_ui_text(prop, "Use Frame Rate", "Respect the frame rate rather then rendering as many frames as possible");
prop= RNA_def_property(srna, "use_display_lists", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_DISPLAY_LISTS);
RNA_def_property_ui_text(prop, "Display Lists", "Use display lists to speed up rendering by keeping geometry on the GPU");
RNA_def_property_update(prop, NC_SCENE, NULL);
prop= RNA_def_property(srna, "deprecation_warnings", PROP_BOOLEAN, PROP_NONE);
prop= RNA_def_property(srna, "use_deprecation_warnings", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_IGNORE_DEPRECATION_WARNINGS);
RNA_def_property_ui_text(prop, "Deprecation Warnings", "Print warnings when using deprecated features in the python API");
RNA_def_property_update(prop, NC_SCENE, NULL);
prop= RNA_def_property(srna, "use_animation_record", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_ENABLE_ANIMATION_RECORD);
RNA_def_property_ui_text(prop, "Record Animation", "Record animation to fcurves");
/* materials */
prop= RNA_def_property(srna, "material_mode", PROP_ENUM, PROP_NONE);

View File

@@ -1639,47 +1639,81 @@ static PyObject *pyrna_struct_values(BPy_PropertyRNA *self)
return BPy_Wrap_GetValues(self->ptr.id.data, group);
}
static PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args)
/* internal use for insert and delete */
int pyrna_struct_keyframe_parse(PointerRNA *ptr, PyObject *args, char *error_prefix,
char **path_full, int *index, float *cfra) /* return values */
{
char *path, *path_full;
int index= -1; /* default to all */
float cfra = CTX_data_scene(BPy_GetContext())->r.cfra;
char *path;
PropertyRNA *prop;
PyObject *result;
if (!PyArg_ParseTuple(args, "s|if:keyframe_insert", &path, &index, &cfra))
return NULL;
if (self->ptr.data==NULL) {
PyErr_Format( PyExc_TypeError, "keyframe_insert, this struct has no data, cant be animated", path);
return NULL;
if (!PyArg_ParseTuple(args, "s|if", &path, &index, &cfra)) {
PyErr_Format(PyExc_TypeError, "%.200s: expected a string and optionally an int and float arguments", error_prefix);
return -1;
}
prop = RNA_struct_find_property(&self->ptr, path);
if (ptr->data==NULL) {
PyErr_Format(PyExc_TypeError, "%.200s: this struct has no data, can't be animated", error_prefix);
return -1;
}
prop = RNA_struct_find_property(ptr, path);
if (prop==NULL) {
PyErr_Format( PyExc_TypeError, "keyframe_insert, property \"%s\" not found", path);
return NULL;
PyErr_Format( PyExc_TypeError, "%.200s: property \"%s\" not found", error_prefix, path);
return -1;
}
if (!RNA_property_animateable(&self->ptr, prop)) {
PyErr_Format( PyExc_TypeError, "keyframe_insert, property \"%s\" not animatable", path);
return NULL;
if (!RNA_property_animateable(ptr, prop)) {
PyErr_Format( PyExc_TypeError, "%.200s: property \"%s\" not animatable", error_prefix, path);
return -1;
}
path_full= RNA_path_from_ID_to_property(&self->ptr, prop);
*path_full= RNA_path_from_ID_to_property(ptr, prop);
if (path_full==NULL) {
PyErr_Format( PyExc_TypeError, "keyframe_insert, could not make path to \"%s\"", path);
return NULL;
if (*path_full==NULL) {
PyErr_Format( PyExc_TypeError, "%.200s: could not make path to \"%s\"", error_prefix, path);
return -1;
}
result= PyBool_FromLong( insert_keyframe((ID *)self->ptr.id.data, NULL, NULL, path_full, index, cfra, 0));
if(*cfra==FLT_MAX)
*cfra= CTX_data_scene(BPy_GetContext())->r.cfra;
return 0; /* success */
}
static PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args)
{
PyObject *result;
/* args, pyrna_struct_keyframe_parse handles these */
char *path_full= NULL;
int index= -1;
float cfra= FLT_MAX;
if(pyrna_struct_keyframe_parse(&self->ptr, args, "keyframe_insert", &path_full, &index, &cfra) == -1)
return NULL;
result= PyBool_FromLong(insert_keyframe((ID *)self->ptr.id.data, NULL, NULL, path_full, index, cfra, 0));
MEM_freeN(path_full);
return result;
}
static PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args)
{
PyObject *result;
/* args, pyrna_struct_keyframe_parse handles these */
char *path_full= NULL;
int index= -1;
float cfra= FLT_MAX;
if(pyrna_struct_keyframe_parse(&self->ptr, args, "keyframe_delete", &path_full, &index, &cfra) == -1)
return NULL;
result= PyBool_FromLong(delete_keyframe((ID *)self->ptr.id.data, NULL, NULL, path_full, index, cfra, 0));
MEM_freeN(path_full);
return result;
}
static PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
{
@@ -2659,6 +2693,7 @@ static struct PyMethodDef pyrna_struct_methods[] = {
/* maybe this become and ID function */
{"keyframe_insert", (PyCFunction)pyrna_struct_keyframe_insert, METH_VARARGS, NULL},
// {"keyframe_delete", (PyCFunction)pyrna_struct_keyframe_delete, METH_VARARGS, NULL}, // WIP
{"driver_add", (PyCFunction)pyrna_struct_driver_add, METH_VARARGS, NULL},
{"is_property_set", (PyCFunction)pyrna_struct_is_property_set, METH_VARARGS, NULL},
{"is_property_hidden", (PyCFunction)pyrna_struct_is_property_hidden, METH_VARARGS, NULL},

View File

@@ -28,6 +28,7 @@
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "DNA_listBase.h"
#include "DNA_screen_types.h"

View File

@@ -266,6 +266,7 @@ void WM_operator_bl_idname(char *to, const char *from){}
void WM_operator_py_idname(char *to, const char *from){}
void WM_operator_ui_popup(struct bContext *C, struct wmOperator *op, int width, int height){}
short insert_keyframe (struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, short flag){return 0;}
short delete_keyframe(struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, short flag){return 0;};
char *WM_operator_pystring(struct bContext *C, struct wmOperatorType *ot, struct PointerRNA *opptr, int all_args){return NULL;}
struct wmKeyMapItem *WM_modalkeymap_add_item(struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value){return NULL;}
struct wmKeyMap *WM_modalkeymap_add(struct wmKeyConfig *keyconf, char *idname, EnumPropertyItem *items){return NULL;}
@@ -301,7 +302,7 @@ void smoke_get_index(void) {return;}
void smoke_step(void) {return;}
*/
char blender_path(){return (char) NULL;}
char blender_path[] = "";
/* CSG */
struct CSG_BooleanOperation * CSG_NewBooleanFunction( void ){return (struct CSG_BooleanOperation *) NULL;}

View File

@@ -168,7 +168,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
bool usefixed = (SYS_GetCommandLineInt(syshandle, "fixedtime", 0) != 0);
bool profile = (SYS_GetCommandLineInt(syshandle, "show_profile", 0) != 0);
bool frameRate = (SYS_GetCommandLineInt(syshandle, "show_framerate", 0) != 0);
bool game2ipo = (SYS_GetCommandLineInt(syshandle, "game2ipo", 0) != 0);
bool animation_record = (SYS_GetCommandLineInt(syshandle, "animation_record", 0) != 0);
bool displaylists = (SYS_GetCommandLineInt(syshandle, "displaylists", 0) != 0);
bool nodepwarnings = (SYS_GetCommandLineInt(syshandle, "ignore_deprecation_warnings", 0) != 0);
bool novertexarrays = (SYS_GetCommandLineInt(syshandle, "novertexarrays", 0) != 0);
@@ -322,7 +322,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
if (blscene)
{
int startFrame = blscene->r.cfra;
ketsjiengine->SetGame2IpoMode(game2ipo,startFrame);
ketsjiengine->SetAnimRecordMode(animation_record, startFrame);
// Quad buffered needs a special window.
if(blscene->gm.stereoflag == STEREO_ENABLED){
@@ -409,7 +409,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
// Set the animation playback rate for ipo's and actions
// the framerate below should patch with FPS macro defined in blendef.h
// Could be in StartEngine set the framerate, we need the scene to do this
ketsjiengine->SetAnimFrameRate( (((double) blscene->r.frs_sec) / blscene->r.frs_sec_base) );
ketsjiengine->SetAnimFrameRate(FPS);
// the mainloop
printf("\nBlender Game Engine Started\n\n");
@@ -567,224 +567,3 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
#endif
}
extern "C" void StartKetsjiShellSimulation(struct wmWindow *win,
struct ARegion *ar,
char* scenename,
struct Main* maggie,
int always_use_expand_framing)
{
int exitrequested = KX_EXIT_REQUEST_NO_REQUEST;
Main* blenderdata = maggie;
RAS_Rect area_rect;
area_rect.SetLeft(ar->winrct.xmin);
area_rect.SetBottom(ar->winrct.ymin);
area_rect.SetRight(ar->winrct.xmax);
area_rect.SetTop(ar->winrct.ymax);
char* startscenename = scenename;
char pathname[FILE_MAXDIR+FILE_MAXFILE];
STR_String exitstring = "";
BLI_strncpy(pathname, blenderdata->name, sizeof(pathname));
#ifndef DISABLE_PYTHON
// Acquire Python's GIL (global interpreter lock)
// so we can safely run Python code and API calls
PyGILState_STATE gilstate = PyGILState_Ensure();
PyObject *pyGlobalDict = PyDict_New(); /* python utility storage, spans blend file loading */
#endif
bgl::InitExtensions(true);
do
{
// get some preferences
SYS_SystemHandle syshandle = SYS_GetSystem();
/*
bool properties = (SYS_GetCommandLineInt(syshandle, "show_properties", 0) != 0);
bool usefixed = (SYS_GetCommandLineInt(syshandle, "fixedtime", 0) != 0);
bool profile = (SYS_GetCommandLineInt(syshandle, "show_profile", 0) != 0);
bool frameRate = (SYS_GetCommandLineInt(syshandle, "show_framerate", 0) != 0);
*/
bool game2ipo = true;//(SYS_GetCommandLineInt(syshandle, "game2ipo", 0) != 0);
bool displaylists = (SYS_GetCommandLineInt(syshandle, "displaylists", 0) != 0);
bool usemat = false;
// create the canvas, rasterizer and rendertools
RAS_ICanvas* canvas = new KX_BlenderCanvas(win, area_rect);
//canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE);
RAS_IRenderTools* rendertools = new KX_BlenderRenderTools();
RAS_IRasterizer* rasterizer = NULL;
if(displaylists) {
if (GLEW_VERSION_1_1)
rasterizer = new RAS_ListRasterizer(canvas, true, true);
else
rasterizer = new RAS_ListRasterizer(canvas);
}
else if (GLEW_VERSION_1_1)
rasterizer = new RAS_VAOpenGLRasterizer(canvas, false);
else
rasterizer = new RAS_OpenGLRasterizer(canvas);
// create the inputdevices
KX_BlenderKeyboardDevice* keyboarddevice = new KX_BlenderKeyboardDevice();
KX_BlenderMouseDevice* mousedevice = new KX_BlenderMouseDevice();
// create a networkdevice
NG_NetworkDeviceInterface* networkdevice = new
NG_LoopBackNetworkDeviceInterface();
// create a ketsji/blendersystem (only needed for timing and stuff)
KX_BlenderSystem* kxsystem = new KX_BlenderSystem();
// create the ketsjiengine
KX_KetsjiEngine* ketsjiengine = new KX_KetsjiEngine(kxsystem);
Scene *blscene = NULL;
blscene = (Scene*) maggie->scene.first;
for (Scene *sce= (Scene*) maggie->scene.first; sce; sce= (Scene*) sce->id.next)
{
if (startscenename == (sce->id.name+2))
{
blscene = sce;
break;
}
}
int cframe = 1, startFrame;
if (blscene)
{
cframe=blscene->r.cfra;
startFrame = blscene->r.sfra;
blscene->r.cfra=startFrame;
// update_for_newframe(); // XXX scene_update_for_newframe wont cut it!
ketsjiengine->SetGame2IpoMode(game2ipo,startFrame);
}
// Quad buffered needs a special window.
if(blscene->gm.stereoflag == STEREO_ENABLED){
if (blscene->gm.stereomode != RAS_IRasterizer::RAS_STEREO_QUADBUFFERED)
rasterizer->SetStereoMode((RAS_IRasterizer::StereoMode) blscene->gm.stereomode);
}
rasterizer->SetBackColor(blscene->gm.framing.col[0], blscene->gm.framing.col[1], blscene->gm.framing.col[2], 0.0f);
if (exitrequested != KX_EXIT_REQUEST_QUIT_GAME)
{
// create a scene converter, create and convert the startingscene
KX_ISceneConverter* sceneconverter = new KX_BlenderSceneConverter(maggie, ketsjiengine);
ketsjiengine->SetSceneConverter(sceneconverter);
sceneconverter->addInitFromFrame=true;
if (always_use_expand_framing)
sceneconverter->SetAlwaysUseExpandFraming(true);
if(usemat)
sceneconverter->SetMaterials(true);
KX_Scene* startscene = new KX_Scene(keyboarddevice,
mousedevice,
networkdevice,
startscenename,
blscene);
#ifndef DISABLE_PYTHON
// some python things
PyObject *gameLogic, *gameLogic_keys;
setupGamePython(ketsjiengine, startscene, blenderdata, pyGlobalDict, &gameLogic, &gameLogic_keys, 0, NULL);
#endif // DISABLE_PYTHON
if (sceneconverter)
{
// convert and add scene
sceneconverter->ConvertScene(
startscene,
rendertools,
canvas);
ketsjiengine->AddScene(startscene);
// start the engine
ketsjiengine->StartEngine(false);
ketsjiengine->SetUseFixedTime(true);
ketsjiengine->SetTicRate(
(double) blscene->r.frs_sec /
(double) blscene->r.frs_sec_base);
// the mainloop
while ((blscene->r.cfra<=blscene->r.efra)&&(!exitrequested))
{
printf("frame %i\n",blscene->r.cfra);
// first check if we want to exit
exitrequested = ketsjiengine->GetExitCode();
// kick the engine
ketsjiengine->NextFrame();
blscene->r.cfra=blscene->r.cfra+1;
// update_for_newframe(); // XXX scene_update_for_newframe wont cut it
}
exitstring = ketsjiengine->GetExitString();
}
if (sceneconverter)
{
delete sceneconverter;
sceneconverter = NULL;
}
}
blscene->r.cfra=cframe;
// set the cursor back to normal
canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL);
// clean up some stuff
if (ketsjiengine)
{
delete ketsjiengine;
ketsjiengine = NULL;
}
if (kxsystem)
{
delete kxsystem;
kxsystem = NULL;
}
if (networkdevice)
{
delete networkdevice;
networkdevice = NULL;
}
if (keyboarddevice)
{
delete keyboarddevice;
keyboarddevice = NULL;
}
if (mousedevice)
{
delete mousedevice;
mousedevice = NULL;
}
if (rasterizer)
{
delete rasterizer;
rasterizer = NULL;
}
if (rendertools)
{
delete rendertools;
rendertools = NULL;
}
} while (exitrequested == KX_EXIT_REQUEST_RESTART_GAME || exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME);
#ifndef DISABLE_PYTHON
Py_DECREF(pyGlobalDict);
// Release Python's GIL
PyGILState_Release(gilstate);
#endif
}

View File

@@ -82,13 +82,16 @@ extern "C"
#include "MEM_guardedalloc.h"
//XXX #include "BSE_editipo.h"
//XXX #include "BSE_editipo_types.h"
#include "DNA_ipo_types.h"
// #include "DNA_ipo_types.h"
#include "BKE_global.h"
#include "BKE_animsys.h"
#include "BKE_library.h"
#include "BKE_ipo.h" // eval_icu
#include "BKE_material.h" // copy_material
#include "BKE_mesh.h" // copy_mesh
#include "DNA_space_types.h"
#include "DNA_anim_types.h"
#include "../../blender/editors/include/ED_keyframing.h"
}
/* Only for dynamic loading and merging */
@@ -621,57 +624,12 @@ void KX_BlenderSceneConverter::RegisterWorldInfo(
m_worldinfos.push_back(pair<KX_Scene*,KX_WorldInfo*>(m_currentScene,worldinfo));
}
/*
* When deleting an IPO curve from Python, check if the IPO is being
* edited and if so clear the pointer to the old curve.
*/
void KX_BlenderSceneConverter::localDel_ipoCurve ( IpoCurve * icu )
{
#if 0 //XXX
if (!G.sipo)
return;
int i;
EditIpo *ei= (EditIpo *)G.sipo->editipo;
if (!ei) return;
for(i=0; i<G.sipo->totipo; i++, ei++) {
if ( ei->icu == icu ) {
ei->flag &= ~(IPO_SELECT | IPO_EDIT);
ei->icu= 0;
return;
}
}
#endif
}
//quick hack
extern "C"
{
Ipo *add_ipo( char *name, int idcode );
//XXX char *getIpoCurveName( IpoCurve * icu );
//XXX struct IpoCurve *verify_ipocurve(struct ID *, short, char *, char *, char *, int);
//XXX void testhandles_ipocurve(struct IpoCurve *icu);
void insert_vert_icu(struct IpoCurve *, float, float, short);
float eval_icu(struct IpoCurve *icu, float ipotime);
//void mat3_to_eul( float *eul,float tmat[][3]);
void mat3_to_compatible_eul( float *eul, float *oldrot,float mat[][3]);
}
IpoCurve* findIpoCurve(IpoCurve* first, const char* searchName)
{
IpoCurve* icu1;
for( icu1 = first; icu1; icu1 = icu1->next )
{
/*XXX char* curveName = getIpoCurveName( icu1 );
if( !strcmp( curveName, searchName) )
{
return icu1;
}*/
}
return 0;
}
void KX_BlenderSceneConverter::ResetPhysicsObjectsAnimationIpo(bool clearIpo)
{
@@ -695,6 +653,7 @@ void KX_BlenderSceneConverter::ResetPhysicsObjectsAnimationIpo(bool clearIpo)
Object* blenderObject = gameObj->GetBlenderObject();
if (blenderObject)
{
#if 0
//erase existing ipo's
Ipo* ipo = blenderObject->ipo;//findIpoForName(blenderObject->id.name+2);
if (ipo)
@@ -728,11 +687,7 @@ void KX_BlenderSceneConverter::ResetPhysicsObjectsAnimationIpo(bool clearIpo)
blenderObject->ipo = ipo;
}
#endif
}
}
@@ -811,8 +766,28 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber)
//KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController();
Object* blenderObject = gameObj->GetBlenderObject();
if (blenderObject && blenderObject->ipo)
if(blenderObject->adt==NULL)
BKE_id_add_animdata(&blenderObject->id);
if (blenderObject && blenderObject->adt)
{
const MT_Point3& position = gameObj->NodeGetWorldPosition();
//const MT_Vector3& scale = gameObj->NodeGetWorldScaling();
const MT_Matrix3x3& orn = gameObj->NodeGetWorldOrientation();
position.getValue(blenderObject->loc);
float tmat[3][3];
for (int r=0;r<3;r++)
for (int c=0;c<3;c++)
tmat[r][c] = orn[c][r];
mat3_to_compatible_eul(blenderObject->rot, blenderObject->rot, tmat);
insert_keyframe(&blenderObject->id, NULL, NULL, "location", -1, frameNumber, INSERTKEY_FAST);
insert_keyframe(&blenderObject->id, NULL, NULL, "rotation_euler", -1, frameNumber, INSERTKEY_FAST);
#if 0
const MT_Point3& position = gameObj->NodeGetWorldPosition();
//const MT_Vector3& scale = gameObj->NodeGetWorldScaling();

View File

@@ -43,7 +43,6 @@ class RAS_MeshObject;
class RAS_IPolyMaterial;
class BL_InterpolatorList;
class BL_Material;
struct IpoCurve;
struct Main;
struct Scene;
@@ -74,9 +73,6 @@ class KX_BlenderSceneConverter : public KX_ISceneConverter
bool m_usemat;
bool m_useglslmat;
void localDel_ipoCurve ( IpoCurve * icu );
// struct Ipo* findIpoForName(char* objName);
public:
KX_BlenderSceneConverter(
Main* maggie,

View File

@@ -710,8 +710,8 @@ bool GPG_Application::startEngine(void)
// Set the animation playback rate for ipo's and actions
// the framerate below should patch with FPS macro defined in blendef.h
// Could be in StartEngine set the framerate, we need the scene to do this
// XXX m_ketsjiengine->SetAnimFrameRate( (((double) scene->r.frs_sec) / scene->r.frs_sec_base) );
Scene *scene= startscene->GetBlenderScene(); // needed for macro
m_ketsjiengine->SetAnimFrameRate(FPS);
}
if (!m_engineRunning)

View File

@@ -154,7 +154,7 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system)
m_showBackground(false),
m_show_debug_properties(false),
m_game2ipo(false),
m_animation_record(false),
// Default behavior is to hide the cursor every frame.
m_hideCursor(false),
@@ -398,7 +398,7 @@ void KX_KetsjiEngine::StartEngine(bool clearIpo)
m_maxPhysicsFrame = 5;
}
if (m_game2ipo)
if (m_animation_record)
{
m_sceneconverter->ResetPhysicsObjectsAnimationIpo(clearIpo);
m_sceneconverter->WritePhysicsObjectToAnimationIpo(m_currentFrame);
@@ -657,7 +657,7 @@ else
scene->UpdateParents(m_frameTime);
if (m_game2ipo)
if (m_animation_record)
{
m_sceneconverter->WritePhysicsObjectToAnimationIpo(++m_currentFrame);
}
@@ -1334,7 +1334,7 @@ void KX_KetsjiEngine::StopEngine()
if (m_bInitialized)
{
if (m_game2ipo)
if (m_animation_record)
{
// printf("TestHandlesPhysicsObjectToAnimationIpo\n");
m_sceneconverter->TestHandlesPhysicsObjectToAnimationIpo();
@@ -1734,10 +1734,10 @@ void KX_KetsjiEngine::SetUseFixedTime(bool bUseFixedTime)
}
void KX_KetsjiEngine::SetGame2IpoMode(bool game2ipo,int startFrame)
void KX_KetsjiEngine::SetAnimRecordMode(bool animation_record, int startFrame)
{
m_game2ipo = game2ipo;
if (game2ipo)
m_animation_record = animation_record;
if (animation_record)
{
//when recording physics keyframes, always run at a fixed framerate
m_bFixedTime = true;

View File

@@ -170,7 +170,7 @@ private:
bool m_show_debug_properties;
/** record physics into keyframes */
bool m_game2ipo;
bool m_animation_record;
/** Hide cursor every frame? */
bool m_hideCursor;
@@ -208,7 +208,7 @@ public:
PyObject* GetPyNamespace(){return m_pythondictionary;};
#endif
void SetSceneConverter(KX_ISceneConverter* sceneconverter);
void SetGame2IpoMode(bool game2ipo,int startFrame);
void SetAnimRecordMode(bool animation_record, int startFrame);
RAS_IRasterizer* GetRasterizer(){return m_rasterizer;};
RAS_ICanvas* GetCanvas(){return m_canvas;};