When 2.5 started its feature-request wiki, I started a discussion on setting up a sort of “verse” that did nothing more than transmit these new “universal handler” commands via a network.
More recently I have discovered OSC which does a fantastic job at sending UDP messages from one thing to another.
As you can guess, I’m running in to plenty of problems. Since the thread is new, I’m just going to post my checklist of issues below. As we smash through my stranger problems I’ll keep developing this area as I have been for the past two months in hopes of making something that actually works.
To catch you up, there are two different OSC modules for python:
- pyKit and the popular thing to say about it is that it is “no longer developed”. A shame because it works very well. Sadly it doesn’t come with any example files so the learning curve is high.
import socket<b>
import OSC</b>
def osc_data(host, port):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind((host, port))
raw, addr = s.recvfrom(1024)
list = OSC.decodeOSC(raw)
return list
#in this one line I imported 16 analog inputs from a ps3 controller, and the 6 axes from a spacenavigator all packed in to one signal
gx, gy, dx, dy, x1, y1, x2, y2, r1, r2, l1, l2, x, c, q, t, l3, r3, sx, sy, sz, srx, sry, srz = osc_data('localhost', 4950)
- SimpleOSC is mantained but it is deceptive in that it is built on the pyKit, but pyKit examples fail their execution. Its code is messier to set up, and it is unusably slow. Frankly I hate it, but I can’t figure out how to “install” the pykit
<b>import osc</b>
try :
osc.state
except AttributeError :
osc.init()
osc.inPort = osc.createListener("127.0.0.1", 9001)
osc.sendMsg('/init', ['done init osc'], "127.0.0.1", 9001)
osc.state = 1
def testF(*msg):
print 'msg: ', msg
print 'msg value is: ', msg[0][2]
# bind the function with an osc tag, when a msg tagged /test arrives funcion testF will be fired
osc.bind(testF, '/test')
osc.getOSC(osc.inPort)
I’ve been doing a lot of python research the past couple of months, and I’ve figured out how to read in long lists of information via OSC. Most of my working files implement code that was done with the game engine, but the question remains: how do I record the values as IPOs
Well, I figure the first step in that direction is to figure out how to have a pythong script loop when you run it (not in the game engine) so its results show up when you press play. I realize this is a sort of “2.5 knows how to do this, but 2.4 it will just be a headache” situation so I’m looking for 2.5-specific solutions
Feel free to jump in with solutions to any of these problems that have had me tearing my hair out.
- I can’t figure out how to “install” the pykit so that the IDLE or Blender can see it within OSX. WIndows has been a little more forgiving. Linux I haven’t tried yet but there are instructions available.
Obviously, as I’m known to do, I’ll keep updating this first post as I make more and more advances.
Oh, and one more thing. It seems that practically everyone who ever got far in this line of research has fallen off the face of the earth!
- http://blogs.mediazone.co.nz/tutorials/2008/05/28/using-the-wiimote-with-blender-on-os-x/ The link to his blend file is dead
- http://web.archive.org/web/*/http://wiretap.stetson.edu/ This site went dead in 2007 so I can’t gain any additional guidance past the html API included in other people’s mirrored files
My solution proposal might a little sloppy right now, but Ton boasted of 2.5’s support for many multiple controllers when he was interviewed by Bart nearly a year ago and since then there has been little to no work that i can see on handling analog input binding. Even if OSC isn’t the fix-all, it’s an open source project that works well and should be explored more.It’s a LOT better than MIDI, that’s for sure.