Allegro : persp_project()

Started by
3 comments, last by GameDev.net 18 years, 11 months ago
Hey, just a quick question I was looking through the allegro source (www.allegro.cc) and i couldnt find the function "persp_project()". Anyone know which file it resides in?
Advertisement
I'm stumped. The only reference I can find is in the "fix.inl", which defines an overload for use with fix numbers. I could not find the implementation (or even the declaration) of the function, although it is used in several examples...

Try to ask the people at allegro.cc, or send a mail at the allegro-help mailing list at sourceforge.

[OpenTK: C# OpenGL 4.4, OpenGL ES 3.0 and OpenAL 1.1. Now with Linux/KMS support!]

Copy & paste for Allegro Manual:

void persp_project(fixed x, y, z, *xout, *yout);
void persp_project_f(float x, y, z, *xout, *yout);

Projects the 3d point (x, y, z) into 2d screen space, storing the result in (*xout, *yout) and using the scaling parameters previously set by calling set_projection_viewport(). This function projects from the normalized viewing pyramid, which has a camera at the origin and facing along the positive z axis. The x axis runs left/right, y runs up/down, and z increases with depth into the screen. The camera has a 90 degree field of view, ie. points on the planes x=z and -x=z will map onto the left and right edges of the screen, and the planes y=z and -y=z map to the top and bottom of the screen. If you want a different field of view or camera location, you should transform all your objects with an appropriate viewing matrix, eg. to get the effect of panning the camera 10 degrees to the left, rotate all your objects 10 degrees to the right.

See also: set_projection_viewport, get_camera_matrix.

Examples using this: ex3d, exstars.
ill try mailing the people at allegro.cc... this is strange
allegro/include/inline/3dmaths.inl


inline void persp_project (fixed x, fixed y, fixed z, fixed *xout, fixed *yout)
{
*xout = fixmul(fixdiv(x, z), _persp_xscale) + _persp_xoffset;
*yout = fixmul(fixdiv(y, z), _persp_yscale) + _persp_yoffset;
}


inline void persp_project_f (float x, float y, float z, float *xout, float *yout)
{
float z1 = 1.0f / z;
*xout = ((x * z1) * _persp_xscale_f) + _persp_xoffset_f;
*yout = ((y * z1) * _persp_yscale_f) + _persp_yoffset_f;
}

This topic is closed to new replies.

Advertisement