Simple(r) example application?

Post questions, comments and feedback to our 3Dconnexion Windows Development Team.

Moderator: Moderators

solveering
Posts: 5
Joined: Tue Jan 25, 2022 6:59 pm

Simple(r) example application?

Post by solveering »

So...
I downloaded the sample files and started going through this... and got totally stuck. For one, the sample application (C#) throws errors at pretty much every point that it can once one (Turbine) of the sample files has been opened. The order I get them in is:
1) TDx.SpaceMouse.Navigation3D.NoDataException: 'This camera does not have a target' (In ViewCallbacks.cs)
2) TDx.SpaceMouse.Navigation3D.NoDataException: 'Nothing Hit' (same class)
3) ... you get the idea.

Now, I am using an old(er) SpaceMouse-enterprise, I think from back in about 2008 or so. I have also tried this with a newer SpaceMouse compact, but the same is going on.
I could perhaps figure out the issues... but really, this is an exceptionally detailed "sample", more like a full application - that does not work out of the box. I can't justify spending a full week to read through the very detailed and unfamiliar code (Really? Custom file menu in an example?). Are there any better/simpler examples that build on the basics and then gradually expand? I was hoping for something along the older format where I can just add a few event handlers that give me Txyz, Rxyz... and then worry about how that interacts with my application, but there seems to be a paradigm shift that I am not equipped for.

Any thoughts/suggestions on a more rudimentary place to start?

Many Thanks,
Ben
ngomes
Moderator
Moderator
Posts: 3321
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: Simple(r) example application?

Post by ngomes »

solveering wrote: Tue Jan 25, 2022 7:10 pm Any thoughts/suggestions on a more rudimentary place to start?
The 3DxTraceNL sample (also included in the SDK) tries to be as simple we could make it whilst maintaining the necessary feature set for what end-users will expect.
Nuno Gomes
solveering
Posts: 5
Joined: Tue Jan 25, 2022 6:59 pm

Re: Simple(r) example application?

Post by solveering »

Thanks for the reply.
The 3DxTraceNL sample is in C++, that does not really help me as I have not used C++ in about 20yrs..
Any other thoughts on something 'simple' that actually works out of the box (with perhaps slightly older hardware)?

Thanks
ngomes
Moderator
Moderator
Posts: 3321
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: Simple(r) example application?

Post by ngomes »

