To be a senior software engineer [2] (QT + OpenGL)

Source: Internet
Author: User

2. Thin villain
The previous section shows how to create a seemingly three-dimensional scene. Of course, we only rely on some texture textures to make it look stereoscopic, rather than actually building a 3D model. In this section, we need to add some elements to the previous scenario. We think of these elements as adult, automobile, or other things. Our goal is to make them appear to be moving in the scene.
Do you still remember that we only drew five faces in the previous section? Now we add the sixth surface, but do not use it as the front of our cube. You can think of the sixth face as a villain in a movie, and the job we want to do is to move this thin villain in our scenario. Of course, this seems very simple. When I finish it, I also feel that it is actually not a substantial progress for learning OpenGL, so I decided to share with you in the next section how to build multiple scenarios and add the content of three-dimensional elements. In this section, we hope that you can patiently read it and learn how to move an object and coordinate system in OpenGL.
The scenario or object movement and rotation are completed at the beginning. The reason for this is that every time we move or rotate an object, we are actually performing updategl (), that is, re-painting our scenario and object. Imagine how we drew a plane. At that time, we used some definite coordinates. In this case, I think you should be able to reflect that the movement of objects and scenes is actually the coordinates of variables. We will operate these variables and then update them.
For the Coordinate System D. Michael Traub: Provides the above explanations for xvector, yvector, and zvector.

To better understand the rotation of X, Y, and Z, let's look at some examples...

X axis-you are using a saw. The axis at the center of the saw blade is placed from left to right (like the X axis in OpenGL ). The sharp sawtooth turns around the X axis. It looks either up or down. It depends on the direction when the saw blade starts to rotate. This is the same as rotating around the X axis in OpenGL. (Cker Note: If you want to splice your face to the display, you must be cut off ^-^ .)

Y axis-assuming you are in a huge tornado center, the center of the tornado points from the ground to the Sky (like the Y axis in OpenGL ). Garbage and fragments go from left to right or from right to left around the Y axis. This is the same as what we rotate around the Y axis in OpenGL.

Z axis-you are looking at a fan from the front. The center of the fan is right toward you (like the Z axis in OpenGL ). The fan blade rotates clockwise or counterclockwise around the Z axis. This is the same as what we rotate around the Z axis in OpenGL.

When you fully understand the above knowledge, you will write your own code to let our thin people move in the scene. However, do you feel not excited at all? You will say, why don't we create a three-dimensional villain...
Below I will pave the way for the next section, and we will discuss it:

① Construct a 3D scene, and the objects inside it are also three-dimensional. Our villain is also three-dimensional. If the objects we construct look similar, we will consider using displaylist to display the list.
② Construct other 3D scenarios, and we can switch between these scenarios as needed. Here, we learn to build some classes and use them to store our scenario information.
③ Read our 3D scenario from a file. Of course, the file stores all the information we need.
④ Introduction to drawing some basic images, including the cylindrical and besell surfaces (these are only described)

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.