void renderGhost() { if (!getGameState()->getPlayer()->isReady()) { return; } IwGxLightingOff(); Ghost *ghost = getGameState()->getGhost(); CIwFVec3 ghostPosition(0, 0, ghost->getDistance()); double ghostRotation = rad(ghost->getRotation()); // Place the markers on the edge of the compass radius // rotated to their correct bearing to current location ghostMatrix->SetRotY(rad(ghost->getBearing())); ghostMatrix->SetTrans(ghostMatrix->RotateVec(ghostPosition)); ghostMatrix->PostRotateY(ghostRotation); IwGxSetModelMatrix(ghostMatrix); if (ghost->pollAnimCaptured()) { ghost_Player->PlayAnim(ghost_Anims[GHOST_ANIM_CAPTURED], 1, 0, BLEND_DURATION); } else if (ghost->pollAnimAgro()) { ghost_Player->PlayAnim(ghost_Anims[GHOST_ANIM_AGRO], 1, 0, BLEND_DURATION); } else if (ghost->pollAnimDodge()) { ghost_Player->PlayAnim(ghost_Anims[GHOST_ANIM_DODGE], 1, 0, BLEND_DURATION); } else if (ghost->pollAnimAttack()) { ghost_Player->PlayAnim(ghost_Anims[GHOST_ANIM_ATTACK], 1, 0, BLEND_DURATION); } IwGxLightingAmbient(true); IwGxSetLightType(0, IW_GX_LIGHT_AMBIENT); int sinceHit = clock() - ghost->getHitTime(); CIwColour colAmbient; if (sinceHit < GHOST_HIT_LENGTH) { int halfAnimation = GHOST_HIT_LENGTH/2; float animState = (float) sinceHit / halfAnimation; if (animState > 1) { animState = 2 - animState; } colAmbient.Set(0xff, 0xff*(1-animState), 0xff*(1-animState), 0xff); } else { // The default state that displays the image as it is colAmbient.Set(0xff, 0xff, 0xff, 0xff); } IwGxSetLightCol(0, &colAmbient); IwGxSetScreenSpaceSlot(1); IwAnimSetSkelContext(ghost_Player->GetSkel()); IwAnimSetSkinContext(ghost_Skin); ghost_Model->Render(); //outline the face under the cursor if (clickX > 0 && clickY > 0) { int32 faceID = ghostCollision->GetFaceUnderCursor(clickX, clickY); if (faceID != -1) { getGameState()->getGhost()->tapped(); clickX = clickY = -1; } else { clickX = clickY = -1; } } // Tidier to reset these IwAnimSetSkelContext(NULL); IwAnimSetSkinContext(NULL); if (ghost->isFound() && !ghost->isDead()) { ghostCollision->RenderEctoplasmaBar((float)ghost->getEctoplasm() / GHOST_MAX_ECTOPLASM, ghostRotation); } }