# MakeHuman models' teeth show through face in the BGE?

I am having trouble trying to get a MakeHuman model to be controlled through a python script in the BGE. The model either doesn't show the teeth, or the eyes, inner mouth and teeth appear over the model, as per the attached image. My game logic is simply a loop connecting the python script to run the armature movements.

.

Here is the code, note that I use numpy to manipulate a matrix which is imported using h5py library (this all works fine, moving the mouth bones). I think my problem lies in my settings, of which Blender has many, or my PC is unable to handle the graphics calculations... Any help would be greatly apprecitated!

import bge
import code
import aud # audio
import numpy as np
import time
import h5py

cn=bge.logic.getCurrentController()
ow=cn.owner

##The default logic tic rate is 60 times per second (60Hz float number)
bge.logic.setLogicTicRate(25.0) #running at 25fsp

global PUpLipMid
global PLoLipMid
global PMouth_R
global PMouth_L
global PTongue
global Pjaw

global j
j=0

def main (cn):
global j
boneInit() #init bones to move armature
if j<119:  #before dataMatrix runs out
print ('main ', j)
[TL, BL, J, MW]=getDataPoints(j)
SKM = ratioFunction(TL, BL, J, MW)
print('SKM\n', SKM)
MovesBones(SKM)
j+=1
sa1() #sound

###################  boneInit  ########################
def boneInit():
if not "init" in ow:
ow["init"]=1
cn.activate(cn.actuators["Armature"])

def getDataPoints(j):
print ('getDataPoints ', j)
with h5py.File('test.h5', 'r') as f:
points = f['/Points'].value
NumDataPoints=points.shape
#print(NumDataPoints[0])
colm=NumDataPoints[0]/4
points.shape = (colm,4) # TL,BL,J,MW
#print (points)
TL=points[j,0] #Dist from nose to: Top Lip
BL=points[j,1] #Bottom Lip
J=points[j,2] #Jaw
MW=points[j,3] #Mouth Width
return TL, BL, J, MW

###################  Ratio Function  #####################
def ratioFunction(TL, BL, J, MW):
#SKM matrix generated for PUpLipMid, PLoLipMid, Pjaw, PMouth_R, PMouth_L
#print('TL=',TL,'BL=',BL,'J=',J,'MW=',MW)
SKM=np.zeros(shape=(5,3)) # SKM 5 bones [x(0),y(1),z(2)] coordnts
SKM[0][2] =(-0.002*TL-0.05) #PUpLipMid
SKM[1][2] =(0.002*BL) #PLoLipMid
SKM[2][2] =(0.0005*J) #Pjaw
SKM[3][0] =(0.002*MW) #PMouth_R
SKM[4][0] =(-0.002*MW) #PMouth_L
#print(SKM)
return SKM

###################  Move bones  ########################
def MovesBones(SKM):
global PUpLipMid
global PLoLipMid
global Pjaw
global PMouth_R
global PMouth_L

PUpLipMid=ow.channels["PUpLipMid"] #boneName=ow.channels["Bone"] #BL_ArmatureObject.channels["ChannelName"]
PUpLipMid.location=[SKM[0][0],SKM[0][2],SKM[0][2]] #zero bone's local location
print("PUpLipMid: ",PUpLipMid.location)
PLoLipMid=ow.channels["PLoLipMid"]
PLoLipMid.location=[SKM[1][0],SKM[1][3],SKM[1][2]]
print("PLoLipMid: ",PLoLipMid.location)
Pjaw=ow.channels["PJaw"]
Pjaw.location=[SKM[2][0],SKM[2][4],SKM[2][2]]
print("Pjaw: ",Pjaw.location)
PMouth_R=ow.channels["PMouth_R"]
PMouth_R.location=[SKM[3][0],SKM[3][5],SKM[3][2]]
print("PMouth_R: ",PMouth_R.location)
PMouth_L=ow.channels["PMouth_L"]
PMouth_L.location=[SKM[4][0],SKM[4][6],SKM[4][2]]
print("PMouth_L: ",PMouth_L.location)

###################  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


I have been playing around with many setting, including that one that you mentioned (thank for clarifying where the clipping planes option was). Your solution does help to an extent, but only if I cut through half the head, and even then the model is not full stable, as per the images below where I have the exact same settings but sometime the teeth and eye pop out when I run the GBE.

• What are your near and far clipping planes set to in the viewport? If the near plane is set too small, you can start to get errors that look a lot like this. – Justin May 19 '14 at 13:37
• If you disable your script and run the game, does the model still have the problems? – David May 19 '14 at 13:51
• Thanks for the replies guys. If I disable the script I get the same effect, yes. @Justin, I am still a noob with Blender, I have Google'd clipping planes but could not fine anything helpful. Can you be a bit more specific? I cannot find many problems of the same kind on the web, but it is common for such distortions to occur in the BGE if your graphics card or RAM cannot handle the worklooad? I have a i7, 6GB RAM PC with Gefroce GT 630m-2GB Nvidia graphics card, surely that should handle a single character mesh being manipulated in the BGE? – CubeBot88 May 20 '14 at 8:11
• The graphics card ram does not cause this kind of artifacts. To me it looks like the depth test is deactivated. This will cause objects to always be drawn on top of the previous ones. Under which circumstances are the teeth and eyes on top and when is the body on top? – maddin45 May 20 '14 at 8:34
• @maddin45 -It seems like the teeth and eyes pop over the face randomly, but after a lot of clicking it does seem to go in a some vague cycle of showing the eyes and teeth, then no eyes and teeth, and then a mix of teeth or eyes over the face. How does one go about activating the 'depth test'? – CubeBot88 May 20 '14 at 9:56