We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexDiscussionExhibition › 3DConnexion SpaceNavigator at work
Pages: 1 2 
3DConnexion SpaceNavigator at work (Read 6789 times)
3DConnexion SpaceNavigator at work
Jan 27th, 2008, 9:19pm
 
This demonstrates the 3D input device.

Tranlation an rotation is fetched from the SpaceNavigator.
The mouse is still available.
Button1, button2 or both are visualized by the cube's color.

The original device driver must be installed.
http://www.3dconnexion.de/

The device is interfaced by the procontroll library (HID support) which must be installed.
http://www.texone.org/procontroll/

have fun
rl

Code:

import procontroll.*; //based on JInput (HID Suport)

//3DConnexion SpaceNavigator Demo for rotation, translation and buttons
//Device must be correctly installed
//procontroll must be installed

//Ralf Löhmer - rl@loehmer.de

ControllIO controll;
ControllDevice device;     //my SpaceNavigator
ControllSlider sliderXpos; //Positions
ControllSlider sliderYpos;
ControllSlider sliderZpos;
ControllSlider sliderXrot; //Rotations
ControllSlider sliderYrot;
ControllSlider sliderZrot;
ControllButton button1;    //Buttons
ControllButton button2;

void setup(){
 size(400,400,P3D);
 colorMode(RGB);

 controll = ControllIO.getInstance(this);
 device = controll.getDevice("SpaceNavigator");//magic name
 device.setTolerance(5.00f);
 
 sliderXpos = device.getSlider("X-Achse");//German in all drivers???
 sliderYpos = device.getSlider("Y-Achse");
 sliderZpos = device.getSlider("Z-Achse");
 sliderXrot = device.getSlider("X-Rotation");
 sliderYrot = device.getSlider("Y-Rotation");
 sliderZrot = device.getSlider("Z-Rotation");
 button1 = device.getButton("Taste 0");
 button2 = device.getButton("Taste 1");
 sliderXpos.setMultiplier(0.01); //sensitivities
 sliderYpos.setMultiplier(0.01);
 sliderZpos.setMultiplier(0.01);
 sliderXrot.setMultiplier(0.0001);
 sliderYrot.setMultiplier(0.0001);
 sliderZrot.setMultiplier(0.0001);

 rectMode(CENTER);
}

float totalX = 0;  //inits
float totalY = 0;
float totalZ = 0;
float totalXrot = 0;
float totalYrot = 0;
float totalZrot = 0;

void draw(){
background(33,170,170);  
totalX = constrain(totalX + sliderXpos.getValue(),10,width-10);
totalY = constrain(totalY + sliderYpos.getValue(),10,height-10);
totalZ = constrain(totalZ + sliderZpos.getValue(),-500,210);
totalXrot = constrain(totalXrot + sliderXrot.getValue(),0,TWO_PI);
totalYrot = constrain(totalYrot + sliderYrot.getValue(),0,TWO_PI);
totalZrot = constrain(totalZrot + sliderZrot.getValue(),0,TWO_PI);

 if(button1.pressed() && button2.pressed()){ //shows the buttons pressed
    fill(255,0,0);
 }else
 if(button2.pressed()){
    fill(0,255,0);
 }else
 if(button1.pressed()){
    fill(0,0,255);
 }else{
    fill(255,255,255);
 }  

lights();
translate(totalX,totalY,totalZ);
rotateX(totalXrot);
rotateY(totalYrot);
rotateZ(totalZrot);
noStroke();
box(90);
stroke (255,0,0);//X
line(-100, 0, 0, 100, 0, 0);
stroke (0,255,0);//Y
line(0, -100, 0, 0, 100, 0);
stroke (0,0,255);//Z
line(0, 0, -100, 0, 0, 100);
}
Re: 3DConnexion SpaceNavigator at work
Reply #1 - Mar 9th, 2008, 7:53pm
 
WOW thanks for the sample code.  The prospect of being able to use my SpaceNavigator in processing is awesome.  Unfortunately i couldn't get it to work.  I keep getting a Null Pointer Error.  I know my drivers are installed correctly and i even reinstalled them just in case. I downloaded the procontroll library and extracted it to my libraries folder in processing.  I was able to run one of the examples provided and got a complete listing of devices and inputs including my Spacenavigator and Wacom tablet.  Whenever i try to make a call to Something.getvalue(); i recieve a Null pointer error.  I'm pretty sure it has to do something with the library path not being correct, Any ideas?

-stephen



Re: 3DConnexion SpaceNavigator at work
Reply #2 - Mar 9th, 2008, 10:56pm
 
Ok well i figured out what the problem was.  Processing was having problems figuring out which inputs where assigned to the controllers.  So what i did was change the text descriptions to there numerical equivalents.  For example:

sliderXpos = device.getSlider("Y-Achse");
sliderYpos = device.getSlider("X-Achse");

