Game Development Community

dev|Pro Game Development Curriculum

Use Your 3dConnexion Controller in T3D/GEA/GE

by Sean Rice · 04/22/2010 (8:52 am) · 6 comments

This will show you the steps required to install and utilize the 3DConnexion controller inside of T3D. I have made the sensitivity on the yaw and pitch pretty high, since I don't want the ultra sensitive device to look up or down unless I have applied some extra effort.

NOTE: The information provided between the ---> <--- may or may not work. So far two users have noticed issues with running this and affecting startup. I was not successful in getting this method to work on either Windows 7 64 or 32 bit. This is provided as a method to get the device to work; however, I am using the alternative method below and am providing scripts for that method. You may use the link provided for a detailed 48 page recently updated thread about the subject.

--->
Windows 2000, XP or Vista Users can download and install the following
www.omniflux.com/devel (look at the bottom of the page for the RBC9 driver for your architecture) and setup the system using the RBC9 driver with gui functions. Information on how to install this can be found in the 3dConnexion forums here www.3dconnexion.com/forum/viewtopic.php?t=336

Windows 7 64 Users should use the following unless they can get the above to work by self signing drivers (I will not support this effort).

<---

glovepie.org/glovepie_download.php

Currently the following glovePIE (this one is for the SpacePilot) script will function for the proper controls of:

3dConnexion Modes toggled by Button 6 (or another)
Game Mode, up/down/move left/move right/turn left/turn right/look around/jump/duck
Oberver Mode, up/down/move left/move right/turn left/turn right/look around/move up/move down
Editor Mode, up/down//move left/move right/turn left/turn right/look around/move up/move down
Object Mode, up/down/left/right/move up/move down on axis controls


Key 1 = Start recording
Key 2 = Stop recording
Key 3 = Restart level
Key 4 = Gui Editor
Key 5 = Mission Editor
Key 6 = change Control Mode Game/Editor/Object
T = 1
R = 2
L = 3
F = 4
Fit = 5

I have made several changes to the original post, since the previous code is embedded and superseded by the one below, I have simply removed it to avoid any confusion. You now only need to map the up/down buttons to move the camera in 3d space correctly. All other functions are working correctly, it may take some getting used to.



// Glovepie script for 3dConnexion Device for Torque 3d by Sean Rice v2.6

if( starting ) {
    // Application name
    var.AppName = "Torque 3D 2009"

    // Dead range [-dead .. dead]
    var.dead = 2

    // Multipliers for each function
    var.move_mult = 0.0005
    var.zoom_mult = 0.0001
    var.objmove_mult = 0.00005
    var.objzoom_mult = 0.00001
    var.rot_mult = 0.000005
    var.objrot_mult = 0.00000001

    // Variables to initialize
    var.mode = 0
    var.prev_mode = 0
    var.reset = false
    var.editor = 0
}

// Read in the mouse position if we're not using the space navigator
if( var.mode == 0 ) {
    var.orig_x = Mouse.VirtualDesktopX
    var.orig_y = Mouse.VirtualDesktopY
}

// Get all the values with dead zones
   var.x=     DeadZone( SpaceBall.x,     var.dead )
   var.y=     DeadZone( SpaceBall.y,     var.dead )
   var.z=     DeadZone( SpaceBall.z,     var.dead )
   var.pitch= DeadZone( SpaceBall.pitch, var.dead )
   var.yaw =  DeadZone( SpaceBall.yaw,   var.dead )
   var.roll = DeadZone( SpaceBall.roll,  var.dead )




// Reset the variables
   var.max = 0;
   var.mode = 0;

