Greetings fellow travelers. I am having trouble with a rig I imported from MakeHuman. It’s all great stuff but when I run the Embedded Player or the Standalone Player my character’s facial features come through the mesh. They are positioned properly, but for some reason they seem to get priority over the outer mesh and are displayed through the outer skin… Here is a picture to illustrate my conundrum:
[ATTACH=CONFIG]299915[/ATTACH]
I cannot attach my blend file here as it exceeds the max file size, but here is my code, I don’t think it will be much use though as it imports numpy, audio and another python module I made with a matrix in it, but in short the code moves bones which drive shape keys to animate the character face in real-time:
import bgeimport code
import aud # audio
import numpy as np
from TTVSEmfadg0_sa1 import TTVSEM #import TTVS emulator's matrix (EM)
import time
cn=bge.logic.getCurrentController()
ow=cn.owner
global i #step counter
i=1 #allow step1 in main to run
global EM #emulator's matrix (EM)
global EMdt #derived EM
global Tcur #current time counter
Tcur=0 #initiate timer
global Pcur #current pose
global PVcur #current pose's value
global Tn #nth time period
global dPdt #rate of change in nth period
global ptr
ptr=0 #initaly points 1st row EM
global dt #time steps
#if program runs at 24fps then
dt=1/24 #sec
## bone KeyShapeDriver viseme names ###
global O_vis
global Rest_vis
global Etc_vis
global AH_vis
global MBP_vis
global OO_vis
global O_vis
global R_vis
global FV_vis
global S_vis
global SH_vis
global EE_vis
global EH_vis
global TH_vis
global L_vis
global G_vis
############# main ############
#1. get and create TTVS timing matrix
#2. play audio WHILE
#3. setting pose using EM
def main (cn):
global i
global EM
global EMdt
if (i==1):
print("step1 ", i)
EM=np.array(TTVSEM()) #get and format EM array
EMdt=dPdt(EM)
print(EMdt)
if (i==2):
print("step2 ", i)
sa1()
time.time() #starts timer
if (i==3):
print("step3 ", i)
boneInit()
if (i==4):
print("step4 ", i)
puppet(EM, EMdt)
if(i==5):
print("main end")
##################### Functions ####################################
###################################################################
###### import TTVS Em Matrix and create timing matrix #########
## get EM and convert into EMdt using diff timing of poses ##
def dPdt(EM):
global i
EMdt=np.zeros(np.shape(EM))
EMdt[:,1]=1/np.r_[1,np.diff(EM[:,1])]
EMdt[:,0]+=EM[:,0]
i=2
return EMdt
#######################################
############## audio ################
def sa1():
global i
# sound = aud.Factory('sa1.mp3') #.file('sa1') #wav file in blender file
print ("I TURNERED OFF THE SOUND @ main STEP2 sa1 Func!")
# if not 'play' in ow: #will play sound only once
# ow['device'] = aud.device()
# ow['device'].play(sound)
# ow['play'] = 1
i=3
#############################################
############## VisBoneList ################
#
# All bone are listed under VisBoneDrivers bone
# _Bone __|__ShapeKey____
# O_vis | VIS_O
# : | :
# : | :
#
def boneInit():
global i
if not "init" in ow:
ow["init"]=1
cn.activate(cn.actuators["Armature"])
global O_vis
global Rest_vis
global Etc_vis
global AH_vis
global MBP_vis
global OO_vis
global O_vis
global R_vis
global FV_vis
global S_vis
global SH_vis
global EE_vis
global EH_vis
global TH_vis
global L_vis
global G_vis
O_vis=ow.channels["O_vis"] #boneName=ow.channels["Bone"] #BL_ArmatureObject.channels["ChannelName"]
O_vis.location=[0,0,0] #zero bone's local location
Rest_vis=ow.channels["Rest_vis"]
Rest_vis.location=[0,0,0]
Etc_vis=ow.channels["Etc_vis"]
Etc_vis.location=[0,0,0]
AH_vis=ow.channels["AH_vis"]
AH_vis.location=[0,0,0]
MBP_vis=ow.channels["MBP_vis"]
MBP_vis.location=[0,0,0]
OO_vis=ow.channels["OO_vis"]
OO_vis.location=[0,0,0]
R_vis=ow.channels["R_vis"]
R_vis.location=[0,0,0]
FV_vis=ow.channels["FV_vis"]
FV_vis.location=[0,0,0]
S_vis=ow.channels["S_vis"]
S_vis.location=[0,0,0]
SH_vis=ow.channels["SH_vis"]
SH_vis.location=[0,0,0]
EE_vis=ow.channels["EE_vis"]
EE_vis.location=[0,0,0]
EH_vis=ow.channels["EH_vis"]
EH_vis.location=[0,0,0]
TH_vis=ow.channels["TH_vis"]
TH_vis.location=[0,0,0]
L_vis=ow.channels["L_vis"]
L_vis.location=[0,0,0]
G_vis=ow.channels["G_vis"]
G_vis.location=[0,0,0]
i=4
##################################################################
######## Viseme Bone Driver Puppet + time keeper (Tcur) ##########
def puppet(EM, EMdt):
global i
global Tcur
global Pcur
global PVcur
global Tn
global dPdt
global ptr
if (ptr>EM.shape[0]): #if at end of EM
print("end")
i=5
elif (Tcur == 0): #get initail pose and its time
#ptr=0 #pointer for keeping place as search through matrix using time tcur
Tn=EM[ptr,1]
while(Tn>Tcur):
Pcur=EM[ptr,0]
Tn=EM[ptr,1]
dPdt=EMdt[ptr,1]
PVcur=1 #init current pose value
PoseUpdate() #(Pcur,PVcur)
print('RealTime:',time.time())
print ('Pcur:',Pcur,'Tcur:',Tcur,'Tn:',Tn,'dPdt:',dPdt,'PVcur:',PVcur,'ptr:',ptr)
Tcur+=1#(1/24)
#Tcur-=1 #counter last while loop
if (Tn>Tcur): #go to next row in matrix if Tcur>Tn
PoseUpdate() #use Pcur,PVcur to move shape key drivers
PVcur=poseVal() #use PVcur,Tcur, dPdt to get current pose value
print('if RealTime:',time.time())
print ('Pcur:',Pcur,'Tcur:',Tcur,'Tn:',Tn,'dPdt:',dPdt,'PVcur:',PVcur,'ptr:',ptr)
else :
ptr+=1
Pcur=EM[ptr,0]
Tn=EM[ptr,1]
dPdt=EMdt[ptr,1]
PVcur=0 #poseVal()
PoseUpdate()
print('else RealTime:',time.time())
print ('Pcur:',Pcur,'Tcur:',Tcur,'Tn:',Tn,'dPdt:',dPdt,'PVcur:',PVcur,'ptr:',ptr)
Tcur+=1#(1/24)
#i=5
######## sub-functions #########
def poseVal(): #use PVcur,dPdt
#if program runs at 33fps and want 0.03s/f then
global PVcur
global dPdt
global ptr
global dt #as each frame lasts 0.03sec
global EM
if (PVcur>1):
PVcur=0
newPV=0
else:
newPV=PVcur+(EM[ptr,1]-EM[ptr-1,1])*dPdt #dt*dPdt #(Tn-Tprv)*dPdt = (EM(ptr,1)-EM(ptr-1,1))*dPdt
print ("new =", newPV)
return newPV
def PoseUpdate (): #use Pcur, PVcur in switch statement to update cur & prv poses
global O_vis
global Rest_vis
global Etc_vis
global AH_vis
global MBP_vis
global OO_vis
global O_vis
global R_vis
global FV_vis
global S_vis
global SH_vis
global EE_vis
global EH_vis
global TH_vis
global L_vis
global G_vis
global Pcur
global PCcur
#for case in Pcur:
#if case('1'):
if Pcur==1:
AH_vis.location=[0,0,PVcur] #zero bone's local location
#print('PB: A/I, BL: AH=',PVcur)
if Pcur==2:
EE_vis.location=[0,0,PVcur] #zero bone's local location
#print('PB: E, BL: EE=',PVcur)
if Pcur==3:
EH_vis.location=[0,0,PVcur] #zero bone's local location
#print('PB: E, BL: EH=',PVcur)
if Pcur==4:
O_vis.location=[0,0,PVcur] #zero bone's local location
#print('PB: O, BL: O |OR| PB: W/R, BL: O(reversed)=',PVcur)
if Pcur==5:
OO_vis.location=[0,0,PVcur] #zero bone's local location
#print('PB: U, BL: OO=',PVcur)
if Pcur==6:
G_vis.location=[0,0,PVcur] #zero bone's local location
#print('PB: G, BL: G=',PVcur)
if Pcur==7:
R_vis.location=[0,0,PVcur] #zero bone's local location
#print('PB: R, BL: R=',PVcur)
if Pcur==8:
S_vis.location=[0,0,PVcur] #zero bone's local location
#print('PB: S, BL: S=',PVcur)
if Pcur==9:
TH_vis.location=[0,0,PVcur] #zero bone's local location
#print('PB: Th, BL: TH=',PVcur)
if Pcur==10:
SH_vis.location=[0,0,PVcur] #zero bone's local location
#print('PB: ?, BL: SH=',PVcur)
if Pcur==11:
FV_vis.location=[0,0,PVcur] #zero bone's local location
#print('PB: F/V, BL: FV=',PVcur)
if Pcur==12:
L_vis.location=[0,0,PVcur] #zero bone's local location
#print('PB: L, BL: L=',PVcur)
if Pcur==13:
MBP_vis.location=[0,0,PVcur] #zero bone's local location
#print('PB: M/B/P, BL: MBP=',PVcur)
if Pcur==14:
Rest_vis.location=[0,0,PVcur] #zero bone's local location
#print('PB: Rest, BL: Rest=',PVcur)
if Pcur==15:
Etc_vis.location=[0,0,PVcur] #zero bone's local location
#print('PB: Rest, BL: Etc=',PVcur)
######### phoneme to viseme mapping and grouping ###################
##
## PrestonBlair == Blender == MatrixNumRep
## A/I == AH == 1
## E == EE,EH == 2,3
## O == O == 4
## U == OO == 5
## C/D/G/K/R/S/Th/Y/Z == G,R,S,Th,SH == 6,7,8,9,10
## F/V == FV == 11
## L (D/Th) == L == 12
## M/B/P == MBP == 13
## W/R == O == 4 (reversed)
## Rest == Rest,Etc == 14,15
######################################################################
Any help is greatly appreciated!!