Surface Dial and Surface Studio Demo

Spin that dial right round

I’ve been working on building out a fun way to get invite people to play around with the Surface Studio and the Dial.  A lot of the awesome apps that have integrated Dial support are professional apps, which have a minimal entry level of application knowledge to use it.

That is the purpose of Fluid.  Fluid is effectively a lava lamp experience for the Surface Studio and Surface Dial.

Get Fluid

Whether you have a Surface Studio or not, if you have a Surface Dial you can get the app here [window store pending].  This is also good for people who don’t want to look at the code, and simply want endless hours of the lava lamp experience the Fluid demo is.

How it Works

The Bits

Fluid is made up of a few coponents

  • The Surface Studio and Dial project
  • RadialControllerUnityBridge for UWP
  • Cocuy
  • Be running Windows 10 Creators Update
  • For Surface Dial on screen capabilities, you’ll need a Surface Studio.

Cocuy

Cocuy drives all the fluid simulation.  It’s capable of a lot more than what you see in Fluid, works well out of the box, and performs well also.  You can get Cocuy from the Unity Asset store, and as of writing it’s $35 USD, worth every cent.

RadialControllerUnityBridge for UWP

Unity does not come with out of the box support for Surface Dial on UWP.  The Surface Dial Bridge, or more specifically the RadialControllerUnityBridge, provides the ability to build for Windows.UI.Input.RadialController and hook RadialController events when deploying to UWP.  If you want to start from scratch, I also recommend checking out the RadialControllerUnityBridge project on github, which also comes with demo Unity Project.

Getting Started

If you want to build the project yourself, it is only a couple of steps.  First, clone the source code from the SurfaceStudioAndDial project on github.  Once you have that, you’ll need to purchase Cocuy from the Unity asset store and import it into your project.  I also recommend getting the latest version of the RadialControllerUnityBridge and build the latest version of the plugin DLL’s to ensure you have the latest version.

The Fluid Project

The Files

The folder structure contains a few general folders.  Images, Prefab should be self explanatory.  Scripts contains all the scripts specific to the Fluid application itself, with the most notable being the SurfaceDialManipulator and the TouchManipulator.

The Addons folder contains Cocuy, and also the RadialController scripts from the RadialControllerUnityBridge project.

The plugins folder has a couple of folders underneath.  The Pixelplacement folder is for iTween, which is awesome and I recommend it for any prototyping you do.  Chances are it will always end up in your ffluid_filesinal apps where you don’t need to squeeze performance in your tweens so check it out.  iTween is free and available on the Unity asset store.

The other plugins folder WSA is for Windows Store Application specific plugins.  In this folder is the RadialController bridge plugin specifically for the UWP Build.  It has a placeholder DLL in the root of the Plugins directory which is used at compile time.  If you are building the plugin from source, ensure you copy the DLL’s over to the correct folders.  Additionally, I recommend copying via the file system otherwise you will lose the plugin import settings if you delete/replace in Unity.

The Scene

The scene is very simple, most of the heavy lifting is done by the scripts and Cocuy.  Mouse and Touch is a GameObject containing the scripts for moues and touch input, but does not contain anything to do with the Surface Dial input.  RadialController contains the Surface Dial configuration, and has the event manager that captures all events and triggers them threadsafe on the Unity game loop.  The Surface Dial events control the Particle Emitter GameObject, which has a few colliders attached as children to interact with the emitter when movement occurs.

fluid_scene.PNG
The Fluid Main Scene – Super SImple

Just Hit Build

While you can hit play and have single touch/mouse interaction in the editor, you will not get Surface Dial support in the editor itself.  It’s something I’m working on, but it’s a bit clunky right now.

To test with the Surface Dial you just hit build as a Windows Store application, which generates a UWP project.  Open the UWP project in Visual Studio, and then run it, voila, instant Surface Dial lava lamp.

Some Parting Notes

I’ve noticed at times the DirectX 11 shaders fail, and the liquid/fluid simulator doesn’t work.  Restarting the application makes it work.  This also happens in the Unity edtor, where hitting stop and play again usually fixes it.  It seems to be a problem in Cocuy itself as the demo projects for Cocuy sometimes do it too.

UWP on screen multi-touch tends to slow down the process, especially as you add 5-10 fingers.  I have tweeked and tuned plenty, but this seems to be an issue with UWP tiself, not the Fluid code.  Tuning helped but even with a ball flying around a screen with no fluid simulation, frame rate still drops with fingers on the screen.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s