SFML community forums
Help => Graphics => Topic started by: elvaka on July 30, 2016, 04:17:18 pm
-
Hi guys,
I'm trying to draw 3D cubes on top of a 2D SFML scene, in a similar way of how buildings are drawn in GTA2 [1]. That is: the bottom side of the cube should be on the same plane as where SFML sprites are drawn.
How can I define my glFrustrum so that 3D elements align with the 2D layer (eg: when I move the camera, 3D and 2D stuff move at the same time)? Or it's not even possible to mix perspective and orthogonal projections like this?
[1] http://www.gouranga.com/images/gta2/gta2-3.jpg
Thanks!
-
Since you're already drawing the scene in 3D for the buildings, could you not also include the ground as a plane (or multiple tiles on a plane) in 3D?
-
This is exactly what my framework xygine (https://github.com/fallahn/xygine/blob/master/xygine/src/mesh/MeshRenderer.cpp#L426) does with 3D models. You can create a camera which assumes the 2D portion of your game is on the 0 z-plane by using the height of the viewport and the vertical FOV to calculate the distance the 3D camera would need to be.
http://www.youtube.com/watch?v=u2th9hMTxdU