SharpGL learning notes (7) OpenGL transformation summary, sharpgl learning notes

Source: Internet
Author: User

SharpGL learning notes (7) OpenGL transformation summary, sharpgl learning notes

The biggest difficulty I encountered with OpenGL was that when I often debug a piece of code, the screen was dark and I didn't know the result was correct. I didn't know how to make it good!

In fact, this is because the basic concepts of OpenGL "transformation" are not well mastered, so that operations such as "correctly displaying a 3D body on the screen and specifying a location" cannot be completed.

 

OpenGL transformations include the most basic 3D transformations in computer graphics, including geometric transformations, projection transformations, cropping transformations, and viewport transformations, as well as understanding and usage of OpenGL's special transformation concepts, such as camera simulation and matrix stack, these foundations are the foundation that cannot be bypassed when we start to enter the 3D world.

Therefore, I spent five articles on these basic concepts in detail.

 

SharpGL learning notes (2) model transformation (geometric transformation)

SharpGL learning notes (3) Projection Transformation and viewpoint transformation

SharpGL Study Notes (4) Projection

SharpGL learning notes (5) view Transformation

SharpGL learning notes (6) cropping and Transformation

 

However, these concepts are scattered. You may feel that they cannot be organically connected in practical applications? This section aims to clarify these basic knowledge points according to the logical relationship of the application, and thoroughly understand the relationship between these functions.

 

Let's take the example of daily use of cameras for example:

In fact, from a three-dimensional space to a two-dimensional plane, just like taking a photo with a camera, we usually have to go through the following steps (the corresponding graphics concept is represented in parentheses ):
Step 1: place the camera on a tripod to align it with a 3D scene (Viewpoint Transformation, Viewing Transformation).
Step 2: place a three-dimensional object in a proper position (Model Transformation (geometric Transformation), Modeling Transformation).
Step 3: select the camera lens and focus on the camera so that the three-dimensional object is projected on the two-dimensional film (Projection Transformation, Projection Transformation).
Step 4: determine the size of a two-dimensional image (Viewport Transformation).
In this way, an object in a three-dimensional space can be represented by a corresponding two-dimensional plane object, and it can be correctly displayed on a two-dimensional computer screen.

Below, it expresses the above meaning.

 

There are several special Coordinate Systems in the 3D graphic world.
Display 3D imagesThis coordinate system is called the world coordinate system..
To display on a graphic display, a two-dimensional Cartesian coordinate system is defined on the screen of the graphic display. This coordinate system is called the screen coordinate system.. The coordinates of the coordinate system are usually taken in the direction parallel to the edge of the screen, and the coordinate origin is taken in the upper left corner. The length unit is usually taken as the length of a pixel. The size can be an integer.
To enable 3D display on a two-dimensional display, dimensionality reduction must be performed through projection. There are two projection methods:Normal projection and Perspective Projection.
Normal projection and Perspective ProjectionDefineViewing Volume ).Normal projection is generally a cube visual body, while perspective projection is generally a pyramid-like visual body. Only objects in the visual view can be projected on the display plane. Other parts cannot.

A rectangle can be defined in the screen window of a 3D image.View(Viewport), The figure after the Visual Object projection is displayed in the video. After the 3D image is changed according to the view, it can be displayed on the full screen or only part of the screen.
In order to adapt to the differences between the coordinates of the physical device and the coordinates of the viewport, we also need to adapt to the transformation of the physical coordinates. This coordinate system is calledPhysical device coordinate system.

As described above, the display process of 3D images should be shown in.

 

In OpenGL, the preceding steps require several statements to be completed. But in 3dsmax, only the Conversion Tool and camera tool can be used.

If the "Move, rotate, scale" tool performs operations on the 3D modelModel Transformation

Adjusting the camera position and target point, as well as rotating the cameraViewpoint Change

Top view, front view, Left view, threeNormal projectionWhile the Camera01 view isPerspective ProjectionAnd the three views, together with the Camera01 view, are fourView

A function option "manual cut" in the camera tool isCrop and transform

Top, front, left, and black lines in the four views of Camera01 areWorld coordinate systemAndScreen Coordinate SystemThe origin is in the upper left corner of each view. The horizontal direction is X, and the vertical direction is Y.

 

 

If you are still confused, you can reply to this post and I will add it again.

Original article: http://www.cnblogs.com/hackpig/

 

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.