def animatePPTRightHand(avatar, ghost, position): if(position == None): rhPPTPosition = array(rhPos); pos = rhPos; else: pos = position #figure out which state we are in, and change the bone we are rotating scaleFactor = 1.0; dir = array(pos) - array(avatar.getBone('Bip01 R UpperArm').getPosition(viz.ABS_GLOBAL)); if(STATE == 1): posArray = array(avatar.getBone('Bip01 R Thigh').getPosition(viz.ABS_GLOBAL)) + dir; pos = [posArray[0], posArray[1], posArray[2]]; rotation = pptExtension.rotateBone(ghost, avatar, 'Bip01 R Thigh', 'Bip01 R Foot', pos); else: rotation = pptExtension.rotateBone(ghost, avatar, 'Bip01 R UpperArm', 'Bip01 R Hand', pos); if DEBUG_MODE: rhSphere.setPosition(ghost.getBone('Bip01 R Forearm').getPosition(viz.ABS_GLOBAL)); rfSphere.setPosition(ghost.getBone('Bip01 R Hand').getPosition(viz.ABS_GLOBAL)); return;
def detectCollision(avatar, ghost, box): boneNames = ['Bip01 L Forearm', 'Bip01 R Forearm']; numBonesToDetect = len(boneNames); for i in range(0, numBonesToDetect): boneName = boneNames[i]; bone = ghost.getBone(boneName); bonePos = bone.getPosition(viz.ABS_GLOBAL); isColliding = vectormath.pointBoxTest(bonePos, box); color = viz.WHITE; if(isColliding): color = viz.RED; nearestPoint = vectormath.nearestPointToBox(bonePos, box); if i == 1: pptExtension.rotateBone(ghost, avatar, 'Bip01 R UpperArm', 'Bip01 R Forearm', nearestPoint, 'Bip01 R UpperArm'); if i == 0: lhSphere.color(color); elif i == 1: rhSphere.color(color);