What object holds keyframes? What processes them?

I’m attempting to expand keyframes to store data setting game-properties, on top of just manipulating an object’s form. So far, I’ve found the code I need to inject into the keyframes, but I don’t know where keyframes are in the source. Any help in finding the keyframe objects, so that I can expand on what they store—and the processes that handle keyframes, so the new data is actually used—would be greatly appreciated.

can’t you utilize any of the existing ways to store data? there are game properties, IDProperties (like “Custom Properties” for the scene) and these properties?

// source/blender/editors/space_time/space_time.c 
time_main_area_draw(const bContext *C, ARegion *ar){
    SpaceTime *stime = CTX_wm_space_time(C);
    time_draw_keyframes(C, stime, ar);        // source/blender/editors/space_time/space_time.c
        Scene *scene = CTX_data_scene(C);
        Object *ob = CTX_data_active_object(C);
        View2D *v2d = &ar->v2d;
        short onlysel = (stime->flag & TIME_ONLYACTSEL);
        time_draw_idblock_keyframes(v2d, (ID *)scene, onlysel);
        time_draw_idblock_keyframes(v2d, (ID *)ob, onlysel);

// source/blender/makesdna/DNA_space_types.h 
struct SpaceTime
    SpaceLink *next, *prev;
    ListBase regionbase;        /* storage of regions for inactive spaces */
    int spacetype;
    float blockscale DNA_DEPRECATED;
    View2D v2d DNA_DEPRECATED;  /* deprecated, copied to region */
    ListBase caches;
    int cache_display;
    int flag;

Thank you for the assist, dirty-stick! I’ll trace the functions used there, to find an optimum injection-point. :slight_smile:

No, CoDEmanX, I can’t use the preexisting storage methods. Imagine a punch-animation, eh. During the wind-up the fist wouldn’t really do any damage. It has to be quickly moving forward. On the frame when the thrust starts, I want to have a keyframe where an attack-value in the fist (a game property) is set. At the end of the punch’s forward motion, the value could then be reset to 0 or whatever else. From what I can tell, such functionality does not exist.

i’m not familiar with BGE, but that really sounds like you should create a new prop for Object types and animate that values (will give you new keyframe points):

bpy.types.Object.attack_power = bpy.props.FloatProperty()

Or compute the velocity directly from fist location in world space (if it’s not already provided as BGE property)

Nah, I’m making a fighting-game, which means I’m dealing with a lot of arbitrary data (dozens, hundreds, if not thousands of actions with multiple unique features); and a shortcut here would reduce the workload by an order of magnitudes. :slight_smile:

Okay! It looks like the two objects I need are bAction and BL_ActionActuator!

What I’m shooting for is a simple dictionary in bAction that’s only handled by BL_ActionActuator’s Update() method. When the frame changes, the actuator will use the frame property as a key in the action’s dictionary: what will be held there is a vector of simple objects that define which property to set to what value.

It looks like bAction is written in C, so I can’t just cram the new data in there. Anyone have an idea of what I could do from here?

  • All ID blocks can have custom properties assigned to them (for example, a list of lists of lists of float/int/bool/string properties, etc.)
  • bAction blocks are also ID blocks

How would I go about assigning those properties in the editor? How would I access them in a game script? This would seriously save me a lot of time and effort~!

bpy.context.scene.animation_data_create()    # execute
bpy.context.scene.animation_data.                   # data

But is it accessible in a game?

i dont know BGE.
you can read animation_data and write animation_data to a data file.
depends what you want todo.

you said your making a fighting game, what part are you working on, collisions, combos, movement …

PROTIP: bpy is completely unusable in the BGE, to the chagrin of everyone.

The feature I’m making will be critical in each of those parts, and more. I’d write to a data-file, but the sheer volume of per-frame changes in every aspect of an object’s properties makes external storage unfeasible. I tried. ^^;

that sounds like a game loop, BGE must have some sort of memory storage.

It does, but nothing that can comfortably store the amount of data in a way where a fighting-game can use it. Just about every game engine out there is based on a “many objects/small amount of logic”-model, while fighting-games are just the opposite; a few objects, each with a TON of logic.

By implementing frame-based storage, Blender will gain a strength that will be wholly unique among 3D engines and immensely useful for any sort of action-game one is likely to make. :3