Water not visible

bmp410

03-04-2009 07:24:33

After some tweaking and a few choice swear words, I was able to get Hydrax to load in my game. It is actually running calculations because in debug mode the performance is terrrible whenever I enable it, however I cannot actually see the water. It is probably something very simple that I am overlooking due to my lack of sleep as of late. Can anyone see anything that I am doing incorrectly?

The code is the initialization for my player camera that follows the node passed in.


void PlayerCamera::Initialize(Ogre::SceneNode *inFocusNode){
focusNode = inFocusNode;

cameraCollisionMgr = Ogre::Singleton<GameCollisionManager>::getSingletonPtr();
cameraCollisionMgr->setSceneManager("Play");

//At least for now, this variable equals:
//cameraNodeName = MyPlayerCam
Ogre::String cameraNodeName = inFocusNode->getName()+ "Cam";

parentNode = Ogre::Singleton<Ogre::Root>::getSingletonPtr()->getSceneManager("Play")->createSceneNode(cameraNodeName + "parent");
//create the camera node

node = parentNode->createChildSceneNode(cameraNodeName);

//create the camera
myCamera = Ogre::Singleton<Ogre::Root>::getSingletonPtr()->getSceneManager("Play")->createCamera(cameraNodeName);

//put set viewport to this camera
Ogre::Singleton<Ogre::Root>::getSingletonPtr()->getAutoCreatedWindow()->getViewport(1)->setCamera(myCamera);

//attach cam to node
node->setPosition( Ogre::Vector3(0, 0, -400));
node->rotate(Ogre::Vector3(0,1,0), Ogre::Degree(180));
node->attachObject(myCamera);

//myCamera->setAutoTracking(true,focusNode,Ogre::Vector3(0,50,0));
node->setAutoTracking(true, parentNode, Ogre::Vector3::NEGATIVE_UNIT_Z, Ogre::Vector3(0, 0, 0));

cameraRaySceneQuery = Ogre::Singleton<Ogre::Root>::getSingletonPtr()->getSceneManager("Play")->createRayQuery(Ogre::Ray());
cameraRaySceneQuery->setSortByDistance(true);

//camera starting values
direction = Ogre::Vector3::ZERO;
rotate = 0.13;
move = 200;
cameraOffset = 400;
myCamera->setNearClipDistance(0.1);

// Create Hydrax object
mHydrax = new Hydrax::Hydrax(Ogre::Singleton<Ogre::Root>::getSingletonPtr()->getSceneManager("Play"), myCamera,
Ogre::Singleton<Ogre::Root>::getSingletonPtr()->getAutoCreatedWindow()->getViewport(1));

mHydrax->setModule(static_cast<Hydrax::Module::Module*>(new Hydrax::Module::ProjectedGrid(// Hydrax parent pointer
mHydrax,
// Noise module
new Hydrax::Noise::Perlin(),
// Base plane
Ogre::Plane(Ogre::Vector3(0,1,0), Ogre::Vector3(0,0,0)),
// Normal mode
Hydrax::MaterialManager::NM_VERTEX,
// Projected grid options (Can be updated each frame -> setOptions(...))
Hydrax::Module::ProjectedGrid::Options(/* Default constructor */))));

mHydrax->setComponents(
static_cast<Hydrax::HydraxComponent>(Hydrax::HYDRAX_COMPONENT_SUN |
Hydrax::HYDRAX_COMPONENT_FOAM |
Hydrax::HYDRAX_COMPONENT_DEPTH |
Hydrax::HYDRAX_COMPONENT_SMOOTH |
Hydrax::HYDRAX_COMPONENT_CAUSTICS |
Hydrax::HYDRAX_COMPONENT_UNDERWATER |
Hydrax::HYDRAX_COMPONENT_UNDERWATER_REFLECTIONS |
Hydrax::HYDRAX_COMPONENT_UNDERWATER_GODRAYS));

mHydrax->create();


bool PlayerCamera::frameStarted(const Ogre::FrameEvent& evt){
//translate camera to keep up with player
//node->setPosition( Ogre::Vector3(node->getPosition().x, 50, -cameraOffset));

mHydrax->update(evt.timeSinceLastFrame);

parentNode->setPosition(focusNode->getPosition() + Ogre::Vector3(0,50,0));
node->needUpdate(true);
cameraGroundCollisionCheck();

return true;
}

bmp410

03-04-2009 18:00:04

Update: I can put my camera under the water plane and get the effect of being under water, I just simply cannot see the top of the water

raygeee

06-04-2009 09:46:03

Try running with disabled shadows.

bmp410

18-04-2009 22:38:24

This worked! Thanks!

Is there any way to have shadows and Hydrax running at the same time?

raygeee

22-04-2009 21:37:19

Yes. I think it's something about the correct loading order. Try loading Hydrax then setting shadow and vice versa - one should do.

al2950

23-04-2009 14:26:25

If you are using stencil shadows then you will run into problems with hydrax. To get shadows working you have to use texture shadows.

eg:

mSceneMgr->setShadowTechnique(SHADOWTYPE_TEXTURE_ADDITIVE);
etc...



Angus

idnemo

28-04-2009 14:57:56

I had the same question.But I dont know how could I disabled shadows?
the Entity's Shadow with setcastshow()?

raygeee

01-05-2009 23:24:26

mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_NONE);

idnemo

03-05-2009 13:42:23

mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_NONE);
I try put this sentence almost everywhere,but I still can't see the water above the water plane.
I use PagedGeometry render trees and grasses,does this plugin incompatible with hydrax?