Ok so I've been slowly implementing some 3D code using some old FPSC models adjusted to work with AGK.
Primarily I'm trying to make a simple VR game so I prototyped the camera code, but I've hit a bit of a bug.
I've implemented some code to switch between a standard FPS view and the VR view. Here's the standard FPS view:
So everything looks fine - although admittedly quite ugly at the moment. However, when I switch to VR mode, things take a turn for the weird:
It's really odd, it's like the textures are inverted and you can see walls behind walls and the door frames are partly visible. Anyway, I'm stuck so anyone have any ideas?
Here my VRRender code:
function RenderEyes()
//positions camera in eye positions for VR
//The next steps use a single camera to create both left and right eye images for the 3D effect.
//update the position of all the objects and camera
Update(0)
if VRactive=1
//hide eye images
SetSpriteVisible( LeftEye.Sprite, 0 )
SetSpriteVisible( RightEye.Sprite, 0 )
//Render both LEFT and rIGTH eyes if running on the Android device
//LEFT EYE
//position the camera for the left eye
SetCameraPosition( 1, LeftEye.PosX, LeftEye.PosY, LeftEye.PosZ)
//set the render target of the camera to the LEFT EYE image.
SetRenderToImage( LeftEye.RenderImage, 0 )
//Clear the old image and render the camera to the target image.
ClearScreen( )
Render( )
//RIGHT EYE
//position the camera for the right eye
SetCameraPosition(1,RightEye.PosX,RightEye.PosY,RightEye.PosZ)
//set the render target of the camera to the RIGHT EYE image.
SetRenderToImage( RightEye.RenderImage, 0 )
//Clear the old image and render the camera to the target image.
ClearScreen( )
Render( )
//ClearScreen()
//SetRenderToScreen()
else
//LEFT EYE
//position the camera for the left eye
SetCameraPosition(1,LeftEye.PosX,LeftEye.PosY,LeftEye.PosZ)
//Set the render target as the screen (for the PC, this is already the target)
SetRenderToScreen( )
ClearScreen()
//Render everything to the screen
Render()
endif
if VRactive=1
//For the android device, the two rendered images need to be positioned in front of each eye.
//LEFT EYE
//update Eye sprite with new image
//SetSpriteImage( LeftEye.Sprite,LeftEye.RenderImage)
//set the sprite size to cover half of the screen.
//SetSpriteSize( LeftEye.Sprite,getvirtualwidth()/2,getvirtualheight()*1.3 )
//position the sprite in the top left corner
//SetSpritePosition( LeftEye.Sprite,0,0 )
//make the sprite visible
SetSpriteVisible( LeftEye.Sprite, 1 )
//RIGHT EYE
//update Eye sprite with new image
//SetSpriteImage( RightEye.Sprite,RightEye.RenderImage)
//set the sprite size to cover half of the screen.
//SetSpriteSize( RightEye.Sprite,getvirtualwidth()/2,getvirtualheight()*1.3 )
//position the sprite in the right half of the screen
//SetSpritePosition( RightEye.Sprite,getvirtualwidth()/2.0,0 )
//make the sprite visible
SetSpriteVisible( RightEye.Sprite, 1 )
SetRenderToScreen()
ClearScreen()
//Render everything to the screen
Render()
//draw a line between the two images
//drawline(getvirtualwidth()/2.0,0.0,getvirtualwidth()/2.0,720,255,255,255)
endif
//Displays the back buffer to the screen and clears the backbuffer for the next frame, updates global time variables
Swap( )
//hide the Eye sprites so that the scene can be captured by the camera
//SetSpriteVisible( LeftEye.Sprite,0 )
//SetSpriteVisible( RightEye.Sprite,0 )
endfunction
Any help is appreciated.