Code: Select all
PostPosted: Thu Apr 10, 2008 8:08 am Post subject:
@Infuse
What Ogre version are you using?
I'm using Eihtort 1.4.6.
I've done everysingle thing possible
Code: Select all
PostPosted: Thu Apr 10, 2008 8:08 am Post subject:
@Infuse
What Ogre version are you using?
Code: Select all
Win32PBuffer::Creating PBuffer of format bits=8 float=false
19:08:43: Win32PBuffer::PBuffer -- Chosen pixel format rgba=8,8,8,8 depth=24 stencil=8
19:08:43: OGRE EXCEPTION(3:RenderingAPIException): wglShareLists() failed in Win32PBuffer::createPBuffer at ..\src\OgreWin32RenderTexture.cpp (line 204)
I was using the pre-compiled demo, so I don't know the setup.Xavyiy wrote:@GordonS
Are you using Hydrax::MaterialManager::SM_GLSL ? or SM_CG with a before version than CG 2.0 ? Try with SM_HLSL.
Xavi
Code: Select all
class WaterFrameListener : public ExampleFrameListener
{
public:
WaterFrameListener(RenderWindow* win, Camera* cam, SceneManager *sceneMgr): ExampleFrameListener(win, cam, false, false)
{
}
bool frameStarted(const FrameEvent &evt, Hydrax::Hydrax *mWater = 0)
{
mWater->update(evt.timeSinceLastFrame);
return WaterFrameListener::frameStarted(evt);
};
protected:
};
class WaterSystem : public ExampleApplication
{
public:
void createWater();
void createScene();
};
Code: Select all
void WaterSystem::createWater()
{
Hydrax::Hydrax *mWater = 0;
mWater = new Hydrax::Hydrax(mSceneMgr, mCamera);
mWater->setMeshOptions(static_cast<Hydrax::Mesh::Options*>(new Hydrax::Mesh::ProjectedGridOptions(256)));
Hydrax::Module::PerlinPG *mModule = new Hydrax::Module::PerlinPG(mWater,Ogre::Plane(Ogre::Vector3(0,1,0),Ogre::Vector3(0,0,0)),
Hydrax::Module::PerlinPG::Options(256));
mWater->setRttOptions(Hydrax::RttOptions(Hydrax::TEX_QUA_1024,Hydrax::TEX_QUA_1024,Hydrax::TEX_QUA_1024));
// Set components
mWater->setComponents(static_cast<Hydrax::HydraxComponent>(Hydrax::HYDRAX_COMPONENT_SUN |
Hydrax::HYDRAX_COMPONENT_FOAM |
Hydrax::HYDRAX_COMPONENT_DEPTH |
Hydrax::HYDRAX_COMPONENT_SMOOTH ));
mWater->setModule(static_cast<Hydrax::Module::Module*>(mModule));
mWater->setShaderMode(Hydrax::MaterialManager::SM_HLSL);
mWater->create();
caelum::Sun *mSun = mCaelumSystem->getSun();
Vector3 mSunDir = mSun->getSunDirection();
Vector3 mCamPos = mCamera->getRealPosition();
Vector3 mSunPosition = mCamPos-(mSunDir.normalisedCopy())*1000000;
mWater->setPosition(Ogre::Vector3(0,0,0));
mWater->setPlanesError(37.5);
mWater->setDepthLimit(110);
mWater->setSunColor(Vector3(1,0.6,0.4));
mWater->setNormalDistortion(0.025);
mWater->setDepthColor(Ogre::Vector3(0.04,0.135,0.185));
mWater->setSmoothPower(45);
mWater->setCausticsScale(12);
mWater->setGlobalTransparency(0.1);
mWater->setFullReflectionDistance(99999997952.0);
mWater->setGlobalTransparency(0);
mWater->setPolygonMode(0);
mWater->setSunPosition(mSunPosition);
mRoot->addFrameListener(new WaterFrameListener(mWindow, mCamera, mSceneMgr));
}
void WaterSystem::createScene()
{
}
Code: Select all
mHydrax->getDecalsManager()->add("WaterVegetable.png");
Put "createWater();" in createScene(), and don't call it manually. Instead, just call "myWater->go();", or whatever ExampleApplication's "start" method was. I don't use the example framework, but, IIRC, the scene manager isn't create on ExampleApplication's constructor, which is all you're calling before createWater().Cobra8472 wrote:...
Looking very good Xavi!Xavyiy wrote:I'm working in a Decal manager for hydrax just now, for place ship trails, oil, water vegetables, etc over the water!
Edit: it's finished!
Here's a shot:(Sorry for my ugly phosothop design !)
and usage:(It returns a Hydrax::Decal wich can be used as a Ogre::SceneNode: Hydrax::Decal::getSceneNode()->setPosition, setScale... etc!)Code: Select all
mHydrax->getDecalsManager()->add("WaterVegetable.png");
Enjoy!
Xavi
I've rewritten all modules, and interfaze system.mehdix wrote:Great!
Two feature requests:
* Is it possible that a detailed noise module like PerlinPG is created/used for bounded water plans, like Perlin? SimpleGrid+Perlin is boring!
* When do you plan to add custom shaped water areas (eg rivers)?
Thanks.
Code: Select all
// Create our projected grid module
Hydrax::Module::ProjectedGrid *mModule
= new Hydrax::Module::ProjectedGrid(// Hydrax parent pointer
mHydrax,
// Noise module
new Hydrax::Noise::Perlin(/* Default options */),
// Base plane
Ogre::Plane(Ogre::Vector3(0,1,0), Ogre::Vector3(0,0,0)),
// Projected grid options (Can be updated each frame -> setOptions(...))
Hydrax::Module::ProjectedGrid::Options(256 /* See more constructors */));
.....OR.....
Hydrax::Module::SimpleGrid *mModule
= new Hydrax::Module::SimpleGrid(// Hydrax parent pointer
mHydrax,
// Noise module
new Hydrax::Noise::Perlin(/* Default options */),
// Simple grid options (Can be updated each frame -> setOptions(...))
Hydrax::Module::SimpleGrid::Options(256, Hydrax::Size(10000,10000) /* See more constructors */));
// Set our module
mHydrax->setModule(static_cast<Hydrax::Module::Module*>(mModule));
Code: Select all
//--------------------------------------------- WaterSystem Class ---------------------------------------------------------------//
class WaterSystem
{
protected:
public:
void createWater();
};
//---------------------------------- Water framelistener. Updates Hydrax -------------------------------------------------------//
class WaterFrameListener : public ExampleFrameListener
{
protected:
Hydrax::Hydrax *mWater;
public:
WaterFrameListener(RenderWindow* win, Camera* cam, SceneManager *sceneMgr): ExampleFrameListener(win, cam, false, false)
{
}
bool frameStarted(const FrameEvent &evt)
{
mWater->update(evt.timeSinceLastFrame);
return ExampleFrameListener::frameStarted(evt);
};
};
Code: Select all
void WaterSystem::createWater()
{
Ogre::Root *mRoot = Ogre::Root::getSingletonPtr();
SceneManager *mSceneMgr = mRoot->getSceneManager("SceneManager1");
Camera *mCamera = mSceneMgr->getCamera("PlayerCam");
RenderWindow *mWindow = mRoot->getAutoCreatedWindow();
Hydrax::Hydrax *mWater = 0;
mWater = new Hydrax::Hydrax(mSceneMgr, mCamera);
mWater->setMeshOptions(static_cast<Hydrax::Mesh::Options*>(new Hydrax::Mesh::ProjectedGridOptions(256)));
Hydrax::Module::PerlinPG *mModule = new Hydrax::Module::PerlinPG(mWater,Ogre::Plane(Ogre::Vector3(0,1,0),Ogre::Vector3(0,0,0)),
Hydrax::Module::PerlinPG::Options(256));
mWater->setRttOptions(Hydrax::RttOptions(Hydrax::TEX_QUA_1024,Hydrax::TEX_QUA_1024,Hydrax::TEX_QUA_1024));
// Set components
mWater->setComponents(static_cast<Hydrax::HydraxComponent>(Hydrax::HYDRAX_COMPONENT_SUN |
Hydrax::HYDRAX_COMPONENT_FOAM |
Hydrax::HYDRAX_COMPONENT_DEPTH |
Hydrax::HYDRAX_COMPONENT_SMOOTH ));
mWater->setModule(static_cast<Hydrax::Module::Module*>(mModule));
mWater->setShaderMode(Hydrax::MaterialManager::SM_HLSL);
mWater->create();
mWater->setPosition(Ogre::Vector3(0,0,0));
mWater->setPlanesError(37.5);
mWater->setDepthLimit(110);
mWater->setSunColor(Vector3(1,0.6,0.4));
mWater->setNormalDistortion(0.025);
mWater->setDepthColor(Ogre::Vector3(0.04,0.135,0.185));
mWater->setSmoothPower(45);
mWater->setCausticsScale(12);
mWater->setGlobalTransparency(0.1);
mWater->setFullReflectionDistance(99999997952.0);
mWater->setGlobalTransparency(0);
mWater->setPolygonMode(0);
mRoot->addFrameListener(new WaterFrameListener(mWindow, mCamera, mSceneMgr));
}
Code: Select all
void Hydrax::update(const Ogre::Real &timeSinceLastFrame)
{
if (mModule)
{
mModule->update(timeSinceLastFrame);
}
}
Crashes on the same line I'm afraid.Xavyiy wrote:@Cobra8472
Delete this line:
Hydrax::Hydrax *mWater = 0;
in createWater() funtion and try again, I think that this is the problem.
@Rambus
I'm going to try record a video of the new SimpleGrid module and post it tomorrow(I've a lot of exams for some weeks).
Thanks for the webspace offer, if I need unrestricted webspace for Hydrax I will contact you!
Sorry for my English.
Can you post the stack? I think something is wrong initialized, like mCamera or mSceneManager is null.Cobra8472 wrote:Crashes on the same line I'm afraid.Xavyiy wrote:@Cobra8472
Delete this line:
Hydrax::Hydrax *mWater = 0;
in createWater() funtion and try again, I think that this is the problem.
@Rambus
I'm going to try record a video of the new SimpleGrid module and post it tomorrow(I've a lot of exams for some weeks).
Thanks for the webspace offer, if I need unrestricted webspace for Hydrax I will contact you!
Sorry for my English.
It's ok if you can't solve, it, really don't want to take your precious dev time away!!
Code: Select all
#ifndef __ExampleApplication_H__
#define __ExampleApplication_H__
#include "Ogre.h"
#include "OgreConfigFile.h"
#include "ExampleFrameListener.h"
#include "Caelum.h"
#include "Hydrax.h"
#include "Modules/Perlin/Perlin.h"
#include "Modules/PerlinPG/PerlinPG.h"
#include <OIS\OIS.h>
#include <windows.h>
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
#include <CoreFoundation/CoreFoundation.h>
// This function will locate the path to our application on OS X,
// unlike windows you can not rely on the curent working directory
// for locating your configuration files and resources.
std::string macBundlePath()
{
char path[1024];
CFBundleRef mainBundle = CFBundleGetMainBundle();
assert(mainBundle);
CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
assert(mainBundleURL);
CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle);
assert(cfStringRef);
CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII);
CFRelease(mainBundleURL);
CFRelease(cfStringRef);
return std::string(path);
}
#endif
using namespace Ogre;
/** Base class which manages the standard startup of an Ogre application.
Designed to be subclassed for specific examples if required.
*/
//-------------------------------------------------------------------------------------------------------------------
class ExampleApplication
{
public:
//-------------------------------------------------------------------------------------------------------------------
ExampleApplication() //constructor
{
mFrameListener = 0;
mRoot = 0;
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
mResourcePath = macBundlePath() + "/Contents/Resources/";
#else
mResourcePath = "";
#endif
}
//-------------------------------------------------------------------------------------------------------------------
virtual ~ExampleApplication() //destructor
{
if (mFrameListener)
{
delete mFrameListener;
}
if (mRoot)
{
delete mRoot;
}
}
//-------------------------------------------------------------------------------------------------------------------
virtual void go(void) //start
{
if (!setup())
{
return;
}
mRoot->startRendering();
destroyScene(); //cleanup
}
//-------------------------------------------------------------------------------------------------------------------
protected:
Root *mRoot;
Camera* mCamera;
ExampleFrameListener* mFrameListener;
RenderWindow* mWindow;
Ogre::String mResourcePath;
caelum::CaelumSystem* mCaelumSystem;
SceneManager *mSceneMgr;
// These internal methods package up the stages in the startup process
// Sets up the application - returns false if the user chooses to abandon configuration.
virtual bool setup(void)
{
String pluginsPath;
#ifndef OGRE_STATIC_LIB
pluginsPath = mResourcePath + "plugins.cfg";
#endif
mRoot = new Root(pluginsPath,
mResourcePath + "ogre.cfg", mResourcePath + "Ogre.log");
setupResources();
bool carryOn = configure();
if (!carryOn) return false;
chooseSceneManager();
createCamera();
createViewports();
TextureManager::getSingleton().setDefaultNumMipmaps(5);
createResourceListener(); //for loading screens
loadResources();
createScene();
createSky(); //Caelum
createFrameListener();
return true;
}
//-------------------------------------------------------------------------------------------------------------------
virtual bool configure(void)
{
if(mRoot->showConfigDialog())
{
mWindow = mRoot->initialise(true);
return true;
}
else
{
return false;
}
}
//-------------------------------------------------------------------------------------------------------------------
public:
virtual void chooseSceneManager(void)
{
mSceneMgr = mRoot->createSceneManager(ST_EXTERIOR_CLOSE, "SceneManager1");
}
//-------------------------------------------------------------------------------------------------------------------
protected:
virtual void createCamera(void)
{
mCamera = mSceneMgr->createCamera("PlayerCam");
mCamera->setPosition(Vector3(0,0,500));
mCamera->lookAt(Vector3(0,0,-300));
mCamera->setNearClipDistance(5);
}
//-------------------------------------------------------------------------------------------------------------------
virtual void createFrameListener(void)
{
mFrameListener= new ExampleFrameListener(mWindow, mCamera);
mFrameListener->showDebugOverlay(true);
mRoot->addFrameListener(mFrameListener);
//mRoot->addFrameListener(new WaterFrameListener(mWindow, mCamera, mSceneMgr));
//mRoot->addFrameListener(new SkyFrameListener(mWindow, mCamera, mSceneMgr, mCaelumSystem));
}
//-------------------------------------------------------------------------------------------------------------------
virtual void createScene(void) = 0; // pure virtual - this has to be overridden
virtual void destroyScene(void){} // Optional to override this
virtual void createViewports(void)
{
Viewport* vp = mWindow->addViewport(mCamera);
vp->setBackgroundColour(ColourValue(0.3,0.3,0.3));
mCamera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
}
//-------------------------------------------------------------------------------------------------------------------
void createSky()
{
bool mPaused = false;
bool mPostFiltering = false;
float mTimeTillNextUpdate;
mCaelumSystem = new caelum::CaelumSystem (mRoot, mSceneMgr);
mCaelumSystem->setManageSceneFog(true);
mCaelumSystem->setSceneFogDensityMultiplier(0.0000000001);
if (mCaelumSystem->getSun ())
{
mCaelumSystem->getSun ()->setAmbientMultiplier (Ogre::ColourValue(0.5, 0.5, 0.5));
mCaelumSystem->getSun ()->setDiffuseMultiplier (Ogre::ColourValue(3, 3, 2.7));
mCaelumSystem->getSun ()->setSpecularMultiplier (Ogre::ColourValue(5, 5, 5));
mCaelumSystem->getSun ()->setManageAmbientLight (true);
}
if (mCaelumSystem->getClouds ())
{
mCaelumSystem->getClouds ()->setCloudSpeed(Ogre::Vector2(0.000005, -0.000009));
mCaelumSystem->getClouds ()->setCloudBlendTime(3600 * 24);
mCaelumSystem->getClouds ()->setCloudCover(0.03);
}
if (mCaelumSystem->getStarfield ())
{
mCaelumSystem->getStarfield ()->setInclination (Degree (13));
}
mCaelumSystem->getUniversalClock ()->setTimeScale (1);
// Winter dawn in the southern hemisphere, looking north
mCaelumSystem->getUniversalClock ()->setGregorianDateTime (2008, 5, 29, 2, 0, 0);
mCaelumSystem->getSolarSystemModel ()->setObserverLongitude (Ogre::Degree(151 + 12.0 / 60));
//caelum::GroundFog *mFog = mCaelumSystem->getGroundFog();
//mFog->setColour(ColourValue(1,1,1));
mCaelumSystem->getSolarSystemModel ()->setObserverLatitude (Ogre::Degree(-33 + 52.0 / 60));
mWindow->addListener (mCaelumSystem);
mTimeTillNextUpdate = 0;
}
//-------------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------------
virtual void setupResources(void)
{
ConfigFile cf;
cf.load(mResourcePath + "resources.cfg");
ConfigFile::SectionIterator seci = cf.getSectionIterator();
String secName, typeName, archName;
while (seci.hasMoreElements())
{
secName = seci.peekNextKey();
ConfigFile::SettingsMultiMap *settings = seci.getNext();
ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
// OS X does not set the working directory relative to the app,
// In order to make things portable on OS X we need to provide
// the loading with it's own bundle path location
ResourceGroupManager::getSingleton().addResourceLocation(
String(macBundlePath() + "/" + archName), typeName, secName);
#else
ResourceGroupManager::getSingleton().addResourceLocation(
archName, typeName, secName);
#endif
}
}
}
virtual void createResourceListener(void)
{
}
virtual void loadResources(void)
{
ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
}
};
#endif
Code: Select all
#include "ExampleApplication.h"
#include "Caelum.h"
#include "Hydrax.h"
#include "Modules/Perlin/Perlin.h"
#include "Modules/PerlinPG/PerlinPG.h"
#include "env_water.h"
class TutorialApplication : public ExampleApplication
{
protected:
public:
TutorialApplication()
{
}
~TutorialApplication()
{
}
protected:
void createScene(void)
{
mCamera->setFarClipDistance(99999*6);
WaterSystem *myWater = new WaterSystem();
myWater->createWater();
//mSceneMgr->setWorldGeometry("terrain.cfg");
}
};
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char **argv)
#endif
{
// Create application object
TutorialApplication app;
try {
app.go();
} catch( Ogre::Exception& e ) {
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
MessageBoxA( NULL, e.what(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
fprintf(stderr, "An exception has occurred: %s\n",
e.what());
#endif
}
return 0;
}