2009-05-15 07:04:50 +00:00
|
|
|
/*
|
|
|
|
OpenMW - The completely unofficial reimplementation of Morrowind
|
|
|
|
Copyright (C) 2008-2009 Nicolay Korslund
|
|
|
|
Email: < korslund@gmail.com >
|
|
|
|
WWW: http://openmw.snaptoad.com/
|
|
|
|
|
|
|
|
This file (terrain.d) is part of the OpenMW package.
|
|
|
|
|
|
|
|
OpenMW is distributed as free software: you can redistribute it
|
|
|
|
and/or modify it under the terms of the GNU General Public License
|
|
|
|
version 3, as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
version 3 along with this program. If not, see
|
|
|
|
http://www.gnu.org/licenses/ .
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
module terrain.terrain;
|
|
|
|
|
2009-06-03 08:06:59 +00:00
|
|
|
import terrain.generator;
|
2009-06-08 12:59:00 +00:00
|
|
|
import terrain.archive;
|
2009-06-06 12:02:18 +00:00
|
|
|
import terrain.bindings;
|
2009-06-08 12:59:00 +00:00
|
|
|
import terrain.quad;
|
|
|
|
import std.file, std.stdio;
|
|
|
|
|
|
|
|
char[] cacheDir = "cache/terrain/";
|
2009-05-15 07:04:50 +00:00
|
|
|
|
2009-05-16 17:58:08 +00:00
|
|
|
void initTerrain(bool doGen)
|
2009-05-15 07:04:50 +00:00
|
|
|
{
|
2009-06-08 12:59:00 +00:00
|
|
|
char[] fname = cacheDir ~ "landscape.cache";
|
|
|
|
|
|
|
|
if(!exists(fname))
|
|
|
|
{
|
|
|
|
writefln("Cache file '%s' not found. Creating:",
|
|
|
|
fname);
|
|
|
|
doGen = true;
|
|
|
|
}
|
|
|
|
|
2009-05-16 17:58:08 +00:00
|
|
|
if(doGen)
|
2009-06-08 12:59:00 +00:00
|
|
|
generate(fname);
|
|
|
|
|
|
|
|
// Load the archive file
|
|
|
|
g_archive.openFile(fname);
|
2009-06-01 13:49:29 +00:00
|
|
|
|
2009-06-06 18:59:40 +00:00
|
|
|
terr_setupRendering();
|
2009-06-08 12:59:00 +00:00
|
|
|
|
|
|
|
// Create the root quad
|
|
|
|
rootQuad = new Quad;
|
2009-06-01 13:49:29 +00:00
|
|
|
}
|
2009-06-08 12:59:00 +00:00
|
|
|
|
|
|
|
extern(C) void d_terr_terrainUpdate()
|
|
|
|
{
|
|
|
|
// Update the root quad each frame.
|
|
|
|
assert(rootQuad !is null);
|
|
|
|
rootQuad.update();
|
|
|
|
}
|
|
|
|
|
|
|
|
Quad rootQuad;
|