X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=erebus2020;a=blobdiff_plain;f=liberebus%2Fsrc%2Ferebus.h;h=758e4d3033a2fa3fea2eec298cb87a90aab01277;hp=e6e067b338375a16fb8e4728694ec38dcfe380a9;hb=HEAD;hpb=11a8b7dc9f82d6ed298cb18c94b8053c41832fa1 diff --git a/liberebus/src/erebus.h b/liberebus/src/erebus.h index e6e067b..758e4d3 100644 --- a/liberebus/src/erebus.h +++ b/liberebus/src/erebus.h @@ -26,10 +26,32 @@ struct erb_aabb { cgm_vec3 pos, sz; }; +struct erb_key { + long tm; + float val; +}; + +enum { + ERB_TRK_X, ERB_TRK_Y, ERB_TRK_Z, /* position (x,y,z) */ + ERB_TRK_QX, ERB_TRK_QY, ERB_TRK_QZ, ERB_TRK_QW, /* rotation quat (xi+yj+zk+w) */ + ERB_TRK_SX, ERB_TRK_SY, ERB_TRK_SZ, /* scaling (x,y,z) */ + ERB_NUM_TRACKS +}; +enum erb_interp { ERB_LINEAR, ERB_STEP, ERB_CUBIC }; +enum erb_extrap { ERB_CLAMP, ERB_EXTEND, ERB_REPEAT }; + +struct erb_track { + enum erb_interp interp; /* interpolation mode */ + enum erb_extrap extrap; /* extrapolation mode */ + struct erb_key *keys; /* dynamic array of keyframes */ + int num_keys, max_keys; /* max_keys: allocated size, num_keys: used */ +}; + struct erb_node { struct erb_node *par; /* parent node */ struct erb_node *clist; /* child nodes */ struct erb_surf *surflist; /* surfaces in this node */ + struct erb_track track[ERB_NUM_TRACKS]; /* PRS keyframe tracks */ float xform[16], inv_xform[16]; /* global transformation */ float node_xform[16], inv_node_xform[16]; /* local transformation */ }; @@ -72,6 +94,8 @@ void erb_destroy(struct erb_rend *erb); int erb_allocframe(struct erb_rend *erb, int width, int height); float *erb_getframe(struct erb_rend *erb); +void erb_setfov(struct erb_rend *erb, float vfov_deg); + /* clears the framebuffer and sample counters to begin rendering a new frame */ void erb_begin(struct erb_rend *erb); /* finalizes the frame, averaging samples (optional) */ @@ -96,8 +120,22 @@ int erb_node_addsurf(struct erb_node *n, struct erb_surf *s); int erb_node_rmsurf(struct erb_node *n, struct erb_surf *s); /* sets the transformation matrix and also calculates the inverse */ +void erb_node_pos(struct erb_node *n, long tm, float x, float y, float z); +void erb_node_rot(struct erb_node *n, long tm, float qx, float qy, float qz, float qw); +void erb_node_rot_axis(struct erb_node *n, long tm, float angle_deg, float x, float y, float z); +void erb_node_scale(struct erb_node *n, long tm, float sx, float sy, float sz); +/* calculates transformation matrices for time tm by keyframe interpolation */ +void erb_node_update(struct erb_node *n, long tm); +/* sets transformation, ignoring animation keyframes */ void erb_node_setxform(struct erb_node *n, float *mat); +void erb_node_eval_pos(struct erb_node *n, long tm, cgm_vec3 *pos); +void erb_node_eval_rot(struct erb_node *n, long tm, cgm_quat *rot); +void erb_node_eval_scale(struct erb_node *n, long tm, cgm_vec3 *scale); + +void erb_node_eval_matrix(struct erb_node *n, long tm, float *mat); /* mat[16] */ +void erb_node_eval_node_matrix(struct erb_node *n, long tm, float *mat); /* mat[16] */ + /* surfaces */ struct erb_surf *erb_surface(int datasz); void erb_free_surface(struct erb_surf *surf);