2011-12-10 13:25:22 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "IL/il.h"
|
|
|
|
#include "IL/ilu.h"
|
|
|
|
|
|
|
|
#include "shared/types.h"
|
2012-01-22 18:39:42 +00:00
|
|
|
|
2012-01-24 13:16:20 +00:00
|
|
|
#include "auto.h"
|
2012-02-21 13:41:02 +00:00
|
|
|
#include "color.h"
|
2012-01-24 13:16:20 +00:00
|
|
|
#include "system.h"
|
|
|
|
#include "camera.h"
|
|
|
|
#include "scenery.h"
|
|
|
|
#include "render.h"
|
2012-04-28 13:36:37 +00:00
|
|
|
#include "main.h"
|
|
|
|
|
2012-06-15 09:31:11 +00:00
|
|
|
#define APP_HEADER 198632.125
|
2011-12-10 13:25:22 +00:00
|
|
|
|
2011-12-23 22:39:13 +00:00
|
|
|
void paysagesInit()
|
2011-12-10 13:25:22 +00:00
|
|
|
{
|
2012-01-24 13:16:20 +00:00
|
|
|
CameraDefinition camera;
|
|
|
|
|
2012-01-07 16:53:23 +00:00
|
|
|
systemInit();
|
2011-12-10 13:25:22 +00:00
|
|
|
ilInit();
|
|
|
|
iluInit();
|
|
|
|
|
2012-01-24 13:16:20 +00:00
|
|
|
sceneryInit();
|
2012-01-22 18:39:42 +00:00
|
|
|
renderInit();
|
2011-12-18 21:59:33 +00:00
|
|
|
|
2012-01-24 13:16:20 +00:00
|
|
|
camera = cameraCreateDefinition();
|
|
|
|
cameraSetLocation(&camera, -12.0, 5.0, 2.0);
|
|
|
|
cameraSetTarget(&camera, 0.0, 5.0, 0.0);
|
2012-02-17 18:07:09 +00:00
|
|
|
cameraRotateYaw(&camera, 1.0);
|
2012-01-24 13:16:20 +00:00
|
|
|
scenerySetCamera(&camera);
|
|
|
|
cameraDeleteDefinition(&camera);
|
2012-01-23 23:45:33 +00:00
|
|
|
|
2011-12-10 13:25:22 +00:00
|
|
|
autoGenRealisticLandscape(0);
|
|
|
|
autoSetDaytime(8, 30);
|
2012-01-22 18:39:42 +00:00
|
|
|
|
2012-01-03 15:40:50 +00:00
|
|
|
// DEBUG
|
2012-06-15 09:31:11 +00:00
|
|
|
/*float last_height, height, x;
|
2012-01-03 15:40:50 +00:00
|
|
|
last_height = height = 0.0;
|
|
|
|
x = 0.0;
|
|
|
|
while (height <= 1.0 || height >= last_height || last_height < 0.1)
|
|
|
|
{
|
|
|
|
last_height = height;
|
|
|
|
height = terrainGetHeight(x, 0.0);
|
|
|
|
x += 0.1;
|
|
|
|
}
|
|
|
|
cameraSetLocation(x - 2.0, height, 0.0);
|
2012-01-05 11:32:14 +00:00
|
|
|
cameraSetTarget(x - 1.0, height, 0.0);*/
|
2011-12-10 13:25:22 +00:00
|
|
|
}
|
2012-01-22 18:39:42 +00:00
|
|
|
|
2012-02-12 16:57:29 +00:00
|
|
|
void paysagesQuit()
|
|
|
|
{
|
|
|
|
sceneryQuit();
|
|
|
|
renderQuit();
|
|
|
|
}
|
|
|
|
|
2012-04-28 13:36:37 +00:00
|
|
|
FileOperationResult paysagesSave(char* filepath)
|
2012-01-22 18:39:42 +00:00
|
|
|
{
|
2012-04-28 13:36:37 +00:00
|
|
|
PackStream* stream = packWriteFile(filepath);
|
2012-06-15 09:31:11 +00:00
|
|
|
float app_header, version_header;
|
2012-04-28 13:36:37 +00:00
|
|
|
|
|
|
|
if (!stream)
|
|
|
|
{
|
|
|
|
return FILE_OPERATION_IOERROR;
|
|
|
|
}
|
|
|
|
|
2012-06-15 09:31:11 +00:00
|
|
|
app_header = (float)APP_HEADER;
|
|
|
|
packWriteFloat(stream, &app_header);
|
|
|
|
version_header = (float)PAYSAGES_CURRENT_DATA_VERSION;
|
|
|
|
packWriteFloat(stream, &version_header);
|
2012-04-28 13:36:37 +00:00
|
|
|
|
|
|
|
scenerySave(stream);
|
|
|
|
|
|
|
|
packCloseStream(stream);
|
|
|
|
|
|
|
|
return FILE_OPERATION_OK;
|
2012-01-22 18:39:42 +00:00
|
|
|
}
|
|
|
|
|
2012-04-28 13:36:37 +00:00
|
|
|
FileOperationResult paysagesLoad(char* filepath)
|
2012-01-22 18:39:42 +00:00
|
|
|
{
|
2012-04-28 13:36:37 +00:00
|
|
|
PackStream* stream = packReadFile(filepath);
|
2012-06-15 09:31:11 +00:00
|
|
|
float app_header, version_header;
|
2012-04-28 13:36:37 +00:00
|
|
|
|
|
|
|
if (!stream)
|
|
|
|
{
|
|
|
|
return FILE_OPERATION_IOERROR;
|
|
|
|
}
|
|
|
|
|
2012-06-15 09:31:11 +00:00
|
|
|
packReadFloat(stream, &app_header);
|
2012-04-28 13:36:37 +00:00
|
|
|
if (app_header != APP_HEADER)
|
|
|
|
{
|
|
|
|
packCloseStream(stream);
|
|
|
|
return FILE_OPERATION_APP_MISMATCH;
|
|
|
|
}
|
|
|
|
|
2012-06-15 09:31:11 +00:00
|
|
|
packReadFloat(stream, &version_header);
|
2012-04-28 13:36:37 +00:00
|
|
|
if ((int)version_header != PAYSAGES_CURRENT_DATA_VERSION)
|
|
|
|
{
|
|
|
|
packCloseStream(stream);
|
|
|
|
return FILE_OPERATION_VERSION_MISMATCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
sceneryLoad(stream);
|
|
|
|
|
|
|
|
packCloseStream(stream);
|
|
|
|
|
|
|
|
return FILE_OPERATION_OK;
|
2012-01-22 18:39:42 +00:00
|
|
|
}
|