i try to do project about control model in blender by using p5 glove ,but i don’t know how to connect it with blender game engine
I recently connected glovepie (in my case for a wiimote, but glovepie also supports VR gloves) to Blender by putting the glovepie output on a network port using the OSC module and reading it in Blender with sockets.
Don’t know what your options are with p5 glove…
If you want I can share the script I used, the one I found on the internet was really buggy.
on the GlovePIE homepage I saw that it supports other hardware, too. I didn’t know that tool. As I got some problems integrating a tracking systems into Blender, it would be great if you could share your script. Maybe it would work that way
My original starting point: click here
Included is a .blend example
Here is the glovepie script, sendOsc(…) puts the data on network port 4950 of the “localhost”, which is your computer.
PIE.FrameRate = 50hz var.a = 0 var.b = 0 if Wiimote.A or Wiimote.Classic.a then var.a = 1 endif if Wiimote.B or Wiimote.Classic.b then var.b = 1 endif var.Pitch = Wiimote.SmoothPitch //var.Pitch = Wiimote.Pitch var.Roll = Wiimote.SmoothRoll //var.Roll = Wiimote.Roll var.Pneg = 0 var.Rneg = 0 if var.Pitch < 0 then var.Pitch = -var.Pitch var.Pneg = 1 endif if var.Roll < 0 then var.Roll = -var.Roll var.Rneg = 1 endif var.Vyaw = Wiimote.MotionPlus.YawSpeed var.Yneg = 0 if var.VYaw < 0 then var.VYaw = -var.VYaw var.Yneg = 1 endif SendOsc("localhost", 4950, "/", var.Pitch, var.Pneg, var.Roll, var.Rneg, var.VYaw, var.Yneg, var.a, var.b) debug = "Pitch = "+Wiimote.Pitch+", Roll = "+Wiimote.Roll+", Yaw = "+Wiimote.Yaw
#Import modules import GameLogic import socket import OSC import Mathutils #Create socket def Init(cont): socket.setdefaulttimeout(0.0) host = "localhost" port = 4950 GameLogic.wiimote = socket.socket( socket.AF_INET, socket.SOCK_DGRAM ) GameLogic.wiimote.bind( (host, port) ) #Get data def Update(cont): own = cont.owner try: #Get data from network port raw = GameLogic.wiimote.recv(1024) #Decode data (glovepie uses the OSC protocol to pack the data) #The rest below is just a typical example, in general it is as follows: #Glovepie_data = OSC.decodeOSC(raw) Pitch, Pneg, Roll, Rneg, VYaw, Yneg, A, B = OSC.decodeOSC(raw) #OSC did not seem to work well with negative values so I made everything positive in glovepie and this has to be reversed again if Pneg: Pitch = - Pitch if Rneg: Roll = - Roll #The Yaw of the wiimote was not stable (guess you have to have a sensor bar), so I only monitor changes and reset when the controller is kept still Yaw = own["Yaw"] if VYaw > 10: if Yneg: VYaw = - VYaw Yaw = Yaw + VYaw / 60.0 else: Yaw = 0.0 own["Yaw"] = Yaw #some complicated vector stuff to orientate the cube euler = Mathutils.Euler(Yaw,Pitch,Roll) matrix = euler.toMatrix() own.worldOrientation = [matrix,matrix,matrix] except: print("recieved no data from wiimote") pass
OSC stands for Open Sound Control, apparently there are two versions, the “OSC” module and the “osc” module. You need OSC which is I think no longer actively developed, however it might be faster and I could not find the decodeOSC() function in osc.
The OSC.py module is included into the blend, you can save the script in the Blender directory for general use.
Wiimote_Example.blend (172 KB)
I will try to guide you. But now I’m trying to call function from p5dll.dll However, I still can not connect with the p5 glove. But never used this method to connect wintracker II with blender game engine successfully
thank you for every suggestion
ps.i can speak english a little. ^^
I can not test anything here and I don’t have a VR glove, but I expect it should be possible to connect the p5 with glovepie. (If you want to try without glovepie I do not know how to do it)
-First connect the p5 with your computer (If it works with bluetooth you will have to search for the (HID?) device with your bluetooth software)
-Once it is properly connected glovepie should be able to find it
-Try to run the following script in glovepie, just as a test example
debug = "test = "+p5.pitch
Glovepie commands regarding the p5 glove can be found by typing “p5.” in the script window of glovepie, it will then show all available commands (at least I expect “p5” to refer to the p5 glove :D)