C # application Video Tutorial 2.2 OpenGL Virtual Simulation Introduction

Source: Internet
Author: User

Three-dimensional after understanding how to draw 2D elements, we try to draw 3D elements.

In fact, more than one triangle can be a tetrahedron, multiple rectangles can also be six, so when drawing 3D elements, as long as the number of vertices match on the line

?

Here we pay particular attention to, I draw the previous three translation and three rotations alone to make variables, if your Translatez default value is 0, you see the default is the yellow face, if the Translatez is set to negative, then see the red, and smaller, If you set the Translatez to a positive number, you won't see anything. Here the reader also needs an extra space to imagine the ability to see where your viewing angle is. By default, your viewing angle is in the position of the brush, so you are the equivalent of the eye on the canvas, you can only see a color, if the space of the brush (note is not a flat brush) Translatez has a value, then the equivalent of the brush lifted out of the canvas, Or the canvas is drawing something (each rendering cycle is to throw away the previous painting, brush translation + rotation + Drawing), so at this point we should imagine that you are holding a paintbrush in the space to draw a 3D diagram (so understand, after the perspective of the question I will introduce another)

?

We have been painting the image in front of the color, in addition to the color can also use the method of mapping. Note the type that you want to use with SHARPGL. Also to turn on allow textured images (so-called GL. Enable (XXX) and GL. Disable (XXX) is the opening and closing of the valve, OpenGL is a state machine, he is running every cycle is to empty the canvas, re-drawing, in the drawing you can always open and close some valves, such as textures, materials, lighting, diffuse reflection and so on, This will be explained in depth later on.)

?

When textures are not enabled, the image you see doesn't have a 3D effect (it's worse than sticking to a color)

?

At the time of drawing we put the front one GL. Begin-gl.end is divided into six pieces, each individually drawn (if you find someone else writing gl.begin (7) in some code, don't feel very strange because of GL. Begin (openggl.gl_quads) This cube is the uint type, which is 7, Front OpenGL many open and close functions are also a UINT type) Gl.normal is the normal direction of the specified face, the orientation of the specified face can make the lighting effect more realistic, especially when importing large 3D objects, in fact, the complex 3D object is also composed of multiple triangular patches (TRIANGLE), if you do not for each Triangular patches Specify normal, then the entire 3D object will look like a plane

?

When it comes to light, you can put together a contrast of light. After the light is turned on, the reader can change the effect of moving the cube from the left to the right (at present it can be thought that the light is a small lamp, and the position is dead, so the distance is more and more dark, or even directly see, if the lighting effect is turned off, it will not be shadowed by the change of position)

?

Lighting In fact can be set up very complex, we do not do large-scale games, it is generally not involved (personally think there is no need to waste too much time on these things), we here set the light source position, ambient light, diffuse light and other parameters directly copied on the line (later on the use of color texture, Because most of the time is still used in color coloring, simple color and color texture effect or the difference is very large, color texture as pure black pillars in the light is very realistic, and pure color brush on the black has no characteristics, draw a ball can be seen immediately

?

?

For more instructional videos and downloads, please pay attention to the following information:

My Youku Space:

Http://i.youku.com/acetaohai123

?

My online forum:

http://csrobot.gz01.bdysite.com/

?

Problem Exchange:

qq:910358960

Email:[email protected]

?

?

C # application Video Tutorial 2.2 OpenGL Virtual Simulation Introduction

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.