paysages: Added file 'app' and 'version' headers.

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@309 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2012-04-28 13:36:37 +00:00 committed by ThunderK
parent fcce20217e
commit 79e687bd09
7 changed files with 177 additions and 46 deletions

9
TODO
View file

@ -1,7 +1,8 @@
Technology Preview 2 : Technology Preview 2 :
- Render tab previews should not rerender when changing render options. - Render tab previews should not rerender when changing render options.
- Compute shadows only once for all textures at a same location. - Compute shadows only once for all textures at a same location (need an intermediary light status).
- Add antialiasing option (pay attention to memory usage). - Add layer sorting/naming.
- Save GUI config (views, render params).
- Add an OSD ability on previews and use it for camera location and user landmarks. - Add an OSD ability on previews and use it for camera location and user landmarks.
- Add a material editor dialog. - Add a material editor dialog.
- Add a zone editor dialog for localized textures. - Add a zone editor dialog for localized textures.
@ -9,13 +10,13 @@ Technology Preview 2 :
- Add a noise filler (and maybe noise intervals ?). - Add a noise filler (and maybe noise intervals ?).
- Improve curve editor. - Improve curve editor.
- Water and terrain LOD moves with the camera, fix it like in the wanderer. - Water and terrain LOD moves with the camera, fix it like in the wanderer.
- Implement a file header/versioning. - More threading in previews and layered previews (with a less detailed layer in the background).
Technology Preview 3 : Technology Preview 3 :
- Restore render progress. - Restore render progress.
- Add antialiasing option (pay attention to memory usage).
- Add basic vegetation system (not sure). - Add basic vegetation system (not sure).
- Improve sky rendering (colors and light halo). - Improve sky rendering (colors and light halo).
- Add rendering steps in small previews (not sure).
Release Candidate : Release Candidate :
- Polish all features and UI. - Polish all features and UI.

View file

@ -64,7 +64,7 @@ int main(int argc, char** argv)
} }
MainWindow::MainWindow(QWidget *parent) : MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent) QMainWindow(parent)
{ {
BaseForm* form; BaseForm* form;
QTabWidget* tabs; QTabWidget* tabs;
@ -154,7 +154,18 @@ void MainWindow::fileSave()
{ {
filepath = filepath.append(".p3d"); filepath = filepath.append(".p3d");
} }
paysagesSave((char*)filepath.toStdString().c_str());
FileOperationResult result = paysagesSave((char*) filepath.toStdString().c_str());
switch (result)
{
case FILE_OPERATION_OK:
break;
case FILE_OPERATION_IOERROR:
QMessageBox::critical(this, tr("Paysages 3D - File saving error"), tr("Can't write specified file : %1").arg(filepath));
break;
default:
QMessageBox::critical(this, tr("Paysages 3D - File saving error"), tr("Unexpected error while saving file : %1").arg(filepath));
}
} }
} }
@ -165,15 +176,31 @@ void MainWindow::fileLoad()
QString filepath = QFileDialog::getOpenFileName(this, tr("Paysages 3D - Choose a scenery file to load"), QString(), tr("Paysages 3D Scenery (*.p3d)")); QString filepath = QFileDialog::getOpenFileName(this, tr("Paysages 3D - Choose a scenery file to load"), QString(), tr("Paysages 3D Scenery (*.p3d)"));
if (!filepath.isNull()) if (!filepath.isNull())
{ {
paysagesLoad((char*)filepath.toStdString().c_str()); FileOperationResult result = paysagesLoad((char*) filepath.toStdString().c_str());
refreshAll(); switch (result)
{
case FILE_OPERATION_OK:
refreshAll();
break;
case FILE_OPERATION_IOERROR:
QMessageBox::critical(this, tr("Paysages 3D - File loading error"), tr("Can't read specified file : %1").arg(filepath));
break;
case FILE_OPERATION_APP_MISMATCH:
QMessageBox::critical(this, tr("Paysages 3D - File loading error"), tr("This file doesn't look like a Paysages 3D file : %1").arg(filepath));
break;
case FILE_OPERATION_VERSION_MISMATCH:
QMessageBox::critical(this, tr("Paysages 3D - File loading error"), tr("This file was created with an incompatible Paysages 3D version : %1").arg(filepath));
break;
default:
QMessageBox::critical(this, tr("Paysages 3D - File loading error"), tr("Unexpected error while loading file : %1").arg(filepath));
}
} }
} }
} }
void MainWindow::showAboutDialog() void MainWindow::showAboutDialog()
{ {
QMessageBox::about(this, tr("Paysages 3D"), tr("A 3D landscape editing and rendering software.\n\nCredits :\nProgramming - Michael Lemaire")); QMessageBox::about(this, tr("Paysages 3D"), tr("A 3D landscape editing and rendering software.\n\nAuthors :\nProgramming - Michael Lemaire\n\nQt - http://qt.nokia.com/\nDevIL - http://openil.sourceforge.net/\nGLib - http://www.gtk.org/\n"));
} }
void MainWindow::quickPreview() void MainWindow::quickPreview()

