Page 1 of 1

cannot use BillboardTextSceneNode and draw3dLine together

Posted: Fri Nov 14, 2008 4:26 am
by Kairu
hi everyone
i cannot use billboardtext scene and draw3dline line together ,example below
i it really cannot is there other way to do it?

thanks

Code: Select all


#include <irrlicht.h>

using namespace irr;

#pragma comment(lib, "Irrlicht.lib")

int main()
{

   // create device
   IrrlichtDevice* device = createDevice( video::EDT_OPENGL, core::dimension2d<s32>(640, 480),
      16, false, false, true);

   if (device == 0)
      return 1; // could not create selected driver.

   video::IVideoDriver* driver = device->getVideoDriver();
   scene::ISceneManager* smgr = device->getSceneManager();

   scene::ICameraSceneNode * cam = smgr->addCameraSceneNodeMaya();
   cam->setPosition(core::vector3df(50,50,50));
   cam->setTarget(core::vector3df(0,0,0));
gui::IGUIFont* font = device->getGUIEnvironment()->getBuiltInFont();

// if i not include this billboardtextscene node i can draw the 3d line
   scene::ITextSceneNode*n = smgr->addBillboardTextSceneNode(font,L"yahoo",0,core::dimension2d< f32 >(10,10),
   core::vector3df(0,0,0),20,video::SColor(100,100,100,100),video::SColor(100,100,100,100));


   while(device->run())
   {
      driver->beginScene(true, true, video::SColor(255,255,255,255));

      smgr->drawAll(); // draw the 3d scene




      driver->draw3DLine(core::vector3df(0,0,0), core::vector3df(50,0,0),
                     video::SColor(255,255,0,0));

      driver->draw3DLine(core::vector3df(0,0,0), core::vector3df(0,50,0),
                     video::SColor(255,0,255,0));

      driver->draw3DLine(core::vector3df(0,0,0), core::vector3df(0,0,50),
                     video::SColor(255,0,0,255));

      driver->endScene();

   }

   device->drop();

   return 0;
}

Posted: Fri Nov 14, 2008 8:44 am
by Dark_Kilauea
You need to set a material and a transformation for the driver before you use draw3DLine (or any draw* function for that matter)

See a scenenode's render() function for an example.

Posted: Fri Nov 14, 2008 9:03 am
by JP
Or just the documentation of IVideoDriver for the drawXXX functions ;)

Posted: Sat Nov 15, 2008 5:47 am
by Kairu
Thanks everyone , i finally managed to show both

another silly question is ,what wrong if i put

Code: Select all

            Dim material As New Material
            material.Lighting = False
            material.Wireframe = False
            driver.SetMaterial(material)
before the ' AddBillboardTextSceneNode '

why it doen't work this way? :?

Posted: Sat Nov 15, 2008 6:58 am
by vitek
All you are doing here is setting the material to be used by the driver for the next draw call. This is only temporary, and anything that does any rendering will set the material it wants before it renders any primitives.

The scene node maintains its own material settings, and they are applied when the node is rendered. If you want to override the material settings used by a scene node, the ISceneNode interface has a set of methods that allow you to do just that.

Travis