3d math optimisation suggestion

Discussion about everything. New games, 3d math, development tips...
Post Reply
ayman
Posts: 51
Joined: Sat Feb 05, 2005 7:33 pm
Location: Piefke State

3d math optimisation suggestion

Post by ayman »

Hi together

just a slight question. Please look at this piece of code from the original CBillboardSceneNode::render() method. It prepares some vectors before it makes the Billboard face the camera:

Code: Select all

	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);
	horizontal.normalize();

	core::vector3df vertical = horizontal.crossProduct(view);
	vertical.normalize();
My question: Isn't the vertical vector Niko calculates here just the same as -up ? Or am I overlooking something?

Regards
Ayman
jox
Bug Slayer
Posts: 726
Joined: Thu Apr 22, 2004 6:55 pm
Location: Germany

Post by jox »

No (or yes, you're overlooking something ;) ).

It would be the case if the upvector is always perpendicular (90 deg) to the view vector. But it isn't the case. You want the vertical vector always perpendicular to the view vector.

Imagine you're looking 45 degrees downwards. The camera upvector will still look straight upwards but the required vertical vector should look 45 degrees up.

The thing is, that the camera upvector is fixed in most cases (looking straight upwards). It's not dependend from the viewing direction.
It is like it is. And because it is like it is, things are like they are.
Post Reply