// Work out the dominant axis
if( Window.AppName == var.AppName ) {

    // Move mode axes
    if( Abs(var.x) > var.max ) {
        var.mode = 1;
        var.max = (var.x);
    }
    if( Abs(var.z) > var.max ) {
        var.mode = 1;
        var.max = Abs(var.z);
    }

    // Up/Down mode axes
    if( Abs(var.y) > var.max ) {
        var.mode = 2;
        var.max = Abs(var.y);
    }

    // Rotate mode axes
    if( Abs(var.yaw) > var.max ) {
        var.mode = 3;
        var.max = Abs(var.yaw);
    }
    if( Abs(var.pitch) > var.max ) {
        var.mode = 3;
        var.max = Abs(var.pitch);
    }

}
//DebugPrint var.mode ;


 if  (Pressed(SpaceBall.Button6 )) {
     //wait 3 seconds ; // pause for 5 seconds to allow gui change then process the commands
         if (var.editor == 0 ) {
         var.editor = 1 ;
         speech.text = &ldquo;Observer Mode&rdquo;
         //DebugPrint var.editor  && " value 1 ";
         } else if (var.editor == 1 ) {
         var.editor = 2 ;
         speech.text = &ldquo;Editor Mode&rdquo;
         //DebugPrint var.editor  && " value 2 ";
         } else if (var.editor == 2 ) {
         var.editor = 3 ;
         speech.text = &ldquo;Object Mode&rdquo;
         //DebugPrint var.editor && " value 3 " ;
         } else {
         var.editor = 0 ;
         speech.text = &ldquo;Game Mode&rdquo;
         //DebugPrint var.editor && " value 0 " ;
         }
}

