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.

3 Dimensional Chat / How to save a 3D screen to an image

Author
Message
giouti
User Offline
Joined: 18th Mar 2019
Location:
Posted: 4th Apr 2019 16:29
Hi all, this is my 1st post to the forum !
I am building an application which draws 3D objects (primitives, like cylinders) on the screen. In one of the routines I try saving the screen , with the 3D objects, into an image : but the problem is that only 2D like text & sprites are saved to the image, no 3D object ! You can see this in the attached files : image.png is what I obtain when saving the screen from the routine, 2019-04-04.png is a print screen, and is what I would like to obtain.
Any suggestion ? Thanks !
Giorgio

Attachments

Login to view attachments
Raven
14
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 4th Apr 2019 18:29
Maybe a little more information... such-as, what are you writing the Program in?
giouti
User Offline
Joined: 18th Mar 2019
Location:
Posted: 4th Apr 2019 22:13
HI Raven, I'm writing it on Windows platform. Should (hopefully) work also on Android.
Thanks!
Raven
14
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 5th Apr 2019 06:25
Alright, well not quite what I asked... but I'm going to assume you're using AppGameKit (although the principal is similar for DBC / DBP / DGDK / AGDK)
As such you're likely using the GetImage( ) and SaveImage( ) Instructions.

This isn't wrong per se, but with AppGameKit you have to be careful about where you're placing said commands.
Remember that when you Sync( ) / Render( ) / Swap( ) / Update( )., these automatically will Clear the Back Buffer (Screen) Cache in preparation for Drawing the Update Frame.

Where as calling DrawText( ) will instantly send the Text to the Back Buffer (Screen) … so it will immediately Draw To Screen., thus when you call the Synchronisation / Update Commands, it'll Re-Draw said Text to the Screen.

This means it's more than possible to accidentally only capture Text / Sprites / 2D Drawing Operations within a Screenshot, as opposed to the Final Composition Image.
As a note this is how you can manipulate 2D Images or perform CPU Screen Effects without having to use Memory Block Operations (which are a little more advanced).

In other words... create a Simple Function, that will Take a Screenshot (this will handle GetImage / SaveImage and I'd recommend Deleting Image once done, else you can easily accidentally use a lot of memory you don't mean to until the App Closes) then create a Trigger Variable.
Something like Global bTakeScreenshot As Boolean, that during the input update you trigger before resetting at the end of the Screenshot Function.

Then you can just call: If bTakeScreenshot Then TakeScreenshot( ) // Place Immediately after Sync( ) or Swap( )
You could test it via a simple If GetPointerPressed Then bTakeScreenshot = -1

Although personally I'd always recommend setting up:
#Constant True -1
#Constant False ‭0

It achieves the same thing as leaving ‬IF operators blank, but it just keeps things inline with C/C++ should you chose to use the "Tier2" AppGameKit, and it's a good practise to get into to use True / False.
That these haven't become Default Keywords in the past 20 Years since Dark BASIC was release still continues to baffle me.
Anyhow … that should work as you expect it to.

In fact this actually provides options., so... say you don't want Text / Lines / UI / etc. as part of the Screenshot; well you can handle the Rendering of the 2D / Sprites / Text / 3D all as Separate Layers., then simply Screenshot the Layer you want to output.
But I wouldn't recommend such until you get used to no longer using the Sync( ) Command that just handles all of the Background Updates and Rendering for you.
giouti
User Offline
Joined: 18th Mar 2019
Location:
Posted: 5th Apr 2019 15:10
Hi Raven , sorry for not having given other details : I currently use AppGameKit Studio 0.50 (Tier 1) for development, and test my programs also in AppGameKit 2 , which is latest stable version, to make sure everything works.
Thank you for your thorough explanation : it's more or less what I had done using other threads & snippets in the forum as a base, and adapting them for my saving routine. Your explanation was useful in making sure that I hadn't messed up with screen instructions order !
So , to make a long story short : this morning I did other tests, by loading a 3D object (a rose) saved in different formats , instead of creating primitive 3D objects, and to my surprise the rose appeared in the saved image when it was loaded in 3DS format !! (see the attached image) This object loaded in FBX, OBJ & DAE formats did not appear, only in 3DS format ! This happens in both AGK2 & AppGameKit Studio.
Do you have any idea about this strange behaviour ? Should I report this situation in any other dedicated forum ?
Thank you,
Giorgio

Attachments

Login to view attachments
Raven
14
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 6th Apr 2019 00:33
That's certainly... odd behaviour, but honestly I don't have the experience with AppGameKit to tell you if this is "Normal" for it.
It seems like it's bugged and probably should be reported.

I'd try the AppGameKit area of the forum, as this one is more for 3D Modelling and related Discussions., primarily with 3rd Party Tools (like Blender / Maya / 3D Studio Max / Modo / etc.)
giouti
User Offline
Joined: 18th Mar 2019
Location:
Posted: 6th Apr 2019 09:33
Thanks again, I'll revert to the other forums!
Have a great day,
Giorgio

Login to post a reply

Server time is: 2019-08-22 15:42:55
Your offset time is: 2019-08-22 15:42:55