Rotating a Billboard

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
Aroth

Rotating a Billboard

Post by Aroth »

Hi. I tried to rotate a billboard, by making it a child of a dummy cube which is a node. So I read somewhere on the forums that if you rotate the parent, the child will also rotate, but that was not the case when I tried that. On screen, the cube rotated, but the car bitmap on the billboard did not.
Here are parts of my code:

Code: Select all


        float carrotation = 0.0; 
         //dummy parent node
	scene::ISceneNode* node = smgr->addTestSceneNode();

	//create billboard with car texture making it a sprite and child of node
	car = device->getSceneManager()->addBillboardSceneNode(node, core::dimension2d<f32>(70,93));
	car->setMaterialFlag(video::EMF_LIGHTING, false);
	car->setMaterialTexture(0, driver->getTexture("data/car.bmp"));
	car->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR); 

//inside main loop

//using bool keys

		if(keys[irr::KEY_KEY_A])
		{
			
			carrotation +=1;
			node->setRotation(node->getPosition() + core::vector3df(0.0f,carrotation,0.0f); 
			std::cout <<carrotation <<"\n";
		} 
Does anyone see the problem?
Thanks
Byron
Posts: 8
Joined: Tue Jan 06, 2004 11:47 pm

Post by Byron »

I don't think that billboard nodes are supposed to rotate, they always face the camera

Byron
Aroth

Post by Aroth »

The billboard is still facing the camera. The image should rotate permendicular to the z axis, so the car image would look like a car turning in grand theft auto 1.
thesmileman
Posts: 360
Joined: Tue Feb 10, 2004 2:20 am
Location: Lubbock, TX

Post by thesmileman »

I think your code for rotation:

Code: Select all

node->setRotation(node->getPosition() + core::vector3df(0.0f,carrotation,0.0f); 
Should be:

Code: Select all

node->setRotation(node->getRotation() + core::vector3df(0.0f,carrotation,0.0f); 
Despite this I don't think a bilboard will rotate the way you want it too but I could be wrong.
Aroth

Post by Aroth »

Well, I tried that, but the results were unexpected. The cube rotates, but its as if the car is attached to the node and always points in one direction and you get a ferris wheel type effect. Mabe if I texture the cube, it would look as a sprite instead of making a billboard a sprite. But thanks anyway.
Robomaniac
Posts: 602
Joined: Sat Aug 23, 2003 2:03 am
Location: Pottstown, PA
Contact:

Post by Robomaniac »

Billboards always face the camera.

Period, that's how their programmed
The Robomaniac
Project Head / Lead Programmer
Centaur Force
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

I think what he means is rotating the billboard on two axis ( axii? ) rather than three. So it is entirely possible to rotate a billboard whilst still always facing the camera.

i.e. if the billboard was |, then it was rotated slightly then it could be / whilst still facing the camera.
stampsm
Posts: 142
Joined: Mon Nov 10, 2003 5:52 pm
Location: Las Vegas

Post by stampsm »

I know in games such as medal of honor the sprites act just like regular billboards but they also rotate which gives than a more realistic look.
Is this what you are looking for, if anyone can find a way i will be interested in learning how to do it.
Aroth

Post by Aroth »

I ment rotating the billboard like a car would rotate in gta, always facing the player.
Domarius
Posts: 178
Joined: Thu Mar 11, 2004 9:51 am
Location: Brisbane, QLD, Australia

Post by Domarius »

Aroth wrote:I ment rotating the billboard like a car would rotate in gta, always facing the player.
There's no principal reason why billboards shouldn't be able to rotate relative to the screen (ie. in the same way that a 2D sprite rotates) 'Billboard' sprites have been rotating since Duke Nukem 3D.

If it isn't possible in Irrlicht yet, I'd say it is just waiting to be implemented.

Also, I've seen other engines that allow you to say which axis's of the billboard is locked, so you can create ones that only pivot around on the spot, but if you move above them, they won't pivot upward to face you. Really usefull for say, the 'billboards' used in Doom, where sometimes statues would be 'billboards' - if you looked down, you wouldn't want them looking back up at you - they wouldn't be stuck on the floor anymore and it would look weird.
Though, being able to lock axis's depends on how they are drawn - I think it's faster when its drawn straight onto the screen - meaning it wouldn't make sense for them to not face the screen. And my Doom example is a bad one - the 'billboards' in Doom WERE drawn directly onto the screen, and you couldn't truely look up and down, it just kind of slid the view up and down without changing the perspective.
Post Reply