Page 1 of 1

Rotating a Billboard

Posted: Fri Mar 19, 2004 3:26 am
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

Posted: Fri Mar 19, 2004 5:05 am
by Byron
I don't think that billboard nodes are supposed to rotate, they always face the camera

Byron

Posted: Sat Mar 20, 2004 4:00 am
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.

Posted: Sat Mar 20, 2004 6:26 pm
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.

Posted: Thu Mar 25, 2004 12:29 am
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.

Posted: Thu Mar 25, 2004 12:30 am
by Robomaniac
Billboards always face the camera.

Period, that's how their programmed

Posted: Thu Mar 25, 2004 1:00 am
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.

Posted: Thu Mar 25, 2004 4:56 pm
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.

Posted: Thu Mar 25, 2004 5:21 pm
by Aroth
I ment rotating the billboard like a car would rotate in gta, always facing the player.

Posted: Mon Mar 29, 2004 12:33 am
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.