我希望我的LibGDX代码中具有动画3d纹理,但是我正在努力寻找方法。
我认为该“应该”如何完成。
a)直接访问和修改模型上的纹理。(通过像素图或ByteBuffer?)
或者
b)预渲染包含所有帧的大图像(例如20),然后移动UV坐标以创建动画的幻觉。(类似于2d / webdesign中的ImageStrips)。
我确实想出了如何每次都可以完全替换材料的方法,但这似乎是一种糟糕得多的方法。因此,如果有人可以显示我需要执行a)或b)的命令(或类似的最佳方法),我将大失所望。我很喜欢数学。OpenGLES或GDX的复杂性我不是:)
(该解决方案至少应能运行HTML / Android,最好是所有版本)
从最新版本开始,在3d曲面上播放2d动画非常容易。首先,请确保熟悉2D动画概念,如此处所述:https : //github.com/libgdx/libgdx/wiki/2D-Animation。然后,代替使用spritebatch,可以使用TextureRegion
(Animation#getKeyFrame
返回)设置表面材质,如下所示:https : //github.com/libgdx/libgdx/blob/master/tests/gdx-tests/ src / com / badlogic / gdx / tests / g3d / TextureRegion3DTest.java。因此,基本上,您可以使用render方法:
attribute.set(animation.getKeyFrame(stateTime, true));
或者,如果您想要更通用的方法:
instance.getMaterial("<name of material>").get(TextureAttribute.class, TextureAttribute.Diffuse).set(animation.getKeyFrame(stateTime, true));
或者,如果ModelInstance中只有一种材料:
instance.materials.get(0).get(TextureAttribute.class, TextureAttribute.Diffuse).set(animation.getKeyFrame(stateTime, true));
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句