Was changed to:

sliderXpos = device.getSlider(0);
sliderYpos = device.getSlider(1);

Now processing knows where to look instead of returning A Null pointer exception.  You can get a listing of slider numbers buttons etc with:

device.printSliders();
device.printButtons();
device.printSticks();
Re: 3DConnexion SpaceNavigator at work
Reply #3 - Mar 11th, 2008, 7:35pm
 
Hallo sgsrules,

I was in doubt myself, whether the German expressions will work for other languages in the driver.

There is a test-program in:
..\libraries\procontroll\examples\procontroll_printDevices

procontroll_printDevices.pde

This will give lots of info for HID-Devices on your computer.

Interesting is the devicename - "SpaceNavigator" for this device.
But this will work for other 6DOF-devices as well, you only need to change the relevant name.;-)

Then you can use your slider-names.

The output of procontroll_printDevices.pde in my case:

<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
SpaceNavigator has:
6 sliders
2 buttons
3 sticks

<<< available SpaceNavigator sliders: >>>

    0: Z-Achse relative
    1: Y-Achse relative
    2: X-Achse relative
    3: Z-Rotation relative
    4: Y-Rotation relative
    5: X-Rotation relative

<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

<<< available SpaceNavigator buttons: >>>

    0: Taste 0
    1: Taste 1

<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

<<< available SpaceNavigator sticks: >>>

    0: Y-Achse Z-Achse
    1: Z-Rotation X-Achse
    2: X-Rotation Y-Rotation

<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

have fun
rl
Re: 3DConnexion SpaceNavigator at work
Reply #4 - Mar 12th, 2008, 7:53am
 
Once again thanks for all the great info.  I went ahead and made a few changes to the code and decided to post them in case anyone was interested.  First i changed the id tags to their numerical equivalent, that way it works with drivers in all languages.  And second i took off the constraints on the axis, hitting an invisible barrier when you're rotating is a bit annoying.

import procontroll.*;
import net.java.games.input.*;


//3DConnexion SpaceNavigator Demo for rotation, translation and buttons
//Device must be correctly installed
//procontroll must be installed

//Ralf Löhmer - rl@loehmer.de

ControllIO controll;
ControllDevice device;     //my SpaceNavigator
ControllSlider sliderXpos; //Positions
ControllSlider sliderYpos;
ControllSlider sliderZpos;
ControllSlider sliderXrot; //Rotations
ControllSlider sliderYrot;
ControllSlider sliderZrot;
ControllButton button1;    //Buttons
ControllButton button2;

void setup(){
 size(400,400,P3D);
 colorMode(RGB);

 controll = ControllIO.getInstance(this);
 device = controll.getDevice("SpaceNavigator");//magic name
 device.setTolerance(5.00f);
 
 sliderXpos = device.getSlider(2);
 sliderYpos = device.getSlider(1);
 sliderZpos = device.getSlider(0);
 sliderXrot = device.getSlider(5);
 sliderYrot = device.getSlider(4);
 sliderZrot = device.getSlider(3);
 button1 = device.getButton(0);
 button2 = device.getButton(1);
 sliderXpos.setMultiplier(0.01); //sensitivities
 sliderYpos.setMultiplier(0.01);
 sliderZpos.setMultiplier(0.01);
 sliderXrot.setMultiplier(0.0001);
 sliderYrot.setMultiplier(0.0001);
 sliderZrot.setMultiplier(0.0001);

 rectMode(CENTER);
}

float totalX = 0;  //inits
float totalY = 0;
float totalZ = 0;
float totalXrot = 0;
float totalYrot = 0;
float totalZrot = 0;

void draw(){
background(33,170,170);  
totalX = totalX + sliderXpos.getValue();
totalY = totalY + sliderYpos.getValue();
totalZ = totalZ + sliderZpos.getValue();  
totalXrot = totalXrot + sliderXrot.getValue();
totalYrot = totalYrot + sliderYrot.getValue();
totalZrot = totalZrot + sliderZrot.getValue();

 if(button1.pressed() && button2.pressed()){ //shows the buttons pressed
    fill(255,0,0);
 }else
 if(button2.pressed()){
    fill(0,255,0);
 }else
 if(button1.pressed()){
    fill(0,0,255);
 }else{
    fill(255,255,255);
 }  

lights();
translate(totalX,totalY,totalZ);
rotateX(totalXrot);
rotateY(totalYrot);
rotateZ(totalZrot);
noStroke();
box(90);
stroke (255,0,0);//X
line(-100, 0, 0, 100, 0, 0);
stroke (0,255,0);//Y
line(0, -100, 0, 0, 100, 0);
stroke (0,0,255);//Z
line(0, 0, -100, 0, 0, 100);
}


Re: 3DConnexion SpaceNavigator at work
Reply #5 - Mar 15th, 2008, 5:43pm
 
