Render BitmapFont in 3D libgdx with ModelBatch

寵の児 提交于 2019-12-08 13:28:52

问题


I want to render a BitmapFont within a libgdx ModelBatch. I've only found samples with "SpriteBatch". Of course I can move the SpriteBatch around in 3D space, but it is either rendered before or after the "ModelBatched" objects. But I'd like to have it rendered in the correct z position.

E.g.

  • Render modelInstanceA (z=20)
  • Render Font (z=30)
  • Render modelInstanceB (z=40)

Then modelInstanceB should cover Render Font should cover modelInstanceB.

In other words I'd like to render a font within a ModelBatch context.

modelBatch.begin(camera);
modelBatch.render(modelInstanceA);
modelBatch.render(font);
modelBatch.render(modelInstanceB);
modelBatch.end();

Is there a built in way to achieve this?


回答1:


If the models are opaque, you could draw your text with SpriteBatch after the modelBatch.end() call, but you'd need to call Gdx.gl.glEnable(GL20.GL_DEPTH_TEST); before spriteBatch.begin(). Then disable it after spriteBatch.end() to clean up (libgdx classes by default expect it to be off).



来源:https://stackoverflow.com/questions/32567900/render-bitmapfont-in-3d-libgdx-with-modelbatch

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!