Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Viewport when using a 3D GUI / HUD?

Author
Message
Zwarteziel
13
Years of Service
User Offline
Joined: 22nd Jan 2011
Location: Netherlands
Posted: 6th Feb 2011 19:54
Hi all. I've been experimenting with DB Pro for a few days, and am trying to make a game (of sorts). Now, I've run into some problems regarding the use of Graphic User Interfaces.

Here are the things I'm trying to achieve:

1). My test-GUI covers most of the screen, and has a tiny 'viewport'. I'd like to display a 3D enviroment in this space.

2). Ideally, the GUI would be allowed to scale according to the resolution the player chooses and would take as less FPS as possible to draw.

So far so good. I've been searching the forum and the tutorials for help and have been messing around with several techniques (pasting images and displaying 3D plains). A post from fellow forum-member Cloggy has resulted in the following code:



The result of wich looks a bit like this:
.

This sort of works. Sort of, because... while I have a scalable GUI, it's not *really* restricting the 3D-world to the viewport... The world is rendered and the 3D-plain is put on top of it. I've been fiddling around with another camera, but I'm not really sure if that's the right direction. So, I'd like to ask these two questions:

1). Is the 3D-plain route the best way of programming a GUI like this?
2). Is it possible to render the 3D world within a specific set of coordinates?

Thank you for any help!
MSon
20
Years of Service
User Offline
Joined: 13th Jul 2004
Location: Earth, (I Think).
Posted: 7th Feb 2011 08:22 Edited at: 7th Feb 2011 08:26
Try the command SET CAMERA VIEW to set the viewport size, (Number 2 on your list)

This is taken from the help files includes with DBPro

Syntax
SET CAMERA VIEW Left, Top, Right, Bottom
SET CAMERA VIEW Camera Number, Left, Top, Right, Bottom

Description
The viewport is the actual area on screen where all 3D is drawn. The default viewport area is the entire screen, but can be specified using this command. You must specify the screen coordinates using integer values.

Example Code


Zwarteziel
13
Years of Service
User Offline
Joined: 22nd Jan 2011
Location: Netherlands
Posted: 7th Feb 2011 16:22
Quote: "Try the command SET CAMERA VIEW to set the viewport size, (Number 2 on your list)"


Thank you for this suggestion. I've added the following lines to my code in order to add another camera:



Unfortunately, this results in a problem that I find difficult to solve: the 3D-plane containing the Gui is now rendered *inside* the viewport of camera 1, while the whole 3D environment itself is still displayed across the whole screen. I guess the situation can best be described as: "Yo dawg, I herd u like a camera in your camera, so we put a camera in your..." Well, you get the point. This picture makes my dilemma more clear perhaps:

Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 7th Feb 2011 20:48 Edited at: 7th Feb 2011 21:01
You won't need to map the camera output to a plane if you just set the view port. Mapping the view of another camera to a plane was a clever work around to do what you want. But if you just set the view port, you don't have to do that.

Also try just using camera zero, instead of making a new one.

So this code by itself will give you a 3D view port on a 2D background that you can put text info or paste images on.



If you allow the user to choose the resolution, you have to adjust. The question becomes...

Do you want to always have the same amount of space for the GUI, and let the camera view expand (or shrink) to fill in the rest?

Or do you want the camera view, GUI area, font size, etc. to scale with the chosen resolution?

The second way involves more calculations, of course.

Zwarteziel
13
Years of Service
User Offline
Joined: 22nd Jan 2011
Location: Netherlands
Posted: 8th Feb 2011 10:47
Thank you Rich!

Ideally, I would like scale everything scale along the chosen resolution. So, a viewport that would (for instance) take up 40% of the screen would do so when using a resolution of either 1024x786 and 1680x1050. I do realize this will be rather more complicated to program, and might not even look very well, since I'm not sure if the GUI's graphics will scale elegantly.

I took a look at both your example and your Quickhack Project (Nice work! - I *loved* Dungeon Hack!). Might I ask if you are using the same method / code as posted above? E.g. drawing a box with a viewport and then different GUI-sections/images in it? If so: is there a benefit in using the box, or is it ment more illustrative, as an example?
Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 8th Feb 2011 13:31
Thanks for the kind comment about Quickhack! I do use a camera view setting in Quickhack, just like in the code I posted.

One thing to remember - if you resize the camera view, and the aspect ratio of the view doesn't match the aspect ratio of the screen resolution, you will need to change the camera aspect ratio.

Good luck!

Login to post a reply

Server time is: 2024-11-23 03:36:30
Your offset time is: 2024-11-23 03:36:30