I'm on OS X 10.5.2(PPPC - Leopard) and I can't get the SpaceNavigator to show up as an HID device. I've tried the procontroll_printDevices applet, but only the trackpad and the keyboard shows up as available devices. Funny thing is that SpaceNavigator shows up as HID devices in both Max/MSP and SuperCollider, but not in Processing.
I've tried both installing and unistalling the 3dConnexion driver, but nothing I've tried yet has worked so far. Anyone else had these problems?
Could this be a problem with the procontroll libray?

Re: 3DConnexion SpaceNavigator at work
Reply #6 - Mar 16th, 2008, 10:02am
 
Hallo blekesaune,

I do not have a MAC to test.

Take a look at:
http://www.3dconnexion.com/forum/index.php?language=german

MAC OS Discussion Forum

There are already lots of info and I found that their staff very quickly answer the upcoming questions.

rl
Re: 3DConnexion SpaceNavigator at work
Reply #7 - Mar 16th, 2008, 9:38pm
 
blekesaune, Try plugging the unit into a different usb port, i'm not really a mac user but this sometimes works on pcs.  Try to see if you can get procontroll working with  your trackpad, if it doesn't work then it's not installed properly.  If it does work try forcing procontroll into using the spacenavigator by using a number lookup like:

device = controll.getDevice(0);
or
device = controll.getDevice(1);

And if all else fails you could always use max/msp to import the controller data into processing using the max to processing libraries.  here's a link:

http://jklabs.net/maxlink/
Re: 3DConnexion SpaceNavigator at work
Reply #8 - Apr 8th, 2008, 11:54pm
 
Hi - I have the same set-up as blekesaune - Mac OS 10.5.2 (PPC) and I get a no show for the SpaceNavigator too - tried my other USB socket as suggested

Very grateful for any thoughts

Many thanks,
Dave
Re: 3DConnexion SpaceNavigator at work
Reply #9 - Jun 15th, 2008, 4:57am
 
great work! - if anyone's ever used the SpaceNavigator with Google Earth or Google Sketchup (or any other 3D program at all) they'll know how wonderful it is to manipulate objects in 3D - I'm sure many people appreciate this work! =]
Re: 3DConnexion SpaceNavigator at work
Reply #10 - Aug 24th, 2008, 10:47am
 
I am having difficulties as well to find the controller with procontroll under OSX 10.5.4, while HID Explorer shows the Spacenavigator perfectly and permits interaction. So any hint or testimonial of using the spacenavigator successfully under OSX would be welcome!

And by the way: The spacenavigator works great with processing on my PC and XP.
Re: 3DConnexion SpaceNavigator at work
Reply #11 - Oct 14th, 2008, 6:29pm
 
I use ControllerMate with ProConroll for Mac support. Works like a charm if set up right. However, I tried to get my SpaceNavigator working on a Windows laptop; it works, but the input values flicker all over the place, and it looks all twitchy. Any ideas on how to fix this? I even tried different USB ports, and no luck. Same flickering. Please share your ideas if you think they'd help.

Best regards,

vb
Re: 3DConnexion SpaceNavigator at work
Reply #12 - Nov 14th, 2008, 10:43pm
 
I've had the same issue with my space navigator on two different pcs running using different units.  The input jumps around quite a bit especially when make faster changes.  I tried importing the source and changed all the floats to doubles to give it higher precision but that didn't do anything.  It's usable but it would be nice if the input didn't "shake" as much.  I've used this in both processing and eclipse and have the exact same issue.  Hopefully someone can identify the cause of this.
Re: 3DConnexion SpaceNavigator at work
Reply #13 - Nov 25th, 2008, 9:22pm
 
Hallo,
i just tried out those flickering issues, also with Processing 1.0.
On my Windows everything works very well.
But try to play around with ".setMultiplier(0.0001)"
that could have a big effect on the flickering.

rl
Re: 3DConnexion SpaceNavigator on OSX
Reply #14 - Dec 28th, 2008, 8:10pm
 
i've looked into the problems with the SpaceNavigator on OS X, and there's an obvious bug in JInput that is preventing it from working (present in the CVS code at time of writing). the OS X code omits support for any device defined as a "multi-axis controller", which includes the SpaceNavigator; joysticks, gamepads etc should work fine.

i have amended the code accordingly and created a new procontroll.jar with this fix, which is working beautifully for me. get it here, and drop it into libraries/procontroll/library:

http://www.erase.net/dump/procontroll.jar

i'll email tex with the relevant fixes so that they can be incorporated in future releases.

one caveat is that i had to modify a couple of parameters in the test sketch above, reducing the tolerance and multipliers significantly (to 0.1f and 1 respectively). as a stab in the dark, maybe the linux and windows JInput libraries are returning non-normalised values (in the range of -500..500), and the OS X version returns normalised values (-1..+1)?
Pages: 1 2