LibGDX "fake 3d" camera / rendering questions

Hi everyone,

There was an interesting post on reddit the other day about a “fake 3d” style of graphics used notably in NIUM (gif) whereby you draw “slices” of your object, and render them with an offset to create a kind of stacked-layer 3d effect (explained here).

I’ve been trying to reproduce this style using LibGDX, and drawing the images to the screen with a Y-offset is simple enough. I am however really struggling with actually creating the sort of camera shown in the example NIUM gif. I’m using the OrthographicCamera LibGDX provides to render the scene itself, and each object in the world has it’s own x and y world coordinate, as would the movable player character.

From what I can understand:

  • Either the objects in the world rotate around the centerpoint of the camera’s view when the “camera” is moved (however this means they are moving their world coordinates, which is bad)

  • …or the “camera” itself is rotating its view of the world, preserving each objects relative x and y location. LibGDX’s camera also has a rotate method, but this entirely flips the items around, and I’m not managing to get the objects own scaling and rotations correct when using this, although it seems like it should be the correct way to do this? This also rotates the axis, which complicates things.

  • The “up” direction by which the layers are offset needs to always be up relative to the screen and ignore the camera’s rotation. So if I do rotate the camera itself and not the objects, as the axis get rotated as well, “up” (adjusting the value of Y) is now relative to the rotation.

I’ve been trying to use the Affine2 class in LibGDX to do the translations, rotation, scaling etc. for the “layered objects” , and some attempts to use the rotation of the camera itself, but I think I’m just not understanding fully what I actually need to rotate/translate and in what order to accomplish this, so I’d really appreciate any pointers on the correct way to do this. Thanks!