Page 1 of 1

Billbord Only Vertical rotation.

Posted: Mon Jul 07, 2008 7:42 pm
by Toadcop
yes i know it's very simple. but i can't manage it how to do that =\

here is the original one (rotate plane to camera)

Code: Select all

void CBillboardSceneNode::render()
{
	video::IVideoDriver* driver = SceneManager->getVideoDriver();
	ICameraSceneNode* camera = SceneManager->getActiveCamera();

	if (!camera || !driver)
		return;

	// make billboard look to camera

	core::vector3df pos = getAbsolutePosition();

	core::vector3df campos = camera->getAbsolutePosition();
	core::vector3df target = camera->getTarget();
	core::vector3df up = camera->getUpVector();
	core::vector3df view = target - campos;
	view.normalize();

	core::vector3df horizontal = up.crossProduct(view);
	if ( horizontal.getLength() == 0 )
	{
		horizontal.set(up.Y,up.X,up.Z);
	}
	horizontal.normalize();
	horizontal *= 0.5f * Size.Width;

	core::vector3df vertical = horizontal.crossProduct(view);
	vertical.normalize();
	vertical *= 0.5f * Size.Height;

	view *= -1.0f;

	for (s32 i=0; i<4; ++i)
		vertices[i].Normal = view;

	vertices[0].Pos = pos + horizontal + vertical;
	vertices[1].Pos = pos + horizontal - vertical;
	vertices[2].Pos = pos - horizontal - vertical;
	vertices[3].Pos = pos - horizontal + vertical;


	// draw

	core::matrix4 mat;
	driver->setTransform(video::ETS_WORLD, mat);

	driver->setMaterial(Material);

	driver->drawIndexedTriangleList(vertices, 4, indices, 2);
}
what i need to change, to have it rotated only at Y axis ?
// yeah the question is very lame i know i am shaming me T_T
tnx in advance.

Posted: Mon Jul 07, 2008 10:09 pm
by hybrid
Check the axis aligned billboard in the patch tracker.

Posted: Mon Jul 07, 2008 10:25 pm
by rogerborg
That's rubbish, that is. Didn't bitplane write a decent axis aligned billboard?