Page 3 of 4

Posted: Thu Feb 19, 2009 10:19 am
by hybrid
What did you achieve so far, what happened when you tried the things you found out so far? There's no way for us to help is you don't tell.

Posted: Thu Feb 19, 2009 10:27 am
by devsh
nothing happened
I called

OnAnimate(timer);
OnRegisterSceneNode();
render();

AND I sTIll CANNOT SEE IT!!!
It only renders if i make it the child of RootSceneNode!!!!!!!!!

So I am wondering... looking at the third example of the tutorial, i see that the custom tetrahedron scene node is not the child of RootSceneNode and its render() function is not empty (unlike Water scene node) but it has DrawVertices(). So I ask What should I put in the render function for the Water scene node to render????

drawMeshbuffer() maybe???

Posted: Thu Feb 19, 2009 10:52 am
by devsh
OK I FOUND THIS

driver->setMaterial(Material);
core::matrix4 Mat;
Mat.makeIdentity();

//On sauvegarde les matrices
core::matrix4 MatrixWorld = driver->getTransform(video::ETS_WORLD);
core::matrix4 MatrixView = driver->getTransform(video::ETS_VIEW);

//On applique les matrices de monde et de vue
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
driver->setTransform(video::ETS_VIEW,Mat);
//On dessine nos Quad ici
//The mesh of the water is static
WaterMesh()->getMeshBuffer()->setHardwareMappingHint(EHM_STATIC);
driver->drawMeshBuffer(WaterMesh()->getMeshBuffer());

//On restaure les matrices
driver->setTransform(video::ETS_VIEW,MatrixView);
driver->setTransform(video::ETS_WORLD,MatrixWorld);

Posted: Thu Feb 19, 2009 12:09 pm
by hybrid
Well, BlindSide already told you to set up the transformation matrices etc. It's probably time to do so.

Posted: Thu Feb 19, 2009 2:09 pm
by devsh
i will try

Posted: Sun Feb 22, 2009 12:08 pm
by devsh
oh yeah i finnaly was able to do it!!

Code: Select all

void RealisticWaterSceneNode::render() {
   VideoDriver->setMaterial(WaterSceneNode->getMaterial(0));
   irr::core::matrix4 Mat;
   Mat.makeIdentity();

   //On sauvegarde les matrices
   irr::core::matrix4 MatrixWorld = VideoDriver->getTransform(irr::video::ETS_WORLD);
   irr::core::matrix4 MatrixView = VideoDriver->getTransform(irr::video::ETS_VIEW);

   //On applique les matrices de monde et de vue
   VideoDriver->setTransform(irr::video::ETS_WORLD, AbsoluteTransformation);
   VideoDriver->setTransform(irr::video::ETS_VIEW,Mat);
   //On dessine nos Quad ici
   //The mesh of the water is static
   WaterMesh->getMeshBuffer(0)->setHardwareMappingHint(irr::scene::EHM_STATIC);
   VideoDriver->drawMeshBuffer(WaterMesh->getMeshBuffer(0));

   //On restaure les matrices
   VideoDriver->setTransform(irr::video::ETS_VIEW,MatrixView);
   VideoDriver->setTransform(irr::video::ETS_WORLD,MatrixWorld);

}
BUT IT STILL DOESNT WANT TO RENDER INTO VIEWPORTS!!!

Posted: Sun Feb 22, 2009 12:18 pm
by devsh
hehe funny, I commented out //Water->OnAnimate(ITimer*);
and split screen works!!

I think its the fault of RTT and ViewPorts.

Posted: Sun Feb 22, 2009 2:00 pm
by devsh
Render Targets screw up the view ports :(

what do now?

Posted: Sun Feb 22, 2009 2:51 pm
by devsh
Honestly I tried everything I EVEN made a workaround using two textures (as to p and bottom of the screen) and setting the render targets to them after OnAnimate(), drawing the scene and then drawing the textures with driver->draw2DImage(TopScreen (or bottom whichever applicable, position2di())
and it still doesnt work.

Posted: Sun Feb 22, 2009 4:28 pm
by devsh
i kind of have it half working, the top screen renders fine but the bottom stays blank. Because i have that little thing that checks if you are under or above the water (it makes the game not call OnAnimate), if you go under then you can see both screens fine.

Posted: Sun Feb 22, 2009 5:11 pm
by devsh
WEll i have almost reached my goal, I have made two begin scenes and end scenes, in the first the first camera is rendered and in the second the other camera renders. The water works, but the screen flickkerrs like hell.

Anysolution to that??

Posted: Sun Feb 22, 2009 5:52 pm
by hybrid
The problem is probably that you didn't understand what happens at those beginScene and endScene calls. However, there's no way to really help you without seeing code (better yet to strip it down to only a few RTT calls instead of having to deal with all water shaders and stuff!).

Posted: Sun Feb 22, 2009 6:01 pm
by devsh
oh its allright now i told it not to clear the back buffer when doing a new scene and when switching RTT to 0.

Code: Select all

void SplitScreenLoop(irr::scene::ICameraSceneNode* cam1,irr::scene::ICameraSceneNode* cam2, RealisticWaterSceneNode* Water) {
   int lastFPS = -1;
   int fps;
   irr::video::IVideoDriver* driver = device->getSceneManager()->getVideoDriver();
   irr::scene::ISceneManager* smgr = device->getSceneManager();
   while (device->run()) {
      if (device->isWindowActive()) {
         driver->beginScene(false, true);
         driver->setViewPort(irr::core::rect<irr::s32>(0,(res.y/2),res.x,res.y));
         smgr->setActiveCamera(cam2);
         if (cam2->getPosition().Y>=Water->getAbsolutePosition().Y) {
            Water->OnAnimate(device->getTimer()->getTime(),2);
            driver->setViewPort(irr::core::rect<irr::s32>(0,(res.y/2),res.x,res.y));
            Water->OnRegisterSceneNode();
            Water->render();
            driver->setViewPort(irr::core::rect<irr::s32>(0,(res.y/2),res.x,res.y));
         }
         smgr->drawAll();
         driver->endScene();
         driver->beginScene(false, true, irr::video::SColor(0,0,0,0));
         driver->setViewPort(irr::core::rect<irr::s32>(0,0,res.x,(res.y/2)));
         smgr->setActiveCamera(cam1);
         if (cam1->getPosition().Y>=Water->getAbsolutePosition().Y) {
            Water->OnAnimate(device->getTimer()->getTime(),1);
            driver->setViewPort(irr::core::rect<irr::s32>(0,0,res.x,(res.y/2)));
            Water->OnRegisterSceneNode();
            Water->render();
            driver->setViewPort(irr::core::rect<irr::s32>(0,0,res.x,(res.y/2)));
         }
         smgr->drawAll();
         driver->endScene();
         //driver->clearBackBuffer(); This is the type of thing i'm looking for
         fps = driver->getFPS();
         if (lastFPS != fps) {

            irr::core::stringw str = L"Project Ninja Star - Nexuiz Map example FPS:";

            str += fps;

            device->setWindowCaption(str.c_str());

            lastFPS = fps;

         }
      }
      else
         device->yield();
   }
}
but now i need a method to clear the back buffer on the ned of my loop!!

is there any function like driver->clearbackbuffer();??? (i cant find one in API)

Posted: Sun Feb 22, 2009 6:02 pm
by hybrid
Shouldn't the end of your render loop be the beginning of the next?

Posted: Sun Feb 22, 2009 6:06 pm
by devsh
If that is what you are after

No, putting true to clear backbuffer in the first beginscene does not work.