Page 1 of 1

Zoom-in / Zoom-Out a 2D Image? Is it possible?

Posted: Thu Jun 06, 2013 5:17 pm
by gauravjha
Hi,

Is it possible to change the scale of a 2D image in Irrlicht? i tried using "driver->getMaterial2D().getTextureMatrix(0).setTextureScale(0.01, 0.01);" but this seems to have no effect on the image?

Any help would be appreciated.

Regards,
Gaurav Jha

Re: Zoom-in / Zoom-Out a 2D Image? Is it possible?

Posted: Fri Jun 07, 2013 7:19 am
by hybrid
Not sure if we support texture scale via 2d material. You have to enable the 2d material at least, otherwise it does not affect anything. Please check example 6 or so (2d rendering and maybe GUI stuff) as that example explains 2d material as well. Otherwise there's no 2d on-the-fly scale, you'd have to scale the image on CPU first. Or use 3d rendering instead.

Re: Zoom-in / Zoom-Out a 2D Image? Is it possible?

Posted: Fri Jun 07, 2013 1:10 pm
by Nadro
You can use this method for it:
http://irrlicht.sourceforge.net/docu/cl ... acf7927354
In src rectangle you have to put texture size (in pixels, so UV you have to multiply by texture width and height). In dest you have to define part of screen which will be covered by image. Texture will scale automatically.

Re: Zoom-in / Zoom-Out a 2D Image? Is it possible?

Posted: Sat Jun 08, 2013 10:31 am
by gauravjha
Thanx for the help.

I am still a bit confused.

I am using the following statement:

driver->draw2DImage(mapFiles[0], rect<s32>(0, 0, 480, 272), rect<s32>(0, 0, 8, 6), 0, 0, true);

The image size I am using is 800*600pixels.

Still there is no affect on the image? Can you suggest what else needs to be done?

I have enabled material2D with the following scale ststement.

driver->getMaterial2D().getTextureMatrix(0).setTextureScale(0.01, 0.01);

Regards,
Gaurav Jha

Re: Zoom-in / Zoom-Out a 2D Image? Is it possible?

Posted: Sat Jun 08, 2013 10:42 am
by Nadro
Just decrease/increase size of dest rectangle. Your src rectangle should be (0,0,800,600). Don't use texture matrix.

Re: Zoom-in / Zoom-Out a 2D Image? Is it possible?

Posted: Sat Jun 08, 2013 12:38 pm
by gauravjha
Hi,

The solution did not work. Can you please suggest what could be the problem?

Regards,
Gaurav Jha

Re: Zoom-in / Zoom-Out a 2D Image? Is it possible?

Posted: Wed Jun 12, 2013 12:03 am
by chronologicaldot
What are you trying to do with it? Is this a texture for a model or are you just trying to draw an image?
If you're just trying to draw an image, you can always just render to a target GUI element ( IVideoDriver::setRenderTarget() ), draw the image as a texture (on a panel or box), and change the camera distance from the image.
The hardest, slowest, but most effective way, is to draw the image pixel by pixel, inserting pixels when the image is zoomed in and skipping pixels when the image is zoomed out. For speed, you'll have to draw the image to a texture before passing it to the engine, but then you're code would be driver-specific.

... and now I'm musing.

Re: Zoom-in / Zoom-Out a 2D Image? Is it possible?

Posted: Sat Jun 15, 2013 12:10 pm
by gauravjha
Thanx.

I was actually trying to draw some 2d Images. But now I have changed the solution and using a scene node and applying textures on it.

Thanx.