View file

@ -772,25 +772,82 @@ rapide (F5)</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="150"/> <location filename="../gui_qt/mainwindow.cpp" line="150"/>
<location filename="../gui_qt/mainwindow.cpp" line="165"/> <location filename="../gui_qt/mainwindow.cpp" line="176"/>
<source>Paysages 3D Scenery (*.p3d)</source> <source>Paysages 3D Scenery (*.p3d)</source>
<translation>Scène Paysages 3D (*.p3d)</translation> <translation>Scène Paysages 3D (*.p3d)</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="163"/> <location filename="../gui_qt/mainwindow.cpp" line="164"/>
<location filename="../gui_qt/mainwindow.cpp" line="167"/>
<source>Paysages 3D - File saving error</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="164"/>
<source>Can&apos;t write specified file : %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="167"/>
<source>Unexpected error while saving file : %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="174"/>
<source>Do you want to load a scenery from file ? Any unsaved changes will be lost.</source> <source>Do you want to load a scenery from file ? Any unsaved changes will be lost.</source>
<translation>Voulez-vous charger une scène ? Les modifications nons sauvegardées seront perdues.</translation> <translation>Voulez-vous charger une scène ? Les modifications nons sauvegardées seront perdues.</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="163"/> <location filename="../gui_qt/mainwindow.cpp" line="174"/>
<source>Paysages 3D - Load scenery</source> <source>Paysages 3D - Load scenery</source>
<translation>Paysages 3D - Charger une scène</translation> <translation>Paysages 3D - Charger une scène</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="165"/> <location filename="../gui_qt/mainwindow.cpp" line="176"/>
<source>Paysages 3D - Choose a scenery file to load</source> <source>Paysages 3D - Choose a scenery file to load</source>
<translation>Paysages 3D - Choisissez un fichier de scène à charger</translation> <translation>Paysages 3D - Choisissez un fichier de scène à charger</translation>
</message> </message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="186"/>
<location filename="../gui_qt/mainwindow.cpp" line="189"/>
<location filename="../gui_qt/mainwindow.cpp" line="192"/>
<location filename="../gui_qt/mainwindow.cpp" line="195"/>
<source>Paysages 3D - File loading error</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="186"/>
<source>Can&apos;t read specified file : %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="189"/>
<source>This file doesn&apos;t look like a Paysages 3D file : %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="192"/>
<source>This file was created with an incompatible Paysages 3D version : %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="195"/>
<source>Unexpected error while loading file : %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="203"/>
<source>A 3D landscape editing and rendering software.
Authors :
Programming - Michael Lemaire
Qt - http://qt.nokia.com/
DevIL - http://openil.sourceforge.net/
GLib - http://www.gtk.org/
</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="88"/> <location filename="../gui_qt/mainwindow.cpp" line="88"/>
<source>Sky</source> <source>Sky</source>
@ -888,17 +945,16 @@ rapide (F5)</translation>
<translation type="obsolete">Voulez-vous charger un paysage ? Les modifications nons sauvegardées seront perdues.</translation> <translation type="obsolete">Voulez-vous charger un paysage ? Les modifications nons sauvegardées seront perdues.</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="176"/> <location filename="../gui_qt/mainwindow.cpp" line="203"/>
<source>Paysages 3D</source> <source>Paysages 3D</source>
<translation>Paysages 3D</translation> <translation>Paysages 3D</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="176"/>
<source>A 3D landscape editing and rendering software. <source>A 3D landscape editing and rendering software.
Credits : Credits :
Programming - Michael Lemaire</source> Programming - Michael Lemaire</source>
<translation>Un logiciel d&apos;édition et rendu de décors naturels en 3D <translation type="obsolete">Un logiciel d&apos;édition et rendu de décors naturels en 3D
Crédits : Crédits :
Développement - Michaël LEMAIRE</translation> Développement - Michaël LEMAIRE</translation>

View file

