|
|
|
@ -1,70 +1,3 @@
|
|
|
|
|
/*
|
|
|
|
|
OpenMW - The completely unofficial reimplementation of Morrowind
|
|
|
|
|
Copyright (C) 2008-2009 Nicolay Korslund
|
|
|
|
|
Email: < korslund@gmail.com >
|
|
|
|
|
WWW: http://openmw.snaptoad.com/
|
|
|
|
|
|
|
|
|
|
This file (ogre.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 ogre.ogre;
|
|
|
|
|
|
|
|
|
|
import core.resource;
|
|
|
|
|
import core.config;
|
|
|
|
|
|
|
|
|
|
import ogre.bindings;
|
|
|
|
|
import gui.bindings;
|
|
|
|
|
import mscripts.setup;
|
|
|
|
|
|
|
|
|
|
import bullet.bindings;
|
|
|
|
|
import util.uniquename;
|
|
|
|
|
import std.stdio;
|
|
|
|
|
|
|
|
|
|
import esm.defs;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern(C) {
|
|
|
|
|
extern int lightConst;
|
|
|
|
|
extern float lightConstValue;
|
|
|
|
|
|
|
|
|
|
extern int lightLinear;
|
|
|
|
|
extern int lightLinearMethod;
|
|
|
|
|
extern float lightLinearValue;
|
|
|
|
|
extern float lightLinearRadiusMult;
|
|
|
|
|
|
|
|
|
|
extern int lightQuadratic;
|
|
|
|
|
extern int lightQuadraticMethod;
|
|
|
|
|
extern float lightQuadraticValue;
|
|
|
|
|
extern float lightQuadraticRadiusMult;
|
|
|
|
|
|
|
|
|
|
extern int lightOutQuadInLin;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class OgreException : Exception
|
|
|
|
|
{
|
|
|
|
|
this(char[] msg) {super("OgreException: " ~ msg);}
|
|
|
|
|
|
|
|
|
|
static void opCall(char[] msg)
|
|
|
|
|
{
|
|
|
|
|
throw new OgreException(msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Place a mesh in the 3D scene graph, at the given
|
|
|
|
|
// location/scale. Returns a node pointer to the inserted object.
|
|
|
|
|
NodePtr placeObject(MeshIndex mesh, Placement *pos, float scale,
|
|
|
|
@ -97,46 +30,6 @@ NodePtr placeObject(MeshIndex mesh, Placement *pos, float scale,
|
|
|
|
|
return node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NodePtr attachLight(NodePtr parent, Color c, float radius)
|
|
|
|
|
{
|
|
|
|
|
return ogre_attachLight(UniqueName("_light").ptr, parent,
|
|
|
|
|
c.red/255.0, c.green/255.0, c.blue/255.0,
|
|
|
|
|
radius);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If 'true' then we must call ogre_cleanup() on exit.
|
|
|
|
|
bool ogreSetup = false;
|
|
|
|
|
|
|
|
|
|
// Make sure we clean up
|
|
|
|
|
static ~this()
|
|
|
|
|
{
|
|
|
|
|
cleanupOgre();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Loads ogre configurations, creats the root, etc.
|
|
|
|
|
void setupOgre(bool debugOut)
|
|
|
|
|
{
|
|
|
|
|
char[] plugincfg;
|
|
|
|
|
|
|
|
|
|
version(Windows)
|
|
|
|
|
plugincfg = "plugins.cfg.win32";
|
|
|
|
|
else version(Posix)
|
|
|
|
|
plugincfg = "plugins.cfg.linux";
|
|
|
|
|
else
|
|
|
|
|
// Assume the user knows what to do
|
|
|
|
|
plugincfg = "plugins.cfg";
|
|
|
|
|
|
|
|
|
|
// Later we will send more config info from core.config along with
|
|
|
|
|
// this function
|
|
|
|
|
if(ogre_configure(config.finalOgreConfig, toStringz(plugincfg), debugOut))
|
|
|
|
|
OgreException("Configuration abort");
|
|
|
|
|
|
|
|
|
|
ogre_initWindow();
|
|
|
|
|
ogre_makeScene();
|
|
|
|
|
|
|
|
|
|
ogreSetup = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setAmbient(Color amb, Color sun, Color fog, float density)
|
|
|
|
|
{
|
|
|
|
|
ogre_setAmbient(amb.red/255.0, amb.green/255.0, amb.blue/255.0,
|
|
|
|
@ -150,24 +43,6 @@ void setAmbient(Color amb, Color sun, Color fog, float density)
|
|
|
|
|
ogre_setFog(fog.red/255.0, fog.green/255.0, fog.blue/255.0, 200, fhigh);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Jump into the OGRE rendering loop. Everything should be loaded and
|
|
|
|
|
// done before calling this.
|
|
|
|
|
void startRendering()
|
|
|
|
|
{
|
|
|
|
|
// Kick OGRE into gear
|
|
|
|
|
ogre_startRendering();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Cleans up after OGRE. Resets things like screen resolution, mouse
|
|
|
|
|
// control and keyboard repeat rate.
|
|
|
|
|
void cleanupOgre()
|
|
|
|
|
{
|
|
|
|
|
if(ogreSetup)
|
|
|
|
|
ogre_cleanup();
|
|
|
|
|
|
|
|
|
|
ogreSetup = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Gives the placement of an item in the scene (position and
|
|
|
|
|
// orientation). It must have this exact structure since we also use
|
|
|
|
|
// it when reading ES files.
|
|
|
|
|