Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon
4. January 2016

 

I was recently working with a tool that exported it’s level data as a directory full of obj files, literally hundreds of them.  You can import them into Blender using File->Import->Obj, unfortunately there is no way to do a select all.  Apparently in Blender 2.4x if you held SHIFT while selecting OBJ import, it would import an entire directory, but this doesn’t appear to work in modern Blender.  You can also SHIFT+Click multiple files to do multiple selection, but this gets tedious when you have hundreds of them.  Unfortunately CTRL + A doesn’t work…

 

Thankfully Blender is extremely scriptable, so let’s turn to Python for a solution.  The following script will import a directory full of OBJ files into the current scene.

import bpy
import os

def fileList(path): 
    for dirpath, dirnames, filenames in os.walk(path):
        for filename in filenames:
            yield os.path.join(dirpath, filename)

for f in fileList("C:\\file\\path\\here\\"):
    if f.lower().endswith(".obj"):
        bpy.ops.import_scene.obj(f)


Be sure to change the path to your directory and if on Mac OS or Linux, to change the path format /to/this/style. Otherwise this script will chug away importing the OBJ files for you. Hopefully at some point Blender gives you the ability to select all while importing and the need for this script goes away completely.

Art, Programming , ,

4. January 2016

 

We recently covered getting started in GearVR development using Samsung’s GearVRf library and the Unity Engine.  Today we are going to finish it off with coverage of getting started using the Unreal Engine.  As with the Unity tutorial, although this is focused on the GearVR, most of the instruction should be equally valid for all Oculus Rift devices.  Of all the game engines, the Unreal was actually the easiest engine to get up and running with the GearVR.

 

There are a few pre-requisites before getting started:

There is a video based version of this tutorial available here and embedded below.

 

Configuring Unreal Engine

In order to be able to run code on your phone we need to add the Oculus Signature file to the application.  With Unreal Engine, this is configured at the engine level which is handy as you only have to configure it once for and it will work with all future projects.  If you haven’t already, sign up for an Oculus developer account, then get your key.  This will generate a file that we need to copy now.

The directory you want is [Unreal Install Dir][Version]\Engine\Build\Android\Java\assets.  In my install it was:

image

 

Creating a Project

You can use just about any settings, but these ones work well.

image

This will mostly just set presets that are mobile friendly.  Click Create Project when ready.

 

Configuring Your Project

If not done already, load your project in Unreal Engine, then select Edit->Plugins:

image

 

Now verify (or turn on) the GearVR and Oculus rift libraries and plugins, like so:

image

 

Now select Edit->Project Settings:

image

 

Locate Android SDK on the left hand side then on the right configure the location of your Android SDK install.

image

 

Now go to Android, set the Android minimum level then click the Configure Now button:

image

 

While in the Android settings, be sure to enable GearVR support!

image

 

Build Your App

 

Now build and package for Android, in the File Menu, select Package Project->Android->Android (ETC2):

image

Pick a location for the generated APK then Ok.

image

For the record, Unreal Engine Android builds are really really really slow.

 

When complete this will generate the APK file to run on your phone, as well as a pair of BAT files to quickly deploy to your device.  The noOBB batch file doesn’t copy data, only the updated executable.  Keep in min,d, you need to have your device either tethered or running wirelessly over adb to deploy.  This means removing it from the GearVR, which is an annoying process.  If you don’t need to fully test VR functionality, it might be faster to work in developer mode. [Link soon]

 

Video

Programming , ,

3. January 2016

 

Earlier we look at getting started doing Gear VR development using Samsung’s GearVRf library.  In that tutorial I mentioned a few times that it is a great deal easier to get started doing Gear VR development using the Unity game engine.  Today we are going to look at the process of getting a game up and running using the Unity game engine.  This tutorial is GearVR specific, however it should be just as applicable for the Oculus Rift.

 

Truth of the matter is getting started with Unity is exceptionally easy, but…

 

The information out there is all out of date and makes the learning curve much harder than it used to be.  First off, Samsung make a set of utilities available and you need to make sure you get the newest version.  However, Unity now has VR built in out of the box, so you don’t need to do anything at all.  This renders almost all of the existing getting started type tutorials completely wrong.

