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 Discussion / How do you take a 3d snapshot from an area NOT in the camera's view?

Author
Message
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 29th Dec 2006 02:49
I wasn't sure how to word the question but here's an explanation of what I'm trying to do.

I want to be able to get a screen capture within a 3d world that isn't within the camera's current view. I have moved and rotated the camera to other positions, tried to get the screen shot and return it to it's original position, but the screen flickers and jumps like crazy!

I have also split the screen with SET CAMERA VIEW, this works, but with undesirable results: I don't want to shrink the main area, and I don't want the snapshot reduced so much in size either.

With 2d, one can just draw on a bitmap that is offscreen and then copy that to the main bitmap. Is there a way to do this with 3d? I tried using CREATE BITMAP and SET CURRENT BITMAP, but it didn't affect the 3d screen.

Any help would be greatly appreciated. Thanks in advance!

Enjoy your day.
Gamers for sale
19
Years of Service
User Offline
Joined: 19th Nov 2005
Location: Some where beneath the elements
Posted: 29th Dec 2006 02:56
I know that this is kinda advanced but you could just use windows api to print screen in dark basic code and save it as a bitmap.

I could come up with some code if you want to do it this way.

How to be successful in a forum:
F-o-r-u-m - f - First solve your own problem, o - test the Outcome, r - retry to solve, u - Underline code with the problem, m - ask the Members to help you.
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 29th Dec 2006 03:02 Edited at: 29th Dec 2006 03:06
My guess is that you are trying to create a reflective surface - like a mirror and unfortunately it can't be done with standard DBC without the flickering, due to only having a single camera viewport.

With careful use of the Sync command you can achieve a passable split-screen effect, but it's of no use for what you want as the second view can't be produced to snapshot it without being seen.

TDK_Man

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 29th Dec 2006 03:07
Thanks for the suggestion GFS,

but unless I'm mistaken, the print screen function in win api reproduces the screen that is currently visible. I can accomplish that with GET IMAGE in DBC. I'm trying to find a way to get an area that ISN'T yet visible or to be able to make that area visible, get the snap-shot and the return to the original camera position without flicker or a big jump in the screen.

I am curious about your suggestion though...

Enjoy your day.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 29th Dec 2006 03:14
@TDK

You read my mind! The split screen does offer the possibility, and I can get flicker free results, but, the image ends up being too small or the resolution not that great and on top of it, I don't want the screen split - the angle of the surface doesn't change as the split screen is always rectangular. Is there no way to send 3d commands to the back buffer or something and capture the image from there before the screen is refreshed?

Enjoy your day.
RUCCUS
20
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 29th Dec 2006 03:44
This is why you shouldve went for DBP , that "SET CAMERA TO IMAGE" command is a mighty useful one.

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 31st Dec 2006 02:35
@Ruccus
I'm sure DB pro has a lot of advantages, but I can't justify the expense.


Anyway, I was able to get a makeshift result close to what I was after by splitting the screen... I can make a mirror with only the relective surface and one screen showing, but it's not perfect.

In terms of the Backbuffer:

I'm curious about the timing of the back buffer. Can I draw to the back buffer, capture the information, clear it, draw again and return to the main application? I'm trying to create a 3d drawing (much like a 2d drawing on another bitmap) out of view. I wrote a DLL that copies the backbuffer to a memblock, but it only seems to populate it with usable info after the screen has been SYNCed. By syncing it, the screen is refreshed with the information I didn't want shown. Thanks in advance for any help.

Enjoy your day.
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 31st Dec 2006 22:57 Edited at: 31st Dec 2006 22:58
As I said before, what you want to do isn't actually possible with the standard version of DB Classic. (A prototype version of DBC which does do it wasn't released to the general public).

Believe me - I've spent a considerable time over the years trying to do what you are and have long since given up.

Fortunately it's one of the many added features which make it worthwhile upgrading to DBP.

TDK_Man

Rigo
21
Years of Service
User Offline
Joined: 13th Jun 2003
Location: Hungary
Posted: 9th Jan 2007 01:44
Some years ago, I made a mirror in DBC, if I find the source or the demo of this, I can upload it, if anybody interested. I already found a shot:

Attachments

Login to view attachments
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 10th Jan 2007 11:42
@Rigo,

I'd definitely be curious! Is it real time? It updates the reflection as things pass in front of it?

Enjoy your day.
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 10th Jan 2007 15:06
Quote: "I'd definitely be curious!"


You're not the only one lol!

TDK_Man

Rigo
21
Years of Service
User Offline
Joined: 13th Jun 2003
Location: Hungary
Posted: 10th Jan 2007 21:17 Edited at: 10th Jan 2007 21:19
Yes, it works in realtime (Check the DEMO! (hold leftbutton to rotate the camera)), but it is too slow...

Dou you know a method for screen capture witch is faster than the "get image" command, but not the "make memblock from bitmap - make image from memblock" combo? If you do, my code would be much faster.

So my mirroring based on the sprites: if you capture the screen with the get image command, this picture will not contain any sprites... so if you make a snapshot from the screen at the "main camera" perspective, and put this sprite to the front, you can go anywhere on your scene, the user only see the sprite (just like in the spy movies, put a picture ahead the security cam xD ), but the get image command will capture the things behind the sprite.

So that is it. But this is too slow: at 640x480@16, with one miror (200x150) run at 35-40 fps (at higher resolutions may slow down to 5-10fps...(my pc: P43.06Ghz-HT, 512MB-DDR2 RAM, NV-7600GS-256MB-PCIE)

So if I can replace the get image command for a faster something, that would be nice...

Rigo.

Attachments

Login to view attachments
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 10th Jan 2007 22:10
Ahhhh... now I see what you have done and I don't think it's what we are talking about!

The effect is the same, but I'm sure your demo has the same side effects that we have been discussing - you just can't see it with just a blank single coloured background.

I'd like to see your demo with the wishing well on a matrix (I'm assuming that you haven't used one here), with a skybox and see the difference (besides a lower framerate).

TDK_Man

Rigo
21
Years of Service
User Offline
Joined: 13th Jun 2003
Location: Hungary
Posted: 10th Jan 2007 23:20 Edited at: 11th Jan 2007 11:32
as you wish.

I worked a bit on the mirror, now the reflection depending on the camera position and angle.

Attachments

Login to view attachments
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 11th Jan 2007 00:32
@Rigo,

Very Clever! That's kinda how I had gotten mine to work.

I did something similar with a split screen. The "second screen" is hidden behind a sprite. I can get close to 300 fps with the uncompiled version. But once I make it into an exe, it slows down to about 90 and it is quite jittery.

Enjoy your day.
Rigo
21
Years of Service
User Offline
Joined: 13th Jun 2003
Location: Hungary
Posted: 11th Jan 2007 05:44 Edited at: 11th Jan 2007 05:47
Thanks, Latch!

Good idea the "split screen hiding" mode, but isnt a problem the camera view smaller than the monitor screen (and if I understand you well, the camera screen have to be so small for a well size of mirrors) ?

Can you show us a Demo?

So, if any hardcoder find the way to this topic, I still looking for a very fast "get image" method...

FZoli.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 11th Jan 2007 10:45
The camera screen is small. But it works out. The smaller size helps with the fps.

The reflection I'm doing is from a pane of glass, so it's see-through. The smaller split screen works okay (not great) because it gives the illusion of an imperfect reflection (not as much detail as in a mirror), and you see things on the other side so that hides a bit of the imperfection with the smaller resolution.

I've always had trouble attaching uploads to these forums. I'll try to attach a demo. But it's not perfect. Like I said, for some reason as an exe it is very jittery - running the source it looks fine. I don't know why it slows down by more than 60%.

Anyway, I'll try and attach a demo...

Enjoy your day.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 11th Jan 2007 10:52
The camera screen is small. But it works out. The smaller size helps with the fps.

The reflection I'm doing is from a pane of glass, so it's see-through. The smaller split screen works okay (not great) because it gives the illusion of an imperfect reflection (not as much detail as in a mirror), and you see things on the other side so that hides a bit of the imperfection with the smaller resolution.

I've always had trouble attaching uploads to these forums. I'll try to attach a demo. But it's not perfect. Like I said, for some reason as an exe it is very jittery - running the source it looks fine. I don't know why it slows down by more than 60%.

Anyway, I'll try and attach a demo...

The numbers are:
FPS
Angle of Incidence
Another angle that isn't used
Angle of Reflection

The camera appears in the mirror as a red cone.

Enjoy your day.

Attachments

Login to view attachments
Rigo
21
Years of Service
User Offline
Joined: 13th Jun 2003
Location: Hungary
Posted: 11th Jan 2007 11:31
not bad!
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 11th Jan 2007 14:40
Attempts from both of you are very impressive, but both obviously suffer from the limitations of DBC and aren't perfect (or fast) enough to be used in a large program - especially whem everything else is going on.

I hadn't thought of using sprites in the process before and might revisit the subject with a fresh pair of eyes.

Good demos though - I'm sure you would do well in the DBC Programming Challenge threads if you take part!

TDK_Man

Login to post a reply

Server time is: 2025-05-27 18:58:48
Your offset time is: 2025-05-27 18:58:48