Problem with addListener to Render Windows

compvis

26-08-2009 08:05:26

hi,

I have a problem with Caelum + Hydrax

if i run separately is OK but if both Caelum and Hydrax in my app. My app will be crash.

I found that problem is in function addListener to Render Window.

mRenderWindow->addListener (mCaelumSystem);

If i remove the line code above the my app runs normally but so slowly

I dont know why ?

My code to init Caleum is:

Caelum::CaelumSystem::CaelumComponent componentMask;
componentMask = static_cast<Caelum::CaelumSystem::CaelumComponent> (
Caelum::CaelumSystem::CAELUM_COMPONENT_SUN |
Caelum::CaelumSystem::CAELUM_COMPONENT_MOON |
Caelum::CaelumSystem::CAELUM_COMPONENT_SKY_DOME |
Caelum::CaelumSystem::CAELUM_COMPONENT_POINT_STARFIELD |
Caelum::CaelumSystem::CAELUM_COMPONENT_CLOUDS |
0);
componentMask = Caelum::CaelumSystem::CAELUM_COMPONENTS_DEFAULT;


mSkySystem = new Caelum::CaelumSystem (Root::getSingletonPtr(), mScene, componentMask);

if (!mSkySystem)
{

return E_SKY;
}
mSkySystem->setManageSceneFog(false);

mScene->setFog(FOG_NONE);

mSkySystem->getUniversalClock ()->setTimeScale (1);

mSkySystem->getCloudSystem()->getLayer(0)->setCloudSpeed(Ogre::Vector2(0.0005, -0.0059));

mRender->addListener (mSkySystem);
Root::getSingletonPtr()->addFrameListener (mSkySystem);



And code to init Hydrax is:

mCam->setFarClipDistance(99999*6);

mCam->setPosition(1302.04f,176.224f,1277.61f);
mCam->lookAt(K_VECTOR(1302.64f,195.678f,277.798f));
mCamLook = K_VECTOR(1302.64f,195.678f,277.798f);


mSea = new Hydrax::Hydrax(mScene,mCam,mRender->getViewport(0));


if (!mSea)
{
return E_OCEAN;
}
Hydrax::Module::ProjectedGrid* module = new Hydrax::Module::ProjectedGrid(
mSea,
new Hydrax::Noise::Perlin,
K_Plane(K_VECTOR(0,1,0),K_VECTOR(0,0,0)),
Hydrax::MaterialManager::NM_VERTEX,
Hydrax::Module::ProjectedGrid::Options()
);


mSea->setModule(static_cast<Hydrax::Module::Module*>(module));

//To remove the line between Caelum and Hydrax
std::vector<Ogre::RenderQueueGroupID> caelumskyqueue;
caelumskyqueue.push_back(static_cast<Ogre::RenderQueueGroupID>(Ogre::RENDER_QUEUE_SKIES_EARLY + 2));
mSea->getRttManager()->setDisableReflectionCustomNearCliplPlaneRenderQueues (caelumskyqueue);

mSea->loadCfg("HydraxDemo.hdx");

try
{
mSea->create();
}
catch (Exception &e)
{
return E_OCEAN;
}

mScene->setWorldGeometry("Island.cfg");//Island.cfg

mSea->getMaterialManager()->addDepthTechnique(
static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().getByName("Island"))
->createTechnique());

klinkLoadForest();


Anybody help me ?

compvis

26-10-2009 04:19:04

hi,

I have a problem with Caelum + Hydrax

if i run separately is OK but if both Caelum and Hydrax in my app. My app will be crash.

I found that problem is in function addListener to Render Window.

mRenderWindow->addListener (mCaelumSystem);

If i remove the line code above the my app runs normally but so slowly

I dont know why ?

My code to init Caleum is:

Caelum::CaelumSystem::CaelumComponent componentMask;
componentMask = static_cast<Caelum::CaelumSystem::CaelumComponent> (
Caelum::CaelumSystem::CAELUM_COMPONENT_SUN |
Caelum::CaelumSystem::CAELUM_COMPONENT_MOON |
Caelum::CaelumSystem::CAELUM_COMPONENT_SKY_DOME |
Caelum::CaelumSystem::CAELUM_COMPONENT_POINT_STARFIELD |
Caelum::CaelumSystem::CAELUM_COMPONENT_CLOUDS |
0);
componentMask = Caelum::CaelumSystem::CAELUM_COMPONENTS_DEFAULT;


mSkySystem = new Caelum::CaelumSystem (Root::getSingletonPtr(), mScene, componentMask);

if (!mSkySystem)
{

return E_SKY;
}
mSkySystem->setManageSceneFog(false);

mScene->setFog(FOG_NONE);

mSkySystem->getUniversalClock ()->setTimeScale (1);

mSkySystem->getCloudSystem()->getLayer(0)->setCloudSpeed(Ogre::Vector2(0.0005, -0.0059));

mRender->addListener (mSkySystem);
Root::getSingletonPtr()->addFrameListener (mSkySystem);



And code to init Hydrax is:

mCam->setFarClipDistance(99999*6);

mCam->setPosition(1302.04f,176.224f,1277.61f);
mCam->lookAt(K_VECTOR(1302.64f,195.678f,277.798f));
mCamLook = K_VECTOR(1302.64f,195.678f,277.798f);


mSea = new Hydrax::Hydrax(mScene,mCam,mRender->getViewport(0));


if (!mSea)
{
return E_OCEAN;
}
Hydrax::Module::ProjectedGrid* module = new Hydrax::Module::ProjectedGrid(
mSea,
new Hydrax::Noise::Perlin,
K_Plane(K_VECTOR(0,1,0),K_VECTOR(0,0,0)),
Hydrax::MaterialManager::NM_VERTEX,
Hydrax::Module::ProjectedGrid::Options()
);


mSea->setModule(static_cast<Hydrax::Module::Module*>(module));

//To remove the line between Caelum and Hydrax
std::vector<Ogre::RenderQueueGroupID> caelumskyqueue;
caelumskyqueue.push_back(static_cast<Ogre::RenderQueueGroupID>(Ogre::RENDER_QUEUE_SKIES_EARLY + 2));
mSea->getRttManager()->setDisableReflectionCustomNearCliplPlaneRenderQueues (caelumskyqueue);

mSea->loadCfg("HydraxDemo.hdx");

try
{
mSea->create();
}
catch (Exception &e)
{
return E_OCEAN;
}

mScene->setWorldGeometry("Island.cfg");//Island.cfg

mSea->getMaterialManager()->addDepthTechnique(
static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().getByName("Island"))
->createTechnique());

klinkLoadForest();


Anybody help me ?



Have fixed !