Search code examples
opengl3d2dlwjgl

Billboarding in LWJGL


I'm making a "2.5D" game with a 3d and 2d items. I have created the 3d world and am now working on the 2d items. I've looked all over for billboarding tutorials, but none of them seemed to work (because I'm a noob and probably messed something up). All I need to know is how to set up the glTranslate and glRotate so that the next render sequence renders an object perpendicular to the plane of the camera, in other words, like 2d but in the 3d world.

Here is what I'm using:

GL11.glPushMatrix();
GL11.glTranslatef(0, 0, 0);
GL11.glRotatef(360.0f - Player.camera.vector.x, 0, -1.0f, 0); 
GL11.glRotatef(Player.camera.vector.z, -1.0f, 0, 0);
renderDroppedItems();

Thanks in advance!


Solution

  • There is a mistake in your code:

    GL11.glRotatef(360.0f - Player.camera.vector.x, 0, -1.0f, 0); 
    

    it should be :

    GL11.glRotatef(360.0f - Player.camera.vector.x, -1.0f, 0, 0);