Search Unity

SpaceNavigator driver [OpenSource]

Discussion in 'Assets and Asset Store' started by PatHightree, May 15, 2013.

  1. TomNCatz

    TomNCatz

    Joined:
    Jan 6, 2015
    Posts:
    24
    I have found an answer to my own issues in a way or two.
    First, since it seemed to work fine in a stand alone build, I deleted the .xml for unity's spacemouse settings. This fixed the issue where it was reading pitch as zoom.
    Second, entirely through incident, I found that if I switched from orthographic mode to perspective mode in the unity window all of the rotation functionality started working. Once I had done that it even worked when I switched back to orthographic. It seems like when the project has all of it's windows in orthographic mode at the time of import not all of the rotations get set up in editor. I unfortunately have to go do other things presently, otherwise I would try to replicate the issue. It is possible that it was just something to do with whatever was originally broken with my unity settings. I will try to reproduce the bug tomorrow and let you know of my success/failure.
     
  2. Jaczehack

    Jaczehack

    Joined:
    Oct 31, 2012
    Posts:
    2
    Hey, great plugin!

    I think there is a problem with the rotation calculation when disabling the horizon locking. The multiplication of the rotation cancels out the inverted rotation. Also, is it not redundant since the rotation is done again below?

    Code (CSharp):
    1.             if (_lockHorizon) {
    2.                 // Perform azimuth in world coordinates.
    3.                 _camera.Rotate(Vector3.up, rotation.y, Space.World);
    4.                 // Perform pitch in local coordinates.
    5.                 _camera.Rotate(Vector3.right, rotation.x, Space.Self);
    6.             } else {
    7.                 // Default rotation method, applies the whole quaternion to the camera.
    8.                 _camera.rotation *= SpaceNavigator.Rotation;  // <---- This one seems to cancel inverted rotation
    9.                 _camera.Rotate(Vector3.up, rotation.y, Space.Self);
    10.                 _camera.Rotate(Vector3.right, rotation.x, Space.Self);
    11.                 _camera.Rotate(Vector3.forward, rotation.z, Space.Self);
    12.             }
    I changed it to the following

    Code (CSharp):
    1.             if (_lockHorizon) {
    2.                 // Perform azimuth in world coordinates.
    3.                 _camera.Rotate(Vector3.up, rotation.y, Space.World);
    4.                 // Perform pitch in local coordinates.
    5.                 _camera.Rotate(Vector3.right, rotation.x, Space.Self);
    6.             } else {
    7.                 // Default rotation method, applies the whole quaternion to the camera.
    8.                 _camera.Rotate(rotation);
    9.             }
    and that seems to work.
     
  3. PatHightree

    PatHightree

    Joined:
    Aug 18, 2009
    Posts:
    297
    @TomNCatz It could very well be that things get set up badly when starting in Orthographic mode, I don't use it much and so it hasn't been tested as well as perspective mode.
    Where did you find the .xml file ?
    It might be causing more problems like inverted axes and stuff like that.

    @Jaczehack That looks pretty redundant indeed. Thanks for pointing it out, I'll look into it.
     
  4. PatHightree

    PatHightree

    Joined:
    Aug 18, 2009
    Posts:
    297
    Version 1.4 has been submitted to the asset store.
    The main feature of this release is the fact that navigation in the editor no longer requires the SpaceNavigator window to be open.
    The fact that the method of how the driver hooks into Unity changed could potentially fix some timing/responsiveness bugs (and possibly introduce new ones :rolleyes:).
     
  5. TomNCatz

    TomNCatz

    Joined:
    Jan 6, 2015
    Posts:
    24
    I have confirmed that rotations seem to be broken in fly mode when the perspective is set to orthographic in 1.3.

    On windows 8 the spacemouse .xml settings files are stored in
    C:\Users\<username>\AppData\Roaming\3Dconnexion\3DxWare\Cfg\
    Each program gets it's own file that is named after the application.

    If I had been thinking, I'd have made a backup of the XML file that was causing the issue instead of just deleting it, then we could compare it to find out what exactly was breaking things. Sorry about that.

    On a completely unrelated note, I wrote up an edit to the "SpaceNavigatorWindow.cs" file which creates hotkeys to change the mode you are in. I added a hotkey and menu item for each of the modes(fly, orbit, tele, and grab) as well as a hotkey which turns on and off horizon lock. I've basically set them to buttons on my spacemouse so I don't have to keep going back to the window. I will need to reassess them to make sure they work with the changes to 1.4, but I think that they will be even more relivant if the device can now be used without the window open. Would you be interested in the edits for consideration in the next release build?
     
  6. PatHightree

    PatHightree

    Joined:
    Aug 18, 2009
    Posts:
    297
    As far as I can tell, there's no need for rotation in orthographic mode, is there ?
    When using mouse+kb to navigate, the orthographic viewport can't be rotated either.
    Teleport mode does allow for the selected object to be rotated.

    Thanks for the file location, I didn't have a Unity xml file there, so apparently I did not make a profile for Unity.
    Still, good to know when trying to explain unwanted behaviour !

    Yes, i definitely would appreciate your code contribution.
    Shortcut keys are a good workaround to map functions to the device buttons.
    Device buttons are one of the last missing features that really irk me.
     
  7. K0ndor

    K0ndor

    Joined:
    Mar 12, 2015
    Posts:
    8
    Hey, I have a problem; I imported the package and everything, but after ~3 seconds of using SpaceNavigator it stops working. It works again only if I restart Unity, but it stops after another 3 seconds. I have Unity 5.0.1, is it not supported?
    Edit: I restarted my system and it kinda works now. BUT after hitting 'play' button it ceases to do so, even after hitting 'stop' and even thou the 'scene' window is open all the time :(
     
    Last edited: May 3, 2015
  8. PatHightree

    PatHightree

    Joined:
    Aug 18, 2009
    Posts:
    297
    I've never seen the driver stop working like that
    - It's been tested on 5.0.1
    - What platform are you on ? PC or Mac ?
    - Is your computer exceptionally fast or slow ?
    - Are you having this problem on other 3dconnexion supported software ?
    - Runtime usage of the driver requires you to program your own interaction, see the 2 provided samples for more info.
    - Version 1.4 does not require the editor window to be open any more for navigation in the editor.
     
  9. Jaczehack

    Jaczehack

    Joined:
    Oct 31, 2012
    Posts:
    2
    I'm not sure if this is related to the problem K0ndor had, but I had a problem where the spacenavigator stopped working on Win7 (both in blender and unity3d). In my case it seemed to be related to that I had switched to a different USB hub. When I plugged it into a USB port directly on my computer, the error disappeared.
     
  10. PatHightree

    PatHightree

    Joined:
    Aug 18, 2009
    Posts:
    297
    Sounds like something between the device and 3dconnexion's driver, not really something I can do anything about.
     
  11. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    Thanks for the update!
    Where's the donation link?

    :)

    Okay found it.
    .
    .
    .
    .
     
  12. PatHightree

    PatHightree

    Joined:
    Aug 18, 2009
    Posts:
    297
    Wow, awesome donation Don.
    Thank you very much!

    Edit: This donation will not be used for buying beer, it is going to Nepal instead.
     
    Last edited: May 6, 2015
  13. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    Your choice, of course! :)

    I'm sure it will be helpful.
     
  14. K0ndor

    K0ndor

    Joined:
    Mar 12, 2015
    Posts:
    8
    I'm running Windows 7 64bit. I have Pentium G3258 - modern and one of the fastest 2-core CPU available, it outruns even i3; but it's certainly not faster than i5. 4gb ram ddr3. Everything runs fine so I don't think it's my hardware.
    I have some weird problem with 3dc software; space navigator doesn't work until I chose some option from their software menu (eg I launch 3dc software, launch 3dsMax, but it's not working; I have to run "tutorial" or "options" from the 3dc menu and then it works fine).
    For now I didn't even try using it in runtime (but in future I sure want to), I'm just using it in editor mode. But it's useless since every time I hit "play" I have to restart Unity if I want to use space navigator in edit mode again.
     
  15. cjr11094

    cjr11094

    Joined:
    Mar 2, 2015
    Posts:
    1
    Hi there -

    This is a great plugin! Thanks so much for this. Couple of quick things:

    1. I tried to use this plugin in Unity with LeapMotion. Currently, this plugin won't work with LeapMotion (you'll get a compiler error) because one of the scripts is named 'Controller' (it conflicts with a class in the LeapMotion package).

    In my project, I changed the name of the 'Controller' script in this plugin to 'SpaceController' (and I also changed the class header).

    This change allows this plugin to function fully with LeapMotion. I proposed this change on GitHub if you'd like to use it!

    2. As far as I can tell, this plugin doesn't allow one to use the buttons on the SpaceNavigator (I tried to add a feature where when you pressed one of the buttons, something would happen, but I didn't see any way to get input from the buttons). Adding that in would be great!
     
  16. schmosef

    schmosef

    Joined:
    Mar 6, 2012
    Posts:
    852
    Maybe this goes without saying but have to updated your 3DConnexion drivers?
     
  17. Parallaxe

    Parallaxe

    Joined:
    Apr 9, 2013
    Posts:
    118
    I have exactly the same problem with the new version of the SpaceNacigator driver. I have not yet been able to track it down, but I have the impression it somehow occurs in certain combinations with VisualStudio 2012 (I'm not using MonoDevelop).

    Only way to resolve it is (just like K0ndor) to stop VS2012 & Unity and to restart both.

    I have switched back to an older version of SpaceNavigator and this one runs like a charm. No random failure with the old version, only the new version randomly stops working.
    BTW: When the SpaceNavigator driver freezes, my SpaceMouse Pro is still working fine outside of Unity.

    My rig's Win7 64bit, 16GB RAM.

    I haven't encountered this problem on my Mac though.
     
  18. col000r

    col000r

    Joined:
    Mar 27, 2008
    Posts:
    699
    Is there a way to get values that are not scaled by the speed setting the user chooses in the 3D connection properties?

    If speed is set to 1, then the values I get from SpaceNavigator.Rotation.eulerAngles are between -1.7 and +1.7, but if it's set to max I get values between around -8 and +8.
    For the project I'm working on I want it to behave exactly the same on all systems, no matter what the user set up. Is that possible somehow?
     
  19. PatHightree

    PatHightree

    Joined:
    Aug 18, 2009
    Posts:
    297
    @col000r
    That's very strange, the sensitivity is set to a constant during play mode.
    In GetTranslation() and GetRotation() the sensitivity is treated like this:
    Code (CSharp):
    1. float sensitivity = Application.isPlaying ? PlayTransSens : TransSens[CurrentGear];
    (see SpaceNavigatorWindows.cs and SpaceNavigatorMac.cs)
    Could it be that you're running an older version or something like that ?
    Maybe you can set a breakpoint there and check what is going wrong.
     
  20. col000r

    col000r

    Joined:
    Mar 27, 2008
    Posts:
    699
    I'll do that and report back!

    In the meantime I've run into another problem, that wasn't here in the previous version. Ever since I updated to the latest version I get a ton of error messages if I open my project on the Mac (where I don't have the spacemouse, not connected and not even installed)

    Have a look, this is a new project with nothing but the SpaceNavigator package inside:
    How can I fix this? (I'm on OS X 10.10 with Unity 5.1.1)
     
  21. PatHightree

    PatHightree

    Joined:
    Aug 18, 2009
    Posts:
    297
    Hmmm, not having a spacenav attached might be a tiny edge case that I didn't test...
    Do the error messages stop when a spacenav is present ?
     
  22. col000r

    col000r

    Joined:
    Mar 27, 2008
    Posts:
    699
    The spamming stopped when I installed the driver. Haven't attached the space mouse, just installed the drivers. But please fix this or any project with your plug-in inside won't be usable for anyone who doesn't have the driver installed.
     
  23. PatHightree

    PatHightree

    Joined:
    Aug 18, 2009
    Posts:
    297
    Ok that's good to know.
    It's a shame that any editor plugin is part of the project, instead of the editor itself.
    Thanks for reporting the bug, unfortunately I can't promise a quick fix as I don't have much time at the moment.
     
  24. col000r

    col000r

    Joined:
    Mar 27, 2008
    Posts:
    699
    Is there a way to detect if the Spacemouse is attached and switched on? I have this project where I want to show a help-screen about the spacemouse on startup, but only if you actually have a spacemouse connected. How do I do that?

    PS: Looking forward to that fix ;)
     
  25. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    Getting some serious drifting in the Unity editor -- when I let go, it's as if it stops updating the values and just keeps the last values. No drifting in 3D mouse test apps. Calibration does nothing. Unity 4.6.2 on mac. edit: same with Unity 5.0.1

    edit: yeah, SampleTranslation() is returning the same values after I've let go.
     
    Last edited: Sep 28, 2015
  26. PatHightree

    PatHightree

    Joined:
    Aug 18, 2009
    Posts:
    297
    Thanks for reporting, these issues can be hard to track down.
    Strange that it only manifests itself on some machines.
    Might be a timing issue.
     
  27. jackhearts

    jackhearts

    Joined:
    Apr 5, 2013
    Posts:
    103
    I'm getting the same on mac. As a workaround hitting the rotation lock on my spacemouse pro cancels out the drifting.
     
  28. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    I've had the drifting in Unity with and without using the Space Mouse, at various times since first starting to use Unity.
    It almost never happens now, but restarting Unity usually fixes it (here).
     
  29. jackhearts

    jackhearts

    Joined:
    Apr 5, 2013
    Posts:
    103
    just curious, does this asset reference anything in the scene that would cause it to be bundled in to a build or will it be stripped away?
     
  30. John1515

    John1515

    Joined:
    Nov 29, 2012
    Posts:
    248
    Just installed it, but experiencing the same problem: camera keeps moving after I stop touching the device.
    It feels like I want to be able to set a deadzone, but I'm unsure if that is really the problem. In blender, I have no deadzone and it doesn't happen there.
    Macbook mid 2014, OS10.10.5 (Yosmite), Unity 5.2.3.

    Other than that, the plugin seems so perfect!! Easy to use, exactly what I was looking for.
     
  31. estudio3D

    estudio3D

    Joined:
    Apr 2, 2014
    Posts:
    15
    Hi. The current version stops working after a while. I have Unity 5.0.1f1 .There any way you could download the previous version?

    Thank you
     
  32. PatHightree

    PatHightree

    Joined:
    Aug 18, 2009
    Posts:
    297
    Hi all, I have a couple of updates.
    First of all, a user called Enrico Tuttobene has graciously provided a fix for the drift that many users encounter on Mac. :)
    A bug fix release is in the works and should be out soon™

    The Unity asset store does not provide older versions of packages, so I collected the older releases that I could find on this page: https://drive.google.com/open?id=0B7oiMnqjvbOJM0NCQ0JvellGT1E
     
    Last edited: Dec 12, 2015
    schmosef likes this.
  33. estudio3D

    estudio3D

    Joined:
    Apr 2, 2014
    Posts:
    15

    Hi. The link is broken (
    Not Found
    Error 404).


    As for my problem, I noticed that the plugin stops working after you click Play in a project. After you play, no longer works until you restart Unity.

    The previous plugin worked perfectly. Even in Unity 5, I remember.

    I clarify that my device is a Space Pilot (no Space Pilot Pro) is not compatible with current versions of the latest drivers. The latest official drivers for this device are valid, 2013. not know if that has something to do.

    Excuse my bad English.

    Thanks and regards.


     
  34. PatHightree

    PatHightree

    Joined:
    Aug 18, 2009
    Posts:
    297
    Oops, my bad. I fixed the link.
    Thanks for pointing that out.

    Unfortunately, I can't reproduce the problem you are having.
    Maybe it is something with the older driver, but I would sooner expect it to just totally not work then...
    If you have time and programming experience, you can dive in and try to debug it yourself, as all the code is open source.
    Otherwise, I hope the older version works for you.

    Cheers, Patrick
     
  35. estudio3D

    estudio3D

    Joined:
    Apr 2, 2014
    Posts:
    15
    Hello PatHightree.
    Thank you very much for updating the link.
    I inform you if it's any help future users to pass them the same case as me.
    To me, Space Pilot (formerly with old drivers, no Space Pilot PRO) works correctly in Unity 5 The plugin version 1.3.3. The only problem, not important, is that you have the plugin window open to work. But it is easily remedied anchoring Unity anywhere, for example following the project window.
    With this and continues to run after you click Play without rebooting Unity.
    Thank you very much for your help and develop this fantastic utility.
    Regards.
     
  36. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    It works great in editor mode but in play mode the camera spins violently out of control, even if I am not touching it. Any idea how to fix this?

    Edit:
    It seems it is interfering with a camera controller script. If I disable that script, the camera remains stationary but the SpaceNavigator can not control the camera either.
     
    Last edited: Jan 7, 2016
  37. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    It does not work in Play mode.
     
  38. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    LOL. Thanks.
     
  39. marc.nader

    marc.nader

    Joined:
    Feb 10, 2016
    Posts:
    2
    Hello Patrick. Thank you so much for this great work we use all day long on our standalone projects. May I ask you which kind of technical constraint prevents a SpaceNavigator to control a Unity WebPlayer file content? (launched from within a browser eg. Firefox or IE). We have a bunch of great developers in our company. Can we contribute a way or the other to your project on the NPAPI side, even though Unity declares it "dead" in a few months...
     
  40. marc.nader

    marc.nader

    Joined:
    Feb 10, 2016
    Posts:
    2
    Hello Patrick. Thank you so much for this great work we use all day long on our standalone projects. May I ask you which kind of technical constraint prevents a SpaceNavigator to control a Unity WebPlayer file content? (launched from within a browser eg. Firefox or IE). We have a bunch of great developers in our company. Can we contribute a way or the other to your project on the NPAPI side, even though Unity declares it "dead" in a few months...
     
    qdin likes this.
  41. PatHightree

    PatHightree

    Joined:
    Aug 18, 2009
    Posts:
    297
    HI Marc, thanks for your kind words.
    Unfortunately I don't have any experience with developing for the webplayer.
    However, I know that is sandboxed pretty well for security reasons.
    This will most likely prevent the webplayer from communicating with the 3dconnexion driver process.
    You are more than welcome to take the code and make it into something more useful for your team.
    But I am not interested in expanding the driver in that direction.
    Expanding the driver from pc to also include mac has increased the testing surface significantly.
    This feature was requested many times, so the benefit outweighs the cost.
    For NPAPI unfortunately, this is not the case.
     
  42. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    Any chance to get a key binding to mirror the center on highlighted item?
    This is really the only thing I miss.
     
  43. PatHightree

    PatHightree

    Joined:
    Aug 18, 2009
    Posts:
    297
    How do you mean mirror ? Like focussing on the selected object when you press F in Unity ?
     
  44. radimoto

    radimoto

    Joined:
    Aug 23, 2012
    Posts:
    257
    Hi Patrick. Just imported this into Unity 5.3.2p4 on Mac, but I'm getting the following errors:

    Assets/SpaceNavigator/Plugins/SpaceNavigatorMac.cs(22,25): error CS0246: The type or namespace name `Vector3' could not be found. Are you missing a using directive or an assembly reference?
    Assets/SpaceNavigator/Plugins/SpaceNavigatorMac.cs(40,25): error CS0246: The type or namespace name `Quaternion' could not be found. Are you missing a using directive or an assembly reference?

    EDIT: Managed to fix this pretty easily. Just add the following to the start of Assets/SpaceNavigator/Plugins/SpaceNavigatorMac.cs. Cheers!

    using UnityEngine;
    using System;
    using System.Runtime.InteropServices;
     
    Last edited: Feb 27, 2016
  45. PatHightree

    PatHightree

    Joined:
    Aug 18, 2009
    Posts:
    297
    Hi radimoto,
    Thanks for reporting and posting the fix.
    People have brought this to my attention and the fix is already in the development branch of the git repo.
    Unfortunately I have not had the time to publish a new package to the asset store, sorry about that.
    I've just submitted the new version for asset store review (thanks for the push ;))

    Changelog
    1.5
    Features
    - Added option to navigate in the editor at runtime.
    - Separate axis lock settings for navigation and manipulation modes.
    - Autosave settings every 30 seconds.
    Fixes
    - Fixed horizon lock, coord sys and snap setting not being saved.
    - Refactored driver settings.
    - Added missing namespaces in SpaceNavigatorMac.cs
     
  46. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    Hi,
    Really appreciate the 3D Pilot mouse driver, fun and functional.
    One thing I really miss is the option to map a key to center selected object in view.
    Any possibility this could be implemented?
    Would be great, thanks!

    Running the 3D mouse in the Editor scene during run-time is fantastic!
     
  47. qdin

    qdin

    Joined:
    Oct 21, 2015
    Posts:
    1
    Hi Marc,
    Any chance you've made any progress and are willing to share some insight? We also have a need for control of our software via the WebPlayer configuration.
    Thanks,
    Eric
     
  48. appdevtk

    appdevtk

    Joined:
    Feb 12, 2014
    Posts:
    1
    Hello, there is a default Unity Hotkey:

    F Frame (centre) selection
    SHIFT+F or double-F Locks the scene view camera to the selected GameObject
    http://docs.unity3d.com/Manual/UnityHotkeys.html
     
  49. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    Yes, thank you, I am aware of the Unity hotkey, I want to be able to bind the hotkey to the Space Pilot.
     
  50. David-Shaw542

    David-Shaw542

    Joined:
    Feb 11, 2015
    Posts:
    5
    Hi Pat. Thanks very much for the plugin. I use it all the time. I've just installed the 5.4 beta 22 to have a quick look at the new features and it seems that the space navigator no longer works. Still works in 5.3.5 though.