@ -13,6 +13,9 @@
#include "camera.h" #include "camera.h"
#include "scenery.h" #include "scenery.h"
#include "render.h" #include "render.h"
#include "main.h"
#define APP_HEADER 1986325632.125
void paysagesInit() void paysagesInit()
{ {
@ -55,12 +58,55 @@ void paysagesQuit()
renderQuit(); renderQuit();
} }
void paysagesSave(char* filepath) FileOperationResult paysagesSave(char* filepath)
{ {
scenerySaveToFile(filepath); PackStream* stream = packWriteFile(filepath);
double app_header, version_header;
if (!stream)
{
return FILE_OPERATION_IOERROR;
}
app_header = (double)APP_HEADER;
packWriteDouble(stream, &app_header);
version_header = (double)PAYSAGES_CURRENT_DATA_VERSION;
packWriteDouble(stream, &version_header);
scenerySave(stream);
packCloseStream(stream);
return FILE_OPERATION_OK;
} }
void paysagesLoad(char* filepath) FileOperationResult paysagesLoad(char* filepath)
{ {
sceneryLoadFromFile(filepath); PackStream* stream = packReadFile(filepath);
double app_header, version_header;
if (!stream)
{
return FILE_OPERATION_IOERROR;
}
packReadDouble(stream, &app_header);
if (app_header != APP_HEADER)
{
packCloseStream(stream);
return FILE_OPERATION_APP_MISMATCH;
}
packReadDouble(stream, &version_header);
if ((int)version_header != PAYSAGES_CURRENT_DATA_VERSION)
{
packCloseStream(stream);
return FILE_OPERATION_VERSION_MISMATCH;
}
sceneryLoad(stream);
packCloseStream(stream);
return FILE_OPERATION_OK;
} }

View file

@ -1,14 +1,23 @@
#ifndef _PAYSAGES_MAIN_H_ #ifndef _PAYSAGES_MAIN_H_
#define _PAYSAGES_MAIN_H_ #define _PAYSAGES_MAIN_H_
#define PAYSAGES_CURRENT_DATA_VERSION 1
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
void paysagesInit(); typedef enum {
void paysagesQuit(); FILE_OPERATION_OK,
void paysagesSave(char* filepath); FILE_OPERATION_IOERROR,
void paysagesLoad(char* filepath); FILE_OPERATION_APP_MISMATCH,
FILE_OPERATION_VERSION_MISMATCH
} FileOperationResult;
void paysagesInit();
void paysagesQuit();
FileOperationResult paysagesSave(char* filepath);
FileOperationResult paysagesLoad(char* filepath);
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -65,10 +65,8 @@ void sceneryQuit()
noiseQuit(); noiseQuit();
} }
void scenerySaveToFile(char* filepath) void scenerySave(PackStream* stream)
{ {
PackStream* stream = packWriteFile(filepath);
noiseSave(stream); noiseSave(stream);
atmosphereSave(stream, &_atmosphere); atmosphereSave(stream, &_atmosphere);
cameraSave(stream, &_camera); cameraSave(stream, &_camera);
@ -79,14 +77,10 @@ void scenerySaveToFile(char* filepath)
texturesSave(stream, &_textures); texturesSave(stream, &_textures);
vegetationSave(stream, _vegetation); vegetationSave(stream, _vegetation);
waterSave(stream, &_water); waterSave(stream, &_water);
packCloseStream(stream);
} }
void sceneryLoadFromFile(char* filepath) void sceneryLoad(PackStream* stream)
{ {
PackStream* stream = packReadFile(filepath);
/* TODO Use intermediary definitions ? */ /* TODO Use intermediary definitions ? */
noiseLoad(stream); noiseLoad(stream);
@ -109,8 +103,6 @@ void sceneryLoadFromFile(char* filepath)
texturesValidateDefinition(&_textures); texturesValidateDefinition(&_textures);
vegetationValidateDefinition(_vegetation); vegetationValidateDefinition(_vegetation);
waterValidateDefinition(&_water); waterValidateDefinition(&_water);
packCloseStream(stream);
} }
void scenerySetAtmosphere(AtmosphereDefinition* atmosphere) void scenerySetAtmosphere(AtmosphereDefinition* atmosphere)

View file

@ -17,7 +17,7 @@
#include "textures.h" #include "textures.h"
#include "vegetation.h" #include "vegetation.h"
#include "water.h" #include "water.h"
#include "pack.h"
#include "renderer.h" #include "renderer.h"
#ifdef __cplusplus #ifdef __cplusplus
@ -27,8 +27,8 @@ extern "C" {
void sceneryInit(); void sceneryInit();
void sceneryQuit(); void sceneryQuit();
void scenerySaveToFile(char* filepath); void scenerySave(PackStream* stream);
void sceneryLoadFromFile(char* filepath); void sceneryLoad(PackStream* stream);
void scenerySetAtmosphere(AtmosphereDefinition* atmosphere); void scenerySetAtmosphere(AtmosphereDefinition* atmosphere);
void sceneryGetAtmosphere(AtmosphereDefinition* atmosphere); void sceneryGetAtmosphere(AtmosphereDefinition* atmosphere);