solveering wrote: Wed Jan 26, 2022 7:53 am Any other thoughts on something 'simple' that actually works out of the box
When reviewing 3DxTestNL, all a developer is expected to is load the solution in Visual Studio (we're using VS2019 Pro but the Community edition should also work), build it, run it and load an "obj" file (as in Wavefront obj file). There are a couple of obj files in the SDK package "models".

The "NoDataFound" exceptions mean just that: the application tried to get information on a particular property but it does exist. This the expected behaviour.

For example, the sample has a GetCameraTarget() handler but the application has no "target", so it just throws a NoDataException and the Navigation3D framework understands that.

Perhaps you're looking at a different exception scenario.
solveering
Posts: 5
Joined: Tue Jan 25, 2022 6:59 pm

Re: Simple(r) example application?

Post by solveering »

Thanks for the reply.
That kind of error handling is not what I am used to (yes, using VS2019-Enterprise, loaded the sample OBJ files). Throwing an error is just that, an error. If something is empty/null/nothing and it isn't needed, why throw an error? The IDE stops on each (I know, I can turn that off...) and therefore makes the 'learning' process very counterintuitive. If it is just for information, shouldn't that go into a different pipeline, perhaps just a label somewhere?
Beyond that though -and this is more at the center of the problem- even though the example shows part of the file, there is no interaction with it possible. Either it does not recognize my controller and does not tell me so (that would be the appropriate place for an exception) or there is a conflict with a driver or any number of other items... those would be nice to get feedback on. But as it stands, this plainly does not work. The "all a developer is expected to" does not lead to a functional example of the capabilities.
Lastly, the exceptions being thrown are "This camera does not have a target" exception (I see no clear way to define a camera, I would assume it would automatically set itself based on the data? That is the way I do that in my application). And then again when there is "Nothing Hit", presumably some hit-testing to determine a center of rotation or something like that?

Any chance there will be a (usable, short) example in the future? As this stands now, I cannot spend the time to got through the 1k+ lines of code to try and figure out how this is meant to work or where/why things don't... I was hoping that that was covered by the sample.

Thanks for the support.
solveering
Posts: 5
Joined: Tue Jan 25, 2022 6:59 pm

Re: Simple(r) example application?

Post by solveering »

Oooo...

so, gave this another try and found two issues (partially my fault - partially).
My old SpaceMouse (Enterprise) is not being recognized by the latest update. Why? Don't know...would have been nice to be told other than by going to the properties page - but I wanted to use that one for testing & development due to the buttons/display. Guess that won't happen then. However, my newer Compact is being recognized - I used the Viewer application that comes with the non SDK download to check these which is what directed me to the issue.
Now, that being said, I have come to a realization in terms of how the SDK sample is set up (feel free to correct me). This is based on a Game approach, not an events-based approach. The app refreshes itself each frame (like a game) and if there is not data - no joy (and endless errors unless you make them silent which is a dangerous thing to do). Once something is loaded (I had to replace where errors are thrown with some hard coded return data), it seems to work mostly as intended.

Is it possible to run this in a non-game mode? With that I mean that the graphics portion is only updated when it is needed, not on a per-frame refresh basis (my application cannot handle that, there is too much going on and I need all the available threads I can get)? In the end I don't care what the example does, but I need to know whether I can rely on there being events that I can listen for and respond to those (if I so choose) rather than polling the HID for changes on a continuous basis... that would seem like an outdated approach and I cannot tell whether that only applies to the graphics here or also to the controller.

Thanks!
ngomes
Moderator
Moderator
Posts: 3321
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: Simple(r) example application?

Post by ngomes »

solveering wrote: Wed Jan 26, 2022 1:49 pm Throwing an error is just that, an error.
Yes but exceptions are not necessarily errors.
solveering wrote: Wed Jan 26, 2022 2:30 pm Is it possible to run this in a non-game mode? With that I mean that the graphics portion is only updated when it is needed, not on a per-frame refresh basis
You can set the frame "timing source" to be either the device (the "SpaceMouse") or the application.

If your application can't keep up a reasonable frame rate (the minimum is about 15 fps or so), then the user-experience will suffer.
solveering
Posts: 5
Joined: Tue Jan 25, 2022 6:59 pm

Re: Simple(r) example application?

Post by solveering »

You can set the frame "timing source" to be either the device (the "SpaceMouse") or the application.
Thank you for that: after running a search for the word "timing" I found where this is defined (NavigationModel.cs : public bool Enable{}) ... perhaps this shines a light on how this can be construed as not being an easy example application for learning how to do this? Yes, the 15fps, I agree. What I meant is that during heavy lifting phases, my UI can be considered less important and therefore I do not want to have waste. I understand the desire to separate the two. With the ability to run this on a device initiated basis, things are far improved.. I believe I can now justify implementing this by picking out the parts that I am actually interested in.

I would nevertheless, humbly, suggest that the dev team reconsider if this is the best way to introduce people to this environment. I consider a simple example one that fits into a handful of methods, not one that spans dozens of classes. What ever happened to using a very primitive WinForms application where Txyz, Rxyz are just labels that show a value? This is a nice way to show off what can be done, but I would argue this is more of a master class than "SpaceBall 101"...

But I do greatly appreciate the support received.

Thanks.
ngomes
Moderator
Moderator
Posts: 3321
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: Simple(r) example application?

Post by ngomes »

solveering wrote: Thu Jan 27, 2022 9:05 am What ever happened to using a very primitive WinForms application where Txyz, Rxyz are just labels that show a value?
It's still around and the source is included in the now-deprecated version 3 of the SDK.

SDK version 4 takes a completely different approach -- as you are only too aware. The paradigm shifted from providing the raw sensor and button data to "camera control". The new approach allows applications to offer a consistent (and complete) set of navigation features for SpaceMouse users but -- again, as you pointed out -- at the expense of a steeper initial learning curve.
IliyaKovac
Posts: 2
Joined: Sat Feb 12, 2022 6:12 am
Location: UK
Contact:

Re: Simple(r) example application?

Post by IliyaKovac »

I have created a very, very simple C# SpaceMouse application test.

However, it cannot pick up rotations. Any help?

https://github.com/IliyaKovac/SpaceMouseTest
jwick
Moderator
Moderator
Posts: 3331
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Re: Simple(r) example application?

Post by jwick »

IliyaKovac,

Newer devices deliver the Rotation data in an extended Translation packet (ID: 1).
Older devices deliver them separately (1: translations, 2: rotations).

We have a C# sample in our SDK (v3). It pinvokes to our library which hides all these details from you.
But you can also use Raw Input as you have done. It makes you do more work to handle differences between devices.
The API itself gives you some functionality related to the driver but the devices work almost 100% the same regardless.
Methedras
Posts: 12
Joined: Sun Dec 17, 2006 5:04 am

Re: Simple(r) example application?

Post by Methedras »

I'm adding to this thread because I can very much relate to the bewilderment of the thread starter. It seems to me like 3DConnexion is trying to position its Space* devices mainly as programmable keyboards, while maximally obfuscating the raw and unprocessed sensor data Txyz, Rxyz.
My experience with SpaceMice reaches twenty years back, starting with a serial SpaceMouse Classic, still with a DLR Label. For which i wrote/ported a Magellan driver to make it available within Xfree86 and Linux. In return, 3DConnexion at that time even awarded me free of charge an unsollicited 2nd SpaceMouse Classic. Those were the times …
Today I'm trying to port some of my old Linux/XFree86/GLUT/C-Programs to WebGL/Three.js and would like to revive my current SpaceNavigator USB.
I downloaded the various SDKs, found the Windows/Web subdirectory with its „WebGL/THREE.js 3DconnexionJS Sample“ program and got this to work. Hooray!

BUT: I didn't find a way to extract the raw, unprocessed sensor data which I need for my own application. As it seems from this thread, these are intentionally hidden?!

While I find it highly commendable that 3DConnexion supports software developers who are weak on Math/Trigonometry, I would also like to see, that the freedom of implementation of one's own interpretation of raw sensor data isn't sacrificed in the process.

This all boils down to the simple question:

How can I access raw, unprocessed sensor data in a JavaScript environment?
ngomes
Moderator
Moderator
Posts: 3321
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: Simple(r) example application?

Post by ngomes »

Methedras wrote: Thu Mar 31, 2022 2:33 am This all boils down to the simple question:

How can I access raw, unprocessed sensor data in a JavaScript environment?
The Gamepad API provides access to the raw data, bypassing the 3Dconnexion driver stack.
Nuno Gomes
Methedras
Posts: 12
Joined: Sun Dec 17, 2006 5:04 am

Re: Simple(r) example application?

Post by Methedras »

Thanks for your concise answer.

Which I of course tried and found to be not working for my SpaceNavigator USB. I'm aware this is a "legacy" device, so I'd even be willing to shell out some money to buy a current, supported device. Assuming, what you claim is true.

To be sure, before I buy: where can I find a current and authoritative compatibility matrix authorized by 3DConnexion which states, as a guaranteed property, the compatibility of 3DConnexions current (sub-)range of 6DOF devices with the current implementation of the gamepad API as per your link?
To leave no room for interpretation: failure to live up to a claimed guaranteed property would entitle me to a return of the defective product for a full refund.

Please see the compatibility matrix for different browsers and their revision for support of the gamepad API in your above link for reference.

Thanks for a pointer.
ngomes
Moderator
Moderator
Posts: 3321
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: Simple(r) example application?

Post by ngomes »

Methedras wrote: Thu Mar 31, 2022 9:27 am Which I of course tried and found to be not working for my SpaceNavigator USB.
I just tried a SpaceNavigator in Gamepad Tester using Google Chrome 100.0 and Microsoft Edge 99.0 on a Windows 10 x64 system.

Works for me.
Post Reply