To prepare for the first VR test I wanted to add the following features which I thought may be needed:
- The ability to change the distance between the two camera positions using the xbox controller.
- The ability to switch the point that each camera was looking between a common point or independent points directly in front of each camera.
To achieve this I added a variable to the
PlayerVision class to store the distance that each camera should be from the center
mHalfCameraDistance, this was then used instead of the hard coded 1 and -1 values when calculating each camera’s position.
To modify this distance, I created two functions, one to increase the distance and one to decrease it by the passed in amounts.
To achieve this I added a boolean variable to the
PlayerVision class called
mLookStraightAhead, if this was set to true then the cameras would look directly ahead of themselves, however if the value was false, then the cameras would share a common look at point.
This was done by calculating a common look at point which was in the look direction from the players position.
The look direction for each camera was calculated as the look position minus the cameras position.
To facilitate controlling these settings from the Xbox controller I updated the
ButtonControlInterface and the
GameControlHub classes to allow detection and reporting of activity on the LB (L1) and RB (R1) buttons.
Then in the main game loop I checked for:
- The action button pressed which would toggle between the two camera look at modes.
- The L1 button pressed which would decrease the distance between the two cameras.
- The R1 button pressed which would increase the distance between the two cameras.
With these changes implemented I placed the phone into the headset and pressed the L1 button to decrease the distance between the two cameras, this had the effect of increasing the distance???
It turns out that when calculating my look direction I had been using a positive z value instead of a negative z value as all my calculations in this test had assumed.
Fixing this issue by inverting the look direction, then highlighted the fact that all my controls had been set to work with this incorrect look direction, testing the values returned from the Xbox controller stick movements showed that these values were inverted (except the one used for Yaw) from what I had assumed, this was fixed by inverting the stick values in the
With the above issues resolved, I once again placed the phone into the headset and my first impressions were good, while looking at objects close to the camera there was a kind of ghosting where you could see the difference between the two camera positions, decreasing the distance between the two cameras had the desired effect and at distances below about 1.0 (0.5 half distance) the image looked great.
One interesting thing I did notice was that when changing the camera at the lower distances, I could see the 3D models move and then my brain would compensate and they would merge back to a single model again, I am assuming that this compensation is not possible at the larger distances between the two cameras, so as not to stress the eyes / brain too much I have decided to work with the half distance set to 0.1 for now.
I did not notice any major difference when the two cameras were looking at a common or independent points but this may be something I notice as the scene grows.
All things considered, this update was quite productive, I got the chance to brush up on my blender skills, fixed some issues with the game and had a successful VR test.
The code at this point in the project can be found here.