Sign in to follow this  

Allegro : persp_project()

This topic is 4597 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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;
}

Share this post


Link to post
Share on other sites

This topic is 4597 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this