TextSceneNode display problem when splitted view

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: TextSceneNode display problem when splitted view

Post by CuteAlien »

Problem is that text-output is GUI. And gui always should be with full viewport. The textscenenode basically does get a 3d-position and then calls drawText for that. In this case it won't work - you have to do it yourself. I can only give you some quick code for doing that for the moving camera in the Irrlicht example (18.SplitScreen).

Add before the endScene().

Code: Select all

 
        // set to full viewport
        driver->setViewPort(rect<s32>(0,0,ResX,ResY));
        irr::scene::ISceneCollisionManager* Coll = device->getSceneManager()->getSceneCollisionManager();
        core::position2di textPos = Coll->getScreenCoordinatesFrom3DPosition(textPos3d, camera[3]);
        // now reverting the viewport calculation for camera 3
        textPos.X *= 0.5f;  
        textPos.Y *= 0.5f;
        textPos.X += ResX/2;
        textPos.Y += ResY/2;
        core::rect<s32> r(textPos, core::dimension2d<s32>(1,1));
        Font->draw(L"some text", r, video::SColor(255,255,255,255), true, true);
 
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply