I have made some progress, I have been able to correctly distort a mesh using Wings3D.
I now have it properly rendering the image on the mesh. Unfortunately I have run into a glitch.
I need to change the aspect ratio of the camera before I render to the image and then change it back to normal afterwards.
It seems that in AppGameKit I can not change the aspect ratio in the loop. If I do not change the aspect ratio it results in a distorted
image when the camera is rotated on the roll axis. See attached images. Two solutions could solve this, more than one camera
or being able to change the aspect ratio. In my opinion AppGameKit should have more then camera especially since all the commands
actually take a camera number already. This pre distorted mesh method is better and faster than the barrel pixel shader method
or my original testing using a barrel vertex shader to distort the mesh.
I base this on my testing results and the information from this article.
http://smus.com/vr-lens-distortion/
Paul, should it be possible to change the aspect ratio like this?
function VR_Update()
SetCameraRotationQuat(1,GetRawRotationVectorW2(),GetRawRotationVectorX2(),GetRawRotationVectorY2(),GetRawRotationVectorZ2())
Update(0)
SetCameraFOV(1,90.0) //Set a larger field of view for the render grab
SetCameraAspect( 1, ( GetVirtualWidth() *0.5 ) / GetVirtualHeight() )
SetCameraPosition(1, 2000.0, 560.0, -3250.0 )
SetRenderToImage(vr_RenderImageID, -1)
ClearScreen()
Render()
SetRenderToScreen()
SetCameraFOV(1,70.0) //Set the field of view back to normal for the viewing of the VR render object planes
SetCameraAspect( 1, GetVirtualWidth() / GetVirtualHeight() )
SetCameraPosition ( 1, 0.0, 0.0, -97.5 ) //Set the camera back to location where VR render object planes are located.
SetCameraLookAt( 1, 0.0, 0.0, 0.0, 0.0 ) //Make sure the camera looks at VR render object planes squarely.
//Draws the center line on screen
drawline( getvirtualwidth() / 2 - 3, 0, getvirtualwidth() / 2 - 3, GetVirtualHeight(), 255, 0, 0)
drawline( getvirtualwidth() / 2, 0, getvirtualwidth() / 2, GetVirtualHeight(), 255, 255, 255)
drawline( getvirtualwidth() / 2 + 3, 0, getvirtualwidth() / 2 + 3, GetVirtualHeight(), 0, 255, 0)
Render()
Swap()
endfunction
The coffee is lovely dark and deep,and I have code to write before I sleep.