Houdini And 3DConnexion Devices

Yes – I have something working! Read on for the story and where I’m at:

I’ve noticed a problem with a lot of animated shorts and student work: The camera work is atrocious. It seems like all the time is spent on perfecting the modeling, animation, and shading, then in the last 10 minutes of production someone puts in a camera and animates it going to the left. Seeing this as a major issue I thought that there must be a better way to have the camera animated easily and a whole lot better. I then recalled I had a 3DConnexion SpaceNavigator that I never use because no applications I use support it. The whole line of 3DConnexion devices might be just what animators need to have better control of their camera.

The SpaceNavigator seems ideally suited to be able to control not just a camera but any object in 3 dimensions, provided that the application can see and understand the device. Unfortunately, Houdini is not one of them. So I researched it a bit and found some hope in an obscure post on the 3DConnexion forum. Someone had been able to use Python to poll data from a device using a Python module called comtypes, a COM client framework (the Windows SDK for the device is a COM dll).  I tried it in Python 2.5.4 and it worked!  At the time it seemed like a simple thing to add the script in Houdini and replace the trans and rotate prints to “hou.node(‘/obj/cam1’).parm(‘my param’).set(my devices param)” and get the camera to receive data from the device.  Long story short – it didn’t work.  Firstly, Houdini doesn’t have _ctypes.pyd which is required by the ctypes module (so I added it to Houdini x.x.xpythonlib which worked).  Secondly, though it seemed that the device driver was being seen, an error kept posting.

So more research was needed. I thought maybe using the old comtypes (v 0.2.1) with the script from the 3DConnection post was the issue, so I upgraded to comtypes 0.6.0. But if you read the post, only 0.2.1 works with the script. More research… then after getting the script to work with 0.6.0, I still got the same error.

So off to odforce I went (to cry for help) which got me thinking more but all of those avenues were dead ends.  Then – you guessed it – more research.  Which lead me to figure out what was wrong. My comtypes module in Houdini wasn’t compiled! I had no .pyc or .pyo files anywhere! And that was it, after I compiled everything using the Python compileall module in Houdini itself it all worked out. Now I can get Houdini’s command window to print the data from the device just fine. The next step is to see if it’s feasible to get this data into Houdini beyond printing to a window, but that is for another day (and another post) mainly because some quick tests cause Houdini to freeze up when I try to use the data to send to a parameter.

Here’s a quick look:

http://vimeo.com/moogaloop.swf?clip_id=4112559&server=vimeo.com&show_title=0&show_byline=0&show_portrait=0&color=00ADEF&fullscreen=1

Houdini Using A 3DConnexion Device Via Python from Geneome on Vimeo.

There are some 32/64-bit issues. The _ctypes.pyd that comes with Python only seems to be compiled for 32-bit machines.  So unless I compile my own 64-bit _cytpes.pyd, this only works with a 32-bit Houdini. You can use a 64 bit _ctypes, which works with Houdini 10 64 bit but you need to use a different ctypes module version (1.0.2). As we are using a COM dll to poll data, this is a Windows only method. I need to look at the 3DConnexion SDK for Linux to see if Linux is in the cards through this or some other method.

(See the follow-up here.)

Advertisements

5 thoughts on “Houdini And 3DConnexion Devices”

  1. Cool, i would love to be able to use something like this to control viewports.

    on a related note i thought you might find this interesting, someone took a Wii-mote and wired the sensor into their pc and they are using it to modify parameters to drive a car around inside the Houdini viewport:

    pretty cool actually, and kinda related to what you are trying to do, so i though i would share

    Like

  2. failure? i don’t think so!

    following up on what Mr. Bleh pointed out, have you tried to get the data into CHOPs first and then reference from there? is that stable? can you have 2 Mouse CHOPs?

    are you able to get any info on why it’s crashing? can you spit out a text file or echo to the console before assigning values to params? you’d have to figure out how to launch H from the cmd line in Windows. cygwin?

    does your method allow you to test other devices like a mouse? does it crash? can you incorporate that HID stuff? what about pygame?

    first i thought you were getting bad data, but now i’m thinking that maybe depending on context you’re polling too often and not allowing H to do other tasks. possible? just guessing here.

    if i sit starring at this text any longer i’ll come up w/ completely opposite ideas… like maybe the polling process is too slow for the param to use it? hopefully fixed by going to CHOPs first, yes?

    whatever it is, you must be really really close. you just need to find the invisible door. ;o)

    good luck. peace, “Use the force, Luke.” & 42

    Like

    1. I haven’t been able to get an error log from Houdini (because I’ve never looked), but I haven’t run the assignment of parameters in the command line of Houdini to see if the same thing happens. The idea of mapping the 3DConnexion device to a mouse output then to a mouse chop might just be the key.

      Not sure if polling too often is causing the issue, but it could be assigning a value directly to a parameter too often might be the issue. Maybe sending the info to chops would resolve this issue. Definitely need to test this.

      BTW, did you notice one of the comments on this video mentioned my site? Very cool!

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s