<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-2">
<META NAME="GENERATOR" CONTENT="Mozilla/4.07 [en] (Win98; I) [Netscape]">
<META NAME="Author" CONTENT="Goran UnreaL Krajnovic">
<TITLE>Chapter 3 - OpenGL Programming Guide (Addison-Wesley Publishing Company)</TITLE>
</HEAD>
<BODY BGCOLOR="#EFEFEF" LINK="#0000FF" VLINK="#551A8B" ALINK="#FF0000">
<DIV ALIGN=right><IMG SRC="figures/SGI_ID.gif" ALT="Silicon Graphics" NOSAVE HEIGHT=43 WIDTH=151 ALIGN=TEXTTOP></DIV>
<HR>
<H1>
Chapter 3<BR>
Viewing</H1>
<B>Chapter Objectives</B>
<P>After reading this chapter, you'll be able to do the following:
<UL>View a geometric model in any orientation by transforming it in three-dimensional
space
<BR>
<P>Control the location in three-dimensional space from which the model
is viewed
<BR>
<P>Clip undesired portions of the model out of the scene that's to be viewed
<BR>
<P>Manipulate the appropriate matrix stacks that control model transformation
for viewing and project the model onto the screen
<BR>
<P>Combine multiple transformations to mimic sophisticated systems in motion,
such as a solar system or an articulated robot arm</UL>
Chapter 2 explained how to instruct OpenGL to draw the geometric models
you want displayed in your scene. Now you must decide how you want to position
the models in the scene, and you must choose a vantage point from which
to view the scene. You can use the default positioning and vantage point,
but most likely you want to specify them.
<P>Look at the image on the cover of this book. The program that produced
that image contained a single geometric description of a building block.
Each block was carefully positioned in the scene: Some blocks were scattered
on the floor, some were stacked on top of each other on the table, and
some were assembled to make the globe. Also, a particular viewpoint had
to be chosen. Obviously, we wanted to look at the corner of the room containing
the globe. But how far away from the scene - and where exactly - should
the viewer be? We wanted to make sure that the final image of the scene
contained a good view out the window, that a portion of the floor was visible,
and that all the objects in the scene were not only visible but presented
in an interesting arrangement. This chapter explains how to use OpenGL
to accomplish these tasks: how to position and orient models in three-dimensional
space and how to establish the location - also in three-dimensional space
- of the viewpoint. All of these factors help determine exactly what image
appears on the sceen.
<P>You want to remember that the point of computer graphics is to create
a two-dimensional image of three-dimensional objects (it has to be two-dimensional
because it's drawn on the screen), but you need to think in three-dimensional
coordinates while making many of the decisions that determine what gets
drawn on the screen. A common mistake people make when creating three-dimensional
graphics is to start thinking too soon that the final image appears on
a flat, two-dimensional screen. Avoid thinking about which pixels need
to be drawn, and instead try to visualize three-dimensional space. Create
your models in some three-dimensional universe that lies deep inside your
computer, and let the computer do its job of calculating which pixels to
color.
<P>A series of three computer operations convert an object's three-dimensional
coordinates to pixel positions on the screen:
<UL>Transformations, which are represented by matrix multiplication, include
modeling, viewing, and projection operations. Such operations include rotation,
translation, scaling, reflecting, orthographic projection, and perspective
projection. Generally, you use a combination of several transformations
to draw a scene.
<BR>
<P>Since the scene is rendered on a rectangular window, objects (or parts
of objects) that lie outside the window must be clipped. In three-dimensional
computer graphics, clipping occurs by throwing out objects on one side
of a clipping plane.
<BR>
<P>Finally, a correspondence must be established between the transformed
coordinates and screen pixels. This is known as a <I>viewport</I> transformation.</UL>
This chapter describes all of these operations, and how to control them,
in the following major sections:
<UL>"Overview: The Camera Analogy" gives an overview of the transformation
process by describing the analogy of taking a photograph with a camera,
presents a simple example program that transforms an object, and briefly
describes the basic OpenGL transformation commands.
<BR>
<P>"Viewing and Modeling Transformations" explains in detail how to specify
and to imagine the effect of viewing and modeling transformations. These
transformations orient the model and the camera relative to each other
to obtain the desired final image.
<BR>
<P>"Projection Transformations" describes how to specify the shape and
orientation of the <I>viewing volume</I>. The viewing volume determines
how a scene is projected onto the screen (with a perspective or orthographic
projection) and which objects or parts of objects are clipped out of the
scene.
<BR>
<P>"Viewport Transformation" explains how to control the conversion of
three-dimensional model coordinates to screen coordinates.
<BR>
<P>"Troubleshooting Transformations" presents some tips for discovering
why you might not be getting the desired effect from your modeling, viewing,
projection, and viewport transformations.
<BR>
<P>"Manipulating the Matrix Stacks" discusses how to save and restore certain
transformations. This is particularly useful when you're drawing complicated
objects that are built up from simpler ones.
<BR>
<P>"Additional Clipping Planes" describes how to specify additional clipping
planes beyond those defined by the viewing volume.
<BR>
<P>"Examples of Composing Several Transformations" walks you through a
couple of more complicated uses for transformations.</UL>
<P><BR>
<HR>
<H2>
Overview: The Camera Analogy</H2>
The transformation process to produce the desired scene for viewing is
analogous to taking a photograph with a camera. As shown in Figure 3-1
, the steps with a camera (or a computer) might be the following:
<OL>Setting up your tripod and pointing the camera at the scene (viewing
transformation).
<BR>
<P>Arranging the scene to be photographed into the desired composition
(modeling transformation).
<BR>
<P>Choosing a camera lens or adjusting the zoom (projection transformation).
<BR>
<P>Determining how large you want the final photograph to be - for example,
you might want it enlarged (viewport transformation).</OL>
After these steps are performed, the picture can be snapped, or the scene
can be drawn.
<P><IMG SRC="figures/fig3-1.gif" ALT="[IMAGE]" >
<P><B>Figure 3-1 : </B>The Camera Analogy
<BR>
<BR>
<P>Note that these steps correspond to the order in which you specify the
desired transformations in your program, not necessarily the order in which
the relevant mathematical operations are performed on an object's vertices.
The viewing transformations must precede the modeling transformations in
your code, but you can specify the projection and viewport transformations
at any point before drawing occurs. Figure 3-2 shows the order in which
these operations occur on your computer.
<P><IMG SRC="figures/fig3-2.gif" ALT="[IMAGE]" >
<P><B>Figure 3-2 : </B>Stages of Vertex Transformation
<BR>
<BR>
<P>To specify viewing, modeling, and projection transformations, you construct
a 4 � 4 matrix <B>M</B>, which is then multiplied by the coordinates of
each vertex <I>v</I> in the scene to accomplish the transformation
<P><B>v'=Mv</B>
<P>(Remember that v
没有合适的资源?快使用搜索试试~ 我知道了~
OPENGL红宝书及源码.
共183个文件
gif:156个
html:25个
txt:1个
需积分: 9 2 下载量 176 浏览量
2009-04-14
16:29:25
上传
评论 1
收藏 4.16MB RAR 举报
温馨提示
opengl红宝书及源代码...喜欢就赶快下吧
资源推荐
资源详情
资源评论
收起资源包目录
OPENGL红宝书及源码. (183个子文件)
Thumbs.db 422KB
COVERIMAGE.gif 472KB
RUNNINGDOG.gif 364KB
NOTEXTURE.gif 285KB
ANTIWIRE.gif 272KB
ALTERNATE.gif 261KB
WIREFRAME.gif 250KB
DEPTH.gif 191KB
SKYFLY.GIF 156KB
FOGGY.gif 143KB
IRIS.GIF 135KB
VILLAGE.GIF 69KB
ART.GIF 68KB
VILLAGE1.GIF 62KB
FLATSHADE.gif 55KB
distort.gif 47KB
newant.sat.gif 40KB
PLATE21A.GIF 37KB
ch05-5.gif 36KB
COLOR1.GIF 34KB
COLOR2.GIF 32KB
TEAPOTS.GIF 32KB
texfig.gif 31KB
SPHERES.GIF 30KB
raster.gif 29KB
icos.gif 21KB
fig2-9.gif 19KB
PLATE28.GIF 18KB
ch03-19.gif 16KB
fig3-1.gif 16KB
antichar.gif 16KB
life.gif 16KB
ENVIRON.GIF 14KB
BLUR.GIF 13KB
texturesurf.gif 12KB
ch03-18.gif 11KB
fig11-5.gif 10KB
ch03-17.gif 10KB
Fig6-1.gif 9KB
lightlocal.gif 9KB
LIGHTINF.GIF 8KB
lightbamb.gif 8KB
CLIPTEA.GIF 8KB
ACC.GIF 8KB
acc.mag.gif 8KB
surface_both.gif 8KB
concave.gif 8KB
JAG.GIF 7KB
fig2-6.gif 7KB
trim.both.gif 7KB
ch02-5.gif 7KB
ambienttea.gif 7KB
fig3-2.gif 7KB
jag.mag.gif 7KB
ch03-22.gif 7KB
POLYTRUE.GIF 6KB
fig5-2.gif 6KB
readpixels.gif 6KB
tex.obj2.gif 6KB
drawpixels.gif 5KB
Plate15.gif 5KB
lightbdiff.gif 5KB
dither.gif 5KB
ch02-6.gif 5KB
fig8-4.gif 5KB
Fig7-2.gif 5KB
scallop.gif 5KB
fig9-4.gif 5KB
fig3-17.gif 4KB
fig3-16.gif 4KB
Fig7-4.gif 4KB
EQAPG05.GIF 4KB
fig03-19.gif 4KB
ch10-2.gif 4KB
fig10-3.gif 4KB
tex.eye.gif 4KB
tex.obj.gif 4KB
EQAPG06.GIF 4KB
dirichlet.gif 4KB
fig5-4.gif 4KB
fig3-4.gif 4KB
repeat.gif 4KB
Fig3-11.gif 4KB
fig3-21.gif 4KB
EQAPG07.GIF 4KB
Fig3-13.gif 4KB
Fig3-12.gif 4KB
ch03-4.gif 3KB
NORMALS.GIF 3KB
MIPMAP.GIF 3KB
fig02-02.gif 3KB
SMOOTH.GIF 3KB
cover.gif 3KB
checker.gif 3KB
bezmesh.gif 3KB
fig5-1.gif 3KB
polys.gif 3KB
eq1304.gif 3KB
fig03-09.gif 3KB
clamp.gif 3KB
共 183 条
- 1
- 2
资源评论
yun845g67
- 粉丝: 1
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功