There is a video version of this tutorial available here.

Getting Started

 

First off, create a project like normal, no need to do anything special.

image

 

Now select Build Settings in the File menu

image

 

Select Android, then Player Settings…

image

 

Now select Virtual Reality Supported.  Also be sure to set your bundle identifer and optionally the Minimum API Level (the lowest possible level is a Galaxy Note running 4.4):

image

 

If you run it now you will get the following error:

image

 

This is because the GearVR wont allow your app to run without the Oculus key.  To get this you need a (free) developer account from Oculus and register your device using this form.  That will generate a file that needs to be copied into your project.

Inside your Unity project, locate the Assets directory and create the following directories Plugins\Android\Assets and copy the signing key in, here is mine:

image

 

Your game should now run just fine on your device.

 

Oculus Utilities for Unity 5

 

The “old” way of supporting GearVR and Oculus Rift in Unity involved importing a set of utilities called the Oculus Utility of Unity 5.  Since these were released however Oculus and Unity have worked to make the integration in Unity more complete.  That said, the transition isn’t complete as of writing.  You still don’t have access to the universal menu or overlays using Unity so you still may have to use the Oculus Utilities.  Fortunately they can still be imported and exist side by side with a default Unity install.

 

In addition to the Oculus Utilities of Unity there is also a set of example projects that you can import.  There is also a guide to Unity 5 integration available on Oculus, although be aware that parts of it are now obsolete.

 

Unity VR Samples

 

There is also a pretty significant set of samples illustrating using VR in Unity available on the Unity Store.  Simply create an empty project and import in the example.  These VR Samples illustrate a number of different concepts required for working with VR in Unity.

 

 

In time, more and more functionality should be built into Unity, making this process even easier.

 

Video Version

Programming ,

30. December 2015

 

GarageGames have just released Torque2D version 3.2.  Torque2D is 2D game engine built over the Torque 3D engine, which is now open source and MIT licensed.

From the release:

While you were singing carols door to door and sipping eggnog by the fireplace, the T2D Steering Committee was hard at work wrapping up one last present! Presenting Torque2D 3.2! This latest incarnation of everybody's favorite 2D engine sports several shiny new features! But before we get into that, let's take a moment of silence to remember the many bugs that lost their lives to make this release possible.


Now then, our first new feature is the FadeTo function. This works like MoveTo except that it changes the blend color over time instead of the position. If you ever wanted to fade a bad guy out when it died or fade a slightly transparent object in, then this function was written for you! It could be used to make your hero flash red when his life is low or slowly change the color of the sky as the sunsets. FadeTo comes with all the support functions of MoveTo including a cancel function and callback when it's finished.


We also added GrowTo which changes the size of an object over time. With GrowTo you can change the x and y at different rates and create all kinds of neat effects. But, there's a catch! Collision shapes don't grow with the sprite. So if your object has collision shapes attached you'll want to use it sparingly. Slight changes can do a lot. Like FadeTo, GrowTo is supported by functions to test and cancel. When an object reaches its target size it will fire a callback.
We also have support now for one way collisions. This is most commonly seen in platformer games when a character jumps up through the platform and magically lands on top of it, but in theory there's many other uses for it. This only works for edge and chain collision shapes.
And finally, last but not least, we have revived ogg! That's right! The open source, compact audio format is back by popular demand. You can start using ogg files again on Windows and Mac OSX.

GameDev News, Programming , ,

30. December 2015

 

This is a tutorial on getting started with Samsung’s GearVRf framework with the Samsung Gear VR.  The GearVR is a virtual reality headset powered by Oculus Rift technology and a modern Samsung android phone.  The GearVRf SDK is a framework made available by Samsung enabling you to develop for the GearVR using Java.  If you are wondering “Hey, can’t you use Unity or Unreal Engine?” yes, yes you can and probably should… but that’s never stopped me from doing things before!

 

First off, there is a guide to getting started available here and it will get you *most* of the way there.  This tutorial covers the missing bits…  There is also a video version available here or embedded below.

 

