libgdx decal dynamic text

前端 未结 2 1556
忘了有多久
忘了有多久 2021-01-28 03:59

I\'m working on 3D (2.5D) application in Libgdx. I\'ve found Decals very useful for this purpose.

In my app there should be layers, that contain dynamical text, now I\'m

相关标签:
2条回答
  • 2021-01-28 04:50

    To get the rotation behaviour of Decals you need to call translate first before rotate on the textTransform Matrix.

    textTransform.idt().translate(-50, 2, 25f).rotate(0, 0, 1, 45);
    

    I'm a little confused about this. Maybe its historically reasoned from a Matrix Stack.

    0 讨论(0)
  • 2021-01-28 04:52

    You can draw directly into 3D space with SpriteBatch by assigning your projection matrix appropriately.

    First, have a Matrix4 that determines the position and rotation of each of your strings of text. The reason you need this is that SpriteBatch and BitmapFont do not have arguments for Z offset.

    Since you can put all your translation into the Matrix4, when you call the draw method, just draw to 0,0.

    You can then use the Matrix4 of each mesh to multiply with the camera's combined matrix before submitting it to the SpriteBatch. So you will want a separate Matrix4 for doing your calculations.

    textTransform.idt().scl(0.2f).rotate(0, 0, 1, 45).translate(-50, 2, 25f);
    //Probably need to scale it down. Scale before moving or rotating.
    
    spriteBatch.setProjectionMatrix(tmpMat4.set(camera.combined).mul(textTransform));
    spriteBatch.begin();
    font.draw(spriteBatch, "Testing 1 2 3", 0, 0);
    spriteBatch.end();
    
    0 讨论(0)
提交回复
热议问题