// If we change modes, disable all buttons
if( var.mode != var.prev_mode || var.reset ) {
    // Handle the keys/moust buttons for all the modes
    if( var.prev_mode == 1 ) {
        Mouse.RightButton = 0
    } else if( var.prev_mode == 1 ) { //
       Mouse.RightButton = 0
    } else if( var.prev_mode == 2 ) { //
        Mouse.RightButton = 0
    } else if( var.prev_mode == 3 ) { //
        Mouse.RightButton = 0
    }

    // We are coming from a 3D mode, let off alt and re-allow mouse events
    //if( var.prev_mode > 0 && not var.reset ) {
     //   Key.Alt = 0
    //    Mouse.Swallow = false
    //}

    Wait( 2ms )

    if( var.mode == 0 ) {
        Key.e = (0)     ;
        Key.c = (0);
        Key.up = (0) ;
        Key.down = (0) ;
        Key.right = (0) ;
        Key.left = (0) ;
        Key.space = (0) ;
        Key.x = (0) ;
        // Reset the mouse to it's original spot
        //Mouse.VirtualDesktopX = var.orig_x
        //Mouse.VirtualDesktopY = var.orig_y
    } else {
        // Reset mouse to center
        //Mouse.CursorPosX = Window.Left + Window.Width / 2
        //Mouse.CursorPosY = Window.Top + Window.Height / 2
    }

    Wait( 2ms )

    // We are moving to a 3D mode hold down alt and swallow all mouse events
    //if( var.mode > 0 && not var.rPIEeset ) {
    //    Mouse.Swallow = false
    //    Key.Alt = 1
    //}

    // Handle the keys/moust buttons for all the modes
    if( var.mode == 0 ) {
        Mouse.RightButton = 0
    } else if( var.mode == 1 && var.editor == 0 ) {//
        Mouse.RightButton = 0
    } else if( var.mode == 2 && var.editor == 0 ) { //
        Mouse.RightButton = 0
    } else if( var.mode == 3 && var.editor == 0 ) { //
        Mouse.RightButton = 0
    } else if( var.mode == 3 && var.editor == 1 ) { //
        Mouse.RightButton = 0
    } else if( var.mode == 3 && var.editor == 2 ) { //
        Mouse.RightButton = 1
    } else if( var.mode == 1 && var.editor == 3 ) { //
        Mouse.LeftButton = 1
    } else if( var.mode == 2 && var.editor == 3 ) { //
        Mouse.LeftButton = 1
}

    Wait( 2ms )
    var.reset = false
}
   // if( Mouse.LeftButton = 1 ) { //
    //   var.mode = 4
} 
//debugprint     var.editor ;

     
if( var.mode == 1 && var.editor == 0 ) { // Move Normal Mode
    //Mouse.VirtualDesktopX += (var.x * var.move_mult)
    //Mouse.VirtualDesktopY += (var.z * var.move_mult)
    Key.up = (SpaceBall.z > 0.97) ;
    Key.down = (SpaceBall.z < -0.97) ;
    Key.right = (SpaceBall.x > 0.97) ;
    Key.left = (SpaceBall.x < -0.97) ;

} else if( var.mode == 1 && var.editor == 1 ) { // Observer Normal Mode
    //Mouse.VirtualDesktopX += (var.x * var.move_mult)
    //Mouse.VirtualDesktopY += (var.z * var.move_mult)
    Key.up = (SpaceBall.z > 0.97) ;
    Key.down = (SpaceBall.z < -0.97) ;
    Key.right = (SpaceBall.x > 0.97) ;
    Key.left = (SpaceBall.x < -0.97) ;

} else if( var.mode == 1 && var.editor == 2 ) { // Editor Mode
    //Mouse.VirtualDesktopX += (var.x * var.move_mult)
    //Mouse.VirtualDesktopY += (var.z * var.move_mult)
    Key.up = (SpaceBall.z > 0.97) ;
    Key.down = (SpaceBall.z < -0.97) ;
    Key.right = (SpaceBall.x > 0.97) ;
    Key.left = (SpaceBall.x < -0.97) ;

} else if( var.mode == 1 && var.editor == 3 ) { // Object Edit Mode
    Mouse.RightButton = 0
    //Mouse.VirtualDesktopX -= (var.yaw * var.rot_mult)
    //Mouse.VirtualDesktopY += (var.pitch * var.rot_mult)
    Mouse.VirtualDesktopX += (var.x * var.objmove_mult)
    Mouse.VirtualDesktopY += (var.z * var.objmove_mult)

} else if( var.mode == 2 && var.editor == 0 ) { // Up and Down Normal Mode
    //Mouse.VirtualDesktopX += (var.y * var.zoom_mult)
    Key.space = (SpaceBall.y > 0.97) ;
    Key.x = (SpaceBall.y < -0.97) ;

} else if( var.mode == 2 && var.editor == 1 ) { // Up and Down Observer Mode
    //Mouse.VirtualDesktopX += (var.y * var.zoom_mult)
    Key.e = (SpaceBall.y > 0.97) ;
    Key.c = (SpaceBall.y < -0.97) ;

} else if( var.mode == 2 && var.editor == 2 ) { // Up and Down Editor Mode
    //Mouse.VirtualDesktopX += (var.y * var.zoom_mult)
    Key.e = (SpaceBall.y > 0.97) ;
    Key.c = (SpaceBall.y < -0.97) ;

} else if( var.mode == 2 && var.editor == 3 ) { // Up and Down Object Mode
    Mouse.RightButton = 0
    //Mouse.VirtualDesktopX -= (var.yaw * var.rot_mult)
    //Mouse.VirtualDesktopY += (var.pitch * var.rot_mult)
    Mouse.VirtualDesktopY += (var.y * var.objzoom_mult)

} else if ( var.mode == 3  && var.editor == 0 ) { // Look Around Game  Mode
    Mouse.VirtualDesktopX -= (var.yaw * var.rot_mult)
    Mouse.VirtualDesktopY += (var.pitch * var.rot_mult)

} else if ( var.mode == 3  && var.editor == 1 ) { // Look Around Observer Mode
    Mouse.VirtualDesktopX -= (var.yaw * var.rot_mult)
    Mouse.VirtualDesktopY += (var.pitch * var.rot_mult)

} else if( var.mode == 3 && var.editor == 2 ) { // Look Around Editor Mode
    //Mouse.RightButton = 0
    Mouse.VirtualDesktopX -= (var.yaw * var.rot_mult)
    Mouse.VirtualDesktopY += (var.pitch * var.rot_mult)
    Key.e = (0)     ;
    Key.c = (0);
    Key.up = (0) ;
    Key.down = (0) ;
    Key.right = (0) ;
    Key.left = (0) ;
}
}

// If we're at the edges, reset the mouse (as long as we're not mode 0)
if( var.mode != 0 && ( Mouse.VirtualDesktopX == 0 || Mouse.VirtualDesktopX == 1 || Mouse.VirtualDesktopY == 0 || Mouse.VirtualDesktopY == 1 ) ) {
    var.reset = true
}



// Store the mode for comparison
var.prev_mode = var.mode

