2
\$\begingroup\$

RotMG, an MMO top-down shooter, takes on a unique 2d-3d style, and has an intriguing camera; enter image description here

The game is obviously 3d, not simply isometric, and if you play the game and turn on camera rotation you will notice the effect the game produces, like so.

RotMG is made using flash, and I am currently experimenting with libgdx (which uses lwjgl/opengl). How should I go about implementing a RotMG-like camera?

\$\endgroup\$
2
\$\begingroup\$

Can't speak to the exact implementation details (and if I could it would be off-topic), but here's some obvious ingredients to put together:

  • The camera is using an orthographic projection. You can tell this because a vertical wall is exactly vertical on-screen no matter where it is — if the camera were perspective then they would be "leaning outward" from the center.

    Once you have the camera set up, you just apply the rotation in 'modelview' space — it's exactly the same as if you had a first-person moving camera. The complete sequence of transformations you'd use are:

    1. orthographic projection
    2. rotate around X axis to look down at world
    3. translate forward and down to establish camera's distance from player character
    4. rotate around Y axis (the player-controlled rotation)
    5. translate horizontally to follow player's position in world

    Note: Since orthographic projection doesn't give any visual cue about how far the camera is from the scene, it can be easier to make mistakes than with perspective projection, and if you get things really wrong you can have the scene disappear due to near/far limits. This isn't a reason not to use orthographic projection — it's just something to know can go wrong.

  • The walls, floors, water pool, etc. are ordinary 3D geometry with low-resolution textures. To have the pixelated effect, make sure to specify NEAREST rather than LINEAR texture magnification filtering.

  • The characters and the water spray are 2D sprites. To learn about how to draw them and keep them upright even as the camera turns, read about billboarding. (The thin black outline and shadows are a completely separate problem to implement.)

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.