Commit ddc0a95c authored by hybrid's avatar hybrid

Fog serialization patch by pc0de.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2773 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 387f910c
......@@ -132,6 +132,14 @@ namespace video
EFT_FOG_EXP2
};
const c8* const FogTypeNames[] =
{
"FogExp",
"FogLinear",
"FogExp2",
0
};
struct SOverrideMaterial
{
//! The Material values
......@@ -912,6 +920,11 @@ namespace video
f32 start=50.0f, f32 end=100.0f, f32 density=0.01f,
bool pixelFog=false, bool rangeFog=false) =0;
//! Gets the fog mode.
virtual void getFog(SColor& color, E_FOG_TYPE& fogType,
f32& start, f32& end, f32& density,
bool& pixelFog, bool& rangeFog) = 0;
//! Get the current color format of the color buffer
/** \return Color format of the color buffer. */
virtual ECOLOR_FORMAT getColorFormat() const =0;
......
......@@ -1402,6 +1402,18 @@ void CNullDriver::setFog(SColor color, E_FOG_TYPE fogType, f32 start, f32 end,
RangeFog = rangeFog;
}
//! Gets the fog mode.
void CNullDriver::getFog(SColor& color, E_FOG_TYPE& fogType, f32& start, f32& end,
f32& density, bool& pixelFog, bool& rangeFog)
{
color = FogColor;
fogType = FogType;
start = FogStart;
end = FogEnd;
density = FogDensity;
pixelFog = PixelFog;
rangeFog = RangeFog;
}
//! Draws a mesh buffer
void CNullDriver::drawMeshBuffer(const scene::IMeshBuffer* mb)
......
......@@ -216,6 +216,10 @@ namespace video
f32 start=50.0f, f32 end=100.0f, f32 density=0.01f,
bool pixelFog=false, bool rangeFog=false);
virtual void getFog(SColor& color, E_FOG_TYPE& fogType,
f32& start, f32& end, f32& density,
bool& pixelFog, bool& rangeFog);
//! get color format of the current color buffer
virtual ECOLOR_FORMAT getColorFormat() const;
......
......@@ -2487,6 +2487,22 @@ void CSceneManager::serializeAttributes(io::IAttributes* out, io::SAttributeRead
out->addString ("Name", Name.c_str());
out->addInt ("Id", ID );
out->addColorf ("AmbientLight", AmbientLight);
// fog attributes from video driver
video::SColor color;
video::E_FOG_TYPE fogType;
f32 start, end, density;
bool pixelFog, rangeFog;
Driver->getFog(color, fogType, start, end, density, pixelFog, rangeFog);
out->addEnum("FogType", fogType, video::FogTypeNames);
out->addColorf("FogColor", color);
out->addFloat("FogStart", start);
out->addFloat("FogEnd", end);
out->addFloat("FogDensity", density);
out->addBool("FogPixel", pixelFog);
out->addBool("FogRange", rangeFog);
}
//! Reads attributes of the scene node.
......@@ -2496,6 +2512,23 @@ void CSceneManager::deserializeAttributes(io::IAttributes* in, io::SAttributeRea
ID = in->getAttributeAsInt("Id");
AmbientLight = in->getAttributeAsColorf("AmbientLight");
// fog attributes
video::SColor color;
video::E_FOG_TYPE fogType;
f32 start, end, density;
bool pixelFog, rangeFog;
if (in->existsAttribute("FogType"))
{
fogType = (video::E_FOG_TYPE) in->getAttributeAsEnumeration("FogType", video::FogTypeNames);
color = in->getAttributeAsColorf("FogColor").toSColor();
start = in->getAttributeAsFloat("FogStart");
end = in->getAttributeAsFloat("FogEnd");
density = in->getAttributeAsFloat("FogDensity");
pixelFog = in->getAttributeAsBool("FogPixel");
rangeFog = in->getAttributeAsBool("FogRange");
Driver->setFog(color, fogType, start, end, density, pixelFog, rangeFog);
}
RelativeTranslation.set(0,0,0);
RelativeRotation.set(0,0,0);
RelativeScale.set(1,1,1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment