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.

DarkBASIC Professional Discussion / How to set object FOV to ortho and move it in screen space?

Author
Message
mr Handy
17
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 30th Aug 2013 11:39
Hi! I want to set object FOV to ortho and move it in screen space. It is are potion bottles. They are part of user interface and should move in screen space. How i can do that? I have tried set object FOV command but the position of object is going crazy as I should calculate it as for other FOV, plus it is not ortho. Any ideas? Maybe, a vertex shader?

TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 30th Aug 2013 12:45
lock object on and disable object zdepth will keep it in screen space. Give that a go, maybe you don't need ortho (because that's a little more complicated).

TheComet

Rudolpho
19
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 30th Aug 2013 12:51
Any reason not to use sprites instead?
You could make an animation of the bottles spinning or whatever if that's what you're after.

If you want something more elaborate, I wrote a simple demo of setting up an orthographic camera for you:


In summary it renders certain objects (masked to the ortho camera) with an orthographic projection to an image. This is then pasted on top of anything rendered by camera 0. By having the ortho matrix set to the size of the screen, this will let you position your "orthographic objects" in screen space rather than world space.
I believe this approach is exactly how DBPro renders 2D in the first place.


"Why do programmers get Halloween and Christmas mixed up?"
mr Handy
17
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 30th Aug 2013 19:10 Edited at: 30th Aug 2013 19:13
@TheComet
I have tried this

@Rudolpho
That is truly amazing, exactly what I need! Also just installed the Matrix1Utilities.

Two questions remains:
1. How do I distribute final executable with Matrix1Utilities?
2. Does shaders work with ortho camera as usual? Can I has glass shader on my bottles? (related to vertex shader part)

Rudolpho
19
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 30th Aug 2013 19:18
Glad I could be of help

1) I don't think there's anything special to that, M1U is as close to "official" addons as you could get, pretty much everyone is using it.

Quote: "Warranty: None, for any purpose whatsoever.
Conditions of use: None.
Royalties required: None."

From the official thread for matrix 1 utilities.
I suppose it would be nice to mention Ian in your credits should you publish your project though.

