[Python-ogre-commit] SF.net SVN: python-ogre: [445] trunk/python-ogre
Brought to you by:
andy_miller,
roman_yakovenko
|
From: <and...@us...> - 2007-10-19 13:16:59
|
Revision: 445
http://python-ogre.svn.sourceforge.net/python-ogre/?rev=445&view=rev
Author: andy_miller
Date: 2007-10-19 06:17:02 -0700 (Fri, 19 Oct 2007)
Log Message:
-----------
Updated QuckGUI and Caelum to latest versions
Added helper function to Caelum (createSimpleSunPositionModel) to help with Linux issues
Modified Paths:
--------------
trunk/python-ogre/ThirdParty/caelum/CaelumExceptions.h
trunk/python-ogre/ThirdParty/caelum/CaelumPrecompiled.cpp
trunk/python-ogre/ThirdParty/caelum/CaelumPrecompiled.h
trunk/python-ogre/ThirdParty/caelum/CaelumPrerequisites.h
trunk/python-ogre/ThirdParty/caelum/CaelumSystem.cpp
trunk/python-ogre/ThirdParty/caelum/CaelumSystem.h
trunk/python-ogre/ThirdParty/caelum/SkyColourModel.cpp
trunk/python-ogre/ThirdParty/caelum/SkyColourModel.h
trunk/python-ogre/ThirdParty/caelum/SkyDome.cpp
trunk/python-ogre/ThirdParty/caelum/UniversalClock.cpp
trunk/python-ogre/ThirdParty/caelum/UniversalClock.h
trunk/python-ogre/ThirdParty/quickgui/QuickGUIBorder.cpp
trunk/python-ogre/ThirdParty/quickgui/QuickGUIComboBox.cpp
trunk/python-ogre/ThirdParty/quickgui/QuickGUIComboBox.h
trunk/python-ogre/ThirdParty/quickgui/QuickGUIExportDLL.h
trunk/python-ogre/ThirdParty/quickgui/QuickGUIHorizontalScrollBar.cpp
trunk/python-ogre/ThirdParty/quickgui/QuickGUIHorizontalTrackBar.cpp
trunk/python-ogre/ThirdParty/quickgui/QuickGUILabel.cpp
trunk/python-ogre/ThirdParty/quickgui/QuickGUILabel.h
trunk/python-ogre/ThirdParty/quickgui/QuickGUIList.cpp
trunk/python-ogre/ThirdParty/quickgui/QuickGUIList.h
trunk/python-ogre/ThirdParty/quickgui/QuickGUIManager.cpp
trunk/python-ogre/ThirdParty/quickgui/QuickGUIManager.h
trunk/python-ogre/ThirdParty/quickgui/QuickGUIMenuLabel.cpp
trunk/python-ogre/ThirdParty/quickgui/QuickGUIMouseCursor.cpp
trunk/python-ogre/ThirdParty/quickgui/QuickGUINStateButton.cpp
trunk/python-ogre/ThirdParty/quickgui/QuickGUIPanel.cpp
trunk/python-ogre/ThirdParty/quickgui/QuickGUIPanel.h
trunk/python-ogre/ThirdParty/quickgui/QuickGUIProgressBar.cpp
trunk/python-ogre/ThirdParty/quickgui/QuickGUIProgressBar.h
trunk/python-ogre/ThirdParty/quickgui/QuickGUIQuad.cpp
trunk/python-ogre/ThirdParty/quickgui/QuickGUIQuad.h
trunk/python-ogre/ThirdParty/quickgui/QuickGUIQuadContainer.cpp
trunk/python-ogre/ThirdParty/quickgui/QuickGUIQuadContainer.h
trunk/python-ogre/ThirdParty/quickgui/QuickGUIRect.cpp
trunk/python-ogre/ThirdParty/quickgui/QuickGUIScrollPane.cpp
trunk/python-ogre/ThirdParty/quickgui/QuickGUIScrollPane.h
trunk/python-ogre/ThirdParty/quickgui/QuickGUISheet.cpp
trunk/python-ogre/ThirdParty/quickgui/QuickGUISheet.h
trunk/python-ogre/ThirdParty/quickgui/QuickGUISkinSet.cpp
trunk/python-ogre/ThirdParty/quickgui/QuickGUIText.cpp
trunk/python-ogre/ThirdParty/quickgui/QuickGUIText.h
trunk/python-ogre/ThirdParty/quickgui/QuickGUITextBox.cpp
trunk/python-ogre/ThirdParty/quickgui/QuickGUITextBox.h
trunk/python-ogre/ThirdParty/quickgui/QuickGUITitleBar.cpp
trunk/python-ogre/ThirdParty/quickgui/QuickGUIVerticalScrollBar.cpp
trunk/python-ogre/ThirdParty/quickgui/QuickGUIVerticalTrackBar.cpp
trunk/python-ogre/ThirdParty/quickgui/QuickGUIWidget.cpp
trunk/python-ogre/ThirdParty/quickgui/QuickGUIWidget.h
trunk/python-ogre/ThirdParty/quickgui/QuickGUIWindow.cpp
trunk/python-ogre/ThirdParty/quickgui/QuickGUIWindow.h
trunk/python-ogre/code_generators/caelum/hand_made_wrappers.py
trunk/python-ogre/code_generators/quickgui/generate_code.py
trunk/python-ogre/code_generators/quickgui/python_quickgui_aliases.h
Added Paths:
-----------
trunk/python-ogre/ThirdParty/caelum/GroundFog.cpp
trunk/python-ogre/ThirdParty/caelum/GroundFog.h
trunk/python-ogre/ThirdParty/quickgui/QuickGUIConsole.cpp
trunk/python-ogre/ThirdParty/quickgui/QuickGUIConsole.h
trunk/python-ogre/ThirdParty/quickgui/QuickGUIMultiLineLabel.cpp
trunk/python-ogre/ThirdParty/quickgui/QuickGUIMultiLineLabel.h
trunk/python-ogre/ThirdParty/quickgui/QuickGUIMultiLineTextBox.cpp
trunk/python-ogre/ThirdParty/quickgui/QuickGUIMultiLineTextBox.h
Modified: trunk/python-ogre/ThirdParty/caelum/CaelumExceptions.h
===================================================================
--- trunk/python-ogre/ThirdParty/caelum/CaelumExceptions.h 2007-10-19 10:21:27 UTC (rev 444)
+++ trunk/python-ogre/ThirdParty/caelum/CaelumExceptions.h 2007-10-19 13:17:02 UTC (rev 445)
@@ -1,21 +1,21 @@
-#ifndef CAELUMEXCEPTIONS_H
-#define CAELUMEXCEPTIONS_H
-
-#include "CaelumPrerequisites.h"
-
-namespace caelum {
-
-/** Exception class for unsupported features.
- * @author Jesús Alonso Abad.
- */
-class DllExport UnsupportedException : public Ogre::Exception {
- public:
- /** Constructor.
- */
- UnsupportedException (int number, const Ogre::String &description, const Ogre::String &source, const char *file, long line)
- : Ogre::Exception (number, description, source, "UnsupportedException", file, line) { }
-};
-
-} // namespace caelum
-
-#endif // CAELUMEXCEPTIONS_H
+#ifndef CAELUMEXCEPTIONS_H
+#define CAELUMEXCEPTIONS_H
+
+#include "CaelumPrerequisites.h"
+
+namespace caelum {
+
+/** Exception class for unsupported features.
+ * @author Jesús Alonso Abad.
+ */
+class DllExport UnsupportedException : public Ogre::Exception {
+ public:
+ /** Constructor.
+ */
+ UnsupportedException (int number, const Ogre::String &description, const Ogre::String &source, const char *file, long line)
+ : Ogre::Exception (number, description, source, "UnsupportedException", file, line) { }
+};
+
+} // namespace caelum
+
+#endif // CAELUMEXCEPTIONS_H
Modified: trunk/python-ogre/ThirdParty/caelum/CaelumPrecompiled.cpp
===================================================================
--- trunk/python-ogre/ThirdParty/caelum/CaelumPrecompiled.cpp 2007-10-19 10:21:27 UTC (rev 444)
+++ trunk/python-ogre/ThirdParty/caelum/CaelumPrecompiled.cpp 2007-10-19 13:17:02 UTC (rev 445)
@@ -1 +1 @@
-#include "CaelumPrecompiled.h"
+#include "CaelumPrecompiled.h"
Modified: trunk/python-ogre/ThirdParty/caelum/CaelumPrecompiled.h
===================================================================
--- trunk/python-ogre/ThirdParty/caelum/CaelumPrecompiled.h 2007-10-19 10:21:27 UTC (rev 444)
+++ trunk/python-ogre/ThirdParty/caelum/CaelumPrecompiled.h 2007-10-19 13:17:02 UTC (rev 445)
@@ -1 +1 @@
-#include "Ogre.h"
+#include "Ogre.h"
Modified: trunk/python-ogre/ThirdParty/caelum/CaelumPrerequisites.h
===================================================================
--- trunk/python-ogre/ThirdParty/caelum/CaelumPrerequisites.h 2007-10-19 10:21:27 UTC (rev 444)
+++ trunk/python-ogre/ThirdParty/caelum/CaelumPrerequisites.h 2007-10-19 13:17:02 UTC (rev 445)
@@ -4,7 +4,20 @@
// Include external headers
#include "Ogre.h"
-#define DllExport
+// Define the dll export qualifier if compiling for Windows
+// // // #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
+// // // #ifdef CAELUM_LIB
+// // // #define DllExport __declspec (dllexport)
+// // // #else
+// // // #ifdef __MINGW32__
+// // // #define DllExport
+// // // #else
+// // // #define DllExport __declspec (dllimport)
+// // // #endif
+// // // #endif
+// // // #else
+ #define DllExport
+// // // #endif
// Define the version code
#define CAELUM_VERSION_MAIN 0
@@ -22,7 +35,7 @@
*/
const float CAMERA_DISTANCE_MODIFIER = 0;
- // Render grounp for caelum stuff
+ // Render group for caelum stuff
// It's best to have them all together
enum CaelumRenderQueueGroupId
{
@@ -30,6 +43,7 @@
CAELUM_RENDER_QUEUE_SKYDOME = Ogre::RENDER_QUEUE_SKIES_EARLY + 1,
CAELUM_RENDER_QUEUE_SUN = Ogre::RENDER_QUEUE_SKIES_EARLY + 2,
CAELUM_RENDER_QUEUE_CLOUDS = Ogre::RENDER_QUEUE_SKIES_EARLY + 3,
+ CAELUM_RENDER_QUEUE_GROUND_FOG = Ogre::RENDER_QUEUE_SKIES_EARLY + 4,
};
}
Modified: trunk/python-ogre/ThirdParty/caelum/CaelumSystem.cpp
===================================================================
--- trunk/python-ogre/ThirdParty/caelum/CaelumSystem.cpp 2007-10-19 10:21:27 UTC (rev 444)
+++ trunk/python-ogre/ThirdParty/caelum/CaelumSystem.cpp 2007-10-19 13:17:02 UTC (rev 445)
@@ -9,14 +9,10 @@
CaelumSystem::CaelumSystem
(
Ogre::Root *root,
- Ogre::SceneManager *sceneMgr,
- bool createSkyColourModel,
- bool createSkyDome,
- bool createSun,
- bool createStarfield,
- bool createClouds,
- bool manageResGroup,
- const Ogre::String &resGroupName
+ Ogre::SceneManager *sceneMgr,
+ CaelumComponent componentsToCreate/* = CAELUM_COMPONENTS_DEFAULT*/,
+ bool manageResGroup/* = true*/,
+ const Ogre::String &resGroupName/* = RESOURCE_GROUP_NAME*/
):
mCleanup(false)
{
@@ -51,27 +47,31 @@
mUniversalClock = new UniversalClock ();
// Set-up attributes
- mManageFog = false;
+ mManageSceneFog = false;
+ mGlobalFogDensityMultiplier = 1;
+ mSceneFogDensityMultiplier = 1;
+ mGroundFogDensityMultiplier = 1;
LOG ("System attributes set up.");
- assert(getSun() == 0);
- assert(getClouds() == 0);
- // Create basic elements
- if (createSkyColourModel) {
+ // Create default components; as requested.
+ if (componentsToCreate & CAELUM_COMPONENT_SKY_COLOUR_MODEL) {
this->setSkyColourModel (new SkyColourModel ());
}
- if (createSkyDome) {
+ if (componentsToCreate & CAELUM_COMPONENT_SKY_DOME) {
this->setSkyDome (new SkyDome (mSceneMgr));
}
- if (createSun) {
+ if (componentsToCreate & CAELUM_COMPONENT_SUN) {
this->setSun (new Sun (mSceneMgr));
}
- if (createClouds) {
+ if (componentsToCreate & CAELUM_COMPONENT_STARFIELD) {
+ this->setStarfield (new Starfield (mSceneMgr));
+ }
+ if (componentsToCreate & CAELUM_COMPONENT_CLOUDS) {
this->setClouds (new LayeredClouds (mSceneMgr));
}
- if (createStarfield) {
- this->setStarfield (new Starfield (mSceneMgr));
+ if (componentsToCreate & CAELUM_COMPONENT_GROUND_FOG) {
+ this->setGroundFog (new GroundFog (mSceneMgr));
}
// Auto-register itself as a frame listener
@@ -97,6 +97,8 @@
setSun (0);
setStarfield (0);
setClouds (0);
+ setGroundFog (0);
+ setSkyColourModel (0);
// Destroy the clock
if (mUniversalClock) {
@@ -143,6 +145,10 @@
if (getClouds ()) {
getClouds ()->notifyCameraChanged (cam);
}
+
+ if (getGroundFog ()) {
+ getGroundFog ()->notifyCameraChanged (cam);
+ }
}
UniversalClock *CaelumSystem::getUniversalClock () const {
@@ -172,25 +178,44 @@
sunDir = Ogre::Vector3::UNIT_Y;
}
+ // Update sun.
if (getSun ()) {
getSun ()->update (relDayTime);
}
+ // Update starfield
if (getStarfield ()) {
getStarfield ()->update (relDayTime);
}
+ // Update skydome.
if (getSkyDome ()) {
getSkyDome ()->setSunDirection (sunDir);
}
- if (mManageFog) {
- // TODO: Fog stuff here!!!
- if (getSkyColourModel ()) {
- mSceneMgr->setFog (Ogre::FOG_EXP2,
- mSkyColourModel->getFogColour (relDayTime, sunDir) * 0.7,
- mSkyColourModel->getFogDensity (relDayTime, sunDir));
- }
+ // Init fog properties from sky colour model.
+ double fogDensity;
+ Ogre::ColourValue fogColour;
+ if (getSkyColourModel ()) {
+ fogDensity = getSkyColourModel ()->getFogDensity (relDayTime, sunDir);
+ fogDensity *= mGlobalFogDensityMultiplier;
+ fogColour = mSkyColourModel->getFogColour (relDayTime, sunDir);
+ } else {
+ fogDensity = 0;
+ fogColour = Ogre::ColourValue::Black;
+ }
+
+ // Update scene fog.
+ if (getManageSceneFog ()) {
+ mSceneMgr->setFog (Ogre::FOG_EXP2,
+ fogColour * 0.7,
+ fogDensity * mSceneFogDensityMultiplier);
+ }
+
+ // Update ground fog.
+ if (getGroundFog ()) {
+ getGroundFog ()->setColour (fogColour);
+ getGroundFog ()->setDensity (fogDensity * mGroundFogDensityMultiplier);
}
// Set sun colours.
@@ -205,7 +230,9 @@
}
}
+ // Update clouds
// This has to be moved out of here, but Universal clock doesn't calculate deltaT
+ // Maybe it's better to update everything every frame?
if (getClouds()) {
double time = mUniversalClock->getCurrentRelativeDayTime ();
Ogre::Vector3 sunDir = getSun() ? mSun->getSunDirection() : Ogre::Vector3::UNIT_Y;
@@ -218,14 +245,42 @@
return true;
}
-void CaelumSystem::setManageFog (bool manage) {
- mManageFog = manage;
+void CaelumSystem::setManageSceneFog (bool value) {
+ mManageSceneFog = value;
+ // Prevent having some stale values around.
+ if (!value) {
+ mSceneMgr->setFog (Ogre::FOG_NONE);
+ }
}
-bool CaelumSystem::isFogManaged () const {
- return mManageFog;
+bool CaelumSystem::getManageSceneFog () const {
+ return mManageSceneFog;
}
+void CaelumSystem::setSceneFogDensityMultiplier (double value) {
+ mSceneFogDensityMultiplier = value;
+}
+
+double CaelumSystem::getSceneFogDensityMultiplier () const {
+ return mSceneFogDensityMultiplier;
+}
+
+void CaelumSystem::setGroundFogDensityMultiplier (double value) {
+ mGroundFogDensityMultiplier = value;
+}
+
+double CaelumSystem::getGroundFogDensityMultiplier () const {
+ return mGroundFogDensityMultiplier;
+}
+
+void CaelumSystem::setGlobalFogDensityMultiplier (double value) {
+ mGlobalFogDensityMultiplier = value;
+}
+
+double CaelumSystem::getGlobalFogDensityMultiplier () const {
+ return mGlobalFogDensityMultiplier;
+}
+
bool CaelumSystem::fireStartedEvent (const Ogre::FrameEvent &e) {
std::set<CaelumListener *>::iterator it, iend = mListeners.end ();
bool flag = true;
Modified: trunk/python-ogre/ThirdParty/caelum/CaelumSystem.h
===================================================================
--- trunk/python-ogre/ThirdParty/caelum/CaelumSystem.h 2007-10-19 10:21:27 UTC (rev 444)
+++ trunk/python-ogre/ThirdParty/caelum/CaelumSystem.h 2007-10-19 13:17:02 UTC (rev 445)
@@ -9,12 +9,33 @@
#include "SkyDome.h"
#include "Starfield.h"
#include "LayeredClouds.h"
+#include "GroundFog.h"
#include "Sun.h"
namespace caelum {
/** Root of the Caelum system.
- This class is the root of the Caelum system.
+
+ Caelum is built from several classes for different sky elements (the sun,
+ clouds, etc). Those classes know very little about each other and are
+ connected through the main CaelumSystem class. This class is responsible
+ for tracking and updating sub-components. It "owns" all of the components,
+ using std::auto_ptr members.
+
+ The constructor will create a standard set of components but you can
+ disable some or change others. When you do something like setXxx(new Xxx())
+ CaelumSystem takes control of the object's lifetime.
+
+ This class is also reponsible for doing all per-frame and per-RenderTarget
+ updates. It's better to keep that logic here instead of coupling components
+ together.
+
+ It's difficult to build a CaelumSystem class which will work for any
+ combination of sky elements. It might be a good idea to have different
+ classes for vastly different sky systems. Alternatively the update logic
+ from Caelum could be refactor to only transfer a number of "common sky
+ parameter" around; but that is a lot harder and ultimately less flexible.
+
@author Jes\xFAs Alonso Abad
*/
class DllExport CaelumSystem : public Ogre::FrameListener, public Ogre::RenderTargetListener {
@@ -43,9 +64,17 @@
/// Reference to the universal clock.
UniversalClock *mUniversalClock;
- /** Flag to indicate if Caelum should manage the fog or not.
- */
- bool mManageFog;
+ /// Flag to indicate if Caelum manages standard Ogre::Scene fog.
+ bool mManageSceneFog;
+
+ /// Global fog density multiplier.
+ double mGlobalFogDensityMultiplier;
+
+ /// Scene fog density multiplier.
+ double mSceneFogDensityMultiplier;
+
+ /// Ground fog density multiplier.
+ double mGroundFogDensityMultiplier;
/** The sky dome.
*/
@@ -67,25 +96,58 @@
*/
std::auto_ptr<SkyColourModel> mSkyColourModel;
+ /** Reference to ground fog; if enabled.
+ */
+ std::auto_ptr<GroundFog> mGroundFog;
+
// Methods --------------------------------------------------------------------
public:
+ /** Flags enumeration for caelum components.
+ * This is an enumeration for the components to create by default in
+ * Caelum's constructor. You can still pass 0 and create everything
+ * by hand.
+ *
+ * CaelumSystem's constructor used to take a number of bools but now
+ * there are too many components and this is nicer.
+ *
+ * CAELUM_COMPONENT_ members are for individual components.
+ * CAELUM_COMPONENTS_ are standard bitmasks.
+ * CAELUM_COMPONENTS_DEFAULT picks elements that don't require
+ * modifications to external materials (right now it excludes ground fog).
+ */
+ enum CaelumComponent
+ {
+ CAELUM_COMPONENT_SKY_COLOUR_MODEL = 1 << 0,
+ CAELUM_COMPONENT_SKY_DOME = 1 << 1,
+ CAELUM_COMPONENT_SUN = 1 << 2,
+ CAELUM_COMPONENT_STARFIELD = 1 << 3,
+ CAELUM_COMPONENT_CLOUDS = 1 << 4,
+ CAELUM_COMPONENT_GROUND_FOG = 1 << 5,
+
+ CAELUM_COMPONENTS_NONE = 0x0000,
+ CAELUM_COMPONENTS_DEFAULT = 0x001F,
+ CAELUM_COMPONENTS_ALL = 0x002F,
+ };
+
/** Constructor.
Registers itself in the Ogre engine and initialises the system.
- @param root The Ogre rool.
- @param sceneMgr The Ogre scene manager.
- @param manageResGroup Tells the system if the resource group has been created externally (true) or if it's to be managed by the system.
- @param resGroupName The resource group name, if it's desired to use an existing one or just a different name.
+ It can also initialize a bunch of default components.
+
+ @param root The Ogre root.
+ @param scene The Ogre scene manager.
+ @param compoment The components to create.
+ @param manageResGroup Tells the system if the resource group has
+ been created externally (true) or if it's to be managed by the system.
+ @param resGroupName The resource group name, if it's desired to
+ use an existing one or just a different name.
*/
CaelumSystem (
Ogre::Root *root,
Ogre::SceneManager *sceneMgr,
- bool createSkyColourModel = true,
- bool createSkyDome = true,
- bool createSun = true,
- bool createStarfield = true,
- bool createClouds = true,
+ CaelumComponent componentsToCreate = CAELUM_COMPONENTS_DEFAULT,
bool manageResGroup = true,
- const Ogre::String &resGroupName = RESOURCE_GROUP_NAME);
+ const Ogre::String &resGroupName = RESOURCE_GROUP_NAME
+ );
/** Destructor.
*/
@@ -193,16 +255,76 @@
return mSkyColourModel.get();
}
- /** Enables/disables the Caelum fog management.
- @param manage True if you want Caelum to manage the fog for you.
+ /** Sets ground fog system.
+ * @param model The sky colour model, or null to disable
*/
- void setManageFog (bool manage);
+ inline void setGroundFog (GroundFog *model) {
+ mGroundFog.reset(model);
+ }
+ /** Get ground fog; if any.
+ */
+ inline GroundFog* getGroundFog () const {
+ return mGroundFog.get();
+ }
+
+ /** Enables/disables Caelum managing standard Ogre::Scene fog.
+ This makes CaelumSystem control standard Ogre::Scene fogging. It
+ will use EXP2 fog with density from SkyColourModel.
+
+ Fog density multipliers are used; final scene fog density is:
+ SceneMultiplier * GlobalMultiplier * SkyColourModel.GetFogDensity
+
+ When this is set to false it also disables all scene fog (but you
+ control it afterwards).
+
+ @param value New value
+ */
+ void setManageSceneFog (bool value);
+
/** Tells if Caelum is managing the fog or not.
- @return True if Caelum manages the fog.
+ @return The value set in setManageSceneFog.
*/
- bool isFogManaged () const;
+ bool getManageSceneFog () const;
+ /** Multiplier for scene fog density (default 1).
+ This is an additional multiplier for Ogre::Scene fog density.
+ This has no effect if getManagerSceneFog is false.
+
+ Final scene fog density is:
+ SceneMultiplier * GlobalMultiplier * SkyColourModel.GetFogDensity
+ */
+ void setSceneFogDensityMultiplier (double value);
+
+ /** Get the value set by setSceneFogDensityMultiplier.
+ */
+ double getSceneFogDensityMultiplier () const;
+
+ /** Multiplier for ground fog density (default 1).
+ This is an additional multiplier for Caelum::GroundFog density.
+ This has no effect if GroundFog is not used.
+
+ Final ground fog density is:
+ GroundFogMultipler * GlobalMultiplier * SkyColourModel.GetFogDensity
+ */
+ void setGroundFogDensityMultiplier (double value);
+
+ /** Get the value set by setGroundFogDensityMultiplier.
+ */
+ double getGroundFogDensityMultiplier () const;
+
+ /** Multiplier for global fog density (default 1).
+ This is an additional multiplier for fog density as received from
+ SkyColourModel. There are other multipliers you can tweak for
+ individual kinds of fog; but this is what you should change from
+ whatever "game logic" you might have.
+ */
+ void setGlobalFogDensityMultiplier (double value);
+
+ /** Get the value set by setSceneFogDensityMultiplier.
+ */
+ double getGlobalFogDensityMultiplier () const;
+
private:
/** Fires the start event to all the registered listeners.
@param e The Ogre FrameEvent object passed this frame.
Added: trunk/python-ogre/ThirdParty/caelum/GroundFog.cpp
===================================================================
--- trunk/python-ogre/ThirdParty/caelum/GroundFog.cpp (rev 0)
+++ trunk/python-ogre/ThirdParty/caelum/GroundFog.cpp 2007-10-19 13:17:02 UTC (rev 445)
@@ -0,0 +1,180 @@
+#include "CaelumPrecompiled.h"
+#include "GroundFog.h"
+#include "CaelumExceptions.h"
+
+namespace caelum {
+ const Ogre::String GroundFog::DEFAULT_PASS_NAME = "CaelumGroundFog";
+
+ GroundFog::GroundFog(
+ Ogre::SceneManager *scene,
+ const Ogre::String &domeMaterialName,
+ const Ogre::String &domeEntityName):
+ mScene(scene)
+ {
+ // Create dome entity, using a prefab sphere.
+ // The prefab sphere has a radius of 50 units.
+ // If this changes in future version of ogre this might break.
+ mDomeEntity = mScene->createEntity(domeEntityName, Ogre::SceneManager::PT_SPHERE);
+ mDomeEntity->setMaterialName(domeMaterialName);
+ mDomeEntity->setCastShadows(false);
+ mDomeEntity->setRenderQueueGroup (CAELUM_RENDER_QUEUE_GROUND_FOG);
+
+ mDomeNode = mScene->getRootSceneNode ()->createChildSceneNode ();
+ mDomeNode->attachObject (mDomeEntity);
+
+ // Maybe it would be better to create the material at runtime instead.
+ // More consistent with the rest of Caelum.
+ mDomeMaterial = static_cast<Ogre::MaterialPtr>(
+ Ogre::MaterialManager::getSingleton().getByName(domeMaterialName));
+ mDomeMaterial->load();
+ if (mDomeMaterial->getBestTechnique() == 0) {
+ throw new UnsupportedException (0, "GroundFog dome material not supported.",
+ "GroundFog", "GroundFog.cpp", -1);
+ }
+ mDomeMaterial->getBestTechnique()->getPass(0)->getFragmentProgramParameters()->setIgnoreMissingParams(true);
+ mDomeMaterial->getBestTechnique()->getPass(0)->getVertexProgramParameters()->setIgnoreMissingParams(true);
+
+ // Initialize default fog parameters
+ mDensity = 0.1;
+ mVerticalDecay = 0.2;
+ mGroundLevel = 5;
+ mFogColour = Ogre::ColourValue::Black;
+
+ forceUpdate();
+ }
+
+ GroundFog::~GroundFog() {
+ mDomeNode->detachObject(mDomeEntity);
+ mScene->destroyEntity(mDomeEntity);
+ mDomeEntity = 0;
+ static_cast<Ogre::SceneNode*>(mDomeNode->getParent())->
+ removeAndDestroyChild(mDomeNode->getName());
+ mDomeNode = 0;
+ mScene = 0;
+ }
+
+ GroundFog::PassSet& GroundFog::getPasses() {
+ return mPasses;
+ }
+
+ const GroundFog::PassSet& GroundFog::getPasses() const {
+ return mPasses;
+ }
+
+ void GroundFog::findFogPassesByName (const Ogre::String& passName) {
+ Ogre::MaterialManager *matManager = Ogre::MaterialManager::getSingletonPtr();
+ Ogre::MaterialManager::ResourceMapIterator matIt = matManager->getResourceIterator();
+ while (matIt.hasMoreElements()) {
+ Ogre::MaterialPtr mat = matIt.getNext();
+ Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator();
+ while (techIt.hasMoreElements()) {
+ Ogre::Technique *tech = techIt.getNext();
+ Ogre::Technique::PassIterator passIt = tech->getPassIterator();
+ while (passIt.hasMoreElements()) {
+ Ogre::Pass *pass = passIt.getNext();
+ if (pass->getName() == passName) {
+ mPasses.insert(pass);
+ }
+ }
+ }
+ }
+ forceUpdate();
+ }
+
+ void GroundFog::setDensity (Ogre::Real density) {
+ if (Ogre::Math::Abs(mDensity - density) > 0.000001) {
+ for (PassSet::iterator it = mPasses.begin(); it != mPasses.end(); ++it) {
+ Ogre::GpuProgramParametersSharedPtr params = (*it)->getFragmentProgramParameters();
+ params->setNamedConstant("fogDensity", density);
+ }
+ mDensity = density;
+ }
+ updateSkyFogging();
+ }
+
+ Ogre::Real GroundFog::getDensity () {
+ return mDensity;
+ }
+
+ void GroundFog::setColour (const Ogre::ColourValue &colour) {
+ for (PassSet::iterator it = mPasses.begin(); it != mPasses.end(); ++it) {
+ Ogre::GpuProgramParametersSharedPtr params = (*it)->getFragmentProgramParameters();
+ params->setNamedConstant("fogColour", colour);
+ }
+ mFogColour = colour;
+ updateSkyFogging();
+ }
+
+ Ogre::ColourValue GroundFog::getColour () {
+ return mFogColour;
+ }
+
+ void GroundFog::setVerticalDecay (Ogre::Real verticalDecay) {
+ if (Ogre::Math::Abs(mVerticalDecay - verticalDecay) > 0.000001) {
+ for (PassSet::iterator it = mPasses.begin(); it != mPasses.end(); ++it) {
+ Ogre::GpuProgramParametersSharedPtr params = (*it)->getFragmentProgramParameters();
+ params->setNamedConstant("fogVerticalDecay", verticalDecay);
+ }
+ mVerticalDecay = verticalDecay;
+ }
+ updateSkyFogging();
+ }
+
+ Ogre::Real GroundFog::getVerticalDecay () {
+ return mVerticalDecay;
+ }
+
+ void GroundFog::setGroundLevel (Ogre::Real groundLevel) {
+ if (Ogre::Math::Abs(mGroundLevel - groundLevel) > 0.000001) {
+ for (PassSet::iterator it = mPasses.begin(); it != mPasses.end(); ++it) {
+ Ogre::GpuProgramParametersSharedPtr params = (*it)->getFragmentProgramParameters();
+ params->setNamedConstant("fogGroundLevel", groundLevel);
+ }
+ mGroundLevel = groundLevel;
+ }
+ updateSkyFogging();
+ }
+
+ Ogre::Real GroundFog::getGroundLevel () {
+ return mGroundLevel;
+ }
+
+ void GroundFog::forceUpdate () {
+ for (PassSet::iterator it = mPasses.begin(); it != mPasses.end(); ++it) {
+ Ogre::GpuProgramParametersSharedPtr params = (*it)->getFragmentProgramParameters();
+ params->setNamedConstant("fogDensity", mDensity);
+ params->setNamedConstant("fogVerticalDecay", mVerticalDecay);
+ params->setNamedConstant("fogGroundLevel", mGroundLevel);
+ params->setNamedConstant("fogColour", mFogColour);
+ }
+ updateSkyFogging();
+ }
+
+ void GroundFog::notifyCameraChanged (Ogre::Camera *cam)
+ {
+ // Move and sky to fill the sky.
+ // Adjust for radius 50.
+ mDomeNode->setPosition (cam->getRealPosition ());
+ if (cam->getFarClipDistance () > 0) {
+ mDomeNode->setScale (Ogre::Vector3::UNIT_SCALE * (1 / 50.0) *
+ (cam->getFarClipDistance () - CAMERA_DISTANCE_MODIFIER));
+ } else {
+ mDomeNode->setScale (Ogre::Vector3::UNIT_SCALE * (1 / 50.0) *
+ (cam->getNearClipDistance () + CAMERA_DISTANCE_MODIFIER));
+ }
+
+ // Send camera height to shader.
+ Ogre::GpuProgramParametersSharedPtr params =
+ mDomeMaterial->getBestTechnique()->getPass(0)->getFragmentProgramParameters();
+ params->setNamedConstant("cameraHeight", cam->getDerivedPosition().y);
+ }
+
+ void GroundFog::updateSkyFogging() {
+ Ogre::GpuProgramParametersSharedPtr params =
+ mDomeMaterial->getBestTechnique()->getPass(0)->getFragmentProgramParameters();
+ params->setNamedConstant("fogDensity", getDensity());
+ params->setNamedConstant("fogColour", getColour());
+ params->setNamedConstant("fogVerticalDecay", getVerticalDecay());
+ params->setNamedConstant("fogGroundLevel", getGroundLevel());
+ }
+}
\ No newline at end of file
Added: trunk/python-ogre/ThirdParty/caelum/GroundFog.h
===================================================================
--- trunk/python-ogre/ThirdParty/caelum/GroundFog.h (rev 0)
+++ trunk/python-ogre/ThirdParty/caelum/GroundFog.h 2007-10-19 13:17:02 UTC (rev 445)
@@ -0,0 +1,126 @@
+#ifndef GROUNDFOG_H
+#define GROUNDFOG_H
+
+#include "CaelumPrerequisites.h"
+
+namespace caelum {
+
+/** Exponential ground fog system implementation.
+ *
+ * This class controls CaelumGroundFog passes in a potentially large number
+ * of materials, changing shader program parameters. This class keeps a list
+ * of passes to control; which can be build based on pass name.
+ *
+ * This simulates a field of fog where "absorption" at a certain point is
+ * exp(-verticalDecay * (h - fogLevel)). This absorption is multiplicative,
+ * the total fog alpha is e^(-density * absorption_on_view_path).
+ *
+ * You can set verticalDecay to 0 and get standard GL_EXP fog. Don't actually
+ * do that though because you'll get a division by 0.
+ */
+class DllExport GroundFog {
+ public:
+ static const Ogre::String DEFAULT_PASS_NAME;
+
+ /** Constructor.
+ */
+ GroundFog (Ogre::SceneManager *scene,
+ const Ogre::String &domeMaterialName = "CaelumGroundFogDome",
+ const Ogre::String &domeEntityName = "CaelumGroundFogDome");
+
+ /** Virtual destructor.
+ */
+ virtual ~GroundFog ();
+
+ /// Handle camera change.
+ void notifyCameraChanged (Ogre::Camera *cam);
+
+ /** Typedef for easier manipulation of a set of Passes.
+ */
+ typedef std::set<Ogre::Pass *> PassSet;
+
+ /** Get the set of currently controlled passes.
+ * This is provided if you really want to change the set by hand.
+ * You should call forceUpdate after modifying this set.
+ */
+ PassSet& getPasses();
+
+ /** Get the set of currently controlled passes.
+ * This is a const overload which doesn't let you modify the
+ * underlying collection.
+ */
+ const PassSet& getPasses () const;
+
+ /** Find caelum fog passes to control by name.
+ * By default this looks for passes called "CaleumGroundFog".
+ * @note This calls forceUpdate()
+ */
+ void findFogPassesByName (const Ogre::String& passName = DEFAULT_PASS_NAME);
+
+ /// Sets the fog density multiplier
+ void setDensity (Ogre::Real density);
+
+ /// Get the fog density multiplier
+ Ogre::Real getDensity ();
+
+ /// Sets fog colour
+ void setColour (const Ogre::ColourValue &colour);
+
+ /// Gets fog colour
+ Ogre::ColourValue getColour ();
+
+ /// Sets the vertical fog decay constant.
+ void setVerticalDecay (Ogre::Real verticalDecay);
+
+ /// Get the vertical fog decay constant.
+ Ogre::Real getVerticalDecay ();
+
+ /** Sets the ground level.
+ * At ground level 'fogginess' is equal to 1.
+ */
+ void setGroundLevel (Ogre::Real GroundLevela);
+
+ /** Get the ground level.
+ */
+ Ogre::Real getGroundLevel ();
+
+ /** Forces an update of all the passes. You have to use this if you modify
+ * the set of passes by hand, otherwise avoid it.
+ */
+ void forceUpdate ();
+
+ private:
+ /// Cached Density
+ Ogre::Real mDensity;
+
+ /// Cached VerticalDecay
+ Ogre::Real mVerticalDecay;
+
+ /// Cached GroundLevel
+ Ogre::Real mGroundLevel;
+
+ /// Fog colour
+ Ogre::ColourValue mFogColour;
+
+ /// The passes to control.
+ PassSet mPasses;
+
+ /// Sky dome material
+ Ogre::MaterialPtr mDomeMaterial;
+
+ /// Sky dome mesh
+ Ogre::SceneNode *mDomeNode;
+
+ /// Sky dome entity
+ Ogre::Entity *mDomeEntity;
+
+ /// The scene to control fog in.
+ Ogre::SceneManager* mScene;
+
+ // Called whenever something changes to update the sky dome.
+ void updateSkyFogging();
+};
+
+}
+
+#endif //GROUNDFOG_H
\ No newline at end of file
Modified: trunk/python-ogre/ThirdParty/caelum/SkyColourModel.cpp
===================================================================
--- trunk/python-ogre/ThirdParty/caelum/SkyColourModel.cpp 2007-10-19 10:21:27 UTC (rev 444)
+++ trunk/python-ogre/ThirdParty/caelum/SkyColourModel.cpp 2007-10-19 13:17:02 UTC (rev 445)
@@ -57,7 +57,7 @@
float SkyColourModel::getFogDensity (float time, const Ogre::Vector3 &sunDir) {
float elevation = sunDir.dotProduct (Ogre::Vector3::UNIT_Y) * 0.5 + 0.5;
Ogre::ColourValue col = getInterpolatedColour (elevation, 1, mSkyGradientsImage, false);
- return col.a * mFogDensityMultiplier;
+ return col.a;
}
Ogre::ColourValue SkyColourModel::getSunSphereColour (float time, const Ogre::Vector3 &sunDir) {
@@ -75,36 +75,45 @@
float elevation = sunDir.dotProduct (Ogre::Vector3::UNIT_Y) * 0.5 + 0.5;
// Hack: return averaged sky colours
- Ogre::ColourValue col = getInterpolatedColour (elevation, elevation, mSkyGradientsImage);
+ Ogre::ColourValue col = getInterpolatedColour (elevation, elevation, mSkyGradientsImage, false);
return Ogre::ColourValue::White * (col.r + col.g + col.b) / 3;
}
-Ogre::ColourValue SkyColourModel::getInterpolatedColour (float x, float height, Ogre::Image *img, bool wrap) {
- // Get the image width
- int width = static_cast<int>(img->getWidth ()) - 1;
+Ogre::ColourValue SkyColourModel::getInterpolatedColour (float fx, float fy, Ogre::Image *img, bool wrapX) {
+ // Don't -> all the time, and avoid unsigned warnings
+ int imgWidth = static_cast<int>(img->getWidth ());
+ int imgHeight = static_cast<int>(img->getHeight ());
- // calculate the height
- height = Ogre::Math::Abs (height);
- int y = (int )((img->getHeight () - 1) * height);
- if (y >= static_cast<int>(img->getHeight ()))
- y--;
+ // Calculate pixel y coord.
+ int py = Ogre::Math::IFloor(Ogre::Math::Abs (fy) * (imgHeight - 1));
+ // Snap to py image bounds.
+ py = std::max(0, std::min(py, imgHeight - 1));
- // Get the two closest pixels
- int curPix, auxPix;
- float diff;
- curPix = (int )(width * x);
- diff = width * x - curPix;
- if (diff < 0) {
- auxPix = curPix - 1;
- }
- else {
- auxPix = curPix + 1;
- }
+ // Get the two closest pixels on x.
+ // px1 and px2 are the closest integer pixels to px.
+ float px = fx * (img->getWidth () - 1);
+ int px1, px2;
+ px1 = Ogre::Math::IFloor(px);
+ px2 = Ogre::Math::ICeil(px);
+ if (wrapX) {
+ // Wrap x coords. The funny addition ensures that it does
+ // "the right thing" for negative values.
+ px1 = (px1 % imgWidth + imgWidth) % imgWidth;
+ px2 = (px2 % imgWidth + imgWidth) % imgWidth;
+ } else {
+ px1 = std::max(0, std::min(px1, imgWidth - 1));
+ px2 = std::max(0, std::min(px2, imgWidth - 1));
+ }
+
// Calculate the interpolated pixel
Ogre::ColourValue c1, c2, cf;
- c1 = img->getColourAt (wrap ? curPix % width : curPix < 0 ? 0 : curPix > width ? width : curPix, y, 0);
- c2 = img->getColourAt (wrap ? auxPix % width : auxPix < 0 ? 0 : auxPix > width ? width : auxPix, y, 0);
+ c1 = img->getColourAt (px1, py, 0);
+ c2 = img->getColourAt (px2, py, 0);
+
+ // Blend the two pixels together.
+ // diff is the weight between pixel 1 and pixel 2.
+ float diff = px - px1;
cf = c1 * (1 - diff) + c2 * diff;
return cf;
Modified: trunk/python-ogre/ThirdParty/caelum/SkyColourModel.h
===================================================================
--- trunk/python-ogre/ThirdParty/caelum/SkyColourModel.h 2007-10-19 10:21:27 UTC (rev 444)
+++ trunk/python-ogre/ThirdParty/caelum/SkyColourModel.h 2007-10-19 13:17:02 UTC (rev 445)
@@ -52,14 +52,6 @@
*/
float getFogDensity (float time, const Ogre::Vector3 &sunDir);
- inline float getFogDensityMultiplier() {
- return mFogDensityMultiplier;
- }
-
- inline void setFogDensityMultiplier(float value) {
- mFogDensityMultiplier = value;
- }
-
/** Get the colour of the sun sphere.
* This colour is used to draw the sun sphere in the sky.
* @return The colour of the sun.
@@ -83,13 +75,19 @@
protected:
/** Gets the interpolated colour between two pixels from an image.
- @param x The horizontal coordinate in the range [0, 1].
- @param height The height at which the pixels are located in the range [0, 1] (will be converted to integer).
+ Interpolate a texture pixel by hand. (fx, fy) are in texture coordinates,
+ ranging [0-1] across the entire texture.
+ Smooth blending is only done on the x coordinate.
+ Wrapping is only supported on X as well.
+
+ @param fx Horizontal coordinate.
+ @param fy Vertical coordiate.
@param img The lookup image.
- @param wrap If the map wraps horizontally or not.
+ @param wrapX To wrap the x coordinate.
@return The interpolated colour.
*/
- static Ogre::ColourValue getInterpolatedColour (float x, float height, Ogre::Image *img, bool wrap = true);
+ static Ogre::ColourValue getInterpolatedColour (float fx, float fy, Ogre::Image *img,
+ bool wrapX = true);
};
} // namespace caelum
Modified: trunk/python-ogre/ThirdParty/caelum/SkyDome.cpp
===================================================================
--- trunk/python-ogre/ThirdParty/caelum/SkyDome.cpp 2007-10-19 10:21:27 UTC (rev 444)
+++ trunk/python-ogre/ThirdParty/caelum/SkyDome.cpp 2007-10-19 13:17:02 UTC (rev 445)
@@ -1,68 +1,68 @@
-#include "CaelumPrecompiled.h"
-#include "SkyDome.h"
-#include "GeometryFactory.h"
-#include "CaelumExceptions.h"
-
-namespace caelum {
-
-const Ogre::String SkyDome::SPHERIC_DOME_NAME = "CaelumSphericDome";
-const Ogre::String SkyDome::SKY_DOME_MATERIAL_NAME = "CaelumSkyDomeMaterial";
-
-SkyDome::SkyDome (Ogre::SceneManager *sceneMgr) {
- mAutoRadius = true;
-
- createSkyDomeMaterial ();
-
- GeometryFactory::generateSphericDome (SPHERIC_DOME_NAME, 32);
- Ogre::Entity *ent = sceneMgr->createEntity ("Dome", SPHERIC_DOME_NAME);
- ent->setMaterialName (SKY_DOME_MATERIAL_NAME);
- ent->setRenderQueueGroup (CAELUM_RENDER_QUEUE_SKYDOME);
- ent->setCastShadows (false);
-
- mNode = sceneMgr->getRootSceneNode ()->createChildSceneNode ();
- mNode->attachObject (ent);
-}
-
-SkyDome::~SkyDome () {
- if (mNode) {
- // Detach and destroy attached entity.
- Ogre::Entity *ent = static_cast<Ogre::Entity *>(mNode->detachObject ("Dome"));
- ent->_getManager ()->destroyEntity (ent);
-
- // Destroy the node
- static_cast<Ogre::SceneNode *>(mNode->getParent ())->removeAndDestroyChild (mNode->getName ());
- mNode = 0;
- }
-
- destroySkyDomeMaterial ();
-}
-
-void SkyDome::notifyCameraChanged (Ogre::Camera *cam) {
- mNode->setPosition (cam->getRealPosition ());
- if (mAutoRadius) {
- if (cam->getFarClipDistance () > 0) {
- mNode->setScale (Ogre::Vector3::UNIT_SCALE * (
- cam->getFarClipDistance () - CAMERA_DISTANCE_MODIFIER));
- } else {
- mNode->setScale (Ogre::Vector3::UNIT_SCALE * (
- cam->getNearClipDistance () + CAMERA_DISTANCE_MODIFIER));
- }
- }
-}
-
-void SkyDome::setFarRadius (float radius) {
- if (radius > 0) {
- mNode->setScale (Ogre::Vector3::UNIT_SCALE * radius);
- mAutoRadius = false;
- } else {
- mAutoRadius = true;
- }
-}
-
-void SkyDome::setSunDirection (Ogre::Vector3 sunDir) {
+#include "CaelumPrecompiled.h"
+#include "SkyDome.h"
+#include "GeometryFactory.h"
+#include "CaelumExceptions.h"
+
+namespace caelum {
+
+const Ogre::String SkyDome::SPHERIC_DOME_NAME = "CaelumSphericDome";
+const Ogre::String SkyDome::SKY_DOME_MATERIAL_NAME = "CaelumSkyDomeMaterial";
+
+SkyDome::SkyDome (Ogre::SceneManager *sceneMgr) {
+ mAutoRadius = true;
+
+ createSkyDomeMaterial ();
+
+ GeometryFactory::generateSphericDome (SPHERIC_DOME_NAME, 32);
+ Ogre::Entity *ent = sceneMgr->createEntity ("Dome", SPHERIC_DOME_NAME);
+ ent->setMaterialName (SKY_DOME_MATERIAL_NAME);
+ ent->setRenderQueueGroup (CAELUM_RENDER_QUEUE_SKYDOME);
+ ent->setCastShadows (false);
+
+ mNode = sceneMgr->getRootSceneNode ()->createChildSceneNode ();
+ mNode->attachObject (ent);
+}
+
+SkyDome::~SkyDome () {
+ if (mNode) {
+ // Detach and destroy attached entity.
+ Ogre::Entity *ent = static_cast<Ogre::Entity *>(mNode->detachObject ("Dome"));
+ ent->_getManager ()->destroyEntity (ent);
+
+ // Destroy the node
+ static_cast<Ogre::SceneNode *>(mNode->getParent ())->removeAndDestroyChild (mNode->getName ());
+ mNode = 0;
+ }
+
+ destroySkyDomeMaterial ();
+}
+
+void SkyDome::notifyCameraChanged (Ogre::Camera *cam) {
+ mNode->setPosition (cam->getRealPosition ());
+ if (mAutoRadius) {
+ if (cam->getFarClipDistance () > 0) {
+ mNode->setScale (Ogre::Vector3::UNIT_SCALE * (
+ cam->getFarClipDistance () - CAMERA_DISTANCE_MODIFIER));
+ } else {
+ mNode->setScale (Ogre::Vector3::UNIT_SCALE * (
+ cam->getNearClipDistance () + CAMERA_DISTANCE_MODIFIER));
+ }
+ }
+}
+
+void SkyDome::setFarRadius (float radius) {
+ if (radius > 0) {
+ mNode->setScale (Ogre::Vector3::UNIT_SCALE * radius);
+ mAutoRadius = false;
+ } else {
+ mAutoRadius = true;
+ }
+}
+
+void SkyDome::setSunDirection (Ogre::Vector3 sunDir) {
float elevation = sunDir.dotProduct (Ogre::Vector3::UNIT_Y);
- elevation = elevation * 0.5 + 0.5;
-
+ elevation = elevation * 0.5 + 0.5;
+
Ogre::GpuProgramParametersSharedPtr vpParams =
mMaterial->getBestTechnique()->getPass(0)->getVertexProgramParameters();
Ogre::GpuProgramParametersSharedPtr fpParams =
@@ -70,150 +70,152 @@
Ogre::TextureUnitState* gradientsTus =
mMaterial->getBestTechnique()->getPass(0)->getTextureUnitState(0);
- vpParams->setNamedConstant ("sunDirection", sunDir);
- fpParams->setNamedConstant ("offset", elevation);
- gradientsTus->setTextureUScroll (elevation);
-}
-
-void SkyDome::setLightAbsorption (float absorption) const {
- if (absorption > 1)
- absorption = 1;
- else if (absorption < 0)
- absorption = 0;
-
+ vpParams->setNamedConstant ("sunDirection", sunDir);
+ fpParams->setNamedConstant ("offset", elevation);
+ gradientsTus->setTextureUScroll (elevation);
+}
+
+void SkyDome::setLightAbsorption (float absorption) const {
+ if (absorption > 1)
+ absorption = 1;
+ else if (absorption < 0)
+ absorption = 0;
+
Ogre::GpuProgramParametersSharedPtr vpParams =
mMaterial->getBestTechnique()->getPass(0)->getVertexProgramParameters();
- vpParams->setNamedConstant ("lightAbsorption", absorption);
-}
-
-void SkyDome::setLightScattering (float scattering) const {
- if (scattering <= 0)
- scattering = 0.00001;
-
+ vpParams->setNamedConstant ("lightAbsorption", absorption);
+}
+
+void SkyDome::setLightScattering (float scattering) const {
+ if (scattering <= 0)
+ scattering = 0.00001;
+
Ogre::GpuProgramParametersSharedPtr fpParams =
mMaterial->getBestTechnique()->getPass(0)->getFragmentProgramParameters();
- fpParams->setNamedConstant ("lightInvScattering", 1.0f / scattering);
-}
-
-void SkyDome::setAtmosphereHeight (float height) const {
- if (height <= 0) {
- height = 0.00001;
- } else if (height > 1) {
- height = 1;
- }
-
+ fpParams->setNamedConstant ("lightInvScattering", 1.0f / scattering);
+}
+
+void SkyDome::setAtmosphereHeight (float height) const {
+ if (height <= 0) {
+ height = 0.00001;
+ } else if (height > 1) {
+ height = 1;
+ }
+
Ogre::GpuProgramParametersSharedPtr fpParams =
mMaterial->getBestTechnique()->getPass(0)->getFragmentProgramParameters();
- fpParams->setNamedConstant ("atmosphereInvHeight", 1.0f / height);
-}
-
-void SkyDome::setSkyGradientsImage (const Ogre::String& gradients) {
- Ogre::TextureUnitState* gradientsTus =
- mMaterial->getTechnique (0)->getPass (0)->getTextureUnitState(0);
-
- gradientsTus->setTextureAddressingMode (Ogre::TextureUnitState::TAM_CLAMP);
-
+ fpParams->setNamedConstant ("atmosphereInvHeight", 1.0f / height);
+}
+
+void SkyDome::setSkyGradientsImage (const Ogre::String& gradients) {
+ Ogre::TextureUnitState* gradientsTus =
+ mMaterial->getTechnique (0)->getPass (0)->getTextureUnitState(0);
+
+ gradientsTus->setTextureAddressingMode (Ogre::TextureUnitState::TAM_CLAMP);
+
// Dagon and Eihort compatibility
#if OGRE_VERSION < ((1 << 16) | (3 << 8))
gradientsTus->setTextureName (gradients, Ogre::TEX_TYPE_2D, -1, true);
#else
gradientsTus->setTextureName (gradients, Ogre::TEX_TYPE_2D);
gradientsTus->setIsAlpha (true);
- #endif
-}
-
-void SkyDome::setAtmosphereDepthImage (const Ogre::String& atmosphereDepth) {
- Ogre::TextureUnitState* atmosphereTus =
- mMaterial->getTechnique (0)->getPass (0)->getTextureUnitState(1);
-
- atmosphereTus->setTextureName (atmosphereDepth, Ogre::TEX_TYPE_1D);
- atmosphereTus->setTextureAddressingMode (Ogre::TextureUnitState::TAM_CLAMP, Ogre::TextureUnitState::TAM_WRAP, Ogre::TextureUnitState::TAM_WRAP);
-}
-
-void SkyDome::createSkyDomeMaterial () {
- // Check shader support.
- // It would be nice to check supported profiles in detail.
- if (!Ogre::Root::getSingleton ().getRenderSystem ()->getCapabilities ()->hasCapability (Ogre::RSC_FRAGMENT_PROGRAM)) {
- throw new UnsupportedException (0, "The card doesn't support fragment programs for the sky dome material.", "SkyDome", "SkyDome.cpp", -1);
- }
- if (!Ogre::Root::getSingleton ().getRenderSystem ()->getCapabilities ()->hasCapability (Ogre::RSC_VERTEX_PROGRAM)) {
- throw new UnsupportedException (0, "The card doesn't support vertex programs for the sky dome material.", "SkyDome", "SkyDome.cpp", -1);
- }
-
- LOG ("Generating sky dome material...");
- if (!Ogre::MaterialManager::getSingleton ().resourceExists (SKY_DOME_MATERIAL_NAME)) {
- LOG ("\tMaterial not found; creating...");
- mMaterial = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton ().create (SKY_DOME_MATERIAL_NAME, RESOURCE_GROUP_NAME));
- mMaterial->setReceiveShadows (false);
- LOG ("\t\tMaterial [OK]");
-
- Ogre::Pass *pass = mMaterial->getTechnique (0)->getPass (0);
- pass->setSceneBlending (Ogre::SBT_TRANSPARENT_ALPHA);
- pass->setDepthCheckEnabled (false);
- pass->setDepthWriteEnabled (false);
- pass->setLightingEnabled (false);
- pass->setFog (true);
-
- // Bind fragment program.
- if (Ogre::Root::getSingleton ().getRenderSystem ()->getCapabilities ()->hasCapability (Ogre::RSC_FRAGMENT_PROGRAM)) {
- Ogre::HighLevelGpuProgramPtr fp = Ogre::HighLevelGpuProgramManager::getSingleton().createProgram ("SkyDomeFP", RESOURCE_GROUP_NAME, "cg", Ogre::GPT_FRAGMENT_PROGRAM);
- fp->setSourceFile ("CaelumShaders.cg");
- fp->setParameter ("entry_point", "SkyDome_fp");
- fp->setParameter ("profiles", "ps_2_0 arbfp1");
- pass->setFragmentProgram ("SkyDomeFP");
- Ogre::GpuProgramParametersSharedPtr parameters = pass->getFragmentProgramParameters();
- parameters->setNamedConstant ("offset", 0.0f);
- parameters->setNamedAutoConstant ("hazeColour", Ogre::GpuProgramParameters::ACT_FOG_COLOUR);
- }
-
- // Bind vertex program.
- if (Ogre::Root::getSingleton ().getRenderSystem ()->getCapabilities ()->hasCapability (Ogre::RSC_VERTEX_PROGRAM)) {
- Ogre::HighLevelGpuProgramPtr vp = Ogre::HighLevelGpuProgramManager::getSingleton().createProgram ("SkyDomeVP", RESOURCE_GROUP_NAME, "cg", Ogre::GPT_VERTEX_PROGRAM);
- vp->setSourceFile ("CaelumShaders.cg");
- vp->setParameter ("entry_point", "SkyDome_vp");
- vp->setParameter ("profiles", "vs_2_0 arbvp1");
- pass->setVertexProgram ("SkyDomeVP");
- Ogre::GpuProgramParametersSharedPtr parameters = pass->getVertexProgramParameters();
- parameters->setNamedAutoConstant ("worldViewProj", Ogre::GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX);
- parameters->setNamedConstant ("sunDirection", Ogre::Vector3 (1, 0, 0));
- }
- LOG ("\t\tPass [OK]");
-
- // Create first texture unit; gradients image.
- pass->createTextureUnitState ();
- setSkyGradientsImage("EarthClearSky2.png");
- LOG ("\t\tTextureUnit - Sky gradient [OK]");
-
- // Create second texture unit; atmosphere depth image.
- pass->createTextureUnitState ();
- setAtmosphereDepthImage("AtmosphereDepth.png");
- LOG ("\t\tTextureUnit - Atmosphere depth [OK]");
-
- mMaterial->load ();
- LOG ("\tDONE");
- } else {
- mMaterial = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton ().getByName (SKY_DOME_MATERIAL_NAME));
- }
- LOG ("DONE");
-}
-
-void SkyDome::destroySkyDomeMaterial () {
- LOG ("Removing sky dome material...");
- if ((Ogre::HighLevelGpuProgramManager::getSingletonPtr()->resourceExists("SkyDomeFP"))) {
- LOG ("Removing sky dome SkyDomeFP...");
- Ogre::HighLevelGpuProgramManager::getSingletonPtr()->remove("SkyDomeFP");
- }
-
- if ((Ogre::HighLevelGpuProgramManager::getSingletonPtr()->resourceExists("SkyDomeVP"))) {
- LOG ("Removing sky dome SkyDomeVP...");
- Ogre::HighLevelGpuProgramManager::getSingletonPtr()->remove("SkyDomeVP");
- }
-
- if (!Ogre::MaterialManager::getSingleton ().resourceExists (SKY_DOME_MATERIAL_NAME)) {
- Ogre::MaterialManager::getSingleton ().remove (SKY_DOME_MATERIAL_NAME);
- }
- mMaterial.setNull ();
- LOG ("DONE");
-}
-
-} // namespace caelum
+ #endif
+}
+
+void SkyDome::setAtmosphereDepthImage (const Ogre::String& atmosphereDepth) {
+ Ogre::TextureUnitState* atmosphereTus =
+ mMaterial->getTechnique (0)->getPass (0)->getTextureUnitState(1);
+
+ atmosphereTus->setTextureName (atmosphereDepth, Ogre::TEX_TYPE_1D);
+ atmosphereTus->setTextureAddressingMode (Ogre::TextureUnitState::TAM_CLAMP, Ogre::TextureUnitState::TAM_WRAP, Ogre::TextureUnitState::TAM_WRAP);
+}
+
+void SkyDome::createSkyDomeMaterial () {
+ // Check shader support.
+ // It would be nice to check supported profiles in detail.
+ if (!Ogre::Root::getSingleton ().getRenderSystem ()->getCapabilities ()->hasCapability (Ogre::RSC_FRAGMENT_PROGRAM)) {
+ throw new UnsupportedException (0, "The card doesn't support fragment programs for the sky dome material.", "SkyDome", "SkyDome.cpp", -1);
+ }
+ if (!Ogre::Root::getSingleton ().getRenderSystem ()->getCapabilities ()->hasCapability (Ogre::RSC_VERTEX_PROGRAM)) {
+ throw new UnsupportedException (0, "The card doesn't support vertex programs for the sky dome material.", "SkyDome", "SkyDome.cpp", -1);
+ }
+
+ LOG ("Generating sky dome material...");
+ if (!Ogre::MaterialManager::getSingleton ().resourceExists (SKY_DOME_MATERIAL_NAME)) {
+ LOG ("\tMaterial not found; creating...");
+ mMaterial = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton ().create (SKY_DOME_MATERIAL_NAME, RESOURCE_GROUP_NAME));
+ mMaterial->setReceiveShadows (false);
+ LOG ("\t\tMaterial [OK]");
+
+ Ogre::Pass *pass = mMaterial->getTechnique (0)->getPass (0);
+ pass->setSceneBlending (Ogre::SBT_TRANSPARENT_ALPHA);
+ pass->setDepthCheckEnabled (false);
+ pass->setDepthWriteEnabled (false);
+ pass->setLightingEnabled (false);
+ pass->setFog (true);
+
+ // Bind fragment program.
+ if (Ogre::Root::getSingleton ().getRenderSystem ()->getCapabilities ()->hasCapability (Ogre::RSC_FRAGMENT_PROGRAM)) {
+ Ogre::HighLevelGpuProgramPtr fp = Ogre::HighLevelGpuProgramManager::getSingleton().createProgram ("SkyDomeFP", RESOURCE_GROUP_NAME, "cg", Ogre::GPT_FRAGMENT_PROGRAM);
+ fp->setSourceFile ("CaelumShaders.cg");
+ fp->setParameter ("entry_point", "SkyDome_fp");
+ fp->setParameter ("profiles", "ps_2_0 arbfp1");
+ pass->setFragmentProgram ("SkyDomeFP");
+ Ogre::GpuProgramParametersSharedPtr parameters = pass->getFragmentProgramParameters();
+ parameters->setIgnoreMissingParams(true);
+ parameters->setNamedConstant ("offset", 0.0f);
+ parameters->setNamedAutoConstant ("hazeColour", Ogre::GpuProgramParameters::ACT_FOG_COLOUR);
+ }
+
+ // Bind vertex program.
+ if (Ogre::Root::getSingleton ().getRenderSystem ()->getCapabilities ()->hasCapability (Ogre::RSC_VERTEX_PROGRAM)) {
+ Ogre::HighLevelGpuProgramPtr vp = Ogre::HighLevelGpuProgramManager::getSingleton().createProgram ("SkyDomeVP", RESOURCE_GROUP_NAME, "cg", Ogre::GPT_VERTEX_PROGRAM);
+ vp->setSourceFile ("CaelumShaders.cg");
+ vp->setParameter ("entry_point", "SkyDome_vp");
+ vp->setParameter ("profiles", "vs_2_0 arbvp1");
+ pass->setVertexProgram ("SkyDomeVP");
+ Ogre::GpuProgramParametersSharedPtr parameters = pass->getVertexProgramParameters();
+ parameters->setIgnoreMissingParams(true);
+ parameters->setNamedAutoConstant ("worldViewProj", Ogre::GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX);
+ parameters->setNamedConstant ("sunDirection", Ogre::Vector3 (1, 0, 0));
+ }
+ LOG ("\t\tPass [OK]");
+
+ // Create first texture unit; gradients image.
+ pass->createTextureUnitState ();
+ setSkyGradientsImage("EarthClearSky2.png");
+ LOG ("\t\tTextureUnit - Sky gradient [OK]");
+
+ // Create second texture unit; atmosphere depth image.
+ pass->createTextureUnitState ();
+ setAtmosphereDepthImage("AtmosphereDepth.png");
+ LOG ("\t\tTextureUnit - Atmosphere depth [OK]");
+
+ mMaterial->load ();
+ LOG ("\tDONE");
+ } else {
+ mMaterial = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton ().getByName (SKY_DOME_MATERIAL_NAME));
+ }
+ LOG ("DONE");
+}
+
+void SkyDome::destroySkyDomeMaterial () {
+ LOG ("Removing sky dome material...");
+ if ((Ogre::HighLevelGpuProgramManager::getSingletonPtr()->resourceExists("SkyDomeFP"))) {
+ LOG ("Removing sky dome SkyDomeFP...");
+ Ogre::HighLevelGpuProgramManager::getSingletonPtr()->remove("SkyDomeFP");
+ }
+
+ if ((Ogre::HighLevelGpuProgramManager::getSingletonPtr()->resourceExists("SkyDomeVP"))) {
+ LOG ("Removing sky dome SkyDomeVP...");
+ Ogre::HighLevelGpuProgramManager::getSingletonPtr()->remove("SkyDomeVP");
+ }
+
+ if (!Ogre::MaterialManager::getSingleton ().resourceExists (SKY_DOME_MATERIAL_NAME)) {
+ Ogre::MaterialManager::getSingleton ().remove (SKY_DOME_MATERIAL_NAME);
+ }
+ mMaterial.setNull ();
+ LOG ("DONE");
+}
+
+} // namespace caelum
Modified: trunk/python-ogre/ThirdParty/caelum/UniversalClock.cpp
===================================================================
--- trunk/python-ogre/ThirdParty/caelum/UniversalClock.cpp 2007-10-19 10:21:27 UTC (rev 444)
+++ trunk/python-ogre/ThirdParty/caelum/UniversalClock.cpp 2007-10-19 13:17:02 UTC (rev 445)
@@ -1,106 +1,106 @@
-#include "CaelumPrecompiled.h"
-#include "UniversalClock.h"
-
-namespace caelum {
-
-UniversalClock::UniversalClock () {
- setSecondsPerDay (86400);
- setDaysPerYear (365);
-
- setTimeScale (1.0);
- setUpdateRate (0); // Sets a new mTimeSinceLastUpdate value as well
-}
-
-void UniversalClock::setSecondsPerDay (const Ogre::Real secs) {
- mSecondsPerDay = secs;
-
- updateSecondsPerYear ();
-}
-
-Ogre::Real UniversalClock::getSecondsPerDay () const {
- return mSecondsPerDay;
-}
-
-void UniversalClock::setDaysPerYear (const Ogre::Real days) {
- mDaysPerYear = days;
-
- updateSecondsPerYear ();
-}
-
-Ogre::Real UniversalClock::getDaysPerYear () const {
- return mDaysPerYear;
-}
-
-void UniversalClock::setCurrentTime (const Ogre::Real sec) {
- mCurrentSecond = Ogre::Math::Abs (sec);
-
- mCurrentSecond -= mSecondsPerYear * Ogre::Math::Floor (mCurrentSecond / mSecondsPerYear);
-}
-
-void UniversalClock::setCurrentRelativeTime (const Ogre::Real time) {
- setCurrentTime (mSecondsPerYear * time);
-}
-
-Ogre::Real UniversalClock::getCurrentTime () const {
- return mCurrentSecond;
-}
-
-Ogre::Real UniversalClock::getCurrentRelativeTime () const {
- return getCurrentTime () / mSecondsPerYear;
-}
-
-Ogre::Real UniversalClock::getCurrentDayTime () const {
- return mCurrentSecond - (mSecondsPerDay * Ogre::Math::Floor (mCurrentSecond / mSecondsPerDay));
-}
-
-Ogre::Real UniversalClock::getCurrentRelativeDayTime () const {
- return getCurrentDayTime () / mSecondsPerDay;
-}
-
-void UniversalClock::setTimeScale (const Ogre::Real scale) {
- mTimeScale = scale;
-}
-
-Ogre::Real UniversalClock::getTimeScale () const {
- return mTimeScale;
-}
-
-void UniversalClock::setUpdateRate (const Ogre::Real rate) {
- mUpdateRate = rate;
-
- if (mUpdateRate < 0)
- mUpdateRate = 0;
-
- forceUpdate ();
-}
-
-Ogre::Real UniversalClock::getUpdateRate () const {
- return mUpdateRate;
-}
-
-bool UniversalClock::update (const Ogre::Real time) {
- setCurrentTime (mCurrentSecond + time * mTimeScale);
-
- mTimeSinceLastUpdate += time;
-
- if (mTimeSinceLastUpdate > mUpdateRate) {
- mTimeSinceLastUpdate -= mUpdateRate * Ogre::Math::Floor (mUpdateRate > 0 ? mTimeSinceLastUpdate / mUpdateRate : 0);
-
- return true;
- }
- else {
- return false;
- }
-}
-
-void UniversalClock::updateSecondsPerYear () {
- mSecondsPerYear = mSecondsPerDay * mDaysPerYear;
-
- forceUpdate ();
-}
-
-void UniversalClock::forceUpdate () {
- mTimeSinceLastUpdate = mUpdateRate + 1;
-}
-
-} // namespace caelum
+#include "CaelumPrecompiled.h"
+#include "UniversalClock.h"
+
+namespace caelum {
+
+UniversalClock::UniversalClock () {
+ setSecondsPerDay (86400);
+ setDaysPerYear (365);
+
+ setTimeScale (1.0);
+ setUpdateRate (0); // Sets a new mTimeSinceLastUpdate value as well
+}
+
+void UniversalClock::setSecondsPerDay (const Ogre::Real secs) {
+ mSecondsPerDay = secs;
+
+ updateSecondsPerYear ();
+}
+
+Ogre::Real UniversalClock::getSecondsPerDay () const {
+ return mSecondsPerDay;
+}
+
+void UniversalClock::setDaysPerYear (const Ogre::Real days) {
+ mDaysPerYear = days;
+
+ updateSecondsPerYear ();
+}
+
+Ogre::Real UniversalClock::getDaysPerYear () const {
+ return mDaysPerYear;
+}
+
+void UniversalClock::setCurrentTime (const Ogre::Real sec) {
+ mCurrentSecond = Ogre::Math::Abs (sec);
+
+ mCurrentSecond -= mSecondsPerYear * Ogre::Math::Floor (mCurrentSecond / mSecondsPerYear);
+}
+
+void UniversalClock::setCurrentRelativeTime (const Ogre::Real time) {
+ setCurrentTime (mSecondsPerYear * time);
+}
+
+Ogre::Real UniversalClock::getCurrentTime () const {
+ return mCurrentSecond;
+}
+
+Ogre::Real UniversalClock::getCurrentRelativeTime () const {
+ return getCurrentTime () / mSecondsPerYear;
+}
+
+Ogre::Real UniversalClock::getCurrentDayTime () const {
+ return mCurrentSecond - (mSecondsPerDay * Ogre::Math::Floor (mCurrentSecond / mSecondsPerDay));
+}
+
+Ogre::Real UniversalClock::getCurrentRelativeDayTime () const {
+ return getCurrentDayTime () / mSecondsPerDay;
+}
+
+void UniversalClock::setTimeScale (const Ogre::Real scale) {
+ mTimeScale = scale;
+}
+
+Ogre::Real UniversalClock::getTimeScale () const {
+ return mTimeScale;
+}
+
+void UniversalClock::setUpdateRate (const Ogre::Real rate) {
+ mUpdateRate = rate;
+
+ if (mUpdateRate < 0)
+ mUpdateRate = 0;
+
+ forceUpdate ();
+}
+
+Ogre::Real UniversalClock::getUpdateRate () const {
+ return mUpdateRate;
+}
+
+bool UniversalClock::update (const Ogre::Real time) {
+ setCurrentTime (mCurrentSecond + time * mTimeScale);
+
+ mTimeSinceLastUpdate += time;
+
+ if (mTimeSinceLastUpdate > mUpdateRate) {
+ mTimeSinceLastUpdate -= mUpdateRate * Ogre::Math::Floor (mUpdateRate > 0 ? mTimeSinceLastUpdate / mUpdateRate : 0);
+
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
+void UniversalClock::updateSecondsPerYear () {
+ mSecondsPerYear = mSecondsPerDay * mDaysPerYear;
+
+ forceUpdate ();
+}
+
+void UniversalClock::forceUpdate () {
+ mTimeSinceLastUpdate = mUpdateRate + 1;
+}
+
+} // namespace caelum
Modified: trunk/python-ogre/ThirdParty/caelum/UniversalClock.h
===================================================================
--- trunk/python-ogre/ThirdParty/caelum/UniversalClock.h 2007-10-19 10:21:27 UTC (rev 444)
+++ trunk/python-ogre/ThirdParty/caelum/UniversalClock.h 2007-10-19 13:17:02 UTC (rev 445)
@@ -...
[truncated message content] |