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.

AppGameKit Classic Chat / Tier 1 :: Trouble with GetImage()

Author
Message
basicFanatic
6
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 23rd Mar 2018 18:29
In VR, I wanted to sample the color right in front of the players eyes.

I render to three three different screens: the monitor, the left eye of the HMD, and the right eye of the HMD. It looks like GetImage() is picking up from the monitor render. So I would think that it would pick up from a 800x800 image, as this is my settings:

SetWindowSize( 800, 800, 0 ) // For some reason, anything other than 1:1 will distort the image
SetVirtualResolution (800, 800)


I created the following code from an example in The Official App Game Kit Tutorial Guide Vol #2:




Now, the problem is that the pickedColorPlane which I use as a crosshair isn't aligned with the area where I pick up the color. What am I doing wrong?
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 23rd Mar 2018 18:39 Edited at: 23rd Mar 2018 18:47
i think you need to Swap() then draw your scene then Render() then GetImage() then ClearScreen()
or you mean it's getting the image but not from the right place?
perhaps try
GetImage(WorldToScreenX(AGKVR.GetHMDX()),WorldToScreenY(AGKVR.GetHMDY()),1,1)
life's one big game
spec= 4ghz, 16gb ram, AMD R9 2700 gpu
basicFanatic
6
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 23rd Mar 2018 19:09
Yeah, I'm getting the image. So I got that far.

I tried your code, but instead of the color picker being slightly offset from the crosshair, it now picks colors from seemingly random locations! It also seems like a somewhat extreme way to find the center of an image!
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 23rd Mar 2018 20:14
ah wait that should be
GetImage(WorldToScreenX(getobjectx(pickedColorPlane)),WorldToScreenY(getobjecty(pickedColorPlane)),1,1)
it will at least help narrow down why you're not getting the expected results.
life's one big game
spec= 4ghz, 16gb ram, AMD R9 2700 gpu
basicFanatic
6
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 24th Mar 2018 10:09
I tried:
GetImage(WorldToScreenX(getobjectx(pickedColorPlane)),WorldToScreenY(getobjecty(pickedColorPlane)),1,1)

Yup, the color picking was pretty much batshit insane. But the values returned was interesting. The X and Y changed with the rotation of the headset. Their values lied somewhere between -2.0 and +2.0

But I'm not sure this line of code is right. Not sure its wrong either. For some reason, I can't wrap my head around it!

My feeling is that it is the HMD display that somehow makes things go awry. A nasty (but working) solution could be to simply manually place the crosshair a little to the right and to above, so it fits.
PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 24th Mar 2018 23:29
Quote: "The X and Y changed with the rotation of the headset."


Well the X and Y in the 3D World so to speak do change depending on rotation in 3D. The X and Y of the screen itself (2D) doesn't.

I think you might be looking for this command ; GetScreenXFrom3D() and GetScreenYFrom3D()
PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 24th Mar 2018 23:35
Oh and according to the manual setviewoffset and setviewzoom influence the result of WorldToScreenX() ccommand causing an offset in screen coordinates.
basicFanatic
6
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 25th Mar 2018 11:25
PHeMoX, you cracked it! GetScreenXFrom3D did the trick:

imgID = GetImage(GetScreenXFrom3D(getobjectx(pickedColorPlane), getobjecty(pickedColorPlane), getobjectz(pickedColorPlane)), GetScreenYFrom3D(getobjectx(pickedColorPlane), getobjecty(pickedColorPlane), getobjectz(pickedColorPlane)),1,1)

Thanks for the help! I was stuck at trying to figure out why those numbers didn't work as intended, so I would never have thought of going the route of GetScreenXFrom3D.

Login to post a reply

Server time is: 2024-04-25 00:46:17
Your offset time is: 2024-04-25 00:46:17