Getting to grips with Unity & VR

At work, I have been tasked with investigating Virtual Reality and what can be done with it.  The results went in to a Lab Report to that was sent to the rest of the business.  When thinking about building any VR proof of concept (POC), Unity just makes sense due to how easy they make it to enable it (a single tick box).  Out of the box, they support the main headsets (Rift, GearVR, Vive) to a useable level.  All of my POC’s where targeted at the Samsung GearVR as currently that’s the only commercial headset available.  This does give you some challenges due to the lack of user interaction possible and performance.  That’s been my major struggle recently, gett the FPS up.

Unity do offer some very nice and pretty VR samples in the Asset store, its recommended for anyone to take a look at how they are put together.  They also show you have to pickup taps / swipes etc on the GearVR touch pad.

Another challenge I have faced with being a programmer, and not a designer is making stuff look awesome, luckily in the Lab we have someone who knows Unity a lot better than I do and has a eye for detail, which most developers lack.

All in all I have enjoyed learning Unity and hope to use it with some proper VR hardware (Vive / Rift), I also hope that if I do get to do a larger project in it, that I have a more powerful machine.  Even my fairly new MacBook Pro struggles with Unity.

I have also learned a lot about good but mainly bad uses of VR,  the key message here is, don’t use VR for everything, use it for its strengths

 

GameJam : Friday 13th Unity Style!

So, a few of us gathered at Compsoft for another random GameJam, there was a theme but I don’t think anyone could remember what it was.  It was more of a hack some stuff together using Unity.  Now I am not the biggest fan of Unity, I love doing things the hard way, Unity seems to do too much for you, like Magic.

This time I focused on trying to get a simple example working for my Oculus Rift DK1 on a Mac, I thought this was going to be very hard.  I googled and saw Oculus’s new SDKs does not support OSX, I also saw very little mention of DK1.  I read about people hacking stuff together etc, things where not looking good.

However, the people at Unity rock, there was a simple tick box on the build settings for my project, that just made magic happen!  I had a simple 3D First person demo from the store, I ticked this box and BOOM, VR baby!.  I was actually blown away, to the point where I actually want to learn Unity!  I had a beautiful 3D Forest in VR without coding a single thing! (The demo of course had code but I had done nothing)

I couldn’t of made this by hand in a million years!  I then proceeded to add snow, a snowman and a elf!

Everyone has been telling me to use Unity, I think their right.  I just need to give in and learn it!

New version of Virtual Worlds Submitted for Android

Just a small update, the following features, bugs have been fixed.

  • Added feature to turn VR mode off
  • Added feature so you no longer need a game controller
  • Fixed issue with be able to place objects in other peoples worlds
  • Fixed a few crashes!

Please check out

Virtual Worlds

Lets release pre-alpha software! Yeah

So, tonight I decided just to punt out Virtual Worlds.  Probably a silly move but nothing has been happening lately with it due to work stuff, a 3 week long cough, 2 birthdays, Christmas and home life!

I will soon know how bad it is!

I managed to do some useful bug fixes, tested it on a couple of controllers etc.  More will come soon!

What does it have?

  • Main world has little huts which is your door way to the other worlds
  • It has some built in help to tell you what buttons do what.
  • It has some nice new textures but sadly very limiting at the moment
  • You can see other players in the game, pretty poor graphics but that will be fixed very soon
  • You can create your own little minecraft type world 🙂 though very basic!

Whats next?

  • Once I see it in the Google Store, I will test it works 🙂 (releases always seem to cause some odd bug)
  • I need to add some more textures ASAP
  • A way for people to report bugs
  • A way for people to talk to each other!

Google Play Link

Virtual Worlds : Progress so far

What? a? Virtual Worlds? What a sh*t name?  Your probably right but its just better than Android 3D mmo thingy!

Progress so far?  I would of liked to give it more time but some times I am not in the mood, sometimes I can’t get out of the mood which also leads to lack of sleep!  Last night I had beer! (not a usual thing sadly)

What can you do so far?

  • Register, login
  • Navigate the main world, which will allow you to enter player zones and create your own zones.
  • You can see other players (as cubes) move about
  • Once in your own zone, you can place cubes to make structures (see below) this has been vastly improved.
  • You can climb your structures to make bigger structures (I had to make a stair case to to make the archway)
  • You can enter delete mode in your zone and delete things with ease
  • Started adding back in the voice engine, sound effects etc
  • There are now system text messages to show you important information
  • Players and zones have text above them showing their username

device-2014-11-15-231021

 

 

 

 

 

 

 

Whats next

So to get it to the point where I can alpha test it I would like to do the follow

  • Create a 3D model for players as they are currently cubes
  • Make a 3D object for a zone, this should grow as the zone gets more popular / better in some way
  • Find a wider range of textures snow, grass, wood, etc
  • Create a control help screen to list gamepad controls
  • Make all commands voice activated (may get dropped)
  • Allow you to send messages to users (may be text or voice)
  • Create some sort of reason to play the game, prices, score boards etc.
  • Implement GCM (push notifications)

