So the plan here is to use the unprojected result to construct a triangle and apply transformation such as rotation without breaking the existing code that accepts 2D space as coordinate.

so in summary is accept 2D coordinates and draw a 3D object on that area with transformation.

on the above code, it looks like the result is in the near clipping plane and when i draw a rectangle using those points, it is not visible on the screen (camera is at Z=5 position).

any idea on how to do this? i know that Z is a player here somewhere but i dont know how. like the Z on the above result is on the near clipping plane, i just want it to be visible on the screen and appear on the specific 2D spot.

let me know if you have any ideas on how to work on this black magic of a problem, Thank you in advance

Share this post

Link to post

Share on other sites

I get why you'd do this in some scenarios, but it strikes me as a weird approach to a relatively simple problem. The game I'm currently working on has 3d elements (the world) with 2d elements on top of it (the UI). The two of them use entirely different shaders and transforms - when drawing 2d elements, I skip the perspective transform altogether rather than transform and have to un-transform it. The 3d stuff gets transformed the same as anyone else would do it, some variation of local, world, camera, perspective transforms, etc., but the 2d stuff simply gets a single transform to go from my reference-sized "ui space" to the device space or whatever the name for that space is.

Unless I'm misunderstanding what you're trying to do.

Edited October 5, 2017 by trjh2k2

0

Share this post

Link to post

Share on other sites

I get why you'd do this in some scenarios, but it strikes me as a weird approach to a relatively simple problem. The game I'm currently working on has 3d elements (the world) with 2d elements on top of it (the UI). The two of them use entirely different shaders and transforms - when drawing 2d elements, I skip the perspective transform altogether rather than transform and have to un-transform it. The 3d stuff gets transformed the same as anyone else would do it, some variation of local, world, camera, perspective transforms, etc., but the 2d stuff simply gets a single transform to go from my reference-sized "ui space" to the device space or whatever the name for that space is.

Unless I'm misunderstanding what you're trying to do.

the project im working now is not a game, originally everything is rendered in 2D using opengl orthographic projection, inputs are specified a 2D X, Y coordinates in screen space, and it will be positioned there like how UI are positioned in games,

it is just lately that they want to put a 3D rotation feature on those 2D elements without breaking the original specification that the user must specify a 2D coordinates to place an object in the screen, since you cannot perform the full rotation specially rotating in Y axis in an orthographic projection, i "enabled" the 3D mode by providing the view and projection matrix while gettinga 2D coordinates as input.