2) It works exactly as usual, all we've done is change the camera's projection matrix. This one will be provided to your shaders using the Proj semantic (or whatever it is, I've forgot) as usual.
The one thing I can think of is that you'll probably have to use a separate orthographic post-processing camera if you want to do that on these objects separately from everything else on screen.


"Why do programmers get Halloween and Christmas mixed up?"
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 30th Aug 2013 23:40
Looks brilliant Rudolpho.

For Matrix1 distribution, you may sometimes find that the Visual C++ redistributable (msvcp71) is required to be copied into your .EXE path or the Windows system folder if not already there.

mr Handy
17
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 30th Aug 2013 23:50 Edited at: 30th Aug 2013 23:53
Thanks! Also does M1U compiles with main exe? AFAIR there was a "externalize dlls" option in compiler - is that for plugins?

P.S.
Quote: "For Matrix1 distribution, you may sometimes find that the Visual C++ redistributable (msvcp71) is required to be copied into your .EXE path or the Windows system folder if not already there."

What? An extra system req.?

Mobiius
Valued Member
22
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 31st Aug 2013 00:00
Quote: "does M1U compiles with main exe?"

Yes. You don't need to include them when distributing your game/program.

Quote: "there was a "externalize dlls" option in compiler - is that for plugins?"

Ignore it. This will require you to manually distribute the core DBPro plugins with your game, rather than them being linked into your exe file. (Useful only for decreasing the filesize of your exe file)

Quote: "An extra system req.?"

The Visual Studio Redist package is available here: x86 and here: x64

Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 31st Aug 2013 00:05 Edited at: 31st Aug 2013 00:06
Quote: "What? An extra system req.?"


Well yeah if the DLLs are not already installed. You must have personally had them pre-installed to have gotten a Matrix1 program to actually run; but some operating systems do not have them installed for you; particularly XP and I think Vista; not sure which service packs. Unfortunately I have forgotten the names of the DLL files; I think they are msvcp71.dll, msvcr71.dll and mfc71.DLL.

DLL redistribution is also a prerequisite to the Dark Dynamix; you need to include the PhysX dlls, manually. I think all DBPRO executables have the DarkBASIC dlls embeded in them; but not these third-party libraries.

Burning Feet Man
17
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 31st Aug 2013 02:47 Edited at: 31st Aug 2013 02:50
Nice sample Rudolpho. I haven't seen this technique used before and will check it out further!

Do you know if object selection works? Other ortho codes aren't compatible when the user goes to click and object, where the objects look orthographic but the selection is selecting in perspective, and the whole process just falls in a heap.

Although I have my own solution to Ortho Camera by simply tweaking the camera presets, and this allows Ortho View & Ortho Object Selection to still work as expected.

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
mr Handy
17
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 31st Aug 2013 02:51
Hmmm... there is a lot of VC++ redists, 2006, 2008 etc... which one do I need?

Rudolpho
19
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 31st Aug 2013 03:41 Edited at: 31st Aug 2013 03:45
@Chris & BFM: thanks

Quote: "Do you know if object selection works? Other ortho codes aren't compatible when the user goes to click and object, where the objects look orthographic but the selection is selecting in perspective, and the whole process just falls in a heap."

I haven't checked that, just did a quick test and it seems it does indeed fail as you say.
I have recently formatted my computer and haven't reinstalled Visual Studio yet, or I would take a look at the dbPickObject implementation. It probably assumes perspective projection and builds a matrix for all the data fields you can set in the sCameraData struct. It should probably be possible to write ones own picking function that works with orthographic projection, but you'll most likely have to recompile the camera/object dll's to do it.

@Mr Handy: I recall one of those dll's being part of some obscurely old package from 2001. I eventually resorted to just downloading the dll files and dropping them in my Windows folder after them failing to have been included in 10+ downloaded VC redists.


"Why do programmers get Halloween and Christmas mixed up?"
mr Handy
17
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 31st Aug 2013 08:47
Quote: "Although I have my own solution to Ortho Camera by simply tweaking the camera presets, and this allows Ortho View & Ortho Object Selection to still work as expected."


This?



Is this "hack" is safe to use? Is the object selection works?

Burning Feet Man
17
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 31st Aug 2013 10:13
I tried that code that you posted previously, but it too had the select object complications. I ended up just using out-of-the-box DBPro camera commands and tweaked the camera until it was "close enough" to looking orthographic. From the discussions had here on the forums, I'm still not sure if this is a good method to use though.

I'll focus some time on ortho camera again, as it's been too long, and none of my old examples are playing nicely. I'll see what I can mock up over the next few days (weeks ).

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Rudolpho
19
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 31st Aug 2013 12:45
That snippet actually does the same as mine, but in a more round-about way. It also "forgets" to set a boolean indicating that the projection matrix is overriden which will cause it to fall back to the default matrix if any other function such as set camera fov is called after that. The reason the boolean isn't set is that DBPro's pointer functionality only support 4-byte DWORDS as described in the help. I'm actually surprised you can poke floats to them, didn't think that would work.


"Why do programmers get Halloween and Christmas mixed up?"
Burning Feet Man
17
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 1st Sep 2013 01:52
Cut & Pasted from a similar thread, here's what I ended up using in my previous Orthographic program, specifically cause it worked with Object selection;



Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
mr Handy
17
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 1st Sep 2013 21:39
Quote: "FOV# = 1"

I may be wrong, but AFAIR that was the one way to set ~ortho and have "depth" in shaders. Have not fully tested M1U way yet.

Rudolpho
19
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 3rd Nov 2013 17:31
If you're still interested, I by chance happened to come up with [url=]a way to pick objects from orthographic camera's[/url]


"Why do programmers get Halloween and Christmas mixed up?"
mr Handy
17
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 3rd Nov 2013 21:43
@Rudolpho
Yeah, that is very interesting. Also, in what type of "ortho" camera it would be used? (FOV 1, matrix utils, dll hack, etc)

Rudolpho
19
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 3rd Nov 2013 22:08 Edited at: 3rd Nov 2013 22:14
Should work with any kind, it uses the actual projection matrix of the camera to unproject screen coordinates and use them for raycasting in world space ("standard" 3D positions).
The kind where you explicitly use an actual orthographic projection should be preferred to get the exact correct look though, I imagine the FOV approach only comes close to actual isometry.

Edit: apparently I forgot to link to my solution in my last post...
Here it is


"Why do programmers get Halloween and Christmas mixed up?"
mr Handy
17
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 16th Nov 2013 22:57
Thanks, Rudolpho!

Login to post a reply

Server time is: 2025-05-17 04:24:02
Your offset time is: 2025-05-17 04:24:02