25 static color Color_xparent;
31 #define MAX_ANIM_INSTANCES 25
57 list_append(&anim_free_list, &anim_render_instance[i]);
119 aps->anim_info = a_info;
122 aps->base_w = base_w;
123 aps->base_h = base_h;
125 aps->stop_at = a_info->total_frames - 1;
127 aps->world_pos = NULL;
129 aps->framerate_independent = 0;
131 aps->skip_frames = 1;
156 Assert( instance != &anim_free_list );
177 instance->
x = aps->
x;
178 instance->
y = aps->
y;
192 if ( aps->
color == NULL ){
221 while (idx < instance->parent->num_keys) {
222 if (key == frame_num)
256 int bitmap_id, bitmap_flags=0, new_frame_num, frame_diff=0,
i, n_frames=0,frame_save;
257 float percent_through, time;
262 Assert( instance != NULL );
277 new_frame_num = instance->
start_at - 1 +
fl2i(percent_through * n_frames + 0.5
f);
279 new_frame_num = instance->
start_at - 1 -
fl2i(percent_through * n_frames + 0.5
f);
296 if( new_frame_num < instance->last_frame_num) {
310 if ( new_frame_num < instance->last_frame_num) {
395 if ( frame_diff > 0 ) {
399 for (
i = 0;
i < frame_diff;
i++ ) {
412 int temp_file_offset = -1;
435 if ( (temp == NULL) && (temp_file_offset < 0) ) {
466 if ( frame_diff == 0 && instance->
last_bitmap != -1 ) {
476 if ( bitmap_id == -1 ) {
502 gr_set_screen_scale(old_max_w_unscaled, old_max_h_unscaled, old_max_w_unscaled_zoomed, old_max_h_unscaled_zoomed);
540 Assert( instance != NULL );
542 if (instance->
frame != NULL)
545 instance->
frame = NULL;
578 if ( A->
screen_id == screen_id || screen_id == 0 ) {
615 Color_xparent.
red = 0;
616 Color_xparent.
green = 255;
617 Color_xparent.
blue = 0;
619 if ( ptr->
width == 0 ) {
650 int floor_size = (
int) pow(2.0, floor_pow);
651 int diff = ptr->
height - floor_size;
652 float waste = 100.0f *
float((floor_size - diff))/(2.0f *(
float)floor_size);
694 Assert( real_filename != NULL );
697 char *
p = strchr( name,
'.' );
816 anim *list, **prev_anim;
820 while (list && (list != ptr)) {
821 prev_anim = &list->
next;
837 if(ptr->
keys != NULL){
844 if (ptr->
cache != NULL) {
851 if (ptr->
data != NULL) {
857 *prev_anim = ptr->
next;
869 if ( ai->
frame == NULL )
902 char root_name[256], pcxname[256];
908 root_name[strlen(filename)-4] = 0;
911 if ( source_anim == NULL )
924 for ( j = 0; j < source_anim->
height; j++ ) {
925 row_data[j] = &ai->
frame[j*source_anim->
width];
952 int i, uncompressed, compressed, *key_frame_nums=NULL, tmp;
955 strcpy_s( filename, real_filename );
956 char *
p = strchr( filename,
'.' );
962 fp =
cfopen(filename,
"rb");
964 printf(
"Fatal error opening %s", filename);
971 Assert(key_frame_nums != NULL);
972 if (key_frame_nums == NULL)
975 for ( i = 0; i < A.
num_keys; i++ ) {
976 key_frame_nums[
i] = 0;
977 cfread(&key_frame_nums[i], 2, 1, fp);
981 cfread(&compressed, 4, 1, fp);
984 percent =
i2fl(compressed) / uncompressed * 100.0f;
986 printf(
"%% of uncompressed size: %.0f%%\n", percent);
987 printf(
"Width: %d\n", A.
width);
988 printf(
"Height: %d\n", A.
height);
992 printf(
"Key Frames: %d\n", A.
num_keys);
994 printf(
"key list: (");
995 for ( i = 0; i < A.
num_keys; i++ ) {
997 printf(
"%d, ", key_frame_nums[i]);
999 printf(
"%d)\n", key_frame_nums[i]);
1004 printf(
"FPS: %d\n", A.
fps);
1010 printf(
"ac version: %d\n", A.
version);
1012 if ( key_frame_nums != NULL ) {
1075 int absolute_offset;
1089 return parent->
cache[cache_offset];
1095 return parent->
cache[0];
int unpack_frame_from_file(anim_instance *ai, ubyte *frame, int size, ubyte *pal_translate, int aabitmap, int bpp)
Unpack frame from file.
int anim_playing(anim_instance *ai)
Return if an anim is playing or not.
int framerate_independent
int anim_write_frames_out(char *filename)
Write the frames of a .ani file out to disk as .pcx files.
#define GR_RESIZE_MENU_NO_OFFSET
anim_instance anim_free_list
int cfread(void *buf, int elsize, int nelem, CFILE *fp)
void anim_level_close()
Called after the end of a mission to clean up any mission dependent anim data.
void anim_set_palette(anim *ptr)
Set animation palette.
#define list_append(head, elem)
#define CFILE_MEMORY_MAPPED
#define Assertion(expr, msg,...)
#define END_OF_LIST(head)
void gr_set_screen_scale(int w, int h, int zoom_w, int zoom_h, int max_w, int max_h, int center_w, int center_h, bool force_stretch)
#define ANF_ALL_KEYFRAMES
#define ANIM_DIRECT_FORWARD
void gr_set_color_fast(color *dst)
void gr_set_bitmap(int bitmap_num, int alphablend_mode, int bitblt_mode, float alpha)
ubyte palette_translation[256]
unsigned char anim_instance_get_byte(anim_instance *ai, int offset)
void anim_release_all_instances(int screen_id)
Free all anim instances that are on the anim_render_list.
GLenum GLuint GLenum GLsizei const GLchar * buf
int bm_release(int handle, int clear_render_targets)
Frees both a bitmap's data and it's associated slot.
void BM_SELECT_TEX_FORMAT()
Sets bm_set_components and bm_get_components to reference texture format functions.
#define BMP_AABITMAP
antialiased bitmap
__inline void gr_set_clip(int x, int y, int w, int h, int resize_mode=GR_RESIZE_FULL)
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
anim_instance anim_render_list
void anim_unpause(anim_instance *ai)
GLdouble GLdouble GLdouble r
void anim_release_render_instance(anim_instance *instance)
Free a particular animation instance that is on the anim_render_list. Do not call this function to fr...
void anim_level_init()
Called at the beginning of a mission to initialize any mission dependent anim data.
sprintf(buf,"(%f,%f,%f)", v3->xyz.x, v3->xyz.y, v3->xyz.z)
int anim_free(anim *ptr)
Free an animation that was loaded with anim_load().
ubyte g3_rotate_vertex(vertex *dest, const vec3d *src)
int Anim_ignore_frametime
#define MONITOR(function_name)
short cfread_short(CFILE *file, int ver, short deflt)
void anim_init()
Initialise animation.
void anim_render_all(int screen_id, float frametime)
Display the frames for the currently playing anims.
ubyte * unpack_frame(anim_instance *ai, ubyte *ptr, ubyte *frame, int size, ubyte *pal_translate, int aabitmap, int bpp)
Unpack frame.
GLint GLint GLint GLint GLint x
#define MONITOR_INC(function_name, inc)
int bm_create(int bpp, int w, int h, void *data, int flags)
void anim_ignore_next_frametime()
anim_instance * anim_play(anim_play_struct *aps)
Will add an anim instance to the anim_render_list. This will cause the anim to be played at the x...
#define MAX_ANIM_INSTANCES
ubyte cfread_ubyte(CFILE *file, int ver, ubyte deflt)
typedef void(APIENTRY *PFNGLARRAYELEMENTEXTPROC)(GLint i)
GLuint const GLchar * name
int max_w_unscaled_zoomed
int Anim_inited
Global variable to pause the playing back of anims.
typedef float(SCP_EXT_CALLCONV *SCPTRACKIR_PFFLOATVOID)()
void anim_read_header(anim *ptr, CFILE *fp)
void anim_play_init(anim_play_struct *aps, anim *a_info, int x, int y, int base_w, int base_h)
Setup an anim_play_struct for passing into anim_play().
ubyte * anim_get_next_raw_buffer(anim_instance *inst, int xlate_pal, int aabitmap, int bpp)
#define ANIM_DIRECT_REVERSE
int framerate_independent
fix timer_get_fixed_seconds()
void anim_reverse_direction(anim_instance *ai)
__inline void gr_aabitmap(int x, int y, int resize_mode=GR_RESIZE_FULL, bool mirror=false)
#define TMAP_FLAG_TEXTURED
int anim_instance_is_streamed(anim_instance *ai)
int g3_draw_bitmap(vertex *pos, int orient, float radius, uint tmap_flags, float depth=0.0f)
#define list_remove(head, elem)
int anim_show_next_frame(anim_instance *instance, float frametime)
This function is called to blit the next frame of an anim instance to the screen. This is normally ca...
#define ANI_STREAM_CACHE_SIZE
void anim_display_info(char *real_filename)
Display information and statistics about a .ani file.
void gr_bitmap(int _x, int _y, int resize_mode)
anim_instance * init_anim_instance(anim *ptr, int bpp)
void * cf_returndata(CFILE *cfile)
void anim_render_one(int screen_id, anim_instance *ani, float frametime)
Display the frames for the passed animation.
int cfclose(CFILE *cfile)
anim_instance anim_render_instance[MAX_ANIM_INSTANCES]
int pcx_write_bitmap(const char *real_filename, int w, int h, ubyte **row_ptrs, ubyte *palette)
void anim_pause(anim_instance *ai)
int anim_stop_playing(anim_instance *instance)
Stop an anim instance that is on the anim_render_list from playing.
int max_h_unscaled_zoomed
anim * anim_load(char *real_filename, int cf_dir_type, int file_mapped)
Load an animation. This stores the compressed data, which instances of the animation can reference...
void BM_SELECT_SCREEN_FORMAT()
Sets bm_set_components and bm_get_components to reference screen format functions.
int cfseek(CFILE *fp, int offset, int where)
void anim_check_for_palette_change(anim_instance *instance)