(i've already wrote some of those problems in skyx topic but i must to repeat here because aren't only skyx problems now

i've implement skyx and hydrax in my project from skyxhydraxdemo, but there's a problem (i think on file inside media...)
here's sky_sea_handling.h
Code: Select all
#ifndef __sea_sky_handling_h_
#define __sea_sky_handling_h_
#include <Ogre.h>
#include <OgreTextAreaOverlayElement.h>
#include "Hydrax/Hydrax.h"
#include "Hydrax/Noise/Perlin/Perlin.h"
#include "Hydrax/Modules/ProjectedGrid/ProjectedGrid.h"
#include "SkyX/SkyX.h"
struct ShadowConfig
{
bool Enable;
int Size;
ShadowConfig(const bool& Enable_, const int& Size_)
: Enable(Enable_)
, Size(Size_)
{
}
};
class BloomListener: public Ogre::CompositorInstance::Listener
{
public:
Hydrax::Hydrax *mHydrax;
SkyX::SkyX *mSkyX;
void notifyMaterialSetup(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat)
{
}
void notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat)
{
if (pass_id == 3)
{
float bloomStrength = 0.75 + Ogre::Math::Clamp<Ogre::Real>(-mSkyX->getAtmosphereManager()->getSunDirection().y, 0, 1)*0.75;
mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("uBloomStrength", bloomStrength);
}
}
};
void sea_sky_init(Ogre::Root *mRoot,Ogre::SceneManager* mSceneMgr,Ogre::RenderWindow* mWindow,Ogre::Camera* mCamera);
//void setShadowMode(Ogre::SceneManager *sm, const ShadowMode& smode);
class HydraxListener : public Ogre::FrameListener
{
public:
Ogre::SceneManager *mSceneMgr;
Ogre::Real mKeyBuffer;
Ogre::Real mLastPositionLength;
Ogre::Camera* mCamera;
// Color gradients
void updateEnvironmentLighting(void);
Hydrax::Hydrax *mHydrax;
SkyX::SkyX *mSkyX;
SkyX::ColorGradient mWaterGradient,
mSunGradient,
mAmbientGradient;
HydraxListener(Ogre::RenderWindow* win, Ogre::Camera* cam, Ogre::SceneManager *sm)
: FrameListener()
, mSceneMgr(sm)
, mKeyBuffer(-1)
, mLastPositionLength((Ogre::Vector3(1500, 100, 1500) - mCamera->getDerivedPosition()).length())
{
// Color gradients
// Water
mWaterGradient = SkyX::ColorGradient();
mWaterGradient.addCFrame(SkyX::ColorGradient::ColorFrame(Ogre::Vector3(0.058209,0.535822,0.779105)*0.4, 1));
mWaterGradient.addCFrame(SkyX::ColorGradient::ColorFrame(Ogre::Vector3(0.058209,0.535822,0.729105)*0.3, 0.8));
mWaterGradient.addCFrame(SkyX::ColorGradient::ColorFrame(Ogre::Vector3(0.058209,0.535822,0.679105)*0.25, 0.6));
mWaterGradient.addCFrame(SkyX::ColorGradient::ColorFrame(Ogre::Vector3(0.058209,0.535822,0.679105)*0.2, 0.5));
mWaterGradient.addCFrame(SkyX::ColorGradient::ColorFrame(Ogre::Vector3(0.058209,0.535822,0.679105)*0.1, 0.45));
mWaterGradient.addCFrame(SkyX::ColorGradient::ColorFrame(Ogre::Vector3(0.058209,0.535822,0.679105)*0.025, 0));
// Sun
mSunGradient = SkyX::ColorGradient();
mSunGradient.addCFrame(SkyX::ColorGradient::ColorFrame(Ogre::Vector3(0.8,0.75,0.55)*1.5, 1.0f));
mSunGradient.addCFrame(SkyX::ColorGradient::ColorFrame(Ogre::Vector3(0.8,0.75,0.55)*1.4, 0.75f));
mSunGradient.addCFrame(SkyX::ColorGradient::ColorFrame(Ogre::Vector3(0.8,0.75,0.55)*1.3, 0.5625f));
mSunGradient.addCFrame(SkyX::ColorGradient::ColorFrame(Ogre::Vector3(0.6,0.5,0.2)*1.5, 0.5f));
mSunGradient.addCFrame(SkyX::ColorGradient::ColorFrame(Ogre::Vector3(0.5,0.5,0.5)*0.25, 0.45f));
mSunGradient.addCFrame(SkyX::ColorGradient::ColorFrame(Ogre::Vector3(0.5,0.5,0.5)*0.01, 0.0f));
// Ambient
mAmbientGradient = SkyX::ColorGradient();
mAmbientGradient.addCFrame(SkyX::ColorGradient::ColorFrame(Ogre::Vector3(1,1,1)*1, 1.0f));
mAmbientGradient.addCFrame(SkyX::ColorGradient::ColorFrame(Ogre::Vector3(1,1,1)*1, 0.6f));
mAmbientGradient.addCFrame(SkyX::ColorGradient::ColorFrame(Ogre::Vector3(1,1,1)*0.6, 0.5f));
mAmbientGradient.addCFrame(SkyX::ColorGradient::ColorFrame(Ogre::Vector3(1,1,1)*0.3, 0.45f));
mAmbientGradient.addCFrame(SkyX::ColorGradient::ColorFrame(Ogre::Vector3(1,1,1)*0.1, 0.35f));
mAmbientGradient.addCFrame(SkyX::ColorGradient::ColorFrame(Ogre::Vector3(1,1,1)*0.05, 0.0f));
}
bool frameStarted(const Ogre::FrameEvent &e)
{
// Check camera height
Ogre::RaySceneQuery *raySceneQuery =
mSceneMgr->
createRayQuery(Ogre::Ray(mCamera->getPosition() + Ogre::Vector3(0,1000000,0),
Ogre::Vector3::NEGATIVE_UNIT_Y));
Ogre::RaySceneQueryResult& qryResult = raySceneQuery->execute();
Ogre::RaySceneQueryResult::iterator i = qryResult.begin();
if (i != qryResult.end() && i->worldFragment)
{
if (mCamera->getPosition().y < i->worldFragment->singleIntersection.y + 30)
{
mCamera->
setPosition(mCamera->getPosition().x,
i->worldFragment->singleIntersection.y + 30,
mCamera->getPosition().z);
}
}
delete raySceneQuery;
// Change SkyX atmosphere options if needed
SkyX::AtmosphereManager::Options SkyXOptions = mSkyX->getAtmosphereManager()->getOptions();
// Time
Ogre::Real mTimeMultiplier = 0.1f;
mSkyX->setTimeMultiplier(mTimeMultiplier);
mSkyX->getAtmosphereManager()->setOptions(SkyXOptions);
// Update environment lighting
updateEnvironmentLighting();
// Update shadow far distance
updateShadowFarDistance();
// Update Hydrax
mHydrax->update(e.timeSinceLastFrame);
// Update SkyX
mSkyX->update(e.timeSinceLastFrame);
mKeyBuffer -= e.timeSinceLastFrame;
return true;
}
/** Update environment lighting
*/
/** Update shadow far distance
*/
void updateShadowFarDistance()
{
Ogre::Light* Light1 = mSceneMgr->getLight("Light1");
float currentLength = (Ogre::Vector3(1500, 100, 1500) - mCamera->getDerivedPosition()).length();
if (currentLength < 1000)
{
mLastPositionLength = currentLength;
return;
}
if (currentLength - mLastPositionLength > 100)
{
mLastPositionLength += 100;
Light1->setShadowFarDistance(Light1->getShadowFarDistance() + 100);
}
else if (currentLength - mLastPositionLength < -100)
{
mLastPositionLength -= 100;
Light1->setShadowFarDistance(Light1->getShadowFarDistance() - 100);
}
}
};
class HydraxRttListener : public Hydrax::RttManager::RttListener
{
public:
Hydrax::Hydrax *mHydrax;
SkyX::SkyX *mSkyX;
void preRenderTargetUpdate(const Hydrax::RttManager::RttType& Rtt)
{
// If needed in any case...
bool underwater = mHydrax->_isCurrentFrameUnderwater();
switch (Rtt)
{
case Hydrax::RttManager::RTT_REFLECTION:
{
// No stars in the reflection map
mSkyX->setStarfieldEnabled(false);
}
break;
case Hydrax::RttManager::RTT_REFRACTION:
{
}
break;
case Hydrax::RttManager::RTT_DEPTH: case Hydrax::RttManager::RTT_DEPTH_REFLECTION:
{
// Hide SkyX components in depth maps
mSkyX->getMeshManager()->getEntity()->setVisible(false);
mSkyX->getMoonManager()->getMoonBillboard()->setVisible(false);
}
break;
}
}
void postRenderTargetUpdate(const Hydrax::RttManager::RttType& Rtt)
{
bool underwater = mHydrax->_isCurrentFrameUnderwater();
switch (Rtt)
{
case Hydrax::RttManager::RTT_REFLECTION:
{
mSkyX->setStarfieldEnabled(true);
}
break;
case Hydrax::RttManager::RTT_REFRACTION:
{
}
break;
case Hydrax::RttManager::RTT_DEPTH: case Hydrax::RttManager::RTT_DEPTH_REFLECTION:
{
mSkyX->getMeshManager()->getEntity()->setVisible(true);
mSkyX->getMoonManager()->getMoonBillboard()->setVisible(true);
}
break;
}
}
};
#endif // #ifndef __sea_sky_handling_h_
Code: Select all
21:31:37: [Hydrax] Depth material created.
21:31:37: [Hydrax] Creating underwater material...
21:31:37: OGRE EXCEPTION(6:FileNotFoundException): Cannot locate resource HydraxDepthReflectionMap in resource group Hydrax or any other group. in ResourceGroupManager::openResource at ..\..\..\..\OgreMain\src\OgreResourceGroupManager.cpp (line 753)
21:31:37: Error loading texture HydraxDepthReflectionMap. Texture layer will be blank. Loading the texture failed with the following exception: OGRE EXCEPTION(6:FileNotFoundException): Cannot locate resource HydraxDepthReflectionMap in resource group Hydrax or any other group. in ResourceGroupManager::openResource at ..\..\..\..\OgreMain\src\OgreResourceGroupManager.cpp (line 753)
21:31:37: Texture: UnderwaterDistortion.jpg: Loading 1 faces(PF_R8G8B8,256x256x1) with hardware generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
21:31:37: [Hydrax] Underwater material created.
21:31:37: [Hydrax] Materials created.
21:31:37: [Hydrax] Creating god rays...
21:31:37: [Hydrax] Perlin destroyed.
21:31:37: [Hydrax] God rays created.
21:31:37: [Hydrax] Creating water mesh...
21:31:37: [Hydrax] Water mesh created.
21:31:37: Can't assign material _NULL_ to SubEntity of SkyXMeshEnt because this Material does not exist. Have you forgotten to define it in a .material script?
21:31:37: Texture: SkyX_Starfield.png: Loading 1 faces(PF_A8R8G8B8,512x512x1) with hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,512x512x1.
21:31:37: Texture: SkyX_Moon.png: Loading 1 faces(PF_A8R8G8B8,512x512x1) with hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,512x512x1.
Code: Select all
#include "sea_sky_handling.h"
ShadowConfig mShadowConfigList[] = {ShadowConfig(false, 0), ShadowConfig(true, 512), ShadowConfig(true, 2048)};
bool mForceDisableShadows = false;
enum ShadowMode
{
SM_NONE = 0,
SM_LOW = 1,
SM_HIGH = 2
};
int mShadowMode = static_cast<int>(SM_LOW);
void setShadowMode(Ogre::SceneManager *sm, const ShadowMode& smode)
{
Ogre::MaterialPtr IslandMat = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().getByName("Island"));
if (mShadowConfigList[smode].Enable && !mForceDisableShadows)
{
sm->setShadowTechnique(Ogre::SHADOWTYPE_TEXTURE_MODULATIVE_INTEGRATED);
sm->setShadowTextureConfig(0, mShadowConfigList[smode].Size, mShadowConfigList[smode].Size, Ogre::PF_X8R8G8B8);
IslandMat->getTechnique(0)->setSchemeName("Default");
IslandMat->getTechnique(1)->setSchemeName("NoDefault");
}
else
{
sm->setShadowTechnique(Ogre::SHADOWTYPE_NONE);
IslandMat->getTechnique(0)->setSchemeName("NoDefault");
IslandMat->getTechnique(1)->setSchemeName("Default");
}
}
void HydraxListener::updateEnvironmentLighting()
{
Ogre::SceneManager* mSceneMgr;
Ogre::Vector3 lightDir = mSkyX->getAtmosphereManager()->getSunDirection();
Ogre::Camera* mCamera;
bool preForceDisableShadows = mForceDisableShadows;
mForceDisableShadows = (lightDir.y > 0.15f) ? true : false;
if (preForceDisableShadows != mForceDisableShadows)
{
setShadowMode(mSceneMgr, static_cast<ShadowMode>(mShadowMode));
}
// Calculate current color gradients point
float point = (-lightDir.y + 1.0f) / 2.0f;
mHydrax->setWaterColor(mWaterGradient.getColor(point));
Ogre::Vector3 sunPos = mCamera->getDerivedPosition() - lightDir*mSkyX->getMeshManager()->getSkydomeRadius()*0.1;
mHydrax->setSunPosition(sunPos);
Ogre::Light *Light0 = mSceneMgr->getLight("Light0"),
*Light1 = mSceneMgr->getLight("Light1");
Light0->setPosition(mCamera->getDerivedPosition() - lightDir*mSkyX->getMeshManager()->getSkydomeRadius()*0.02);
Light1->setDirection(lightDir);
Ogre::Vector3 sunCol = mSunGradient.getColor(point);
Light0->setSpecularColour(sunCol.x, sunCol.y, sunCol.z);
Ogre::Vector3 ambientCol = mAmbientGradient.getColor(point);
Light0->setDiffuseColour(ambientCol.x, ambientCol.y, ambientCol.z);
mHydrax->setSunColor(sunCol);
}
void sea_sky_init(Ogre::Root *mRoot,Ogre::SceneManager* mSceneMgr,Ogre::RenderWindow* mWindow,Ogre::Camera* mCamera)
{
// Hydrax object
Hydrax::Hydrax *mHydrax = 0;
// SkyX object
SkyX::SkyX *mSkyX = 0;
bool mBloomCompositor = true;
// Hydrax initialization code ---------------------------------------------
// ------------------------------------------------------------------------
// Create Hydrax object
mHydrax = new Hydrax::Hydrax(mSceneMgr, mCamera, mWindow->getViewport(0));
// Create our projected grid module
Hydrax::Module::ProjectedGrid *mModule
= new Hydrax::Module::ProjectedGrid(// Hydrax parent pointer
mHydrax,
// Noise module
new Hydrax::Noise::Perlin(/*Generic one*/),
// Base plane
Ogre::Plane(Ogre::Vector3(0,1,0), Ogre::Vector3(0,0,0)),
// Normal mode
Hydrax::MaterialManager::NM_VERTEX,
// Projected grid options
Hydrax::Module::ProjectedGrid::Options(/*Generic one*/));
// Set our module
mHydrax->setModule(static_cast<Hydrax::Module::Module*>(mModule));
// Load all parameters from config file
// Remarks: The config file must be in Hydrax resource group.
// All parameters can be set/updated directly by code(Like previous versions),
// but due to the high number of customizable parameters, since 0.4 version, Hydrax allows save/load config files.
mHydrax->loadCfg("HydraxDemo.hdx");
// Create water
mHydrax->create();
// Add the Hydrax Rtt listener
mHydrax->getRttManager()->addRttListener(new HydraxRttListener());
// Hydrax initialization code end -----------------------------------------
// ------------------------------------------------------------------------
// SkyX initialization code ---------------------------------------------
// ------------------------------------------------------------------------
// Create SkyX object
mSkyX = new SkyX::SkyX(mSceneMgr, mCamera);
// No smooth fading
mSkyX->getMeshManager()->setSkydomeFadingParameters(false);
// A little change to default atmosphere settings :)
SkyX::AtmosphereManager::Options atOpt = mSkyX->getAtmosphereManager()->getOptions();
atOpt.RayleighMultiplier = 0.003075f;
atOpt.MieMultiplier = 0.00125f;
atOpt.InnerRadius = 9.92f;
atOpt.OuterRadius = 10.3311f;
mSkyX->getAtmosphereManager()->setOptions(atOpt);
// Create the sky
mSkyX->create();
// Add a basic cloud layer
mSkyX->getCloudsManager()->add(SkyX::CloudLayer::Options(/* Default options */));
// SkyX initialization code end -----------------------------------------
// ------------------------------------------------------------------------
// Bloom compositor
Ogre::CompositorManager::getSingleton().
addCompositor(mWindow->getViewport(0), "Bloom")->addListener(new BloomListener());
Ogre::CompositorManager::getSingleton().
setCompositorEnabled(mWindow->getViewport(0), "Bloom", mBloomCompositor);
// Shadows
mSceneMgr->setShadowCameraSetup(Ogre::ShadowCameraSetupPtr(new Ogre::FocusedShadowCameraSetup()));
mSceneMgr->setShadowTextureCasterMaterial("ShadowCaster");
mSceneMgr->getLight("Light1")->setShadowFarDistance(1750);
setShadowMode(mSceneMgr, static_cast<ShadowMode>(mShadowMode));
// Add the Hydrax depth technique to island material
mHydrax->getMaterialManager()->addDepthTechnique(
static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().getByName("Island"))
->createTechnique());
// Add frame listener
mRoot->addFrameListener(new HydraxListener(mWindow, mCamera, mSceneMgr));
}
Code: Select all
// Light
Ogre::Light *mLight0 = mSceneMgr->createLight("Light0");
mLight0->setDiffuseColour(1, 1, 1);
mLight0->setCastShadows(false);
// Shadow caster
Ogre::Light *mLight1 = mSceneMgr->createLight("Light1");
mLight1->setType(Ogre::Light::LT_DIRECTIONAL);
Code: Select all
sea_sky_init(mRoot,mSceneMgr,mWindow,mCamera);

The code seems to be correct, alas I'm experiencing some problems over the media files, please see below an exctract from my log file:
21:31:37: Can't assign material _NULL_ to SubEntity of SkyXMeshEnt because this Material does not exist. Have you forgotten to define it in a .material script?
21:31:37: OGRE EXCEPTION(6:FileNotFoundException): Cannot locate resource HydraxDepthReflectionMap in resource group Hydrax or any other group. in ResourceGroupManager::openResource at ..\..\..\..\OgreMain\src\OgreResourceGroupManager.cpp (line 753)
21:31:37: Error loading texture HydraxDepthReflectionMap. Texture layer will be blank. Loading the texture failed with the following exception: OGRE EXCEPTION(6:FileNotFoundException): Cannot locate resource HydraxDepthReflectionMap in resource group Hydrax or any other group. in ResourceGroupManager::openResource at ..\..\..\..\OgreMain\src\OgreResourceGroupManager.cpp (line 753)
The question is: as I have copied the demo's media folder in my project why the system keeps giving me errorswith the same files and similar code?