Torque 3D Now Supports the Razer Hydra Controller

The Razer Hydra Controller and Torque 3D

Razer Hydra Controller Wiki Page

Razer Hydra and Torque 3D Demo Game: Hydra Ryder

Input Handling Changes in Torque 3D

The Future

Back on September 20, 2012, we launched the MIT licensed version of Torque 3D on GitHub . Next on December 19, 2012, we launched the first new release under open source , version 2.0. Then on January 10, 2013, the T3D Steering Committee announced the roadmap for version 3.0 . Within this roadmap was improved support for various input devices to take advantage of current and future controllers that are entering the PC market.The first new input device was the Leap Motion with support added to thebranch as announced in my blog on January 24, 2013 . Today we announce support for another input device, the Razer Hydra controller in Torque 3D’sbranch on GitHub The Razer Hydra controller combines the standard buttons and thumb sticks of a gamepad with motion sensing technology by Sixense to determine the absolute position and rotation of each hand with respect to a base station. If you are not familiar with the Razer Hydra controller you should head over to their site where you may read more about it and watch some videos of the controller in action.Through the Sixense SDK, Torque 3D is able to receive the gamepad and physical input and interpret it as input events that are sent to your game. Most of the game support you will come across for the Razer Hydra does not take full advantage of the controller’s capabilities. Most often the controller is used in an emulation mode to replace some mouse or thumb stick input. However, with Torque 3D, you will be able to take full advantage of the Razer Hydra controller’s unique capabilities.The following types of input events are currently supported:These are all of the thumb stick, trigger and button input events you would expect from a Xbox 360 compatible gamepad controller. Each Razer Hydra handheld controller has a thumb stick, trigger, shoulder button, thumb stick button, start button, and four numbered buttons. Between the two handheld controllers, this is actually more controls than are available on a Xbox 360 controller.This is what makes the Razer Hydra unique. Each handheld controller reports its absolute position (in millimeters) and rotation with respect to the Hydra’s base unit. Torque 3D receives this information and passes it onto your application.Because the position input events are all relative to the base station, you will often need to come up with a scheme to determine where the user’s neutral, or starting position is. You could assume that the base station is always front and center of the user at a required distance, but from my experience this is often not the case. For example, I usually have the base station sit to the left of my keyboard because of how my desk is arranged.Based on the values returned by the Leap Sixense SDK, Torque 3D can interpret the rotation of a handheld controller as if it were a gamepad thumb stick. Imagine that a stick is coming out of the top of the handheld controller and as you tilt your hand, you are moving this stick. This also takes advantage of Torque 3D’s action mapping system including being able to define dead zones. This adds another level of control over your application without needing to worry about dealing with the absolute position and rotation values. You could, for example, move the player around in one of Torque 3D’s standard templates by using these events.With your application it is possible that the above input events don’t fit in with how you would like to use the Razer Hydra controller. In this case, Torque 3D provides a single input event each time it reads a frame from the Razer Hydra. This frame is presented as a special SimObject (theclass) with the frame’s properties accessible using TorqueScript methods. These frames are automatically stored on theSimGroup so a short history may be accessed at any time (and old frames are recycled to become new frames).All of this information and more in now available on the Razer Hydra Wiki Page on GitHub. This includes a more thorough description of these input events, how to best use them, as well as how to add Razer Hydra support to your own Torque 3D project.To help demonstrate using the Razer Hydra controller and Torque 3D, I have created a small, example game called. In this game you dual wieldpistols to fire at various targets on a gun range.When you first start a game session you are asked to calibrate your Razer Hydra controllers. This is so Torque 3D knows where your shoulders are, and can therefore correctly calculate your arm and hand positions within the game. I tried a number of different schemes and found it best to just ask the player to hold their controllers up to their shoulders and press a trigger.With the calibration complete, you are taken to the firing range and may use either or both pistols to try and hit the various targets. The demo makes use of thephysics engine for some of the interactions.Thedemo is available for anyone to try out, although you will need a Razer Hydra controller to take advantage of it. Download the demo here:Just unzip the package and launch the executable. Be sure to have your Razer Hydra controller plugged into your machine before starting the demo game.Thedemo game makes use of the newclass that is available in thebranch. This class was first introduced with thedemo game for the Leap Motion as talked about here . In this case, theclass is used to handle the game’s state machine from startup, to calibration, to when actually in the game.To allow for complete control over the player’s hand position and rotation I created a newderived class called. This new class serves a couple of purposes. The first is to work with theclass that is available in thebranch and was first discussed on my Leap Motion blog (although it was never actually used there). Theclass allows us to process absolute position and rotation changes on both the client and server, and is processed in. There I store the given position and rotation values as player wrist position and rotation.The second purpose of theclass is to take a special skeleton model that includes shoulder and wrist nodes (along with an eye node and mount points) and manually take control of the wrist nodes to transform them to match the user’s movements. Theclass automatically adjusts a weapon’s targeting when in first person to fire where the player is looking, so I also needed to decouple this so that wherever the user points their hands is where the mounted pistol would fire.I have also made theclass fully networkable, so you could, in theory, have multiple players using their Razer Hydra controllers to shoot at targets.In order to match the user’s movements to that of the player’s skeleton I had to first take the user through a calibration stage. During calibration the user is indicating both the physical position of their shoulders relative to the Hydra base station, as well as the width of their shoulders. I then subtract this known starting position from all future position input events and use this new relative position to move the player skeleton’s wrist nodes with respect to the skeleton’s shoulder nodes. And knowing the user’s shoulder width allows me to scale the user’s movements to match the size of the player’s skeleton. I’ve successfully had my four year old shooting at targets using the Razer Hydra controllers and the pistols always remain within the expected view.In order to provide you with access to myclass I have set up thedemo with its own repository: Torque3D-HydraRyder . This only includes theproject with its source, script and art files, but you could drop it into thedirectory of a standard Torque 3D repository clone and recompile it there. Be sure that you are building off of thebranch to gain access to the Razer Hydra input files.In order to support the Razer Hydra controller a number of changes were required to how Torque 3D handles its input devices. Fortunately, all of this work was already done to support the Leap Motion. You may read about the various input device and event changes at the bottom of my Leap Motion blog These are just the first steps at supporting the Razer Hydra controller. Any community input would be much appreciated.- Dave