周一到周五,天天一篇,北京时间早上7点准时更新~程序员
What You’ll Learn in This Chapter(本章你将会学到啥)编程
What a vector is, and why you should care about them(什么是向量以及为何你须要注意他们)
What a matrix is, and why you should care more about them(什么是矩阵以及为何你须要更注意它们)
How we use matrices and vectors to move geometry around(咱们如何使用矩阵和向量来移动几何物体)
What the OpenGL conventions and coordinate spaces are(OpenGL中的转换以及坐标空间是啥)
So far, you have learned to draw points, lines, and triangles and have written simple shaders that pass your hard-coded vertex data through unmodified(如今,你已经学过了如何绘制点、线以及三角形,而且咱们写了一些简单的shader,它们不对数据进行修改,仅仅是起到了在图形管线中传递数据的做用). We haven’t really been rendering in 3D—which is odd for a book on 3D graphics!(咱们尚未真正的渲染3D的东西,这对于一本3D图形的书来讲不是很奇怪吗) Well, to turn a collection of shapes into a coherent scene, you must arrange them in relation to one another and to the viewer(然而,要有条理的去在3D场景中组织物体,你必须管理他们之间的相对关系以及和摄像机的关系). In this chapter, you start moving shapes and objects around in your coordinate system(在本小节,你将开始在你的坐标系统中移动物体). The ability to place and orient your objects in a scene is a crucial tool for any 3D graphics programmer(对于3D程序员来讲,在场景中去放置和旋转物体的能力是很是关键的). As you will see, it is actually convenient to describe your objects’ dimensions around the origin and then transform the objects into the desired positions(你将会看到,去定义物体的维度以及控制物体的位置仍是比较容易的)promise
Is This the Dreaded Math Chapter?(这是一个狗带的数学章节吗)app
In most books on 3D graphics programming, yes, this would be the dreaded math chapter(在大多数3D图形书籍里,确实,这就是一章狗带的数学内容). However, you can relax; we take a more moderate approach to these principles than some texts(不过,你能够放轻松,咱们将使用一些更温馨的手段来说解这些原理而不是紧靠文字描述)ide
One of the fundamental mathematical operations that will be performed by your shaders is the coordinate transform, which boils down to multiplying matrices with vectors and with each other(最基本的数学操做中的一个就是你会在shader中用到的坐标系转换,它涉及到矩阵与矩阵以及矩阵与向量的乘法). The keys to object and coordinate transformations are two matrix conventions used by OpenGL programmers(对于OpenGL程序员来讲,坐标系转换的关键在于两个矩阵). To familiarize you with these matrices, this chapter strikes a compromise between two extremes in computer graphics philosophy(为了让你熟悉 这些矩阵,本章节将采用计算机图形学中两种极端 思路的这种方案来进行讲解). On the one hand, we could warn you, “Please review a textbook on linear algebra before reading this chapter.”(一方面,咱们会警告你说,请在阅读本章以前,先看一看线性代数的 书) On the other hand, we could perpetuate the deceptive reassurance that you can “learn to do 3D graphics without all those complex mathematical formulas.”(另外一方面,咱们也会不断的告诉你,即使没有那些复杂的数学理论,你也能够学会3D图形学) But we don’t agree with either camp(可是,咱们实际上两边都不一样意)工具
In reality, you can get along just fine without understanding the finer mathematics of 3D graphics, just as you can drive your car every day without having to know anything at all about automotive mechanics and the internal combustion engine(实际上,你能够在没必要精通3D数学的状况下,很好的处理3D编程问题,就像你没必要懂什么汽车生产以及发动机的原理就能开车同样). But you had better know enough about your car to realize that you need an oil change every so often, that you have to fill the tank with gas regularly, and that you must change the tires when they get bald(可是你最好是更多的了解你的车子,这样你就能够知道何时该加油了 ,何时该打气了). This knowledge makes you a responsible (and safe!) automobile owner(这些知识能让你更好的玩转你的车子). If you want to be a responsible and capable OpenGL programmer, the same standards apply(若是你但愿变成一个更强的OpenGL程序员,道理是同样的). You need to understand at least the basics so you know what can be done and which tools best suit the job(你至少须要了解最基本的数学,这样你才能知道你能够作什么以及什么工具是最适合你的项目的). If you are a beginner you will find that, with some practice, matrix math and vectors will gradually make more sense, and you will develop a more intuitive (and powerful) ability to make full use of the concepts we introduce in this chapter(若是你是一个新手,你将会发现,随着不断的练习,你将会获得更多的矩阵以及向量方面的体会,而且你将能更好的去理解咱们本章节提到的这些概念)ui
So even if you don’t already have the ability to multiply two matrices in your head, you need to know what matrices are and how they serve as the means to OpenGL’s 3D magic(因此,即使你不知道如何计算矩阵的乘法,你须要知道什么是矩阵,以及他们在OpenGL中的意义). But before you go dusting off that old linear algebra textbook (doesn’t everyone have one?)(可是在你开始再次翻开你的线性代数课本以前,不要惧怕:由于咱们的sb7库里面应包含了一个叫vmath的组件,它能很好的帮你解决数学计算方面的问题), have no fear: The sb7 library has a component called vmath that contains a number of useful classes and functions that can be used to represent and manipulate vectors and matrices. They can be used directly with OpenGL and are very similar in syntax and appearance to GLSL—the language you’ll be writing your shaders in(他们能够像你即将在shader中使用矩阵的方式同样使用). So, you don’t have to do all your matrix and vector manipulation yourself, but it’s still a good idea to know what they are and how to apply them(因此你并不须要本身亲手实现全部这些数学计算,可是知道怎么实现这些数学计算以及如何应用他们任然是值得你努力的方向). See—you can eat your cake and have it, too!this
本日的翻译就到这里,明天见,拜拜~~idea
第一时间获取最新桥段,请关注东汉书院以及图形之心公众号spa
东汉书院,等你来玩哦