diff --git a/TODO b/TODO
index 3c0ec2c..a588799 100644
--- a/TODO
+++ b/TODO
@@ -1,7 +1,8 @@
Technology Preview 2 :
- Render tab previews should not rerender when changing render options.
-- Compute shadows only once for all textures at a same location.
-- Add antialiasing option (pay attention to memory usage).
+- Compute shadows only once for all textures at a same location (need an intermediary light status).
+- 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 a material editor dialog.
- Add a zone editor dialog for localized textures.
@@ -9,13 +10,13 @@ Technology Preview 2 :
- Add a noise filler (and maybe noise intervals ?).
- Improve curve editor.
- 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 :
- Restore render progress.
+- Add antialiasing option (pay attention to memory usage).
- Add basic vegetation system (not sure).
- Improve sky rendering (colors and light halo).
-- Add rendering steps in small previews (not sure).
Release Candidate :
- Polish all features and UI.
diff --git a/gui_qt/mainwindow.cpp b/gui_qt/mainwindow.cpp
index d3dca1d..ed7e497 100644
--- a/gui_qt/mainwindow.cpp
+++ b/gui_qt/mainwindow.cpp
@@ -31,14 +31,14 @@ int main(int argc, char** argv)
{
MainWindow* window;
int result;
-
+
paysagesInit();
QApplication app(argc, argv);
-
+
QTranslator qtTranslator;
QTranslator myTranslator;
-
+
if (myTranslator.load("paysages_" + QLocale::system().name(), "./i18n"))
{
app.installTranslator(&myTranslator);
@@ -56,20 +56,20 @@ int main(int argc, char** argv)
window->show();
result = app.exec();
-
+
delete window;
-
+
paysagesQuit();
return result;
}
MainWindow::MainWindow(QWidget *parent) :
- QMainWindow(parent)
+QMainWindow(parent)
{
BaseForm* form;
QTabWidget* tabs;
QToolBar* toolbar;
-
+
tabs = new QTabWidget(this);
form = new FormTerrain(tabs);
@@ -112,7 +112,7 @@ MainWindow::MainWindow(QWidget *parent) :
toolbar->toggleViewAction()->setEnabled(false);
toolbar->setIconSize(QSize(32, 32));
addToolBar(Qt::LeftToolBarArea, toolbar);
-
+
toolbar->addAction(QIcon("images/new.png"), tr("&New"), this, SLOT(fileNew()))->setShortcut(QKeySequence(tr("Crtl+N")));
toolbar->addAction(QIcon("images/save.png"), tr("&Save"), this, SLOT(fileSave()))->setShortcut(QKeySequence(tr("Crtl+S")));
toolbar->addAction(QIcon("images/load.png"), tr("&Load"), this, SLOT(fileLoad()))->setShortcut(QKeySequence(tr("Crtl+L")));
@@ -154,7 +154,18 @@ void MainWindow::fileSave()
{
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)"));
if (!filepath.isNull())
{
- paysagesLoad((char*)filepath.toStdString().c_str());
- refreshAll();
+ FileOperationResult result = paysagesLoad((char*) filepath.toStdString().c_str());
+ 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()
{
- 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()
@@ -190,9 +217,9 @@ void MainWindow::explore3D()
DialogWanderer* dialog = new DialogWanderer(this, &camera, true);
result = dialog->exec();
-
+
delete dialog;
-
+
if (result == QDialog::Accepted)
{
scenerySetCamera(&camera);
diff --git a/i18n/paysages_fr.ts b/i18n/paysages_fr.ts
index 5f0388f..5fa3377 100644
--- a/i18n/paysages_fr.ts
+++ b/i18n/paysages_fr.ts
@@ -772,25 +772,82 @@ rapide (F5)
-
+
Scène Paysages 3D (*.p3d)
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Voulez-vous charger une scène ? Les modifications nons sauvegardées seront perdues.
-
+
Paysages 3D - Charger une scène
-
+
Paysages 3D - Choisissez un fichier de scène à charger
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -888,17 +945,16 @@ rapide (F5)
Voulez-vous charger un paysage ? Les modifications nons sauvegardées seront perdues.
-
+
Paysages 3D
-
- Un logiciel d'édition et rendu de décors naturels en 3D
+ Un logiciel d'édition et rendu de décors naturels en 3D
Crédits :
Développement - Michaël LEMAIRE
diff --git a/lib_paysages/main.c b/lib_paysages/main.c
index b1b3cb2..e052cfc 100644
--- a/lib_paysages/main.c
+++ b/lib_paysages/main.c
@@ -13,6 +13,9 @@
#include "camera.h"
#include "scenery.h"
#include "render.h"
+#include "main.h"
+
+#define APP_HEADER 1986325632.125
void paysagesInit()
{
@@ -55,12 +58,55 @@ void paysagesQuit()
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;
}
diff --git a/lib_paysages/main.h b/lib_paysages/main.h
index efef7db..8c663cc 100644
--- a/lib_paysages/main.h
+++ b/lib_paysages/main.h
@@ -1,14 +1,23 @@
#ifndef _PAYSAGES_MAIN_H_
#define _PAYSAGES_MAIN_H_
+#define PAYSAGES_CURRENT_DATA_VERSION 1
+
#ifdef __cplusplus
extern "C" {
#endif
-void paysagesInit();
-void paysagesQuit();
-void paysagesSave(char* filepath);
-void paysagesLoad(char* filepath);
+ typedef enum {
+ FILE_OPERATION_OK,
+ FILE_OPERATION_IOERROR,
+ FILE_OPERATION_APP_MISMATCH,
+ FILE_OPERATION_VERSION_MISMATCH
+ } FileOperationResult;
+
+ void paysagesInit();
+ void paysagesQuit();
+ FileOperationResult paysagesSave(char* filepath);
+ FileOperationResult paysagesLoad(char* filepath);
#ifdef __cplusplus
}
diff --git a/lib_paysages/scenery.c b/lib_paysages/scenery.c
index 5a20707..cf46a41 100644
--- a/lib_paysages/scenery.c
+++ b/lib_paysages/scenery.c
@@ -65,10 +65,8 @@ void sceneryQuit()
noiseQuit();
}
-void scenerySaveToFile(char* filepath)
+void scenerySave(PackStream* stream)
{
- PackStream* stream = packWriteFile(filepath);
-
noiseSave(stream);
atmosphereSave(stream, &_atmosphere);
cameraSave(stream, &_camera);
@@ -79,14 +77,10 @@ void scenerySaveToFile(char* filepath)
texturesSave(stream, &_textures);
vegetationSave(stream, _vegetation);
waterSave(stream, &_water);
-
- packCloseStream(stream);
}
-void sceneryLoadFromFile(char* filepath)
+void sceneryLoad(PackStream* stream)
{
- PackStream* stream = packReadFile(filepath);
-
/* TODO Use intermediary definitions ? */
noiseLoad(stream);
@@ -109,8 +103,6 @@ void sceneryLoadFromFile(char* filepath)
texturesValidateDefinition(&_textures);
vegetationValidateDefinition(_vegetation);
waterValidateDefinition(&_water);
-
- packCloseStream(stream);
}
void scenerySetAtmosphere(AtmosphereDefinition* atmosphere)
diff --git a/lib_paysages/scenery.h b/lib_paysages/scenery.h
index 1ebfe87..61e89da 100644
--- a/lib_paysages/scenery.h
+++ b/lib_paysages/scenery.h
@@ -17,7 +17,7 @@
#include "textures.h"
#include "vegetation.h"
#include "water.h"
-
+#include "pack.h"
#include "renderer.h"
#ifdef __cplusplus
@@ -27,8 +27,8 @@ extern "C" {
void sceneryInit();
void sceneryQuit();
-void scenerySaveToFile(char* filepath);
-void sceneryLoadFromFile(char* filepath);
+void scenerySave(PackStream* stream);
+void sceneryLoad(PackStream* stream);
void scenerySetAtmosphere(AtmosphereDefinition* atmosphere);
void sceneryGetAtmosphere(AtmosphereDefinition* atmosphere);