From: Andreas Eversberg Date: Sun, 29 Apr 2018 18:39:41 +0000 (+0200) Subject: Add option make make planets perfectly round X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=mercenary-reloaded.git;a=commitdiff_plain;h=22147ca0c055331b4c9eed97852d9d74e879e136 Add option make make planets perfectly round --- diff --git a/src/mercenary/main.c b/src/mercenary/main.c index 1b3656d..b6b59be 100644 --- a/src/mercenary/main.c +++ b/src/mercenary/main.c @@ -83,6 +83,7 @@ static int config_improve_extend_roads = 1; /* set to 1 to extend roads */ static int config_improve_smooth_planets = 1; /* set to 1 to rotate planets smoothly */ static int config_improve_stars_rotation = 1; /* set to 1 to improve star rendering */ static int config_improve_fix_sky_rotation = 0; /* set to 1 to fix sky rotation */ +static int config_improve_round_planets = 0; /* set to 1 to make planets exactly round */ #define CPU_SPEED 7093790.0; @@ -186,6 +187,11 @@ int parse_args(int argc, char *argv[]) print_info(" fixed by rotating all sky object by 180 degrees. The original (wrong)\n"); print_info(" rotation is default, because it preserves the game's spirit!\n"); print_info(" This option requires OpenGL rendering. (default = %d)\n", config_improve_fix_sky_rotation); + print_info(" --round-planets 1 | 0\n"); + print_info(" The original game renders planets and explosion debris horizontally\n"); + print_info(" stretched. This compensates the vertical stretch of NTSC vs PAL video.\n"); + print_info(" The original (stretched) sphere makes the game authentic.\n"); + print_info(" This option requires OpenGL rendering. (default = %d)\n", config_improve_round_planets); print_info("Debug options:\n"); print_info(" -o --debug-opengl\n"); print_info(" Use split screen to display both Amiga and OpenGL rendering.\n"); @@ -312,6 +318,12 @@ illegal_parameter: goto missing_parameter; config_improve_fix_sky_rotation = atoi(argv[i]); } else + if (!strcmp(argv[i], "--round-planets")) { + i++; + if (argc == i) + goto missing_parameter; + config_improve_round_planets = atoi(argv[i]); + } else if (!strcmp(argv[i], "-o") || !strcmp(argv[i], "--debug-opengl")) { config_debug_opengl = 1; } else @@ -718,7 +730,7 @@ static void main_loop(void) frame_render = 0; /* start capturing for improved graphics */ if (render_improved) - render_capture_start(config_fov, config_improve_extend_roads, config_improve_smooth_planets, config_improve_stars_rotation, config_improve_fix_sky_rotation, config_debug_transparent); + render_capture_start(config_fov, config_improve_extend_roads, config_improve_smooth_planets, config_improve_stars_rotation, config_improve_fix_sky_rotation, config_improve_round_planets, config_debug_transparent); /* execute until the rendered image is ready (wait for VBL) */ cycle_count = 0; diff --git a/src/mercenary/render.c b/src/mercenary/render.c index 1c845b5..31190ea 100644 --- a/src/mercenary/render.c +++ b/src/mercenary/render.c @@ -59,9 +59,9 @@ #define MAX_MOVING_OBJECTS 16 /* maximum number of moving objects (used for interpolation) */ #define MAX_EXPLOSION 256 /* how many explosion particles can be stored in one object */ #define PLANET_VERTICES 128 -#define PLANET_ELIPSE 1.17 +#define PLANET_STRETCH 1.19 /* stretch horizontally (this compensates NTSC/PAL line ratio of 625/525)*/ #define EXPLOSION_VERTICES 16 -#define EXPLOSION_ELIPSE 1.17 +#define EXPLOSION_STRETCH 1.19 /* as above */ #define SIGHT_DIST 78.74 /* distanc of sights in inch */ #define FIX_OBJECT_SCALE 16 @@ -240,6 +240,7 @@ typedef struct interpolation { static int extend_roads; /* extend roads in its original width, rather than just using a single point */ static int improve_stars; /* stars are rendered spherical */ static int fix_sky_rotation; /* sky will rotate correctly by rotating planets/comet by 180 degrees */ +static double planet_aspect, explosion_aspect; /* aspect ratio */ static double fov; static double debug_opacity; static double frustum_slope_64, frustum_slope_fov; @@ -291,7 +292,7 @@ static void flush_old_items(void) } /* rendering starts, initialize variables */ -void render_capture_start(double _fov, int _extend_roads, int _smooth_planets, int _improve_stars, int _fix_sky_rotation, int debug) +void render_capture_start(double _fov, int _extend_roads, int _smooth_planets, int _improve_stars, int _fix_sky_rotation, int _round_planets, int debug) { #if defined(DEBUG_COLOR) || defined(DEBUG_VERTEX) printf("start rendering a new frame...\n"); @@ -313,6 +314,8 @@ void render_capture_start(double _fov, int _extend_roads, int _smooth_planets, i extend_roads = _extend_roads; fix_sky_rotation = _fix_sky_rotation; improve_stars = _improve_stars; + planet_aspect = (_round_planets) ? 1.0 : PLANET_STRETCH; + explosion_aspect = (_round_planets) ? 1.0 : EXPLOSION_STRETCH; /* set some transpareny, if debugging is enabled */ debug_opacity = (debug) ? 0.5 : 1.0; @@ -2233,7 +2236,7 @@ void render_one_item(render_item_t *render_item, int vr) for (i = 0; i < PLANET_VERTICES; i++) { _sin = size * sin(2.0 * M_PI * (double)i / PLANET_VERTICES); _cos = size * cos(2.0 * M_PI * (double)i / PLANET_VERTICES); - circle_x[i] = _sin * PLANET_ELIPSE; + circle_x[i] = _sin * planet_aspect; circle_y[i] = _cos; circle_z[i] = 0.0; crescent_x[i] = circle_x[i] * crescent; @@ -2249,7 +2252,7 @@ void render_one_item(render_item_t *render_item, int vr) for (i = 0; i < PLANET_VERTICES; i++) { _sin = size * sin(2.0 * M_PI * (double)i / PLANET_VERTICES); _cos = size * cos(2.0 * M_PI * (double)i / PLANET_VERTICES); - circle_x[i] = _sin * PLANET_ELIPSE; + circle_x[i] = _sin * planet_aspect; circle_y[i] = _cos; circle_z[i] = 0.0; crescent_x[i] = circle_x[i] * crescent; @@ -2536,7 +2539,7 @@ void render_one_item(render_item_t *render_item, int vr) size = render_item->u.explosion.size[e] * (fabs(loc_z) / 256.0); /* create and render cicle */ for (i = 0; i < EXPLOSION_VERTICES; i++) { - x[i] = loc_x + size * sin(2 * M_PI * (double)i / EXPLOSION_VERTICES) * EXPLOSION_ELIPSE; + x[i] = loc_x + size * sin(2 * M_PI * (double)i / EXPLOSION_VERTICES) * explosion_aspect; y[i] = loc_y + size * cos(2 * M_PI * (double)i / EXPLOSION_VERTICES); z[i] = loc_z; } diff --git a/src/mercenary/render.h b/src/mercenary/render.h index 8766c35..d563208 100644 --- a/src/mercenary/render.h +++ b/src/mercenary/render.h @@ -1,5 +1,5 @@ -void render_capture_start(double _fov, int _extend_roads, int _smooth_planets, int _improve_stars, int _fix_sky_rotation, int debug); +void render_capture_start(double _fov, int _extend_roads, int _smooth_planets, int _improve_stars, int _fix_sky_rotation, int _round_planets, int debug); void render_capture_stop(void); void render_capture_event(int event); int render_all_items(double inter, int vr);