dark-hammer / include / engine / anim.h

The branch '0.4.7' does not exist.
/***********************************************************************************
 * Copyright (c) 2013, Sepehr Taghdisian
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 *
 * - Redistributions of source code must retain the above copyright notice, 
 *   this list of conditions and the following disclaimer.
 * - Redistributions in binary form must reproduce the above copyright notice,
 *   this list of conditions and the following disclaimer in the documentation 
 *   and/or other materials provided with the distribution.
 *
 ***********************************************************************************/

#ifndef __ANIM_H__
#define __ANIM_H__

#include "core/types.h"
#include "core/vec-math.h"
#include "core/hash-table.h"
#include "cmp-types.h"

enum anim_flags
{
    ANIM_LOOP = (1<<0), /* animation is looped */
    ANIM_SCALE = (1<<1) /* animation has scale values */
};

struct ALIGN16 anim_pose
{
    struct vec4f pos_scale; /* w = uniform_scale */
    struct quat4f rot;
};

/* poses for one frame. each element in 'poses' array should match element(s) in ..
 * xforms of hierarchy mesh or poses in skeleton
 */
struct anim_channel
{
    struct anim_pose* poses;    /* count: anim_clip.pose_cnt */
};

/* clip: series of frames and channel data */
struct anim_clip
{
    char name[32];
    uint32 fps;
    uint32 frame_cnt;
    fl32 duration;
    fl32 ft;
    uint32 flags;   /* combination of enum anim_flags */
    uint32 pose_cnt;
    char* binds;   /* maps each joint/node to binded hierarchy/skeleton nodes. size: char(32)*pose_cnt */
    struct anim_channel* channels;  /* count: frame_cnt */
    struct allocator* alloc;
};

/* sets of animation clips 
 * long clips can be divided into subclips for better referencing
 * for example an animation clip (loaded form file) can contain 'walk', 'attack', 'bend-over' subclips */
struct anim_subclip
{
    char name[32];
    uint32 frame_start; /* must be < subclip->frame_end */
    uint32 frame_end;   /* must be <= clip->frame_cnt */
};

struct anim_set
{
    struct allocator* alloc;
    reshandle_t clip_hdl;
    uint32 subclip_cnt;
    struct anim_subclip* subclips;
    struct hashtable_fixed table;    /* key: name_hash, value: clip_id */
};

/*************************************************************************************************/
/* animation clip: keyframe bank */
struct anim_clip* anim_loadh3da(struct allocator* alloc, const char* h3da_filepath, 
    uint32 thread_id);
void anim_unload(struct anim_clip* clip);

/* animation set: clip bank */ 
struct anim_set* anim_create_animset(struct allocator* alloc, struct allocator* tmp_alloc, 
    const char* animset_json, reshandle_t clip_hdl);
void anim_destroy_animset(struct anim_set* animset);

void anim_update_clip_hierarchal(struct anim_clip* clip, fl32 t, const uint32* bindmap, 
    const cmphandle_t* xforms, bool_t looped);

#endif /* __ANIM_H__ */
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.