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:
/***************************************
PICK COLOR WITH GRIP
***************************************/
if AGKVR.RightController_ButtonPressed(2) = TRUE // grip pressed
SetCameraPosition( 1, AGKVR.GetHMDX(), AGKVR.GetHMDY(), AGKVR.GetHMDZ())
SetCameraRotation( 1, AGKVR.GetHMDAngleX(), AGKVR.GetHMDAngleY(), AGKVR.GetHMDAngleZ())
// Place the crosshair at the center
SetObjectVisible( pickedColorPlane, 0 )
SetObjectPosition( pickedColorPlane, AGKVR.GetHMDX(), AGKVR.GetHMDY(), AGKVR.GetHMDZ())
SetObjectRotation( pickedColorPlane, AGKVR.GetHMDAngleX(), AGKVR.GetHMDAngleY(), AGKVR.GetHMDAngleZ())
MoveObjectLocalZ ( pickedColorPlane, 0.7)
Render()
imgID = GetImage(400, 400.0, 1.0, 1.0) // 400*400 is half the virtual resolution
backput = "Image exists: " + str(GetImageExists( imgID )) + " "
backput = backput + "Image width: " + str(GetImageWidth( imgID )) + " "
backput = backput + "Image height: " + str(GetImageHeight( imgID )) + " "
memID = CreateMemblockfromImage(imgID) // ERROR
red = GetMemblockbyte(memID,12)
green = GetMemblockbyte(memID,13)
blue = GetMemblockbyte(memID,14)
colour = (red<<16) + (green<<8) + blue
DeleteImage(imgID)
DeleteMemblock(memID)
SuckedRed = (colour && 0XFF0000) >> 16
SuckedGreen = (colour && 0XFF00) >> 8
SuckedBlue = colour && 0XFF
cRed = SuckedRed
cGreen = SuckedGreen
cBlue = SuckedBlue
SetObjectColor(laserPointer, cRed, cGreen, cBlue, 255)
SetObjectColor(pickedColorPlane, cRed, cGreen, cBlue, 255)
SetObjectVisible( pickedColorPlane, 1 )
else
SetObjectVisible( pickedColorPlane, 0 ) // Hide plane when grip not pressed
endif
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?