def think(self): elapsed = self.getEntityStateElapsed() state = self.getEntityState() if state == 1: if elapsed < self.FadeInDuration: self.fogNode.setExpDensity(CIGlobals.lerp2(0.0, self.fogDensity, elapsed / self.FadeInDuration)) else: self.fogNode.setExpDensity(self.fogDensity) elif state == 0: if elapsed < self.FadeOutDuration: self.fogNode.setExpDensity(CIGlobals.lerp2(self.fogDensity, 0.0, elapsed / self.FadeOutDuration)) else: self.fogNode.setExpDensity(0.0)
def updateAttachment(self, jointName, x, y, z, h, p, r, serverTime): #print("Update attachment") if jointName in self.attachmentInterps: last = self.attachmentInterps[jointName] else: last = None now = globalClockDelta.getFrameNetworkTime() renderTime = now - Lag if last: t1 = last[6] else: t1 = 0.0 t2 = serverTime #print(t2, renderTime, t1) attachment = self.find("**/" + jointName) if not attachment.isEmpty(): if renderTime <= t2 and renderTime >= t1 and last: total = t2 - t1 portion = renderTime - t1 ratio = portion / total #print("lerp", t1, t2, renderTime, ratio) interpX = CIGlobals.lerp2(last[0], x, ratio) interpY = CIGlobals.lerp2(last[1], y, ratio) interpZ = CIGlobals.lerp2(last[2], z, ratio) interpH = CIGlobals.lerp2(last[3], h, ratio) interpP = CIGlobals.lerp2(last[4], p, ratio) interpR = CIGlobals.lerp2(last[5], r, ratio) attachment.setPosHpr(interpX, interpY, interpZ, interpH, interpP, interpR) else: #print("no lerp") attachment.setPosHpr(x, y, z, h, p, r) self.attachmentInterps[jointName] = [x, y, z, h, p, r, serverTime]