Noah Copeland
Member
I previously had a mode-7 type "special stage" working, but it used the old d3d functions from GMS 8.
I'm redoing it using cameras and projections matrixs for two reasons.
1 - Since d3d functions are not in GMS2, so there was a lot of messy baggage in the code with compat scripts
2 - The old way does not work on Android for me. The new test gif you are seeing here does work on Android.
I'm wanting to draw sprites for objects (rings, spikes, etc) as 2D billboards that ignore the deformation of the projection, and instead "scale" based on handrawn frames, BUT are still drawn in the appropriate location in 3D space. Essentially, translating 3D world space to 2D screen space. Think like the old school SNES Mario Kart effect.
We had previously figured it out, but its not working with the new functions, and only works with the old d3d method. So I'm opening a new topic, since its starting from scratch.
Here is the Camera code that achieves the 3D effect.
GML:
/// @description Insert description here
var VW = global.ViewWidth;
var VH = global.ViewHeight;
camera = camera_create();
view_camera[0] = camera;
var viewmat2D = matrix_build_lookat(objSS_Player.x, objSS_Player.y, -100, objSS_Player.x, objSS_Player.y, objSS_Player.z, 0, 1, 0) //matrix_build_lookat(640, 240, -10, 640, 240, 0, 0, 1, 0);
var projmat2D = matrix_build_projection_ortho(VW, VH, 1.0, 32000.0);
var viewmat3D = matrix_build_lookat(x, objSS_Player.y, -50, objSS_Player.x, objSS_Player.y, objSS_Player.z, 0, 0, 1);
var projmat3D = matrix_build_projection_perspective_fov(100, VW/VH, 1, 320)
camera_set_view_mat(camera, viewmat3D);
camera_set_proj_mat(camera, projmat3D);
camera_apply(camera);