Irrlicht 1.8 - IBillboardTextSceneNode relative pos bugged

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Erelas
Competition winner
Posts: 20
Joined: Mon Apr 18, 2011 8:40 am

Irrlicht 1.8 - IBillboardTextSceneNode relative pos bugged

Post by Erelas »

Greetings,

We recently switched from irrlicht 1.7.2 to the nightly build of v1.8 for our project TANK@WAR.
One of the few problems we are having since the new version is the position / transformation of the Player name tags.
These are IBillboardTextSceneNodes with a players tank node as parent (and with position.Y = 5 (m)), so that they follow the player's tank correctly as they move about.

Code: Select all

 
scene::IBillboardTextSceneNode* playerNameNode = smgr->addBillboardTextSceneNode(
                        font, // font
                        playerName.c_str(), // text
                        player->getTank()->getNode(), // parent
                        dimension, // dimension
                        core::vector3df(0, 5, 0), // position
                        -1, // id
                        color, // color
                        color); // color
 
I created a separate project to get a clear look at the problem, to see if I could recreate it. One build with irrlicht 1.7.2 and a test with 1.8.

Here I create a simple cube scene node with a FlyCircleAnimator and add a IBillboardTextSceneNode as a child.
When compiled and run with 1.7.2 the pos is fine, in v1.8 however the pos stays at (0, 0, 0).

Any ideas?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Irrlicht 1.8 - IBillboardTextSceneNode relative pos bugg

Post by hybrid »

Do you use a viewport setting somewhere in your code? Where's the project you mentioned? Any code for us?
Erelas
Competition winner
Posts: 20
Joined: Mon Apr 18, 2011 8:40 am

Re: Irrlicht 1.8 - IBillboardTextSceneNode relative pos bugg

Post by Erelas »

Thanks for the quick reply ^^
Here is the code of the test project.

Code: Select all

 
#include <irrlicht.h>
 
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
 
 
IrrlichtDevice *device;
 
int main(){
   // Create device
   //video::E_DRIVER_TYPE driverType = video::EDT_DIRECT3D9;
   video::E_DRIVER_TYPE driverType = video::EDT_OPENGL;
 
   device = createDevice(driverType, dimension2du((u32)800, (u32)600), 32, false, true, false, 0);
   if (!device) {
      printf("Error creating Irrlicht device\n");
      return 0;
   }
 
   // Obtain device internals
   IVideoDriver* driver = device->getVideoDriver();
   ISceneManager* smgr = device->getSceneManager();
 
        // Add an animated mesh
        ISceneNode* node = smgr->addCubeSceneNode(100);
        if (node){
                node->setMaterialTexture( 0, driver->getTexture("media/rock1.jpg") );
                node->setMaterialFlag(EMF_ANISOTROPIC_FILTER, true);
                node->setMaterialFlag(EMF_ANTI_ALIASING, true);
 
                // Add rotation animator
                irr::scene::ISceneNodeAnimator* anim = smgr->createRotationAnimator(core::vector3df(0.1f, 0.1f, 0.1f));
 
                node->addAnimator(anim);
                anim->drop();
 
                anim = smgr->createFlyCircleAnimator();
                node->addAnimator(anim);
                anim->drop();
        }
 
        // Add a viewing camera
        ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS(0, 100.f, 0.05f);
        camera->setPosition(vector3df(0,0, -150));
 
 
 
        //Add player name to tank
        gui::IGUIFont* font = smgr->getGUIEnvironment()->getFont("./media/stencil_big.xml"); // TODO use different font
        core::stringw text("TESTTESTTEST");
 
        irr::video::SColor color = video::SColor(255, 180, 0, 0);
 
        irr::core::dimension2df dimension = (irr::core::dimension2df) font->getDimension(text.c_str());
        dimension.Width = dimension.Width / dimension.Height;
        dimension.Height = 1;
 
        dimension.Width *= 10;
        dimension.Height *= 10;
 
        scene::IBillboardTextSceneNode* billboardTextNode = smgr->addBillboardTextSceneNode(font, // font
                        text.c_str(), // text
                        node, // parent
                        dimension, // dimension
                        core::vector3df(0, 100, 0), // position
                        -1, // id
                        color, // color
                        color); // color
 
        int lastFPS = -1;
 
        // Main rendering loop
        while(device->run()){
                driver->beginScene(true, true, SColor(255, 125, 200, 255));
                smgr->drawAll();
                driver->endScene();
 
                int fps = driver->getFPS();
 
                if (lastFPS != fps){
                        core::stringw str = L"BillboardText test - Irrlicht Engine [";
                        str += driver->getName();
                        str += "] FPS:";
                        str += fps;
 
                        device->setWindowCaption(str.c_str());
                        lastFPS = fps;
                }
        }
 
        device->drop();
 
        // Done
        return 0;
}
 
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Irrlicht 1.8 - IBillboardTextSceneNode relative pos bugg

Post by CuteAlien »

Thanks for the testcase. It's fixed now again in new svn trunk (ISceneNode::OnAnimate was no longer called and so position never got updated).
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
Erelas
Competition winner
Posts: 20
Joined: Mon Apr 18, 2011 8:40 am

Re: Irrlicht 1.8 - IBillboardTextSceneNode relative pos bugg

Post by Erelas »

I see, thanks for looking into this! ^^
Post Reply