The aim is to have a demo zone thats setup for xmas when I release alpha:)

Off to bed!

New Android Project : VR 3D framework

So Virtual Reality has been one of my favourite subjects since I saw Lawnmover man as a kid.  I have made some very strange things in the past to try and make my own hardware / software for VR.  Oh boy where the Amiga days good fun!

So a few months ago, I made a simple split-screen 3D demo for iOS that used the Duo gamer controller, this can be found here:

https://github.com/burf2000/3DiOSDemo

I will be updating that soon to support normal iOS7 controllers so that Apple will accept it.  The Duo was added as a hack and never had a SDK 🙁

However,  due to the awesome news of Google Cardboard (VR via Cardboard!) and Oculus Rift working with Samsung to create a VR headset (uses your Note 4).  I thought it would be a good idea to start making my own one, similar to the iOS one but uses Android.

It can be found here:

https://github.com/burf2000/Android-3D-SplitScreen

I have just added support for the Moga game controller.

On a side note, this is worth a read

Getting VR to Run on Android Is “Hell,” Oculus’ Carmack Says

 

 

 

GLKIT Object Picking

For anyone who has played with OpenGL ES, its really hard work (iOS or Android). I have spent many hours on OpenGL ES 1.0 and 2.0, making my own frameworks etc.

Apple introduced GLKit in iOS 5 if I remembered correctly and it was designed to make the maths side easier. One of the things I struggle with is object picking, this is touching the screen and turning that in to a 3D position in the OpenGL world. Generally there is 2 ways to do this, Colour picking and Ray Picking.
Colour picking is when the user touches the screen, every object is rendered as a different colour and then you detect what colour that person touched to work out where they touched.

Ray Picking, is where you fire off a ray and work out what the first object is that it hits. This requires quite a bit of maths which people have already done for you but in different programming languages.

However, the point of this article is that I discovered that Apple have added functions to help with Ray Picking namely GLKMathUnproject

Code based from this StackOverFlow post http://stackoverflow.com/questions/20214498/updating-opengl-es-touch-detection-ray-tracing-for-ipad-retina

This works out when you touch the floor (self.plane) and then puts self.cube at that position

- (BOOL)didTouchObject: (CGPoint) tapLoc
{
tapLoc.x *= [UIScreen mainScreen].scale;
tapLoc.y *= [UIScreen mainScreen].scale;

bool testResult;

GLint viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);

GLKVector3 nearPt = GLKMathUnproject(GLKVector3Make(tapLoc.x, (tapLoc.y-viewport[3])*-1, 0.0), _baseModelViewMatrix, _projectionMatrix, &viewport[0] , &testResult);
GLKVector3 farPt = GLKMathUnproject(GLKVector3Make(tapLoc.x, (tapLoc.y-viewport[3])*-1, 1.0), _baseModelViewMatrix, _projectionMatrix, &viewport[0] , &testResult);

//farPt = GLKVector3Subtract(farPt, nearPt);

float xDif = (farPt.x – nearPt.x) / 1000;
float yDif = (farPt.y – nearPt.y) / 1000;
float zDif = (farPt.z – nearPt.z) / 1000;

for (int i = 0; i < 100; i ++)
{
if ((nearPt.x + (xDif * i)) > self.plane.position.x – self.plane.scale.x && (nearPt.x + (xDif * i)) < self.plane.position.x + self.plane.scale.x &&
(nearPt.y + (yDif * i)) > self.plane.position.y – self.plane.scale.y && (nearPt.y + (yDif * i)) < self.plane.position.y + self.plane.scale.y &&
(nearPt.z + (zDif * i)) > self.plane.position.z – self.plane.scale.z && (nearPt.z + (zDif * i)) < self.plane.position.z + self.plane.scale.z)
{

NSLog(@”Hit cube”);
self.cube.position = GLKVector3Make(nearPt.x + (xDif * i), nearPt.y + (yDif * i), nearPt.z + (zDif * i));
return YES;
}

}

return NO;

}

3D Stereoscopic demo for iOS

So the main reason I created a GitHub account was to upload my work on BurfWorld3D (Sorry for the rubbish name).

I have a keen interest in virtual reality and I decided to buy a (they also sent me one as I signed up as a developer.) This allows you to turn your Android/iPhone in to a head mounted display giving the user a virtual reality experience for a small cost. The issue I had was that the Durovis OpenDive SDK is for Unity only and so I started the hunt to find something I could use or convert so that native OpenGL apps could be made.

I also got for Christmas a DuoGamer iPad controller which was made for Gameloft games only, however luckily someone had made their own SDK for it which I found on GitHub. I thought this would be a great way to move around in the 3D space.

So, I created a simple 3D demo where you can walk around buildings, up stairs, etc. Has collision control and gravity, still needs a lot of work but may help others.

2014-03-20 17.52.00

BurfWorld 3D on GitHub

Thanks to mringwal for the Duo Gamer SDK.

Thanks to sphereinabox For the initial OpenGl iOS split screen view for the iPad.