First off there are a number or pre-requisites before you can begin, you need to have the following installed/configured/registered:

 

The Eclipse requirement is unfortunate, however NDK support was only recently added to Android Studio.  In time expect it to work with Android Studio instead.

 

As part of the installation, make note of where you extract the Oculus SDK.  The Samsung VR SDK has to be installed at the same directory level and I believe requires the folder be named ovr_sdk_mobile.  In other words, if you installed the Oculus Mobile SDK to c:\dev\ovr_sdk_mobile then clone GearVRf to the c:\dev folder. Change into the appropriate folder and run the command:

git clone https://github.com/Samsung/GearVRf.git

This will take a few minutes and download the GearVR SDK.  Now we are ready to start working in Eclipse.  Follow the instructions from Samsung specifically “Build Configuration” to setup Eclipse, then copy the files mentioned in the section “Oculus Mobile SDK”, it’s just 3 jars to 3 different folders that need to be copied.

 

Now we are ready to import the Samsung SDK into Eclipse.  Select File->Import… then Existing Android Code into Workspace.

image

 

Now select the Framework folder ( for example c:\dev\GVRf\Framework if you cloned the sdk into the c:\dev directory ), then click Next.

Go to the menu Project and turn off Build Automatically.  Then in the same menu select Clean… toggle if not already the “Clean all Projects” tick then click OK.  This will now build the SDK.  If you get an error, there is a good chance the your NDK or Android SDK settings in Eclipse are wrong, so start there.

 

Hopefully however everything ran fine.  In which case, let’s start with a sample from the SDK.  In the same workspace you imported and built the framework, import another existing Android project using the same settings, this time importing a project from Sample subdirectory of the GearVRf install folder. 

 

Now that we have a project to run, this next part is CRITICAL or your app will crash on start.  If you haven’t already, go to the Oculus site and register for a signing key ( the link is available above ) and put in the id of your phone.  Instructions are available on the same page as the form on Oculus.  This process will generate and download a file that needs to be included in each application you run.  Simply copy this file into the assets folder of the sample you imported.

 

Now plug in your phone then in Eclipse in Package Explorer, right click the imported demo and select Run As->Android Application. The APK should now be generated and copied to your phone.  However it wont run as you need to insert your device into the GearVR now ( we will address this shortly ).  For now, unplug your phone, run your newly installed app, then insert into the GearVR.  If it loads the main menu, your application crashed.  Ideally your app will now be running. 

 

So that’s it, the steps required to get started with GearVR development using Samsung’s GearVRf SDK.  If you are thinking… Unity/Unreal would be a hell of a lot easier!  You are right… I’ll cover getting started with both of those in the near future.

 

Now that we are running you will quickly notice that putting the device into the GearVR over and over is a pain and requires you to disconnect your device from USB each time making debugging impossible.  Don’t worry, there are two ways around this.

 

Debugging a Samsung Gear VR application

 

Running in Developer Mode ( no headset )

For most builds, you can actually run your code without a device.  This way you can leave it plugged in and remove the time consuming insert in phone and restart process.  First you need to put your phone into developer mode for Oculus.

  • Swipe down and select Settings gear icon
  • Tap Applications
  • Tap Application Manager
  • Locate Gear VR Service, tap
  • Tap Manage Storage
  • Tap VR Service Version Several times
  • Swipe Developer Mode on.  Now you can run without the Rift (great way to record video by the way…)

There is a dedicated post and video on this topic now available here.

 

Debug Wireless

You can also set adb into wireless mode. 

  • On your phone select Settings->Wireless->Click your active connection, make note of your IP address
  • Open a terminal/command prompt and cd into your Android SDK folder\platform-tools
  • Plug in your phone
  • In the terminal/command prompt type adb tcpip 5555
  • Now connect to device wireless with adb connect 123.123.123.123 (<--- obviously, your IP address here)
  • Unplug your device.  At this point you may want to restart Eclipse.
  • Now you can run from Eclipse directly to the device without having to plug in.

 

Video

Programming ,

Month List

Popular Comments