请教一个英文方面的问题
有段代码注释看不懂,有人能翻译一下吗?谢谢,这对我很重要,回着有分!!!!!!!!!
Compile and run the application. Now left clicking toggles the light on and off! Note that since we no longer call the ExampleFrameListener's frameStarted method, we cannot move the camera around (yet).
This method of storing the previous state of the mouse button works well, since we know we already have acted on the mouse state. The drawback is to use this for every key we bind to an action, we'd need a boolean variable for it. One way we can get around this is to keep track of the last time any button was pressed, and only allow actions to happen after a certain amount of time has elapsed. We keep track of this state in the mToggle variable. If mToggle is greater than 0, then we do not perform any actions, if mToggle is less than 0, then we do perform actions. We'll use this method for the following two key bindings.
The first thing we want to do is decrement the mToggle variable by the time that has elapsed since the last frame:
Now, our transVector variable has the translation we wish to apply to the camera's SceneNode. The first pitfall we can encounter when doing this is that if you rotate the SceneNode, then our x, y, and z coordinates will be wrong when translating. To fix this, we need to apply all of the rotations we have done to the SceneNode to our translation node. This is actually simpler than it sounds.
To represent rotations, Ogre does not use transformation matrices like some graphics engines. Instead it uses Quaternions for all rotation operations. The math behind Quaternions involves four dimensional linear algebra, which is very difficult to understand. Thankfully, you do not have to understand the math behind them to understand how to use them. Quite simply, to use a Quaternion to rotate a vector, all you have to do is multiply the two together. In this case, we want to apply all of the rotations done to the SceneNode to the translation vector. We can get a Quaternion representing these rotations by calling SceneNode::getOrientation(), then we can apply them to the translation node using multiplication.
The second pitfall we have to watch out for is we have to scale the amount we translate by the amount of time since the last frame. Otherwise, how fast you move would be dependent on the framerate of the application. Definitely not what we want. This is the function call we need to make to translate our camera node without encountering these problems:
Now we have introduced something new. Whenever you translate a node, or rotate it about any axis, you can specify which Transformation Space you want to use to move the object. Normally when you translate an object, you do not have to set this parameter. It defaults to TS_PARENT, meaning that the object is moved in whatever transformation space the parent node is in. In this case, the parent node is the root scene node. When we press the W button (to move forward), we subtracted from the Z direction, meaning we move towards the negative Z axis. If we did not specify TS_LOCAL in this previous line of code, we would move the camera along the global -Z axis. However, since we are trying to make a camera which goes forward when we press W, we need it to go in the direction that the node is actually facing. Hence, we use the "local" transformation space.
There is another way we can do this (though it is less direct). We could have gotten the orientation of the node, a quaternion, and multiplied this by the direction vector to get the same result. This would be perfectly valid:
[解决办法]
大概翻译了一下, 中间有部分是在翻译不下去了,知道大概意思, 表达太难了,lz自己去领会吧,
第一段是说: note后面:记住如果没有调用ExampleFrameListener's frameStarted 的启动函数, 就不能移动camera照相机.
第二段, 存储鼠标, 按钮先前的状态的方法很可行, 如果我们已经知道鼠标的状态, 并且在执行这种状态, 缺点是当我们给每一个动作绑定关键帧时候, 我们需要一个bool变量,. 一种解决方法是我们能用这个变量来跟踪上次任何被按下的按钮, 只有一段时间以后才允许事件发生, 我们用mToggle变量来跟踪这种状态, if(mToggle > 0)不去做任何事, if mToggle < 0 就执行相应的行为. 我门将用这种方法来下面这两种绑定:
我们要做的第一件事就是从上一帧开始, 随着时间的经过来递减mToggle变量.
现在 transVector变量已经保存的我们想要对camera's 的场景结点移动的量值, 碰到的第一个毛病就是对camera's SceneNode旋转以后, 当我们在进行移动时, 面对的就是错误的x,y,z坐标. 为了固定, 我们需要将对场景中的结点所施加的旋转同样也作用到我们将要转移的结点上, 实现这些操作是简单的.
为了表现旋转, Orge与一般的游戏引擎不一样, 不使用变换矩阵, 相反的它是使用Quaternions(四元数)来处理各种操作。在Quaternions背后的数学知识主要是四维的线性代数,那些东西是很难理解的。幸运的是你没有必要为了应用而去搞明白里面的数学原理。十分简单, 使用Quaternions去旋转一个向量,所有你只需要做的是将两者相乘。在上面那种情况下, 我们想要对SceneNode和移动向量施加一系列的旋转操作,我们通过调用函数:SceneNode::getOrientation()来获得一个Quaternion, 代表这些旋转操作,然后我们将它与Quaternion相乘, 来施加给移动向量。
我们必须注意的第二个缺陷是
The second pitfall we have to watch out for is we have to scale the amount we translate by the amount of time since the last frame. Otherwise, how fast you move would be dependent on the framerate of the application. Definitely not what we want. This is the function call we need to make to translate our camera node without encountering these problems:
现在我们已经介绍了一些新的东西,无论何时, 你围绕某个轴旋转或者移动一个顶点,你能指定你想要的变换空间来使用,为了移动一个物体。 正常情况下你不需要设置这个参数, 因为他的额默认值是 TS_PARENT, 意思是物体可以在任何父结点所在的变换空间被移动。 这种情况下父结点就是场景的根节点。当我们按下W按钮时, 是朝z轴负方向移动,如果我们不再前一行的代码里面修改TS_LOCAL, 我们就会将照相机朝z轴负方向移动。 然而, 但我们按下W按钮, 既然我们用照相机, 我们就需要他朝着结点的实际朝向运动。因此, 我们使用本地(局部的)变换空间(主要是坐标系的变换),
还有另外一种不太直接的方法, 假如我们得到了结点的方位, 还有一个quaternion(四元数),将四元数乘以一个方向向量,就可得到相同的结果,这种方法也是很实用的。
中间错误不少啊, 将究吧, 英语能力有限啊, 哈哈~~~
[解决办法]
用了2.5小时,最开始没有想到要这么久,翻译的不准确,见谅!下面是内容:
///////////////////////////////////////////////////////////////////////////////////////////
编译并运行此应用程序。单击左键保证灯(怀疑是闪光灯呢)的开和关!注意由于不再调用ExampleFrameListener的帧开始(frameStarted)方法,我们还不能动相机。
因为我们已经对鼠标的状态进行了操作,存储鼠标按钮前一状态的方法能够达到满意效果。使用这个方法的代价是,需要为每一个动作上绑定的键值(key)准备一个布尔型变量。一个绕开此种做法的方式是我们记录上一次任何按钮被点击的时间,并且点击后要过一定时间才允许动作执行。我们在变量mToggle中保存这个设定时间的剩余值。如果mToggle大于0,我们什么也不做;一旦mToggle小于0,我们开始执行动作。我们在下面的两个绑定键值上使用这种办法。
我们要做的第一件事情是根据自从上一帧画面到当前时间逝去的时间值来减少mToggle的值。首先,变量transVector保存了我们希望应用在相机的画面节点上的转换值。我们这么做时候遇到的第一个陷阱就是:如果旋转动了画面节点,我们的x,y和z坐标在转换时候就会错误。要解决这个问题,我们需要将所有的在画面节点上的旋转都相应的应用在转换后的节点上。这其实比它听起来更简单。
Ogre不像某些图像引擎使用据阵来表示旋转。它使用四元数(不会用这东东)来做所有的旋转。这牵涉到四维线性代数,非常不容易理解的。幸好你只是想要理解如何使用这个旋转方法的话,没有必要必理解这些数学方面的东西。想要使用四元数旋转一个向量的话,非常简单,你只要把这两个(哪两个,没有搞清楚,汗一个,楼主自己体会吧)相乘就可以。在这种情况下,我们希望把所有对画面节点做的旋转都应用在转换后的向量上。我们可以通过调用SceneNode::getOrientation()来获得表示这些旋转的四元数,然后将这些四元数与转换后的节点相乘。
我们要小心的第二个陷阱是必须根据从上一帧到目前逝去的时间按比例来进行转换。否则,图片更换的速度将取决于应用程序的帧率,绝对不是我们想要得。下面的是我们需要调用的函数,使用它可以转换我们的相机节点而不会遇到此种问题:现在我来介绍一些新的东西。当你想要转换一个节点,或者关于任何一个坐标轴对它进行旋转,你都可以指定你希望转换到的转换空间。平常时候当你进行对象转换时候,你不一定要设定这个参数。因为它有缺省值为TS_PARENT,意味着此对象将被转换到它的父节点被转换到的转换空间去(就相当于继承一样)。在这种情况下,父节点被作为根节点。当我们点击W按钮(向前移动),从Z轴方向减少,表示向Z轴负半轴移动。如果没有在前一行代码中指定TS_LOCAL,我们会沿着全局的-Z轴移动相机。然而,因为我们想要制作一个当按下W时候向前走的相机,我们需要它向着节点实际面对着的方向走。因此,我们使用"local"转换空间。
我们还有另外一种方法来做这些(虽然这步入上面那样直接)。我们可以获得节点的定位,它是一个四元数,然后用它与方向向量相乘得到相同的结果。这也是非常有效的。
[解决办法]
编译和运行应用。现在左击鼠标钮子关灯和起飞!注意既然我们不再致电exampleframelistener ' s framestarted方法,我们可以不动照相机左右(但) 。
这种方法储存以前的鼠标效果良好,因为我们知道我们已经采取了鼠标状态。缺点:就是用这种为每个关键,我们结合行动的情况,我们' d需要一个布尔变量。其中一个方法,我们可以回避这个问题,是保持轨道的最后一次任何按钮被压,而只有允许采取行动发生后,在一定的时间已经过去了。我们记录这个国家在mtoggle变数。如果mtoggle大于0 ,则我们不从事任何行动,如果mtoggle小于0 ,然后我们做演出行动。我们'黎镑用这种方法为以下两个关键绑定。
第一件事,我们想要做的是递减的mtoggle变由随着时间的消逝,因为最后一帧:
现在,我们transvector变数,翻译,我们想申请照相机' s scenenode 。第一个陷阱,我们可以遇到的时候这样做的是,如果你轮换scenenode那么,我们的x , y和z坐标,将错当翻译。要解决此问题,我们需要运用所有的轮调,我们已经做了scenenode我们的翻译节点。其实,这是简单得多,它的声音。
代表轮换, ogre不使用变换矩阵像有些图形引擎。相反,它使用四元数,为所有的轮换行动。数学四元数的背后牵涉到四维线性代数,这是很难理解的。值得庆幸的是,你不用了解数学的背后他们了解如何使用它们。很简单,用一个四元数旋转矢量,所有你必须做的,是成倍增加,两者结合起来。在这种情况下,我们要运用所有的轮换做给scenenode以翻载体。我们可以得到四元数,代表这些轮换致电scenenode : : getorientation ( ) ,那么我们可以运用到翻译节点用乘法。
第二个陷阱,我们要警惕的是,我们已进入规模数量,我们的翻译是由大量的时间,因为最后一帧。否则,你的移动速度此举将依赖于framerate该项目的申请。绝对不是我们想要的。这是函数调用,我们需要作翻译,我们的摄像头节点没有遇到这些问题:
现在,我们已引进新的东西。每当你翻译的一个节点,或旋转,这对任何轴时,你可以指定其中变换空间,你要使用的动议表示反对。通常,当你翻译的一个对象,你不用设置这个参数。它默认为ts_parent ,意思是说这个物体移动,无论变换空间母公司节点英寸在这种情况下,家长节点是根场景节点。当我们的记者在w按钮(向前迈进) ,我们从中减去z轴方向,也就是我们走向负z轴。如果我们没有指明ts_local在这以前的代码行,我们会朝照相机沿着全球z轴。然而,由于我们正试图使相机,其中前进时,我们的新闻周,我们需要它去,在他认为适当的指示节点实际上面对的问题。因此,我们用"本地人"的转型空间。
也有另一种方法,我们可以做到这一点(虽然它是那么直接) 。我们本来可以得到的方向节点,四元数,再乘以这个方向向量,以得到同样的结果。这将是完全有效的:
嘿嘿
这是google翻译的