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 */
};
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) */
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);