I can't see my 2Dline...

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
KAHIMA
Posts: 19
Joined: Sun Mar 01, 2009 7:44 am

I can't see my 2Dline...

Post by KAHIMA »

I've made a speedometer but the needle can't be seen??what am I supposed to do??Please help...
Here's the my source code :

Code: Select all

	video::IVideoDriver* driver = device->getVideoDriver();
	gui::IGUIEnvironment* env = device->getGUIEnvironment();
	driver-> draw2DLine (position2d <s32> (20, 20), position2d <s32> (80, 80), SColor(0, 0, 0, 0));
	env->addImage(driver->getTexture("speedometer.png"),
		core::position2d<s32>(800,10));
Masterhawk
Posts: 299
Joined: Mon Nov 27, 2006 6:52 pm
Location: GERMANY
Contact:

Post by Masterhawk »

i guess you have to draw the line in every frame. and then you should draw it later than the gui, otherwise the needle will be hidden behind the image
Image
Cloudef
Posts: 123
Joined: Wed Dec 03, 2008 9:02 pm
Location: Finland

Post by Cloudef »

Also you need to draw it beetwen beginscene and endscene tags.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

And you need to setup the driver's transform matrix and material as per the documentation.
Image Image Image
KAHIMA
Posts: 19
Joined: Sun Mar 01, 2009 7:44 am

Post by KAHIMA »

Would you like to give me the way to create the line per frame ? I dont know how to create that?
Sylence
Posts: 725
Joined: Sat Mar 03, 2007 9:01 pm
Location: Germany
Contact:

Post by Sylence »

You call draw2DLine() in your while( device->run() ) loop between beginScene() and endScene()
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
KAHIMA
Posts: 19
Joined: Sun Mar 01, 2009 7:44 am

Post by KAHIMA »

I still can't see the line... whereas i did your suggestion to write between while device run etc....
Sylence
Posts: 725
Joined: Sat Mar 03, 2007 9:01 pm
Location: Germany
Contact:

Post by Sylence »

See JP's post. You have to setup the transform matrix and the material.
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
KAHIMA
Posts: 19
Joined: Sun Mar 01, 2009 7:44 am

Post by KAHIMA »

Code: Select all

SMaterial m;
   m.Lighting=false;
   driver->setMaterial(m);
   driver->setTransform(video::ETS_WORLD, core::matrix4());
it's that true?? but i still can't see my line...
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

Code: Select all

SMaterial m;
          m.Lighting = false;
          Driver->setMaterial(m);
          Driver->setTransform(video::ETS_WORLD, core::matrix4());

		  Driver->draw3DLine(vector3df(0,0,0),vector3df(1,0,0),video::SColor(255,255,0,0));
		  Driver->draw3DLine(vector3df(0,0,0),vector3df(0,1,0),video::SColor(255,0,255,0));
		  Driver->draw3DLine(vector3df(0,0,0),vector3df(0,0,1),video::SColor(255,0,0,255));
This code will draw three lines at the world origin. Call it at the proper place the guys mentioned above and you should be fine. :wink:

EDIT: Oops. This is for 3d. The 2d variation is almost the same though.
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
KAHIMA
Posts: 19
Joined: Sun Mar 01, 2009 7:44 am

Post by KAHIMA »

Code: Select all

while(device->run())
		if (device->isWindowActive())
		{
			driver->beginScene(true, true, 0 );
			SMaterial m;
			m.Lighting = false;
			driver->setMaterial(m);
			driver->setTransform(video::ETS_WORLD, core::matrix4());
			driver->draw3DLine(vector3df(0,0,0),vector3df(1,0,0),video::SColor(255,255,0,0));
			driver->draw3DLine(vector3df(0,0,0),vector3df(0,1,0),video::SColor(255,0,255,0));
			driver->draw3DLine(vector3df(0,0,0),vector3df(0,0,1),video::SColor(255,0,0,255));
			smgr->drawAll();
			env->drawAll();
			driver->endScene();
			
if i use that's code, i just see tha line at about 1 second... i don't understand ... I just want to make needle for a speedometer, or any others idea??
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

I`d use the compass code and draw a poly on screen and rotate it if I was you. This will give you some benefits than using the line- you can use whatever speedometer needle you want and customize it better- by one rotation only. Just look for "compass", "compass scene node", or you can check Acki`s extensions for ICompassSceneNode also ( http://abusoft.g0dsoft.com/ ). :wink:
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
KAHIMA
Posts: 19
Joined: Sun Mar 01, 2009 7:44 am

Post by KAHIMA »

What do you mean with ICompassSceneNode, i could't find it...
Where i can found the tutorial and the library? I really new in this case...
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Search these forums for compass or IGUICompass. I wrote a gui element that represents a compass some time ago, and it has been adapted several times. You should find it and the others.

Travis
Post Reply