![]() ![]() The transformation into default coordinates reverses the direction of the z-axis. The convention in OpenGL is to work with a coordinate system in which the positive z-direction points toward the viewer and the negative z-direction points away from the viewer. This is not a contradiction: The coordinate system that is actually used is arbitrary. Now, the default coordinate system in OpenGL, the one that you are using if you apply no transformations at all, is similar but has the positive direction of the z-axis pointing into the screen. OpenGL programmers usually think in terms of a coordinate system in which the x- and y-axes lie in the plane of the screen, and the z-axis is perpendicular to the screen with the positive direction of the z-axis pointing out of the screen towards the viewer. In this section, we will concentrate on how to construct a scene in 3D-what we have referred to as modeling. We will put off a discussion of lighting until Chapter 4. The objects are shaded in a way that imitates the interaction of objects with the light that illuminates them. Another factor is the “shading” of the objects. We will discuss projection in the next section. This is due to the way that the 3D scene is “projected” onto 2D. ![]() For one thing, objects that are farther away from the viewer in 3D look smaller in the 2D image. (The illusion is much stronger if you can rotate the image.) Several things contribute to the effect. This example is a 2D image, but it has a 3D look. The on-line version of this section has a demo version of this image in which you drag on the axes to rotate the image. The x-axis is green, the y-axis is blue, and the z-axis is red. The positive directions of the x, y, and z axes are shown as big arrows. This image illustrates a 3D coordinate system. The z-axis is perpendicular to both the x-axis and the y-axis. (That’s essentially what it means to be three dimensional.) The third coordinate is often called z. In three dimensions, you need three numbers to specify a point. We have seen the power of this when we discussed transforms, which are defined mathematically in terms of coordinates but which have real, useful physical meanings. Points and objects are real things, but coordinates are just numbers that we assign to them so that we can refer to them easily and work with them mathematically. More than that, the assignment of pairs of numbers to points is itself arbitrary to a large extent. The coordinates are often referred to as x and y, although of course, the names are arbitrary. In two dimensions, you need a pair of numbers to specify a point. If you use texture coordinates greater than 1 and your texture is set to repeat, then it's as if the rubber sheet was infinite in size and the texture was tiled across it.\)Ī coordinate system is a way of assigning numbers to points. That's basically how texture coordinates work. (Say, and ) then move those pins (without taking them out) to your desired vertex coordinates (Say, and ), so that the rubber sheet is stretched out and the image is distorted. You'd take 3 pins and place them in the rubber sheet in the positions of each of your desired texture coordinates. Now let's say you wanted to draw a triangle using that texture. Think of a rectangular rubber sheet with your texture image printed on it, where the length of each side is normalized to the range 0-1. Texture coordinates specify the point in the texture image that will correspond to the vertex you are specifying them for.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |