Corners of a sprite, without matrices

Blitz3D Forums/Blitz3D Programming/Corners of a sprite, without matrices

Let's say we have a quad we want to face the camera. Given the position of the camera, and the position of the quad, we can calculate a vector we want to align the quad to.

The quad is defined as four vertices at (-1,-1,0),(-1,1,0),(1,1,0), and (1,-1,0). Now, what is the fastest way to calculate the new coordinates, hopefully without using matrices?

Take your normal which points in the direction your object faces. We'll call this NormalX.

This is the hard part:

Calculate normals which are 90 degrees to this normal. Call these NoralY and NormalZ.

This is hard because you may have a normal which points towards the camera, but you have no defined up/down left/right. You'll have to decide how you're going to determine those directions for yourself.

Once you've done that, all you need do is this:


Multiply NormalX by the new point's X coordinate.
Multiply NormalY by the new point's Y coordinate.
Multiply NormalZ by the new point's Z coordinate.

Add the three normals.

The result is the location of your transformed point.


You can imagine this like moving a knight on a rotated chessboard. First you move it along the transformed X axis, then along the transformed Y axis, and finally you move it along the transformed Z axis because I just took it with that pawn you failed to notice.