Projection Transformation and view Transformation

Source: Internet
Author: User

Notes:

0. Projection Transformation: describes how to specify the shape and direction of a visual object (Viewing Volume. View transform: explains how to control the transformation from 3D model coordinates to screen coordinates.

1. No matter perspective projection or parallel projection (orthogonal projection), only objects in the visual object can be seen.

2. Default point of view for OpenGL

(Eyex, eyey, Eyez) = (0.0, 0.0, 0.0); (UPX, upy, upz) = (0.0, 1.0, 0.0) points to the Z axis negative half axis.

(You can also specify it through glulookat)

Function introduction:

Viewpoint settings


/* This function is used to set the point of view, the point of view focus, and the upward direction of the Point of view */

// Order: V1 (centerx-eyex, centery-eyey, centerz-Eyez) V2 (UPX, upy, upz)

// V3 is the projection vector of V2 on V1 as the normal vector plane

// If the vector V1 and V2 are parallel, the viewpoint will not see any objects. [Avoid this situation]

// V2 is not the upward direction of the viewpoint, that is, it is not converted by the view, and is projected to the upward direction of the Two-dimensional screen image.

// The upward direction of the viewpoint is V3.

void gluLookAt( GLdouble eyex, GldoubleEyey, GldoubleEyez, 

GldoubleCenterx, GldoubleCentery, GldoubleCenterz, 

GldoubleUPX, GldoubleUpy, GldoubleUpz );


Perspective Projection (Camera Model)

/* This function is used to createSymmetricView a four-prism scene (the upper and lower sides of the Four-prism scene are similar rectangles, and the link between the two rectangles is high )*/

// Fovy is the vertical angle of view (Unit °) in the range of (0,180). The larger the angle, the more things you can see. It is the memory mon in the figure.

// Aspect is the ratio of width to height PQ/Mn (a positive number)

// Znear is the distance from the viewpoint to the near-cut surface OA (a positive number)

// Zfar is the distance from the viewpoint to the remote cut face OB (a positive number ob> OA)

void gluPerspective( GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar );


/* This function is used to create a four-prism visual body (the upper and lower sides of the Four-prism visual body are similar rectangles, but the link between the two rectangles is not set to their height )*/

// P (left, top) T (right, bottom) q (right, top) S (left, bottom)

// Znear is the distance from the viewpoint to the near-cut surface (a positive number)

// Zfar indicates the distance from the viewpoint to the remote cut plane (a positive number zfar> znear)

void glFrustum( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble znear, GLdouble zfar );


Parallel projection


/* This function is used to create a parallel projection.Visual cube box */

// P(left, top) T(right, bottom) Q(right, top) S(left, bottom)

// Near, far is positive in front of the viewpoint, negative in the back of the viewpoint (this does not mean that the front of the viewpoint will be displayed, and the back will not be displayed)

// For example: glulookat (0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glortho (-10.0, 10.0,-10.0, 10.0,-7.0, 9.0 );

// Auxwiresphere (8.0); the mesh ball can be fully displayed (that is, the whole ball falls into the visual body ).


void glOrtho( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far );


View Transform


/* This function is used to specify the screen origin and length/width values when the screen is transformed */

void glViewport( GLint x, GLint y, GLsizei width, GLsizei height );

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.