Developement Java3D with SpaceTraveler

Questions and answers about 3Dconnexion devices on Windows.

Moderator: Moderators

jwick
Moderator
Moderator
Posts: 3331
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

It seems like your thread is blocking waiting for data from the SpaceTraveler. That's why your mouse doesn't do anything until you move the ST.

There may be other ways to do this, but I'd start a separate thread to listen to the ST and use the main thread to listen to the mouse and the other system events. When something happens on the ST thread, you can update TransformGroups, and wake up the main thread so it redraws.

You could also ship the raw ST data to the main thread to have it do the modifications to TransformGroups.

Does this help?

Jim
3Dx Software Development
chamorrus
Posts: 10
Joined: Wed Oct 10, 2007 5:31 am

Post by chamorrus »

Hi Jim! Thanks again for your reply!
I think that you're right, it seems to be like the thread is blocked... But I have to apologize just because I don't know how to start another thread to listen to the ST events...
I want to do that but I don't know how... Can you help me?! (I don't want code, I want ideas or clues)

Thanks in advance!
jwick
Moderator
Moderator
Posts: 3331
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

???

class SpaceTravelerThread extends Thread {

SpaceTravelerThread() {
// Initialize the connection to the ST
// Initialize a way of waking up the main thread
...
}

public void run() {
// loop listening to the ST and waking the main thread
}

}
chamorrus
Posts: 10
Joined: Wed Oct 10, 2007 5:31 am

Post by chamorrus »

Hi Jim!!
Thanks for the code... I thought that you mean another thing when you talk about separating threads... hehehe sorry for the misunderstanding.
Now I can't test the code until monday.
I'll post the result then.

And thank you very much for your help!
chamorrus
Posts: 10
Joined: Wed Oct 10, 2007 5:31 am

Post by chamorrus »

Hello again Jim!

After the misunderstanding of the last week (sorry again for that), I have been testing the possibility of programming the SpaceNavigator and Mouse Behaviors in separate threads.
I put the SpaceNavigator behavior in one separate thread and it won't work. I tried to program the mouse behavior in a separate thread with the same luck.
My last chance (trying to test both behaviors, SpaceNavigator and mouse, each in a separate thread) neither work.

Do you have more ideas?! Now I'm completely lost...
samgp
Posts: 2
Joined: Mon Oct 15, 2007 7:36 am

Post by samgp »

Hi chamorrus!

I'm experimenting exactly the same problem.
I also tried the solution you mentioned with the same luck you had.
The Mouse Behavior (whether Zoom or Translation) really works, but when I carry out the Transform3D update, the Shape3D I'm trying to Translate appears to flicker. It's because of the translation is really done, but inmediatly the Shape3D returns to it's original position.

It seems to be that there is some kind of daemon which 'recalculates' the position of the Shape and only it's modified if a SpaceTraveler event is captured, so modifications done with the mouse will not work.

Any idea on how to do that?
chamorrus
Posts: 10
Joined: Wed Oct 10, 2007 5:31 am

Post by chamorrus »

Hi samgp,
I'm still testing with the code and I get no solution. It's like the Mouse behavior were completely covered by the SpaceNavigator behavior... It seems to be like the method processStimulus() is never triggered...

Have you reproduced the problem Jim?!
jwick
Moderator
Moderator
Posts: 3331
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

Hi chamorrus and samgp,

I'm an old fashioned debugger. I print out what is going on. I find this particularly useful in processes in which a lot of simultaneous threads are running. I'd print out the values you get from the device, the changes to your matrices (Transform3D) and put a print in processStimulus (for the mouse and the 3Dx device). You might have to put print statements in the JNIsiapp library to see what else is going on.

Finally, I'd turn logging on in the driver which would tell me which window is connecting to the device, and use Spy++ to see which window that is.

The driver normally sends data to the window with focus. If you have a process that doesn't have a window, it won't work. If your window doesn't have focus you may have to use the SiGrabDevice call to do a hard grab on the data stream from the device. This will ensure that the data goes to your window even if another window is in the foreground.

Jim
3Dx Software Development
chamorrus
Posts: 10
Joined: Wed Oct 10, 2007 5:31 am

Post by chamorrus »

Hi guys!

I think I found a solution... Not the best one but it works. What I do is passing a reference of the MouseBehavior class I want to manipulate to the SpacemouseDevice class so when I capture a mouse event I do the necessary transformations to the MouseBehavior class.

The way I use to stop the SpaceNavigator thread to capture all the events is putting the line
siapp.SiWaitForEvent();
into a comment, so the Thread will not block waiting for events.

The problem I have now is that I get the next error:

"java.lang.UnsatisfiedLinkError: SiInitialize (...)" but I've seen there's another thread about this issue, so I'm going to have a look.

Hope it helps and thank you for your reply Jim, but I don't have enough time right now to follow the steps you posted.

If I found any other way to solve the problem I'll post it here. Thanks for all the posts!
samgp
Posts: 2
Joined: Mon Oct 15, 2007 7:36 am

Post by samgp »

Hi chamorrus,

I thought about the solution you post before, but I don't rely on it... It works, but I think it is not the best way to solve the problem.
About the problem you are having with the java.lang.UnsatisfiedLinkError, I have the same problem, just when the application executes the line siapp.SiInitialize(); I have been reading about the error we have with no luck. Have you found a solution?!
Can you help us with that Jim?!
- I have the file JNIsiapp.dll in the folder system32.
- I have checked that System.getProperty("java.library.path") contains that folder.
- I also checked that the name of the .dll is right (I mean case sensitive).
- ...

Now I'm 100% lost. Any comment will be very helpful!
chamorrus
Posts: 10
Joined: Wed Oct 10, 2007 5:31 am

Post by chamorrus »

Hi samgp... I think I cannot help you with that issue...
I'm really interested in solving the problem of the unsatisfied link error so if you have any clue, code, hint... anything, I would be very grateful.
Post Reply