def makePathTrack(self, nodePath, posPoints, velocity, raycast=0): retval = Sequence() if raycast: retval.append(Func(nodePath.enableRaycast, 1)) chip = base.cr.doId2do.get(self.chipId) self.chipPaths = CCharPaths.getPaths(chip.getName(), chip.getCCLocation()) self.posPoints = posPoints chipDuration = chip.walk.walkTrack.getDuration() self.notify.debug('chipDuration = %f' % chipDuration) chipDistance = CCharPaths.getWalkDistance(self.srcNode, self.destNode, ToontownGlobals.ChipSpeed, self.chipPaths) self.revolutions = chipDistance / self.completeRevolutionDistance srcOffset = (0, 0) if self.srcNode in self.offsetDict: srcOffset = self.offsetDict[self.srcNode] srcTheta = math.atan2(srcOffset[1], srcOffset[0]) if srcTheta < 0: srcTheta += 2 * math.pi if srcTheta > 0: srcRev = (2 * math.pi - srcTheta) / 2 * math.pi else: srcRev = 0 self.srcTheta = srcTheta destOffset = (0, 0) if self.destNode in self.offsetDict: destOffset = self.offsetDict[self.destNode] destTheta = math.atan2(destOffset[1], destOffset[0]) if destTheta < 0: destTheta += 2 * math.pi self.destTheta = destTheta self.revolutions += srcRev endingTheta = srcTheta + (self.revolutions % 1.0) * 2 * math.pi diffTheta = destTheta - endingTheta destRev = diffTheta / 2 * math.pi self.revolutions += destRev while self.revolutions < 1: self.revolutions += 1 def positionDale(t): self.orbitChip(t) retval.append(LerpFunctionInterval(positionDale, chipDuration)) if raycast: retval.append(Func(nodePath.enableRaycast, 0)) return retval
def makePathTrack(self, nodePath, posPoints, velocity, raycast = 0): retval = Sequence() if raycast: retval.append(Func(nodePath.enableRaycast, 1)) chip = base.cr.doId2do.get(self.chipId) self.chipPaths = CCharPaths.getPaths(chip.getName(), chip.getCCLocation()) self.posPoints = posPoints chipDuration = chip.walk.walkTrack.getDuration() self.notify.debug('chipDuration = %f' % chipDuration) chipDistance = CCharPaths.getWalkDistance(self.srcNode, self.destNode, ToontownGlobals.ChipSpeed, self.chipPaths) self.revolutions = chipDistance / self.completeRevolutionDistance srcOffset = (0, 0) if self.srcNode in self.offsetDict: srcOffset = self.offsetDict[self.srcNode] srcTheta = math.atan2(srcOffset[1], srcOffset[0]) if srcTheta < 0: srcTheta += 2 * math.pi if srcTheta > 0: srcRev = (2 * math.pi - srcTheta) / 2 * math.pi else: srcRev = 0 self.srcTheta = srcTheta destOffset = (0, 0) if self.destNode in self.offsetDict: destOffset = self.offsetDict[self.destNode] destTheta = math.atan2(destOffset[1], destOffset[0]) if destTheta < 0: destTheta += 2 * math.pi self.destTheta = destTheta self.revolutions += srcRev endingTheta = srcTheta + (self.revolutions % 1.0) * 2 * math.pi diffTheta = destTheta - endingTheta destRev = diffTheta / 2 * math.pi self.revolutions += destRev while self.revolutions < 1: self.revolutions += 1 def positionDale(t): self.orbitChip(t) retval.append(LerpFunctionInterval(positionDale, chipDuration)) if raycast: retval.append(Func(nodePath.enableRaycast, 0)) return retval
def makePathTrack(self, nodePath, posPoints, velocity, raycast=0): """Create the interval of dale orbiting chip.""" retval = Sequence() if raycast: retval.append( Func(nodePath.enableRaycast, 1)) chip = base.cr.doId2do.get(self.chipId) self.chipPaths = CCharPaths.getPaths( chip.getName(), chip.getCCLocation() ) self.posPoints = posPoints #chipDuration = CCharPaths.getWalkDuration(self.srcNode, # self.destNode, # ToontownGlobals.ChipSpeed, # self.chipPaths) # using getWalkDuration returns a bigger duration than chip uses chipDuration = chip.walk.walkTrack.getDuration() self.notify.debug('chipDuration = %f' % chipDuration) chipDistance = CCharPaths.getWalkDistance(self.srcNode, self.destNode, ToontownGlobals.ChipSpeed, self.chipPaths) #import pdb; pdb.set_trace() self.revolutions = chipDistance / self.completeRevolutionDistance # now lets add in the extra revs from the randomization offset srcOffset = (0,0) if self.srcNode in self.offsetDict: srcOffset = self.offsetDict[self.srcNode] srcTheta = math.atan2(srcOffset[1], srcOffset[0]) # srcTheta returns a value in range -pi to pi if srcTheta < 0: srcTheta += 2 * math.pi if srcTheta > 0: srcRev = ( (2 * math.pi) - srcTheta) / ( 2 * math.pi) else: srcRev = 0 self.srcTheta = srcTheta destOffset = (0,0) if self.destNode in self.offsetDict: destOffset = self.offsetDict[self.destNode] destTheta = math.atan2(destOffset[1], destOffset[0]) # destTheta returns a value in range -pi to pi if destTheta < 0: destTheta += 2 * math.pi self.destTheta = destTheta self.revolutions += srcRev endingTheta = srcTheta+ ((self.revolutions % 1.0) * 2 * math.pi) diffTheta = destTheta - endingTheta destRev = diffTheta / ( 2 * math.pi) self.revolutions += destRev # really short segments might produce negative revolutions while self.revolutions < 1: self.revolutions += 1 def positionDale(t): self.orbitChip(t) retval.append(LerpFunctionInterval(positionDale, chipDuration)) if raycast: retval.append( Func(nodePath.enableRaycast, 0)) return retval