Rotate Image-2D

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
_willa
Posts: 3
Joined: Fri Nov 21, 2008 9:23 am
Location: Madrid ( Spain )

Rotate Image-2D

Post by _willa »

I do not understand after multiple tests as you can rotate a picture 2d
I tested "driver-> draw2DImage" but neither works.

Code: Select all

    video::ITexture* images = driver->getTexture("../../media/2ddemo.bmp");
    
   	scene::ISceneNode* image2d = smgr->addBillboardSceneNode(0,irr::core::dimension2d<f32>(50,50));
    image2d->setMaterialTexture(0, driver->getTexture("../../media/particlewhite.bmp"));
  
	image2d->setMaterialFlag(video::EMF_LIGHTING, false);
	image2d->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
	
        while(device->run() && driver)
        {
            driver->beginScene(true, true, video::SColor(255,120,102,136));
			
			/*  driver->draw2DImage(images, core::position2d<s32>(780,60), core::rect<s32>(10,10,300,200),0,
                                video::SColor(255,(time) % 255,255,255), true); */

			image2d->setRotation(image2d->getRotation()+vector3df(0,0.1,-0.05));
			smgr->drawAll();
			driver->end();
		}
someone knows how to do it ?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

A billboard turns automatically towards the camera, so there's no reason one would rotate it - it's overwritten in the drawAll call anyway. You should simply use a quad with an IMeshSceneNode, this will support arbitrary rotations.
_willa
Posts: 3
Joined: Fri Nov 21, 2008 9:23 am
Location: Madrid ( Spain )

Post by _willa »

I do not understand your answer
you mean something like

Code: Select all

	IVideoDriver* driver = device->getVideoDriver();
	ISceneManager* smgr = device->getSceneManager();
	IGUIEnvironment* guienv = device->getGUIEnvironment();
	
	IMesh* mesh = smgr->getMesh("../../media/particlewhite.bmp");
	scene::IMeshSceneNode* image2d = smgr->addMeshSceneNode(mesh);
	
while(device->run() && driver)
    {
        driver->beginScene(true, true, video::SColor(255,120,102,136));
		image2d->setRotation(image2d->getRotation()+vector3df(0,0.1,-0.05));
		smgr->drawAll();
		driver->end();
	}

JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

You need to make a quad mesh somehow. Either with addHillPlaneMesh or by using a modelling package. Then you would pass that mesh to addMeshSceneNode.

getMesh(x.bmp) is pure rubbish i'm afraid...
Image Image Image
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Simple 2D image rotations are currently not supported by Irrlicht. So you have to texture some polygons and rotate those instead - or hack the engine yourself by changing the draw2DImage functions.
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
_willa
Posts: 3
Joined: Fri Nov 21, 2008 9:23 am
Location: Madrid ( Spain )

Object 2D ( more features )

Post by _willa »

I have been trying various ways, including by example "2DGraphics" included in ".. \ examples" and can not get to work with rotations in 2d images.


Based on the example of "2DGraphics" and included the following code.

Code: Select all

	scene::ISceneNode* playerNode = smgr->addEmptySceneNode();           
	playerNode->setMaterialFlag(EMF_LIGHTING, false);
	playerNode->setMaterialTexture( 0, driver->getTexture("../../media/portal1.bmp") );
    playerNode->setPosition(vector3df(100, 5, -5)); 
	playerNode->setMaterialType(video::EMT_SOLID );

while(device->run() && driver)
{
          driver->beginScene(true, true, video::SColor(0,120,102,136));
         // ...  
	                playerNode->setRotation(playerNode->getRotation()+vector3df(0,.5,0)); 
         // ...
	driver->endScene();
}
But the texture is still not rotate!!!

Somebody know how to do this ?

I just want to rotate an image 2d in a plane.
Thank you
Castaa
Posts: 39
Joined: Mon Jul 07, 2008 7:38 pm
Location: San Francisco
Contact:

Post by Castaa »

Billboard nodes should be able to be rotated along the axis facing the camera? To spin them clock or counterclock wise right?
My game: Star Sonata
Star Sonata is a massively multiplayer space game.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

They "should" be able to do that, but they currently can't.

There's a whole slew of changes waiting on 1.5 to be released, including more flexible billboards, so if you want to see feature updates, please checkout and help test 1.5. ;)
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Castaa
Posts: 39
Joined: Mon Jul 07, 2008 7:38 pm
Location: San Francisco
Contact:

Post by Castaa »

rogerborg wrote:They "should" be able to do that, but they currently can't.

There's a whole slew of changes waiting on 1.5 to be released, including more flexible billboards, so if you want to see feature updates, please checkout and help test 1.5. ;)
Thank you for the reply and tip :D
My game: Star Sonata
Star Sonata is a massively multiplayer space game.
Post Reply