首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

JME3 官方课程翻译

2012-12-27 
JME3 官方教程翻译?What is updateGeometricState() and when do I need it?UpdateGeometricState()方法的

JME3 官方教程翻译

?

What is updateGeometricState() and when do I need it?UpdateGeometricState()方法的用处,什么时候用?

In jme3 it is more important thanin jme2 that the correct updating and rendering order is kept, this is why youshould understand what updateGeometricState() is all about.

在jme3中有了很重要的跟新,渲染序列可控性也大大提高,所以到处都会用到updateGeometricState()这个方法,你必须对这个方法有深刻的理解。

What does updateGeometricState() do? updateGeometricState()用来做什么。

The call toupdateGeometricState() applies all changes made to a Spatials location, rotation and scale andcomputes the correct worldposition including the Spatials parent position (if there is one) so allinformation is correct for the rendering process. When updateGeometricState()is called on a Node, all child Spatials will be updated as well, given thattheir flags indicate something has changed. In a normal update loop,updateGeometricState() is called once on the Scenes rootNode just beforerendering.

updateGeometricState()会在三维空间中应用所有的更改,包括:位置、旋转、缩放以及纠正所有父级别的三维空间坐标,所以此时所有的信息都会在渲染线程中纠正。当updateGeometricState()在一个节点上被调用时,所有的子空间将被更新,并且给他们的标志标记上已经改变的记录,通常的跟新循环中该方法只在场景的根节点开始渲染前调用一次。

Why would you want to use updateGeometricState()yourself then?为什么你有时候想要来使用updateGeometricState()方法?

Since the world location of spatials is only knownafter updateGeometricState() has been called in jme2, it was commonpractice for some to call updateGeometricState() on the spatial to compute itscorrect location because it had been changed before. In jme3 you should not do that as updateGeometricState()should only be called once on the rootNode of the scene during the update loop.If you really have to updateGeometric(), do so on the rootNode. In some testshowever, especially physics tests, you might see that updateGeometricState() isused on created PhysicsNodes. This is however before they are added to a rootNode that is part of alive scene. When a Spatial has a parent or was added to the root node, do not call updateGeometricState() onit.

由于在jme2中场景空间对象的世界坐标 只有在updateGeometricState()被调用后才能知道,在空间对象上调用updateGeometricState()来计算正确的世界坐标在空间中的位置是常用的做法,因为它之前已经被改变了。? 在jme3中你可以不用那么做,updateGeometricState()仅仅在每次循环中只在根节点上调用一次。如果你趋势有必要去调用updateGeometric(),那就在根节点上调用。然而在一些练习中,尤其是物理检测中你可能会看到 updateGeometric()在被创建的物理节点上被使用,这是由于在它们成为活动场景的一部分之前需要计算它(物理节点)的位置。当一个三维空间对象有一个父节点或者已经被添加到了根节点,请不要调用updateGeometric()。

When to change a Spatials translation当发生了空间对象的转换

So going along this logic, youshould not change the Spatials translation after updateGeometricState() hasbeen called anymore. So how or when do you change it? Before. :) TheInputListeners for example are called before updateGeometricState() is calledon the rootNode and the Spatials are in their correct, updated state from thelast loop run. Now you can use setLocalTranslation etc. to modify yourSpatials, also using translation info from the other Spatials. The controllers(updateLogicalState()) are the second chance to modify your Spatials, they areused by the animation and particle systems for example. If you absolutely needto read the world location of a spatial in your normal update() call, youshould call updateGeometricState() once on the root Node of the scene and readthe world locations after that.

依照这个逻辑,你不应该在调用了updateGeometricState()之后再去做一些空间对象的变换。那么什么时候或者怎么才能进行变换呢?首先一个输入监听器被一个实例在根节点调用updateGeometricState()之前被调用并且空间对象已经处于它们的正确位置,在循环的最后更新状态。现在你可以使用setLocalTranslation()或其他的方法来修改你的空间对象,同样可以从其他的空间对象使用变换信息。控制器()会马上对你的空间对象作出修改,它们被动画和粒子系统使用。如果你绝对需要在你的update()中得到一个空间对象的世界坐标,你可以在根节点上调用一次updateGeometricState()之后来读取世界坐标。

?

《这篇文章字不多,给我搞的云里雾里的,效果很不好,请高手指点一下。。。》

热点排行