2012-01-10 20:51:27 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
2012-01-11 16:11:34 +00:00
|
|
|
#include <string.h>
|
2012-01-10 20:51:27 +00:00
|
|
|
|
2012-01-24 13:16:20 +00:00
|
|
|
#include "../lib_paysages/auto.h"
|
2012-01-29 21:45:58 +00:00
|
|
|
#include "../lib_paysages/main.h"
|
2012-01-24 13:16:20 +00:00
|
|
|
#include "../lib_paysages/render.h"
|
|
|
|
#include "../lib_paysages/scenery.h"
|
2012-01-10 20:51:27 +00:00
|
|
|
|
2012-01-29 21:45:58 +00:00
|
|
|
void startRender(Renderer* renderer, char* outputpath, int width, int height, int quality)
|
2012-01-11 16:11:34 +00:00
|
|
|
{
|
|
|
|
printf("\rRendering %s ... \n", outputpath);
|
2012-01-29 21:45:58 +00:00
|
|
|
rendererStart(renderer, width, height, quality);
|
2012-01-11 16:11:34 +00:00
|
|
|
printf("\rSaving %s ... \n", outputpath);
|
|
|
|
remove(outputpath);
|
2012-01-29 21:45:58 +00:00
|
|
|
renderSaveToFile(renderer->render_area, outputpath);
|
2012-01-11 16:11:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void displayHelp()
|
|
|
|
{
|
|
|
|
printf("Usage : TODO\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void _previewUpdate(double progress)
|
|
|
|
{
|
|
|
|
printf("\rProgress : %0.1f%% ", progress * 100.0);
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
|
2012-01-10 20:51:27 +00:00
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2012-01-24 13:16:20 +00:00
|
|
|
Renderer renderer;
|
2012-01-11 16:11:34 +00:00
|
|
|
int conf_render_width = 800;
|
|
|
|
int conf_render_height = 600;
|
|
|
|
int conf_render_quality = 5;
|
|
|
|
int conf_nb_pictures = 1;
|
|
|
|
double conf_daytime_start = 0.4;
|
|
|
|
double conf_daytime_step = 0.0;
|
|
|
|
int outputcount;
|
|
|
|
char outputpath[500];
|
2012-01-24 13:16:20 +00:00
|
|
|
|
2012-01-11 16:11:34 +00:00
|
|
|
argc--;
|
|
|
|
argv++;
|
2012-01-24 13:16:20 +00:00
|
|
|
|
2012-01-11 16:11:34 +00:00
|
|
|
while (argc--)
|
|
|
|
{
|
|
|
|
if (strcmp(*argv, "-h") == 0 || strcmp(*argv, "--help") == 0)
|
|
|
|
{
|
|
|
|
displayHelp();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if (strcmp(*argv, "-n") == 0 || strcmp(*argv, "--count") == 0)
|
|
|
|
{
|
|
|
|
if (argc--)
|
|
|
|
{
|
|
|
|
conf_nb_pictures = atoi(*(++argv));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strcmp(*argv, "-rw") == 0 || strcmp(*argv, "--width") == 0)
|
|
|
|
{
|
|
|
|
if (argc--)
|
|
|
|
{
|
|
|
|
conf_render_width = atoi(*(++argv));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strcmp(*argv, "-rh") == 0 || strcmp(*argv, "--height") == 0)
|
|
|
|
{
|
|
|
|
if (argc--)
|
|
|
|
{
|
|
|
|
conf_render_height = atoi(*(++argv));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strcmp(*argv, "-rq") == 0 || strcmp(*argv, "--quality") == 0)
|
|
|
|
{
|
|
|
|
if (argc--)
|
|
|
|
{
|
|
|
|
conf_render_quality = atoi(*(++argv));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strcmp(*argv, "-di") == 0 || strcmp(*argv, "--daystart") == 0)
|
|
|
|
{
|
|
|
|
if (argc--)
|
|
|
|
{
|
|
|
|
conf_daytime_start = atof(*(++argv));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strcmp(*argv, "-ds") == 0 || strcmp(*argv, "--daystep") == 0)
|
|
|
|
{
|
|
|
|
if (argc--)
|
|
|
|
{
|
|
|
|
conf_daytime_step = atof(*(++argv));
|
|
|
|
}
|
|
|
|
}
|
2012-01-24 13:16:20 +00:00
|
|
|
|
2012-01-11 16:11:34 +00:00
|
|
|
argv++;
|
|
|
|
}
|
2012-01-24 13:16:20 +00:00
|
|
|
|
2012-01-11 16:11:34 +00:00
|
|
|
printf("Initializing ...\n");
|
2012-01-10 20:51:27 +00:00
|
|
|
paysagesInit();
|
2012-01-24 13:16:20 +00:00
|
|
|
|
2012-01-29 21:45:58 +00:00
|
|
|
renderer = sceneryCreateStandardRenderer();
|
|
|
|
rendererSetPreviewCallbacks(&renderer, NULL, NULL, _previewUpdate);
|
2012-01-24 13:16:20 +00:00
|
|
|
|
2012-01-11 16:11:34 +00:00
|
|
|
for (outputcount = 0; outputcount < conf_nb_pictures; outputcount++)
|
|
|
|
{
|
|
|
|
autoSetDaytimeFraction(conf_daytime_start);
|
2012-01-24 13:16:20 +00:00
|
|
|
|
2012-01-11 16:11:34 +00:00
|
|
|
sprintf(outputpath, "output/pic%05d.png", outputcount);
|
2012-01-29 21:45:58 +00:00
|
|
|
startRender(&renderer, outputpath, conf_render_width, conf_render_height, conf_render_quality);
|
2012-01-24 13:16:20 +00:00
|
|
|
|
2012-01-11 16:11:34 +00:00
|
|
|
conf_daytime_start += conf_daytime_step;
|
|
|
|
}
|
2012-01-29 21:45:58 +00:00
|
|
|
|
2012-02-12 16:57:29 +00:00
|
|
|
printf("Cleaning up ...\n");
|
2012-01-29 21:45:58 +00:00
|
|
|
rendererDelete(&renderer);
|
2012-02-12 16:57:29 +00:00
|
|
|
paysagesQuit();
|
2012-01-24 13:16:20 +00:00
|
|
|
|
2012-01-11 16:11:34 +00:00
|
|
|
printf("\rDone. \n");
|
2012-01-24 13:16:20 +00:00
|
|
|
|
2012-01-10 20:51:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|