12 November 2015

Using the Xbox 360 Scene it controllers in Unity3d

Today, as a proof of concept I adapted the Xbox 360 Scene it controller code that I had previously written to act as an input controller for my recently completed Unity3d Space Shooter game.

The Space Shooter game is nothing special, it is the result of going through the beginner tutorial on the Unity website.

It took me a good while to figure out how to hack the code I wrote into the Unity system. Keep in mind that this is just a hack and a more robust solution is needed for a production ready system.

Here is the link to the original project. I have updated it so that it is now fully compatible with Unity3d.

Changes

For some strange reason the Unity system did not like me using asynchronous reading from the USB device. The code just hung there on BeginRead and never got anything back from the device. I had to change the code to do a direct synchronous read from the USB device to get the code working properly in Unity.

I had to make the following changes to my PlayerController class to read the Xbox 360 Big Button Controller successfully

Limitations

The input code is dependent on the Update loop which makes it vulnerable to frame-rate drops and performance issues. Also it is likely that any issues with the controller code will significantly impact the performance of the game.

I ended up using the Loom technique to ensure that all updates coming from the USB device would be marshaled correctly to the main Unity thread.

For performance and speed reasons I ended up using a simple array to hold the state of the pressed buttons in each loop and using simple bit operations to read and unset the values (private Buttons[] _state = new Buttons[4];). This makes the code a little hard to read for beginners but don't worry the techniques really are quite naive.

There is no easing when dealing with the Axis values (movement). This means that all movements coming in from the Big Button Controllers will be in discreet steps and not show a nice smoothed motion like the keyboard buttons and other controllers will.

I will have to incorporate this code into a custom Input Manager to actually make this code robust enough to use in non-trivial situations. Currently I have no idea how to achieve this though.

The full Unity script

I simply attached the script to the GameController object like so


26 August 2015

Update #4 Google Maps Directions to GPX data w/elevation data

The  Google Maps Directions to GPX tool now has support for elevation data for each route/track point.

Try it here

Elevation Notes

The tool relies on the Google Elevation API for elevation information.

This data is obtained by sampling along the given path, which in this case will be the start and end point of your directions.

Due to restrictions in the Google Elevation API, rather than return elevation data at each route point along the path, I had to implement the tool to request elevation by sampling along the length of the path. The number of samples requested is equal to the number of route points. Due to the fact that the path is sampled along the surface of the earth the accuracy of this elevation data might have a high degree of in-accuracy.

25 August 2015

Update #3 to Google Maps Directions to GPX data

ようこそいらっしゃいました。
(Welcome in Japanese)!

The Google Maps Directions to GPX now has support for all available languages in Google Maps. What this means is that you can get directions and next turn information in other languages than English.

Update #3 is now live but I am still working on providing accurate "next-turn" information for non-English languages. This will be available shortly.

Try it now


Are you interested in the development of this tool? Here are the previous posts: Original post, Update #1Update #2Update #3, Update #4.

20 August 2015

Integrating Social Media Markup into Google Blogger Templates

The Google Blogger.com template system is flexible and somewhat programmable. However getting to learn its idiosyncrasies and mastering the template language it are close to impossible.

I wanted to integrate Google+, Facebook, Twitter and Pinterest sharing markup into my template. It took me the better part of a day to battle it and force all the relevant data to show up where I liked it to.

To save you the same headache I want to share with you how to do it. Below is a link to a how-to document I put up on GitHub that describes what needs to be done:

View on GitHub

Validators

18 August 2015

Update #2 to Google Maps Directions to GPX data

I've applied several major updates to the tool discussed in this article. Update #1Update #2Update #3, Update #4 and Original post.

The Google Maps Directions to GPX has received its second update.

Try it

Change log

  • Support for short urls (e.g. "goo.gl/maps/..." links).
  • Support for multi destination directions.
  • Waypoints will now get a full address into their <desc> field if available.
  • Option to exclude creation of waypoints (external to the route).
  • Option to provide a custom name for the route.
  • Improved error handling and validation of Google Maps links.
  • Addressing an issue where if URL is missing sections the Google service will estimate the destination (this will most likely cause an incorrect route to be generated).


Changes to JSON output only 

These have not yet been integrated into the GPX format.
  • Inclusion of Google StreetView imagery where available.
  • Preliminary support for elevation profile data (only for walking and cycling directions).
  • Turn information available in markup format ("step" field).
  • List of all countries the route passes through.
  • List of all destinations in route (in addition to start and finish).

Try it


Map Link with Multi Destination Directions

Map Link with Cycling Directions (will have elevation data)

16 August 2015

Update #1 to Google Maps Directions to GPX data

I've applied several major updates to the tool discussed in this article. Update #1Update #2Update #3, Update #4 and Original post.

In a previous post I shared an experimental tool that I had been tinkering with that converts Google directions to GPX format.

After quite a few interesting suggestions and discussions with readers I want to present Update #1 to this tool.

Try it


Major changes

  1. New and more user friendly UI with error checking.
  2. More control over output format and output file types (the tool now defaults to generating a file that has the broadest compatibility with the GPX standard).
  3. Auto-generation of unique route point names (format "RPxxx").
  4. Option to include the full direction text with each route point in the <desc> field.
  5. Option to include a brief next turn information with each route point in the <cmt> field.
  6. Optional JSON response for future web-development
The new UI with all options

Try it