- applied lighting patch from Chris Robinson

- terrain gen not finished


git-svn-id: https://openmw.svn.sourceforge.net/svnroot/openmw/trunk@120 ea6a568a-9f4f-0410-981a-c910a81bb256
actorid
nkorslund 16 years ago
parent 61030fc382
commit 2e1f97f3d5

@ -39,6 +39,8 @@ import sound.audio;
import input.keys;
import input.ois;
import ogre.ogre;
ConfigManager config;
/*
@ -167,6 +169,23 @@ struct ConfigManager
float sfxVolume = saneVol(ini.getFloat("Sound", "SFX Volume", 0.5));
bool useMusic = ini.getBool("Sound", "Enable Music", true);
lightConst = ini.getInt("LightAttenuation", "UseConstant", 0);
lightConstValue = ini.getFloat("LightAttenuation", "ConstantValue", 0.0);
lightLinear = ini.getInt("LightAttenuation", "UseLinear", 1);
lightLinearMethod = ini.getInt("LightAttenuation", "LinearMethod", 1);
lightLinearValue = ini.getFloat("LightAttenuation", "LinearValue", 3.0);
lightLinearRadiusMult = ini.getFloat("LightAttenuation", "LinearRadiusMult", 1.0);
lightQuadratic = ini.getInt("LightAttenuation", "UseQuadratic", 0);
lightQuadraticMethod = ini.getInt("LightAttenuation", "QuadraticMethod", 2);
lightQuadraticValue = ini.getFloat("LightAttenuation", "QuadraticValue", 16.0);
lightQuadraticRadiusMult = ini.getFloat("LightAttenuation", "QuadraticRadiusMult", 1.0);
lightOutQuadInLin = ini.getInt("LightAttenuation", "OutQuadInLin", 0);
*mouseSensX = ini.getFloat("Controls", "Mouse Sensitivity X", 0.2);
*mouseSensY = ini.getFloat("Controls", "Mouse Sensitivity Y", 0.2);
*flipMouseY = ini.getBool("Controls", "Flip Mouse Y Axis", false);
@ -360,6 +379,23 @@ struct ConfigManager
writeFloat("SFX Volume", mo.getFloat("sfxVolume"));
writeBool("Enable Music", mo.getBool("useMusic"));
section("LightAttenuation");
comment("For constant attenuation");
writeInt("UseConstant", lightConst);
writeFloat("ConstantValue", lightConstValue);
comment("For linear attenuation");
writeInt("UseLinear", lightLinear);
writeInt("LinearMethod", lightLinearMethod);
writeFloat("LinearValue", lightLinearValue);
writeFloat("LinearRadiusMult", lightLinearRadiusMult);
comment("For quadratic attenuation");
writeInt("UseQuadratic", lightQuadratic);
writeInt("QuadraticMethod", lightQuadraticMethod);
writeFloat("QuadraticValue", lightQuadraticValue);
writeFloat("QuadraticRadiusMult", lightQuadraticRadiusMult);
comment("For quadratic in exteriors and linear in interiors");
writeInt("OutQuadInLin", lightOutQuadInLin);
section("Game Files");
foreach(int i, ref s; gameFiles)
writeString(format("GameFile[%d]",i), s[esmDir.length..$]);

@ -272,6 +272,14 @@ class NiAlphaProperty : Property
Taken from:
http://niftools.sourceforge.net/doc/nif/NiAlphaProperty.html
Right now we only use standard alpha blending (see the Ogre code
that sets it up) and it appears that this is the only blending
used in the original game. Bloodmoon (along with several mods) do
however use other settings, such as discarding pixel values with
alpha < 1.0. This is faster because we don't have to mess with the
depth stuff like we did for blending. And OGRE has settings for
this too.
*/
// Tested against when certain flags are set (see above.)

@ -21,6 +21,29 @@
*/
//-----------------------------------------------------------------------
// E X P O R T E D V A R I A B L E S
//-----------------------------------------------------------------------
extern "C"
{
int lightConst;
float lightConstValue;
int lightLinear;
int lightLinearMethod;
float lightLinearValue;
float lightLinearRadiusMult;
int lightQuadratic;
int lightQuadraticMethod;
float lightQuadraticValue;
float lightQuadraticRadiusMult;
int lightOutQuadInLin;
}
//-----------------------------------------------------------------------
// E X P O R T E D F U N C T I O N S
//-----------------------------------------------------------------------
@ -244,12 +267,37 @@ extern "C" Light* ogre_attachLight(char *name, SceneNode* base,
float radius)
{
Light *l = mSceneMgr->createLight(name);
l->setDiffuseColour(r,g,b);
// This seems to look reasonably ok.
l->setAttenuation(3*radius, 0, 0, 12.0/(radius*radius));
//l->setAttenuation(5*radius, 0, 0, 8.0/(radius*radius));
radius /= 4.0f;
float cval=0.0f, lval=0.0f, qval=0.0f;
if(lightConst)
cval = lightConstValue;
if(!lightOutQuadInLin)
{
if(lightLinear)
radius *= lightLinearRadiusMult;
if(lightQuadratic)
radius *= lightQuadraticRadiusMult;
if(lightLinear)
lval = lightLinearValue / pow(radius, lightLinearMethod);
if(lightQuadratic)
qval = lightQuadraticValue / pow(radius, lightQuadraticMethod);
}
else
{
// FIXME:
// Do quadratic or linear, depending if we're in an exterior or interior
// cell, respectively. Ignore lightLinear and lightQuadratic.
}
// The first parameter is a cutoff value on which meshes to
// light. If it's set to small, some meshes will end up 'flashing'
// in and out of light depending on the camera distance from the
// light.
l->setAttenuation(10*radius, cval, lval, qval);
// base might be null, sometimes lights don't have meshes
if(base) base->attachObject(l);

@ -36,6 +36,25 @@ 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);}

File diff suppressed because it is too large Load Diff

@ -27,8 +27,10 @@ import terrain.generator;
void initTerrain(bool doGen)
{
/*
if(doGen)
generate();
*/
//terr_setupRendering();
}

@ -0,0 +1,48 @@
/*
OpenMW - The completely unofficial reimplementation of Morrowind
Copyright (C) 2008-2009 Nicolay Korslund
Email: < korslund@gmail.com >
WWW: http://openmw.sourceforge.net/
This file (cachefile.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 util.cachefile;
import monster.util.string;
import std.file;
void makeDir(char[] pt)
{
if(exists(pt))
{
if(!isdir(pt))
throw new Exception(pt ~ " is not a directory");
}
else
mkdir(pt);
}
void makePath(char[] pt)
{
assert(!pt.begins("/"));
foreach(int i, char c; pt)
if(c == '/')
makeDir(pt[0..i]);
if(!pt.ends("/"))
makeDir(pt);
}
Loading…
Cancel
Save