libgdx - How to animate textures in a 3d model? -
i wish have animated 3d texture in libgdx code struggling find out how it.
i assume how "should" done either;
a) straight accessing , modifying texture on model. (via pixmap? bytebuffer?)
or
b) prerendering big image containing frames (say, 20) , moving uv co-ordinates create illusion of animation. (akin imagestrips in 2d/webdesign).
i did work out how replace material eachtime, seems much worse way of doing it. if show commands need either a) or b) (or similar optimal method) great-fall. maths fine with. intricacies of opengles or gdx not :)
(the solution should @ to the lowest degree work html/android compiles, ideally everything)
since latest release easy play 2d animation on 3d surface. first create sure familiar 2d animation concept, explained on here: https://github.com/libgdx/libgdx/wiki/2d-animation. then, instead of using spritebatch, can utilize textureregion
(which animation#getkeyframe
returns) set material of surface, shown here: https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests/src/com/badlogic/gdx/tests/g3d/textureregion3dtest.java. in render method:
attribute.set(animation.getkeyframe(statetime, true));
or if want more generic approach:
instance.getmaterial("<name of material>").get(textureattribute.class, textureattribute.diffuse).set(animation.getkeyframe(statetime, true));
or, if there's 1 material in modelinstance:
instance.materials.get(0).get(textureattribute.class, textureattribute.diffuse).set(animation.getkeyframe(statetime, true));
libgdx textures bytebuffer
No comments:
Post a Comment