Page 1 of 1

Draw a 2D image with a depth

Posted: Fri Apr 23, 2010 5:40 pm
by Maleesh
Hi all!

I need to order the 2d images regardless the order of they drawing. So, Can anyone please tell me how to draw 2d images with a depth. I did it with pure OpenGL, but I started to port that code into IrrLicht. Now I can't find a way to do it. :roll:

I'm talking about something like this,

Code: Select all

	glBegin(GL_QUADS);

	//Top-left 
	glTexCoord2f(l, t);
	glVertex3f(x, YY, _depth);

	// Top-right
	glTexCoord2f(r, t);
	glVertex3f(XX, YY, _depth);
	
	// Bottom-right 
	glTexCoord2f(r, b);
	glVertex3f(XX, y, _depth);

	// Bottom-left
	glTexCoord2f(l, b);
	glVertex3f(x, y, _depth);	
	
	glEnd();
Please forgive me if this is a noob one :) , that is because this is my first time at IrrLicht. I'm asking this after spending a almost a day to find the solution :(

Thank you very much..

Regards,
Maleesh

Posted: Sat Apr 24, 2010 2:00 am
by Josie
What you should do is encapsulate what you draw into scenenodes, Irrlicht automatically orders those by depth, regardless of what order you create them in.

Posted: Sat Apr 24, 2010 2:11 am
by Kalango
You can do a list and order them by depth so when you call the draw function for each one, the distant ones are drawn first and the closer ones are drawn last.
You can also make scene nodes for 2d images using 3d quads and ortho cameras (dont forget to lock X and Y rotation).... its pretty straight foward and easy and you can also rotate and scale without problem and also render them with(or without) filters and custom materials (like normal maps for lighting pwnage)....

Draw a 2D image with a depth

Posted: Sat Apr 24, 2010 3:26 am
by Maleesh
Josie wrote:What you should do is encapsulate what you draw into scenenodes, Irrlicht automatically orders those by depth, regardless of what order you create them in.
Thank you.
How to use addSceneNode() ? It returns me NULL. And Scenenodes are ordered (z) by IrrLicht, not by OpenGL. Isn't it ?
Kalango wrote: You can do a list and order them by depth so when you call the draw function for each one, the distant ones are drawn first and the closer ones are drawn last.
Thank you. But we don't want to do it, if IrrLicht can do it itself ?

Can anyone please show me the code to load a image and render it with scene node? I searched about it, but no luck on the forum or wiki. Help this noob please. Thank you very much. :)

Posted: Sat Apr 24, 2010 3:32 am
by Virion

Posted: Sat Apr 24, 2010 4:14 am
by Maleesh
Thanks. It is about creating a custom scene node. So, I can't simply add my texture to scenenode to get rendered it ?

Posted: Sat Apr 24, 2010 7:14 pm
by Scarabol
Hi,

just use this example and add your texture with:
setMaterialTexture();

MfG
Scarabol