3D GUI?

Previous topic - Next topic

Qube

My main reason for this is to be able to do a 3D GUI on top of the current 3D world I've drawn. I've tried with math but after a while objects begin to bounce and vibrate, which is not good  :'(

For example, say you wanted to have a spinning cube at the bottom left of your screen while allowing the camera to fly around a model of a car. If you use X_SCREEN2WORLD and then math to point the model at the camera it works great until the camera location is far away then we get object bounce and vibrate.

Is there any way to reset the 3D world in order simply overlap a 3D gui?


Kitty Hello

why must the GUI be 3D? Why not use X_MAKE2D and overlap the 2D gui after the 3D work?

matchy

Yeah why not? Just overlap as it's not a world or part of the world. I'd imagine either 2D or 3D GUI is drawn on to 2D sprite then after on to the 3D world.

Slydog

You want static location 3D GUI controls overlaying a 3D world?

Could a VIEWPORT be overlaid onto the main 3D world?   
Then just draw the 3D GUI in the VIEWPORT? 
I'm not sure if you could still see the original 3d world thru the new viewport.
I have a 3D object inside a viewport with 2D polygons (not in viewport) on top of that object, so it could be possible.

Another option, you may have to calculate the GUI object's location and rotation based on the current camera.
It's distance from the camera would be about the camera's min view distance (1st parameter in the 'X_MAKE3D' command, 'znear'), plus a bit more perhaps.

To figure out it's screen x, y location you may need to calculate the camera's direction vector.
Just subtract the camera's 'look at' location from the current camera's location, this should give you the direction vector the camera is facing.  Then place the 3d objects based on this vector. 

Man, just reading that tells me that it's not the best solution!  Sounds too complicated.

Or, just render the GUI first offscreen (using CREATESCREEN) to make it a sprite, then paste that sprite over the main 3D view.
I'm not sure of the overhead this will cause, but the code may be the easiest.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Qube

In my 3D game I would prefer to have a 3D HUD which requires a few models at certain 2D screen coordinates. I can use the X_SCREEN2WORLD to get the 2D to 3D coordinates but naturally these objects rotate when the camera moves. As mentioned, using math to point the objects at the camera works fine but over distances you get wobble and vibrating of the 3D HUD objects as the math isn't perfect precision.

A 2D HUD / GUI is currently what I am doing but it would open up for improvement if I could draw all my world objects, reset and then draw my 3D HUD / GUI.

I was thinking on the lines of a secondary camera whereby you do your game as normal, then call the secondary camera and overlap the GUD / GUI on top.

Is that possible? or just best to skip the idea and stick to the common practice of a 2D HUD on top of a 3D world?

Slydog

I did a quick viewport test, and that seems to work.
Keep your main 3d world as it is.
Then create a viewport for the entire screen (or just portion that shows the GUI), and position the gui objects in this viewport.
The GUI should overlap the existing world, and not replace.

I was thinking of a 3D GUI a while back. 
It would look cool if you have 3D object buttons (or other controls) that wobbled to your touch.
Or a scroll list that got larger/closer at bottom, smaller/further at top, like Star Wars opening scrolling message.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Kitty Hello

totally insane idea. I start to like it.