Key.F3 = SpaceBall.Button1 ;
Key.F4 = SpaceBall.Button2 ;
Key.F7 = SpaceBall.Button3 ;
Key.F10 = SpaceBall.Button4 ;
Key.F11 = SpaceBall.Button5 ;

Key.1 = SpaceBall.Button7 ;
Key.2 = SpaceBall.Button8 ;
Key.3 = SpaceBall.Button9 ;
Key.4 = SpaceBall.Button10 ;
Key.5 = SpaceBall.Fit ;

#1
04/22/2010 (11:54 am)
Much more advanced script with full control over directionals, turning, up down, button controls from above.

Code obsolete and superseded by above code, to avoid confusion it was removed.
#2
04/22/2010 (12:18 pm)
Something interesting of note, when holding your rotational axis on an object, you can now use the 3dConnexion to rotate your object with precision. You can play with this field below to adjust the amount of rotational force you can apply with the rotation. At the value below the movement is decently fast, adjust it to 0.0000001 and you can get within .001 degrees of where you want the object for pristine object placement.

var.rot_mult = 0.000005
#3
04/22/2010 (7:15 pm)
Very cool of you to post this. Haven't tried it yet, but thanks in advance!

Oh, and as a warning to others... the RBC9 drivers would hang my computer in a perpetual startup cycle if I had anything laying against it or on top of it. Just unplug the device to get the computer to start.
#4
04/22/2010 (7:47 pm)
Updated the top post with a new script that offers several modes. The current issue is that the Torque engine offers multiple control methods. Mouse control out of the gui, Right Click with mouse control in and moving/rotation of files. Since the the application doesn't change the Window name when switching to editing mode we do not have a way of switching automatically. To counteract this I created a function to allow mode switching. You also do not need to map the turn right/left keys anymore, just the up/down keys.

In order for the script to work correctly, you must assign (or change) button6 to be... button6 and not translations map. Mode 0 (normal open mode) allows control of the game from within the standard mode. Mode 1 allows control in the World Editor by use of the right mouse button, Mode 2 allows some control over the objects in game. In this mode you can place the mouse cursor over the movement/rotation/scale axis and push/pull/rotate. It will then "lock" to the object on that axis and allow you to manipulate it. Left click to "unlock" the mouse from the object. You can also do this in Mode 0 as well by holding the left mouse button down to lock on the axis. Unfortunately you can only lock onto this specific Axis; although, you can lock onto the merged Axi point and control the object in 3D space with the 3DConnexion.

Speed is controlled via these outputs, var.obj* are specifically for object manipulation and may need to be tweaked for your setup/likings. These should be placed on the slowest speed that actually produces movement, yet anything slower stops movement (or close to!). The reason is that your going to most likely use the mouse to move the object relatively close to the correct location prior to using the 3DConnexion for final placement/manipulation.

var.move_mult = 0.0005  
    var.zoom_mult = 0.0001  
    var.objmove_mult = 0.00005  
    var.objzoom_mult = 0.00001  
    var.rot_mult = 0.000005  
    var.objrot_mult = 0.00000001
#5
04/22/2010 (7:52 pm)
@Jameson, I have tried the RBC9 drivers now on 32bit and 64bit windows 7 and have yet to have any success with them. I found that the driver BSODed my laptop upon installation the first time and complained that the driver couldn't start until I unplugged the device. I also noticed that my laptop hung on startup if it was plugged in. I offered it since it seemed more of a "supported" app from 3DConnexion then the GlovePIE.

So far, other then GlovePIE locking up during initial script creation I have yet had it to fail me. It's also nice that it is just a program that I can close anytime I like.



Shut down GlovePIE from the keyboard hold and type (Shift PIE).
#6
04/22/2010 (9:32 pm)
Additional changes to the top post, I added an additional mode, Observer Mode and a mode change announcement. You should hear a voice announce the various modes as you select them, this way your more sure of the selected mode. I am looking into seeing if I can adjust the LED on the 3DConnexion for those who have it to display the corresponding mode.

Game Mode (normal)
Observer Mode
Editor Mode
Object Mode (somewhat wanky at the moment, cursor needs to be right on the objects Axis to work correctly)