-
Notifications
You must be signed in to change notification settings - Fork 948
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'nifogproperty' into 'master'
Handle NiFogProperty (feature #5173) Closes #5173 See merge request OpenMW/openmw!3642
- Loading branch information
Showing
7 changed files
with
115 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "fog.hpp" | ||
|
||
#include <osg/Matrix> | ||
#include <osg/State> | ||
|
||
namespace NifOsg | ||
{ | ||
|
||
Fog::Fog() | ||
: osg::Fog() | ||
{ | ||
} | ||
|
||
Fog::Fog(const Fog& copy, const osg::CopyOp& copyop) | ||
: osg::Fog(copy, copyop) | ||
, mDepth(copy.mDepth) | ||
{ | ||
} | ||
|
||
void Fog::apply(osg::State& state) const | ||
{ | ||
osg::Fog::apply(state); | ||
#ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE | ||
float fov, aspect, near, far; | ||
state.getProjectionMatrix().getPerspective(fov, aspect, near, far); | ||
glFogf(GL_FOG_START, near * mDepth + far * (1.f - mDepth)); | ||
glFogf(GL_FOG_END, far); | ||
#endif | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef OPENMW_COMPONENTS_NIFOSG_FOG_H | ||
#define OPENMW_COMPONENTS_NIFOSG_FOG_H | ||
|
||
#include <osg/Fog> | ||
|
||
namespace NifOsg | ||
{ | ||
|
||
// osg::Fog-based wrapper for NiFogProperty that autocalculates the fog start and end distance. | ||
class Fog : public osg::Fog | ||
{ | ||
public: | ||
Fog(); | ||
Fog(const Fog& copy, const osg::CopyOp& copyop); | ||
|
||
META_StateAttribute(NifOsg, Fog, FOG) | ||
|
||
void setDepth(float depth) { mDepth = depth; } | ||
float getDepth() const { return mDepth; } | ||
|
||
void apply(osg::State& state) const override; | ||
|
||
private: | ||
float mDepth{ 1.f }; | ||
}; | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters