BGE PythonCode:-
import bge
import math
from math import *
import mathutils
x=0
def rotate():
global x
# Get the whole bge scene
scene = bge.logic.getCurrentScene()
# Helper vars for convenience
source = scene.objects
# Get the whole Armature
main_arm = source.get('Armature')
ob = bge.logic.getCurrentController().owner
ob.channels['Bone.001'].joint_rotation = mathutils.Vector([0,0,x])
ob.channels['Bone.000'].joint_rotation = mathutils.Vector([0,0,-x])
ob.channels['Bone.002'].joint_rotation = mathutils.Vector([0,x,0])
ob.update()
x=x+.01
|
This is just a first proof of concept for moving bones of an armature in Blenders Game engine.
Next step is to hot wire these onto VinMoov....
update..later that afternoon :-
Here you see the Pinky finger in action....(the bones do not show up in the game engine)
import bge
import serial
import math
from math import *
import mathutils
ser=serial.Serial(4,115200)
a=0.0
b=0.0
c=0.0
d=0.0
e=0.0
f=0.0
g=0.0
h=0.0
i=0.0
j=0.0
k=0.0
l=0.0
m=0.0
n=0.0
o=0.0
p=0.0
def read_serial():
while ser.inWaiting()!=0:
global a
global b
global c
global d
global e
global f
global g
global h
global i
global j
global k
global l
global m
global n
global o
global p
a=(ord(ser.read(1)))
b=(ord(ser.read(1)))
c=(ord(ser.read(1)))
d=(ord(ser.read(1)))
e=(ord(ser.read(1)))
f=(ord(ser.read(1)))
g=(ord(ser.read(1)))
h=(ord(ser.read(1)))
i=(ord(ser.read(1)))
j=(ord(ser.read(1)))
k=(ord(ser.read(1)))
l=(ord(ser.read(1)))
m=(ord(ser.read(1)))
n=(ord(ser.read(1)))
o=(ord(ser.read(1)))
p=(ord(ser.read(1)))
# Get the whole bge scene
scene = bge.logic.getCurrentScene()
# Helper vars for convenience
source = scene.objects
# Get the whole Armature
main_arm = source.get('Armature')
print((a))
ob = bge.logic.getCurrentController().owner
# Get part of Armature and place a rotation on it
ob.channels['pinky.tip'].joint_rotation = mathutils.Vector([-a/32,0,0])
ob.channels['pinky.mid'].joint_rotation = mathutils.Vector([-a/32,0,0])
ob.channels['pinky.base'].joint_rotation = mathutils.Vector([-a/32,0,0])
ob.channels['Left.pinky.palm1'].joint_rotation = mathutils.Vector([-a/32,0,0])
# VERY IMPORTANT update
ob.update()
|