*** empty log message ***

This commit is contained in:
Mark Mine 2001-02-19 02:27:50 +00:00
parent 5e4835f8b6
commit 1f5e16730d

View File

@ -126,19 +126,27 @@
raise Exception("Error: NodePath.__getBlend: Unknown blend type") raise Exception("Error: NodePath.__getBlend: Unknown blend type")
def __lerp(self, functor, time, blendType, taskName=None): def __lerp(self, functorFunc, duration, blendType, taskName=None):
"""__lerp(self, functor, float, string, string) """
__lerp(self, functorFunc, float, string, string)
Basic lerp functionality used by other lerps. Basic lerp functionality used by other lerps.
Fire off a lerp. Make it a task if taskName given.""" Fire off a lerp. Make it a task if taskName given.
import Lerp """
# make the lerp # functorFunc is a function which can be called to create a functor.
lerp = Lerp.Lerp(functor, time, (self.__getBlend(blendType))) # functor creation is defered so initial state (sampled in functorFunc)
# will be appropriate for the time the lerp is spawned
from TaskManagerGlobal import * from TaskManagerGlobal import *
# make the task function # make the task function
def lerpTaskFunc(task): def lerpTaskFunc(task):
import Lerp
import Task import Task
import ClockObject import ClockObject
if task.init == 1:
# make the lerp
functor = task.functorFunc()
task.lerp = Lerp.Lerp(functor, task.duration, task.blendType)
task.init = 0
dt = ClockObject.ClockObject.getGlobalClock().getDt() dt = ClockObject.ClockObject.getGlobalClock().getDt()
task.lerp.setStepSize(dt) task.lerp.setStepSize(dt)
task.lerp.step() task.lerp.step()
@ -149,7 +157,10 @@
# make the lerp task # make the lerp task
lerpTask = Task.Task(lerpTaskFunc) lerpTask = Task.Task(lerpTaskFunc)
lerpTask.lerp = lerp lerpTask.init = 1
lerpTask.functorFunc = functorFunc
lerpTask.duration = duration
lerpTask.blendType = self.__getBlend(blendType)
if (taskName == None): if (taskName == None):
# don't spawn a task, return one instead # don't spawn a task, return one instead
@ -159,7 +170,7 @@
taskMgr.spawnTaskNamed(lerpTask, taskName) taskMgr.spawnTaskNamed(lerpTask, taskName)
return lerpTask return lerpTask
def __autoLerp(self, functor, time, blendType, taskName): def __autoLerp(self, functorFunc, time, blendType, taskName):
"""_autoLerp(self, functor, float, string, string) """_autoLerp(self, functor, float, string, string)
This lerp uses C++ to handle the stepping. Bonus is This lerp uses C++ to handle the stepping. Bonus is
its more efficient, trade-off is there is less control""" its more efficient, trade-off is there is less control"""
@ -167,6 +178,7 @@
from ShowBaseGlobal import * from ShowBaseGlobal import *
# make a lerp that lives in C++ land # make a lerp that lives in C++ land
functor = functorFunc()
lerp = AutonomousLerp.AutonomousLerp(functor, time, lerp = AutonomousLerp.AutonomousLerp(functor, time,
self.__getBlend(blendType), self.__getBlend(blendType),
base.eventHandler) base.eventHandler)
@ -192,75 +204,88 @@
raise Exception("Error: NodePath.lerpColor: bad number of args") raise Exception("Error: NodePath.lerpColor: bad number of args")
def lerpColorRGBA(self, r, g, b, a, time, blendType="noBlend", def lerpColorRGBA(self, r, g, b, a, time,
auto=None, task=None): blendType="noBlend", auto=None, task=None):
"""lerpColorRGBA(self, float, float, float, float, float, """lerpColorRGBA(self, float, float, float, float, float,
string="noBlend", string=none, string=none) string="noBlend", string=none, string=none)
""" """
def functorFunc(self = self, r = r, g = g, b = b, a = a):
import ColorLerpFunctor import ColorLerpFunctor
# just end rgba values, use current color rgba values for start # just end rgba values, use current color rgba values for start
startColor = self.getColor() startColor = self.getColor()
functor = ColorLerpFunctor.ColorLerpFunctor(self, functor = ColorLerpFunctor.ColorLerpFunctor(
self,
startColor[0], startColor[1], startColor[0], startColor[1],
startColor[2], startColor[3], startColor[2], startColor[3],
r, g, b, a) r, g, b, a)
return functor
#determine whether to use auto, spawned, or blocking lerp #determine whether to use auto, spawned, or blocking lerp
if (auto != None): if (auto != None):
return self.__autoLerp(functor, time, blendType, auto) return self.__autoLerp(functorFunc, time, blendType, auto)
elif (task != None): elif (task != None):
return self.__lerp(functor, time, blendType, task) return self.__lerp(functorFunc, time, blendType, task)
else: else:
return self.__lerp(functor, time, blendType) return self.__lerp(functorFunc, time, blendType)
def lerpColorRGBARGBA(self, sr, sg, sb, sa, er, eg, eb, ea, time, def lerpColorRGBARGBA(self, sr, sg, sb, sa, er, eg, eb, ea, time,
blendType="noBlend", auto=None, task=None): blendType="noBlend", auto=None, task=None):
"""lerpColorRGBARGBA(self, float, float, float, float, float, """lerpColorRGBARGBA(self, float, float, float, float, float,
float, float, float, float, string="noBlend", string=none, string=none) float, float, float, float, string="noBlend", string=none, string=none)
""" """
def functorFunc(self = self, sr = sr, sg = sg, sb = sb, sa = sa,
er = er, eg = eg, eb = eb, ea = ea):
import ColorLerpFunctor import ColorLerpFunctor
# start and end rgba values # start and end rgba values
functor = ColorLerpFunctor.ColorLerpFunctor(self, sr, sg, sb, sa, functor = ColorLerpFunctor.ColorLerpFunctor(self, sr, sg, sb, sa,
er, eg, eb, ea) er, eg, eb, ea)
return functor
#determine whether to use auto, spawned, or blocking lerp #determine whether to use auto, spawned, or blocking lerp
if (auto != None): if (auto != None):
return self.__autoLerp(functor, time, blendType, auto) return self.__autoLerp(functorFunc, time, blendType, auto)
elif (task != None): elif (task != None):
return self.__lerp(functor, time, blendType, task) return self.__lerp(functorFunc, time, blendType, task)
else: else:
return self.__lerp(functor, time, blendType) return self.__lerp(functorFunc, time, blendType)
def lerpColorVBase4(self, endColor, time, blendType="noBlend", def lerpColorVBase4(self, endColor, time,
auto=None, task=None): blendType="noBlend", auto=None, task=None):
"""lerpColorVBase4(self, VBase4, float, string="noBlend", string=none, """lerpColorVBase4(self, VBase4, float, string="noBlend", string=none,
string=none) string=none)
""" """
def functorFunc(self = self, endColor = endColor):
import ColorLerpFunctor import ColorLerpFunctor
# just end vec4, use current color for start # just end vec4, use current color for start
startColor = self.getColor() startColor = self.getColor()
functor = ColorLerpFunctor.ColorLerpFunctor(self, startColor, endColor) functor = ColorLerpFunctor.ColorLerpFunctor(
self, startColor, endColor)
return functor
#determine whether to use auto, spawned, or blocking lerp #determine whether to use auto, spawned, or blocking lerp
if (auto != None): if (auto != None):
return self.__autoLerp(functor, time, blendType, auto) return self.__autoLerp(functorFunc, time, blendType, auto)
elif (task != None): elif (task != None):
return self.__lerp(functor, time, blendType, task) return self.__lerp(functorFunc, time, blendType, task)
else: else:
return self.__lerp(functor, time, blendType) return self.__lerp(functorFunc, time, blendType)
def lerpColorVBase4VBase4(self, startColor, endColor, time, def lerpColorVBase4VBase4(self, startColor, endColor, time,
blendType="noBlend", auto=None, task=None): blendType="noBlend", auto=None, task=None):
"""lerpColorVBase4VBase4(self, VBase4, VBase4, float, string="noBlend", """lerpColorVBase4VBase4(self, VBase4, VBase4, float, string="noBlend",
string=none, string=none) string=none, string=none)
""" """
def functorFunc(self = self, startColor = startColor,
endColor = endColor):
import ColorLerpFunctor import ColorLerpFunctor
# start color and end vec # start color and end vec
functor = ColorLerpFunctor.ColorLerpFunctor(self, startColor, endColor) functor = ColorLerpFunctor.ColorLerpFunctor(
self, startColor, endColor)
return functor
#determine whether to use auto, spawned, or blocking lerp #determine whether to use auto, spawned, or blocking lerp
if (auto != None): if (auto != None):
return self.__autoLerp(functor, time, blendType, auto) return self.__autoLerp(functorFunc, time, blendType, auto)
elif (task != None): elif (task != None):
return self.__lerp(functor, time, blendType, task) return self.__lerp(functorFunc, time, blendType, task)
else: else:
return self.__lerp(functor, time, blendType) return self.__lerp(functorFunc, time, blendType)
def lerpHpr(self, *posArgs, **keyArgs): def lerpHpr(self, *posArgs, **keyArgs):
@ -278,56 +303,61 @@
# bad args # bad args
raise Exception("Error: NodePath.lerpHpr: bad number of args") raise Exception("Error: NodePath.lerpHpr: bad number of args")
def lerpHprHPR(self, h, p, r, time, blendType="noBlend", auto=None, def lerpHprHPR(self, h, p, r, time, other=None,
task=None, other=None): blendType="noBlend", auto=None, task=None):
"""lerpHprHPR(self, float, float, float, float, string="noBlend", """lerpHprHPR(self, float, float, float, float, string="noBlend",
string=none, string=none, NodePath=none) string=none, string=none, NodePath=none)
Perform a hpr lerp with three floats as the end point Perform a hpr lerp with three floats as the end point
""" """
def functorFunc(self = self, h = h, p = p, r = r, other = other):
import HprLerpFunctor import HprLerpFunctor
# it's individual hpr components # it's individual hpr components
if (other != None): if (other != None):
# lerp wrt other # lerp wrt other
startHpr = self.getHpr(other) startHpr = self.getHpr(other)
functor = HprLerpFunctor.HprLerpFunctor(self, functor = HprLerpFunctor.HprLerpFunctor(
self,
startHpr[0], startHpr[1], startHpr[2], startHpr[0], startHpr[1], startHpr[2],
h, p, r, other) h, p, r, other)
else: else:
startHpr = self.getHpr() startHpr = self.getHpr()
functor = HprLerpFunctor.HprLerpFunctor(self, functor = HprLerpFunctor.HprLerpFunctor(
self,
startHpr[0], startHpr[1], startHpr[2], startHpr[0], startHpr[1], startHpr[2],
h, p, r) h, p, r)
return functor
#determine whether to use auto, spawned, or blocking lerp #determine whether to use auto, spawned, or blocking lerp
if (auto != None): if (auto != None):
return self.__autoLerp(functor, time, blendType, auto) return self.__autoLerp(functorFunc, time, blendType, auto)
elif (task != None): elif (task != None):
return self.__lerp(functor, time, blendType, task) return self.__lerp(functorFunc, time, blendType, task)
else: else:
return self.__lerp(functor, time, blendType) return self.__lerp(functorFunc, time, blendType)
def lerpHprVBase3(self, hpr, time, other=None,
def lerpHprVBase3(self, hpr, time, blendType="noBlend", auto=None, blendType="noBlend", auto=None, task=None):
task=None, other=None):
"""lerpHprVBase3(self, VBase3, float, string="noBlend", string=none, """lerpHprVBase3(self, VBase3, float, string="noBlend", string=none,
string=none, NodePath=None) string=none, NodePath=None)
Perform a hpr lerp with a VBase3 as the end point Perform a hpr lerp with a VBase3 as the end point
""" """
def functorFunc(self = self, hpr = hpr, other = other):
import HprLerpFunctor import HprLerpFunctor
# it's a vbase3 hpr # it's a vbase3 hpr
if (other != None): if (other != None):
# lerp wrt other # lerp wrt other
functor = HprLerpFunctor.HprLerpFunctor(self, (self.getHpr(other)), functor = HprLerpFunctor.HprLerpFunctor(
hpr, other) self, (self.getHpr(other)), hpr, other)
else: else:
functor = HprLerpFunctor.HprLerpFunctor(self, (self.getHpr()), functor = HprLerpFunctor.HprLerpFunctor(
hpr) self, (self.getHpr()), hpr)
return functor
#determine whether to use auto, spawned, or blocking lerp #determine whether to use auto, spawned, or blocking lerp
if (auto != None): if (auto != None):
return self.__autoLerp(functor, time, blendType, auto) return self.__autoLerp(functorFunc, time, blendType, auto)
elif (task != None): elif (task != None):
return self.__lerp(functor, time, blendType, task) return self.__lerp(functorFunc, time, blendType, task)
else: else:
return self.__lerp(functor, time, blendType) return self.__lerp(functorFunc, time, blendType)
def lerpPos(self, *posArgs, **keyArgs): def lerpPos(self, *posArgs, **keyArgs):
@ -345,12 +375,13 @@
# bad number off args # bad number off args
raise Exception("Error: NodePath.lerpPos: bad number of args") raise Exception("Error: NodePath.lerpPos: bad number of args")
def lerpPosXYZ(self, x, y, z, time, blendType="noBlend", auto=None, def lerpPosXYZ(self, x, y, z, time, other=None,
task=None, other=None): blendType="noBlend", auto=None, task=None):
"""lerpPosXYZ(self, float, float, float, float, string="noBlend", """lerpPosXYZ(self, float, float, float, float, string="noBlend",
string=None, NodePath=None) string=None, NodePath=None)
Perform a pos lerp with three floats as the end point Perform a pos lerp with three floats as the end point
""" """
def functorFunc(self = self, x = x, y = y, z = z, other = other):
import PosLerpFunctor import PosLerpFunctor
if (other != None): if (other != None):
# lerp wrt other # lerp wrt other
@ -362,34 +393,38 @@
startPos = self.getPos() startPos = self.getPos()
functor = PosLerpFunctor.PosLerpFunctor(self, startPos[0], functor = PosLerpFunctor.PosLerpFunctor(self, startPos[0],
startPos[1], startPos[2], x, y, z) startPos[1], startPos[2], x, y, z)
return functor
#determine whether to use auto, spawned, or blocking lerp #determine whether to use auto, spawned, or blocking lerp
if (auto != None): if (auto != None):
return self.__autoLerp(functor, time, blendType, auto) return self.__autoLerp(functorFunc, time, blendType, auto)
elif (task != None): elif (task != None):
return self.__lerp(functor, time, blendType, task) return self.__lerp(functorFunc, time, blendType, task)
else: else:
return self.__lerp(functor, time, blendType) return self.__lerp(functorFunc, time, blendType)
def lerpPosPoint3(self, pos, time, blendType="noBlend", auto=None, def lerpPosPoint3(self, pos, time, other=None,
task=None, other=None): blendType="noBlend", auto=None, task=None):
"""lerpPosPoint3(self, Point3, float, string="noBlend", string=None, """lerpPosPoint3(self, Point3, float, string="noBlend", string=None,
string=None, NodePath=None) string=None, NodePath=None)
Perform a pos lerp with a Point3 as the end point Perform a pos lerp with a Point3 as the end point
""" """
def functorFunc(self = self, pos = pos, other = other):
import PosLerpFunctor import PosLerpFunctor
if (other != None): if (other != None):
#lerp wrt other #lerp wrt other
functor = PosLerpFunctor.PosLerpFunctor(self, (self.getPos(other)), functor = PosLerpFunctor.PosLerpFunctor(
pos, other) self, (self.getPos(other)), pos, other)
else: else:
functor = PosLerpFunctor.PosLerpFunctor(self, (self.getPos()), pos) functor = PosLerpFunctor.PosLerpFunctor(
self, (self.getPos()), pos)
return functor
#determine whether to use auto, spawned, or blocking lerp #determine whether to use auto, spawned, or blocking lerp
if (auto != None): if (auto != None):
return self.__autoLerp(functor, time, blendType, auto) return self.__autoLerp(functorFunc, time, blendType, auto)
elif (task != None): elif (task != None):
return self.__lerp(functor, time, blendType, task) return self.__lerp(functorFunc, time, blendType, task)
else: else:
return self.__lerp(functor, time, blendType) return self.__lerp(functorFunc, time, blendType)
def lerpPosHpr(self, *posArgs, **keyArgs): def lerpPosHpr(self, *posArgs, **keyArgs):
@ -407,38 +442,42 @@
# bad number off args # bad number off args
raise Exception("Error: NodePath.lerpPosHpr: bad number of args") raise Exception("Error: NodePath.lerpPosHpr: bad number of args")
def lerpPosHprPoint3VBase3(self, pos, hpr, time, blendType="noBlend", def lerpPosHprPoint3VBase3(self, pos, hpr, time, other=None,
auto=None, task=None, other=None): blendType="noBlend", auto=None, task=None):
"""lerpPosHprPoint3VBase3(self, Point3, VBase3, string="noBlend", """lerpPosHprPoint3VBase3(self, Point3, VBase3, string="noBlend",
string=none, string=none, NodePath=None) string=none, string=none, NodePath=None)
""" """
def functorFunc(self = self, pos = pos, hpr = hpr, other = other):
import PosHprLerpFunctor import PosHprLerpFunctor
if (other != None): if (other != None):
# lerp wrt other # lerp wrt other
startPos = self.getPos(other) startPos = self.getPos(other)
startHpr = self.getHpr(other) startHpr = self.getHpr(other)
functor = PosHprLerpFunctor.PosHprLerpFunctor(self, functor = PosHprLerpFunctor.PosHprLerpFunctor(
startPos, pos, self, startPos, pos,
startHpr, hpr, other) startHpr, hpr, other)
else: else:
startPos = self.getPos() startPos = self.getPos()
startHpr = self.getHpr() startHpr = self.getHpr()
functor = PosHprLerpFunctor.PosHprLerpFunctor(self, functor = PosHprLerpFunctor.PosHprLerpFunctor(
startPos, pos, self, startPos, pos,
startHpr, hpr) startHpr, hpr)
return functor
#determine whether to use auto, spawned, or blocking lerp #determine whether to use auto, spawned, or blocking lerp
if (auto != None): if (auto != None):
return self.__autoLerp(functor, time, blendType, auto) return self.__autoLerp(functorFunc, time, blendType, auto)
elif (task != None): elif (task != None):
return self.__lerp(functor, time, blendType, task) return self.__lerp(functorFunc, time, blendType, task)
else: else:
return self.__lerp(functor, time, blendType) return self.__lerp(functorFunc, time, blendType)
def lerpPosHprXYZHPR(self, x, y, z, h, p, r, time, blendType="noBlend", def lerpPosHprXYZHPR(self, x, y, z, h, p, r, time, other=None,
auto=None, task=None, other=None): blendType="noBlend", auto=None, task=None):
"""lerpPosHpr(self, float, string="noBlend", string=none, """lerpPosHpr(self, float, string="noBlend", string=none,
string=none, NodePath=None) string=none, NodePath=None)
""" """
def functorFunc(self = self, x = x, y = y, z = z,
h = h, p = p, r = r, other = other):
import PosHprLerpFunctor import PosHprLerpFunctor
if (other != None): if (other != None):
# lerp wrt other # lerp wrt other
@ -458,22 +497,25 @@
startPos[2], x, y, z, startPos[2], x, y, z,
startHpr[0], startHpr[1], startHpr[0], startHpr[1],
startHpr[2], h, p, r) startHpr[2], h, p, r)
return functor
#determine whether to use auto, spawned, or blocking lerp #determine whether to use auto, spawned, or blocking lerp
if (auto != None): if (auto != None):
return self.__autoLerp(functor, time, blendType, auto) return self.__autoLerp(functorFunc, time, blendType, auto)
elif (task != None): elif (task != None):
return self.__lerp(functor, time, blendType, task) return self.__lerp(functorFunc, time, blendType, task)
else: else:
return self.__lerp(functor, time, blendType) return self.__lerp(functorFunc, time, blendType)
def lerpPosHprScale(self, pos, hpr, scale, time, blendType="noBlend", def lerpPosHprScale(self, pos, hpr, scale, time, other=None,
auto=None, task=None, other=None): blendType="noBlend", auto=None, task=None):
"""lerpPosHpr(self, Point3, VBase3, float, float, string="noBlend", """lerpPosHpr(self, Point3, VBase3, float, float, string="noBlend",
string=none, string=none, NodePath=None) string=none, string=none, NodePath=None)
Only one case, no need for extra args. Call the appropriate lerp Only one case, no need for extra args. Call the appropriate lerp
(auto, spawned, or blocking) based on how(if) a task name is given (auto, spawned, or blocking) based on how(if) a task name is given
""" """
def functorFunc(self = self, pos = pos, hpr = hpr,
scale = scale, other = other):
import PosHprScaleLerpFunctor import PosHprScaleLerpFunctor
if (other != None): if (other != None):
# lerp wrt other # lerp wrt other
@ -493,13 +535,14 @@
startHpr, hpr, startHpr, hpr,
startScale, scale) startScale, scale)
return functor
#determine whether to use auto, spawned, or blocking lerp #determine whether to use auto, spawned, or blocking lerp
if (auto != None): if (auto != None):
return self.__autoLerp(functor, time, blendType, auto) return self.__autoLerp(functorFunc, time, blendType, auto)
elif (task != None): elif (task != None):
return self.__lerp(functor, time, blendType, task) return self.__lerp(functorFunc, time, blendType, task)
else: else:
return self.__lerp(functor, time, blendType) return self.__lerp(functorFunc, time, blendType)
def lerpScale(self, *posArgs, **keyArgs): def lerpScale(self, *posArgs, **keyArgs):
@ -517,11 +560,12 @@
# bad number off args # bad number off args
raise Exception("Error: NodePath.lerpScale: bad number of args") raise Exception("Error: NodePath.lerpScale: bad number of args")
def lerpScaleVBase3(self, scale, time, blendType="noBlend", auto=None, def lerpScaleVBase3(self, scale, time, other=None,
task=None, other=None): blendType="noBlend", auto=None, task=None):
"""lerpPos(self, VBase3, float, string="noBlend", string=none, """lerpPos(self, VBase3, float, string="noBlend", string=none,
string=none, NodePath=None) string=none, NodePath=None)
""" """
def functorFunc(self = self, scale = scale, other = other):
import ScaleLerpFunctor import ScaleLerpFunctor
if (other != None): if (other != None):
# lerp wrt other # lerp wrt other
@ -532,19 +576,21 @@
functor = ScaleLerpFunctor.ScaleLerpFunctor(self, functor = ScaleLerpFunctor.ScaleLerpFunctor(self,
(self.getScale()), scale) (self.getScale()), scale)
return functor
#determine whether to use auto, spawned, or blocking lerp #determine whether to use auto, spawned, or blocking lerp
if (auto != None): if (auto != None):
return self.__autoLerp(functor, time, blendType, auto) return self.__autoLerp(functorFunc, time, blendType, auto)
elif (task != None): elif (task != None):
return self.__lerp(functor, time, blendType, task) return self.__lerp(functorFunc, time, blendType, task)
else: else:
return self.__lerp(functor, time, blendType) return self.__lerp(functorFunc, time, blendType)
def lerpScaleXYZ(self, sx, sy, sz, time, blendType="noBlend", def lerpScaleXYZ(self, sx, sy, sz, time, other=None,
auto=None, task=None, other=None): blendType="noBlend", auto=None, task=None):
"""lerpPos(self, float, float, float, float, string="noBlend", """lerpPos(self, float, float, float, float, string="noBlend",
string=none, string=none, NodePath=None) string=none, string=none, NodePath=None)
""" """
def functorFunc(self = self, sx = sx, sy = sy, sz = sz, other = other):
import ScaleLerpFunctor import ScaleLerpFunctor
if (other != None): if (other != None):
# lerp wrt other # lerp wrt other
@ -557,13 +603,14 @@
functor = ScaleLerpFunctor.ScaleLerpFunctor(self, functor = ScaleLerpFunctor.ScaleLerpFunctor(self,
startScale[0], startScale[1], startScale[0], startScale[1],
startScale[2], sx, sy, sz) startScale[2], sx, sy, sz)
return functor
#determine whether to use auto, spawned, or blocking lerp #determine whether to use auto, spawned, or blocking lerp
if (auto != None): if (auto != None):
return self.__autoLerp(functor, time, blendType, auto) return self.__autoLerp(functorFunc, time, blendType, auto)
elif (task != None): elif (task != None):
return self.__lerp(functor, time, blendType, task) return self.__lerp(functorFunc, time, blendType, task)
else: else:
return self.__lerp(functor, time, blendType) return self.__lerp(functorFunc, time, blendType)