Monday, March 9, 2015

Photo VR - Saving the Snap

I've started working on my project for Oculus' "VR Jam", an event where developers are encouraged to create a VR game or experience for the Samsung "Gear VR". I don't own a Gear VR but I thought I'd go ahead and test with the DK2 until I find someone that does. My game is pretty simple, anyone whose played the N64 classic "Pokemon Snap" will find the concept familair. You are carted around an environment and then take pictures of the wildlife around you. Your "snapshots" will be graded on things like composition, subject matter, and lighting. Since the game is a mobile experience I am designing it around using one button so bait and such probably won't be a feature, but we'll see.

I started with the "PictureTaker" class. This handles saving snapshots to file, as well as the game data used to judge the quality of the photo. I've run into one obstacle so far working with VR which wasn;t too much of an issue but it was fun to solve. Since the screen is rendering the two cameras for both eyes I can't just use Application.ScreenShot because the snap will show what you would see if you tried to view the game on a normal monitor, or this:


This is obviously not ideal, so my solution was to have a third camera in the scene that is disabled by default. When the fire button is used, the camera is re-activated, and aligned between the two eye cams, this camera renders to a render texture and a frame from that is saved to file as a PNG. The result is this:

Much better... 

For saving the game data I made a sub class called "SnapShot" this contains the game data for each picture like what level it was taken in and what it is a picture of. As of now to tell this subject Im just firing a single ray from the center and pushing that objects name to a snapshot objects list of subjects List, then that snap is added to another list that will be eventually serialized and saved to file. The next trick is to make sure the saved game data lines up with each saved PNG. Here's my class so far:

http://pastebin.com/WMVrNBbu




No comments:

Post a Comment