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 / Rendering two cameras to one view port.

Author
Message
Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 16th May 2011 04:53 Edited at: 16th May 2011 12:13
I've been cutting some code lately, and in writing some code which orientates 3D objects to my camera via trigonometry functions, I realized that I might be doing things the hard way.

If I have two cameras, with Camera 1 floating above and focused on a ground matrix at 45°, can I also have camera 2, focused 90° at the ground at a cube object, but with both cameras rendering to the same view port?

The given effect would be a visible matrix plane at 45° with a cube that's square to the viewer.

I hope I've explained myself OK. I can draw a picture if required.


EDIT: I dug through the DBPro snippets database, and found an example.



The fps is horrendous though, but at least I now have a starting point on how to research this. Any guidance would be greatly received.

*Mouth explodes water all over the screen*: WHOA. Changed the GenerateAlpha flag from 1 to 2, and we have a smooth frame rate! NOW THIS HAS MY INTEREST.

EDIT: Finally got home from work and can test this out some more. I need to figure out how to select a camera for working with the Pick Object command. In the below code snippet, when the main code is amended with it, you can click the large cube, but not the top left hand corner cube.



I'd like the option to click either, or even both? Hmmm...

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 21st May 2011 14:12 Edited at: 21st May 2011 14:14
This is what I'm talking about.

Here's a link to my latest test.

https://sites.google.com/site/bfmstudios/Home/Application.zip?attredirects=0&d=1

Finally getting somewhere.

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 21st May 2011 14:16
IIRC, the PICK OBJECT function uses the current camera. So all you need to do to pick using both cameras is to set the current camera appropriately before you check.

Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 22nd May 2011 01:51
Ahh, excellent. I'll make note of that.

I don't think it'll work in this specific example though, due to the camera trickery I've got going on. Since the orthographic selection box is a pasted image, I can only use an overlay of buttons or keyboard commands to interact with it.

If I'm going down the wrong path, please let me know. I'm keen to learn alternate techniques to what I'm doing here. Trawling through threads in this forum just to find answers takes up so much of my time, but I think I'm reaching a stage where I can actually produce something of significance pretty soon.

Long term perseverance is the key.

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 22nd May 2011 08:00 Edited at: 23rd May 2011 15:00
Wrong wrong wrong! My entire approach has been wrong!

Two commands and I've now seen the light.

Set Camera View
Backdrop off

Hopefully problem solved!

EDIT: So much reading about the history of orthographic views failing to work with the pick object command.

Good news is, Pick Object seems to work fine when I've zoomed the camera exactly 2000 units away. Due to the Orthographic camera effect, the object doesn't shrink, but eventually as I hit the 2000 distance mark, the pick object command matched directly up with the moving object.

Now, thanks to the clues given by IanM, I can have multiple camera views, with alpha, that all work with pick object, regardless of perspective OR orthographic!

Woo hoo! Best DBPro weekend EVER!

EDIT: Aww, party is over. Pick Object is broken, as per my example below. Any ideas on how to fix this?



Any takers?

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 28th May 2011 00:07
I can only think "pick screen" and sparky's collision/raycasting.

Test if pick screen works. if it doesn't it's possible to write your own pick screen function, but I'm only about 70% sure how to do that xD


Tell me if there's a broken link to images in a thread I post, and I'll fix 'em.
Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 31st May 2011 02:15
Fingers crossed that "Pick Screen" works with an orthographic camera view. I've been held up for the past few days and unable to test it, but will definitely get this tested by next week. Pick Screen and collision detection with a camera masked object should hopefully work... Slighty clunky though...

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 2nd Jun 2011 14:24
Great news. I've been working through the D3DFunc ini & help files, and it looks like there's even a demo written by Jason Clogg which was exactly what I needed! Thanks to Jason, I can now learn the tricks of the trade regarding orthographic projection and object selection.

Early days yet, but I'm hoping that this is what I've been looking for. ^_^

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 7th Jun 2011 13:42
I'm having a bit of a blonde moment. Two camera's, with their views overlaying one another. If backdrop on is set for camera 0, and backdrop off is set for camera 1, I can see both camera's overlaying one another. But, what do I do if I want to switch the camera order?

Example, the reverse of the above. If backdrop off is set for camera 0, and backdrop on is set for camera 1, camera 0 is no longer visible. I'm looking for the command which shuffles camera 0's draw order in front of camera 1.

Sure I'll figure it out, but give a yell if you know!

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 7th Jun 2011 14:40
You might find it easier (and faster) if you use the Image kit. Just draw to render target images (just images really) and then paste them onto the screen wherever you like or even turn them into sprites. That way you could do the lot with only one camera.

I haven't any sample code but I'm sure I could have a go if you're interested?

Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 7th Jun 2011 15:29 Edited at: 8th Jun 2011 14:31
Heya Baxslash.

I've reviewed the image solution, but it had too many draw backs (heh), such as complications when ray casting and slower frame rates.

At the moment, I'm putting together a ray casting demo for myself, and I'm really keen on learning how to use 3D plane objects as message boxes and buttons. Mixing in Orthographic Views, Pick Object\Pick Screen, and the incompatibilities that all of these commands have with each other, I've really got my work cut out for me!

Currently I'm figuring out how to ray cast into a matrix cell, and upon clicking the cell changes colour. In doing so, I was going to have a couple of camera angles, side by side on screen, but I also requied an "overlay" of camera 0 which covered both Camera 1 & 2, so that the Message box planes would render to Camera 0 thus overlay Camera 1 & 2 view ports.

In my code below, I've put this requirement on the back burner until someone can advise further on technique.


Note to the cutters & pasters out there, you'll need a Matrix1's Utilities and also D3DFunc to compile and run my code.

EDIT: Ha! Ok, come full circle, again. Done some more testing, and I've found the best way to produce an orthographic view is to toggle the camera distance, range and FOV. All of the pick screen/pick object code continues to work, and to be honest I can't tell the difference between a FOV of 0.5 and Orthographic.

Any thoughts?

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia

Login to post a reply

Server time is: 2024-11-16 21:51:13
Your offset time is: 2024-11-16 21:51:13