0
$\begingroup$

I wanted to make a little demo for a console with Realm of the Mad God esc graphics to brush up my C and SDL skills.

View of the walls I'm trying to recreate

One problem I'm running in to is creating the 3D walls. The console I'm working with does not actually allow for 3D hardware acceleration at this moment of time and thus I can't really use real 3D. I noticed the perspective looked off in RotMG as well so I figured they must be using fake 3D also.

Now I have tried layering 2d textures on top of eachother as detailed here although this didn't quite work out so I modified the algorithm a bit and the blocks looked a lot better. Problem is they wouldn't sit next to eachother convincingly so I figured this is not the right tool for the job.

What type of algorithm should I use to recreate the 3D walls without actually using GL or other real 3D technologies?

$\endgroup$
2
  • $\begingroup$ Have you considered creating the walls in a 3D app (and only the walls) you could use opengl to program it up, or just use something like blender to create them. Then set up a handful of camera angles to take snapshots. Save those snap shots to an atlas, and just use the saved snapshots. If you camera angle is fixed, and the walls are all axis aligned, then you really only need a handful of views. At draw time, elements on the same side of the wall as the camera are drawn over the wall, elements on the opposite side of the wall from the camera get the wall draw on them. $\endgroup$
    – pmw1234
    Feb 17, 2021 at 16:11
  • $\begingroup$ It just occurred to me that another way to draw the walls is via ray casting similar to how Wolfenstein used ray casting, but that could have game wide ramifications. But it frees the camera to change angles. $\endgroup$
    – pmw1234
    Feb 17, 2021 at 16:15

1 Answer 1

3
$\begingroup$

What they're using in this game is called an orthographic projection. It is a special type of a projection, which does not bend objects, it does not mean that they are not using 3D.

Now, of course you can achieve this kind of effect using 2D coordinates only if you want. But it requires some mathematical understanding of the situation, as you need to do 3D calculations in order to calculate the correct 2D coordinates to use. If you do it this way, you can draw points or lines between the points after calculating the positions, and it will give the effect you want.

But here in RotMG, they are also doing texture mapping on those walls, which uses information about the actual size of the surface in 3D space. This information is lost if you simply calculate the 2D positions of the corners without also doing the texture mapping yourself.

So here you have two options:

  • You can give up your console and start doing some real 3D stuff (OpenGL, etc...).
  • You can become very good at linear algebra, preferably including homogenous coordinates, project the points from 3D to 2D space, draw your lines/points in your console, or interpolate the 3D positions with some form of rasterization, if you want to decorate the wall using texture mapping. But once you understand all of that, I'm afraid you won't want to use your limited console anymore.
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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