mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 18:31:55 -04:00
*** empty log message ***
This commit is contained in:
parent
6e7dcb7ff3
commit
ffb3b7b230
@ -106,46 +106,67 @@
|
||||
else:
|
||||
return [self]
|
||||
|
||||
def pprintPos(self, sd = 2):
|
||||
def pprintPos(self, other = None, sd = 2):
|
||||
""" Pretty print a node path's pos """
|
||||
from PandaObject import *
|
||||
formatString = '%0.' + '%d' % sd + 'f'
|
||||
pos = self.getPos()
|
||||
print (self.getName() + '.setPos(' +
|
||||
if other:
|
||||
pos = self.getPos(other)
|
||||
otherString = other.getName() + ', '
|
||||
else:
|
||||
pos = self.getPos()
|
||||
otherString = ''
|
||||
print (self.getName() + '.setPos(' + otherString +
|
||||
formatString % pos[0] + ', ' +
|
||||
formatString % pos[1] + ', ' +
|
||||
formatString % pos[2] +
|
||||
')\n')
|
||||
|
||||
def pprintHpr(self, sd = 2):
|
||||
def pprintHpr(self, other = None, sd = 2):
|
||||
""" Pretty print a node path's hpr """
|
||||
from PandaObject import *
|
||||
formatString = '%0.' + '%d' % sd + 'f'
|
||||
hpr = self.getHpr()
|
||||
print (self.getName() + '.setHpr(' +
|
||||
if other:
|
||||
hpr = self.getHpr(other)
|
||||
otherString = other.getName() + ', '
|
||||
else:
|
||||
hpr = self.getHpr()
|
||||
otherString = ''
|
||||
print (self.getName() + '.setHpr(' + otherString +
|
||||
formatString % hpr[0] + ', ' +
|
||||
formatString % hpr[1] + ', ' +
|
||||
formatString % hpr[2] +
|
||||
')\n')
|
||||
|
||||
def pprintScale(self, sd = 2):
|
||||
def pprintScale(self, other = None, sd = 2):
|
||||
""" Pretty print a node path's scale """
|
||||
from PandaObject import *
|
||||
formatString = '%0.' + '%d' % sd + 'f'
|
||||
scale = self.getScale()
|
||||
print (self.getName() + '.setScale(' +
|
||||
if other:
|
||||
scale = self.getScale(other)
|
||||
otherString = other.getName() + ', '
|
||||
else:
|
||||
scale = self.getScale()
|
||||
otherString = ''
|
||||
print (self.getName() + '.setScale(' + otherString +
|
||||
formatString % scale[0] + ', ' +
|
||||
formatString % scale[1] + ', ' +
|
||||
formatString % scale[2] +
|
||||
')\n')
|
||||
|
||||
def pprintPosHpr(self, sd = 2):
|
||||
def pprintPosHpr(self, other = None, sd = 2):
|
||||
""" Pretty print a node path's pos and, hpr """
|
||||
from PandaObject import *
|
||||
formatString = '%0.' + '%d' % sd + 'f'
|
||||
pos = self.getPos()
|
||||
hpr = self.getHpr()
|
||||
print (self.getName() + '.setPosHpr(' +
|
||||
if other:
|
||||
pos = self.getPos(other)
|
||||
hpr = self.getHpr(other)
|
||||
otherString = other.getName() + ', '
|
||||
else:
|
||||
pos = self.getPos()
|
||||
hpr = self.getHpr()
|
||||
otherString = ''
|
||||
print (self.getName() + '.setPosHpr(' + otherString +
|
||||
formatString % pos[0] + ', ' +
|
||||
formatString % pos[1] + ', ' +
|
||||
formatString % pos[2] + ', ' +
|
||||
@ -154,14 +175,21 @@
|
||||
formatString % hpr[2] +
|
||||
')\n')
|
||||
|
||||
def pprintPosHprScale(self, sd = 2):
|
||||
def pprintPosHprScale(self, other = None, sd = 2):
|
||||
""" Pretty print a node path's pos, hpr, and scale """
|
||||
from PandaObject import *
|
||||
formatString = '%0.' + '%d' % sd + 'f'
|
||||
pos = self.getPos()
|
||||
hpr = self.getHpr()
|
||||
scale = self.getScale()
|
||||
print (self.getName() + '.setPosHprScale(' +
|
||||
if other:
|
||||
pos = self.getPos(other)
|
||||
hpr = self.getHpr(other)
|
||||
scale = self.getScale(other)
|
||||
otherString = other.getName() + ', '
|
||||
else:
|
||||
pos = self.getPos()
|
||||
hpr = self.getHpr()
|
||||
scale = self.getScale()
|
||||
otherString = ''
|
||||
print (self.getName() + '.setPosHprScale(' + otherString +
|
||||
formatString % pos[0] + ', ' +
|
||||
formatString % pos[1] + ', ' +
|
||||
formatString % pos[2] + ', ' +
|
||||
@ -173,25 +201,40 @@
|
||||
formatString % scale[2] +
|
||||
')\n')
|
||||
|
||||
def zeroPos(self):
|
||||
def iPos(self, other = None):
|
||||
""" Set node path's pos to 0,0,0 """
|
||||
self.setPos(0,0,0)
|
||||
if other:
|
||||
self.setPos(other, 0,0,0)
|
||||
else:
|
||||
self.setPos(0,0,0)
|
||||
|
||||
def zeroHpr(self):
|
||||
def iHpr(self, other = None):
|
||||
""" Set node path's hpr to 0,0,0 """
|
||||
self.setHpr(0,0,0)
|
||||
if other:
|
||||
self.setHpr(other, 0,0,0)
|
||||
else:
|
||||
self.setHpr(0,0,0)
|
||||
|
||||
def unitScale(self):
|
||||
def iScale(self, other = None):
|
||||
""" SEt node path's scale to 1,1,1 """
|
||||
self.setScale(1,1,1)
|
||||
if other:
|
||||
self.setScale(other, 1,1,1)
|
||||
else:
|
||||
self.setScale(1,1,1)
|
||||
|
||||
def zeroPosHpr(self):
|
||||
def iPosHpr(self, other = None):
|
||||
""" Set node path's pos and hpr to 0,0,0 """
|
||||
self.setPosHpr(0,0,0,0,0,0)
|
||||
if other:
|
||||
self.setPosHpr(other,0,0,0,0,0,0)
|
||||
else:
|
||||
self.setPosHpr(0,0,0,0,0,0)
|
||||
|
||||
def reset(self):
|
||||
def iPosHprScale(self, other = None):
|
||||
""" Set node path's pos and hpr to 0,0,0 and scale to 1,1,1 """
|
||||
self.setPosHprScale(0,0,0,0,0,0,1,1,1)
|
||||
if other:
|
||||
self.setPosHprScale(other, 0,0,0,0,0,0,1,1,1)
|
||||
else:
|
||||
self.setPosHprScale(0,0,0,0,0,0,1,1,1)
|
||||
|
||||
# private methods
|
||||
|
||||
|
@ -1,29 +0,0 @@
|
||||
"""EventInterval module: contains the EventInterval class"""
|
||||
|
||||
from PandaModules import *
|
||||
from Interval import *
|
||||
from MessengerGlobal import *
|
||||
|
||||
class EventInterval(Interval):
|
||||
|
||||
# special methods
|
||||
|
||||
def __init__(self, name, sentArgs=[]):
|
||||
"""__init__(name, sentArgs)
|
||||
"""
|
||||
duration = 0.0
|
||||
self.prevt = 0.0
|
||||
self.sentArgs = sentArgs
|
||||
Interval.__init__(self, name, duration)
|
||||
|
||||
def setT(self, t, entry=0):
|
||||
""" setT(t, entry)
|
||||
Go to time t
|
||||
"""
|
||||
if (t < 0):
|
||||
self.prevt = t
|
||||
return
|
||||
elif (t == 0) or (self.prevt < 0):
|
||||
messenger.send(self.name, self.sentArgs)
|
||||
self.prevt = 0.0
|
||||
|
170
direct/src/interval/FunctionInterval.py
Normal file
170
direct/src/interval/FunctionInterval.py
Normal file
@ -0,0 +1,170 @@
|
||||
"""FunctionInterval module: contains the FunctionInterval class"""
|
||||
|
||||
from PandaModules import *
|
||||
from Interval import *
|
||||
from MessengerGlobal import *
|
||||
|
||||
class FunctionInterval(Interval):
|
||||
|
||||
functionIntervalNum = 1
|
||||
|
||||
# special methods
|
||||
def __init__(self, function, name = None):
|
||||
"""__init__(function, name = None)
|
||||
"""
|
||||
duration = 0.0
|
||||
self.prevt = 0.0
|
||||
self.function = function
|
||||
|
||||
if (name == None):
|
||||
name = 'FunctionInterval-%d' % FunctionInterval.functionIntervalNum
|
||||
FunctionInterval.functionIntervalNum += 1
|
||||
|
||||
Interval.__init__(self, name, duration)
|
||||
|
||||
def setT(self, t, entry=0):
|
||||
""" setT(t, entry)
|
||||
Go to time t
|
||||
"""
|
||||
if (t < 0):
|
||||
self.prevt = t
|
||||
return
|
||||
elif (t == 0) or (self.prevt < 0):
|
||||
self.function()
|
||||
self.prevt = 0.0
|
||||
|
||||
### FunctionInterval subclass for throwing events ###
|
||||
class EventInterval(FunctionInterval):
|
||||
# Initialization
|
||||
def __init__(self, event, sentArgs=[]):
|
||||
"""__init__(name, sentArgs)
|
||||
"""
|
||||
def sendFunc(event = event, sentArgs = sentArgs):
|
||||
messenger.send(event, sentArgs)
|
||||
# Create function interval
|
||||
FunctionInterval.__init__(self, sendFunc, name = event)
|
||||
|
||||
### Function Interval subclass for adjusting scene graph hierarchy ###
|
||||
class ParentInterval(FunctionInterval):
|
||||
# PosInterval counter
|
||||
parentIntervalNum = 1
|
||||
# Initialization
|
||||
def __init__(self, nodePath, parent, name = None):
|
||||
"""__init__(nodePath, parent, name)
|
||||
"""
|
||||
def reparentFunc(nodePath = nodePath, parent = parent):
|
||||
nodePath.reparentTo(parent)
|
||||
# Determine name
|
||||
if (name == None):
|
||||
name = 'ParentInterval-%d' % ParentInterval.parentIntervalNum
|
||||
ParentInterval.parentIntervalNum += 1
|
||||
# Create function interval
|
||||
FunctionInterval.__init__(self, reparentFunc, name = name)
|
||||
|
||||
### Function Interval subclasses for instantaneous pose changes ###
|
||||
class PosInterval(FunctionInterval):
|
||||
# PosInterval counter
|
||||
posIntervalNum = 1
|
||||
# Initialization
|
||||
def __init__(self, nodePath, pos, duration = 0.0,
|
||||
name = None, other = None):
|
||||
"""__init__(nodePath, pos, duration, name)
|
||||
"""
|
||||
# Create function
|
||||
def posFunc(np = nodePath, pos = pos, other = other):
|
||||
if other:
|
||||
np.setPos(other, pos)
|
||||
else:
|
||||
np.setPos(pos)
|
||||
# Determine name
|
||||
if (name == None):
|
||||
name = 'PosInterval-%d' % PosInterval.posIntervalNum
|
||||
PosInterval.posIntervalNum += 1
|
||||
# Create function interval
|
||||
FunctionInterval.__init__(self, posFunc, name = name)
|
||||
|
||||
class HprInterval(FunctionInterval):
|
||||
# HprInterval counter
|
||||
hprIntervalNum = 1
|
||||
# Initialization
|
||||
def __init__(self, nodePath, hpr, duration = 0.0,
|
||||
name = None, other = None):
|
||||
"""__init__(nodePath, hpr, duration, name)
|
||||
"""
|
||||
# Create function
|
||||
def hprFunc(np = nodePath, hpr = hpr, other = other):
|
||||
if other:
|
||||
np.setHpr(other, hpr)
|
||||
else:
|
||||
np.setHpr(hpr)
|
||||
# Determine name
|
||||
if (name == None):
|
||||
name = 'HprInterval-%d' % HprInterval.hprIntervalNum
|
||||
HprInterval.hprIntervalNum += 1
|
||||
# Create function interval
|
||||
FunctionInterval.__init__(self, hprFunc, name = name)
|
||||
|
||||
class ScaleInterval(FunctionInterval):
|
||||
# ScaleInterval counter
|
||||
scaleIntervalNum = 1
|
||||
# Initialization
|
||||
def __init__(self, nodePath, scale, duration = 0.0,
|
||||
name = None, other = None):
|
||||
"""__init__(nodePath, scale, duration, name)
|
||||
"""
|
||||
# Create function
|
||||
def scaleFunc(np = nodePath, scale = scale, other = other):
|
||||
if other:
|
||||
np.setScale(other, scale)
|
||||
else:
|
||||
np.setScale(scale)
|
||||
# Determine name
|
||||
if (name == None):
|
||||
name = 'ScaleInterval-%d' % ScaleInterval.scaleIntervalNum
|
||||
ScaleInterval.scaleIntervalNum += 1
|
||||
# Create function interval
|
||||
FunctionInterval.__init__(self, scaleFunc, name = name)
|
||||
|
||||
class PosHprInterval(FunctionInterval):
|
||||
# PosHprInterval counter
|
||||
posHprIntervalNum = 1
|
||||
# Initialization
|
||||
def __init__(self, nodePath, pos, hpr, duration = 0.0,
|
||||
name = None, other = None):
|
||||
"""__init__(nodePath, pos, hpr, duration, name)
|
||||
"""
|
||||
# Create function
|
||||
def posHprFunc(np = nodePath, pos = pos, hpr = hpr, other = other):
|
||||
if other:
|
||||
np.setPosHpr(other, pos, hpr)
|
||||
else:
|
||||
np.setPosHpr(pos, hpr)
|
||||
# Determine name
|
||||
if (name == None):
|
||||
name = 'PosHprInterval-%d' % PosHprInterval.posHprIntervalNum
|
||||
PosHprInterval.posHprIntervalNum += 1
|
||||
# Create function interval
|
||||
FunctionInterval.__init__(self, posHprFunc, name = name)
|
||||
|
||||
class PosHprScaleInterval(FunctionInterval):
|
||||
# PosHprInterval counter
|
||||
posHprScaleIntervalNum = 1
|
||||
# Initialization
|
||||
def __init__(self, nodePath, pos, hpr, scale, duration = 0.0,
|
||||
name = None, other = None):
|
||||
"""__init__(nodePath, pos, hpr, scale, duration, other, name)
|
||||
"""
|
||||
# Create function
|
||||
def posHprScaleFunc(np=nodePath, pos=pos, hpr=hpr, scale=scale,
|
||||
other = other):
|
||||
if other:
|
||||
np.setPosHprScale(other, pos, hpr, scale)
|
||||
else:
|
||||
np.setPosHprScale(pos, hpr, scale)
|
||||
# Determine name
|
||||
if (name == None):
|
||||
name = ('PosHprScale-%d' %
|
||||
PosHprScaleInterval.posHprScaleIntervalNum)
|
||||
PosHprScaleInterval.posHprScaleIntervalNum += 1
|
||||
# Create function interval
|
||||
FunctionInterval.__init__(self, posHprScaleFunc, name = name)
|
@ -3,10 +3,9 @@
|
||||
from DirectObject import *
|
||||
from Interval import *
|
||||
from AnimInterval import *
|
||||
from EventInterval import *
|
||||
from FunctionInterval import *
|
||||
from LerpInterval import *
|
||||
from MopathInterval import *
|
||||
from PosHprInterval import *
|
||||
from SoundInterval import *
|
||||
from WaitInterval import *
|
||||
|
||||
|
@ -1,86 +0,0 @@
|
||||
"""PosHprInterval module: contains the PosHprInterval class"""
|
||||
|
||||
from PandaModules import *
|
||||
from Interval import *
|
||||
|
||||
class PosHprInterval(Interval):
|
||||
|
||||
posHprNum = 1
|
||||
|
||||
# special methods
|
||||
|
||||
def __init__(self, node, pos, hpr, duration, name=None):
|
||||
"""__init__(node, pos, hpr, duration, name)
|
||||
"""
|
||||
self.node = node
|
||||
self.pos = pos
|
||||
self.hpr = hpr
|
||||
if (name == None):
|
||||
n = 'PosHpr-%d' % self.posHprNum
|
||||
self.posHprNum = self.posHprNum + 1
|
||||
else:
|
||||
n = name
|
||||
Interval.__init__(self, n, duration)
|
||||
|
||||
def setT(self, t, entry=0):
|
||||
""" setT(t, entry)
|
||||
Go to time t
|
||||
"""
|
||||
if (t < 0):
|
||||
return
|
||||
elif (entry == 1):
|
||||
self.node.setPosHpr(self.pos, self.hpr)
|
||||
|
||||
class PosInterval(Interval):
|
||||
|
||||
posNum = 1
|
||||
|
||||
# special methods
|
||||
|
||||
def __init__(self, node, pos, duration, name=None):
|
||||
"""__init__(node, pos, duration, name)
|
||||
"""
|
||||
self.node = node
|
||||
self.pos = pos
|
||||
if (name == None):
|
||||
n = 'Pos-%d' % self.posNum
|
||||
self.posNum = self.posNum + 1
|
||||
else:
|
||||
n = name
|
||||
Interval.__init__(self, n, duration)
|
||||
|
||||
def setT(self, t, entry=0):
|
||||
""" setT(t, entry)
|
||||
Go to time t
|
||||
"""
|
||||
if (t < 0):
|
||||
return
|
||||
elif (entry == 1):
|
||||
self.node.setPos(self.pos)
|
||||
|
||||
class HprInterval(Interval):
|
||||
|
||||
hprNum = 1
|
||||
|
||||
# special methods
|
||||
|
||||
def __init__(self, node, hpr, duration, name=None):
|
||||
"""__init__(node, hpr, duration, name)
|
||||
"""
|
||||
self.node = node
|
||||
self.hpr = hpr
|
||||
if (name == None):
|
||||
n = 'Hpr-%d' % self.hprNum
|
||||
self.hprNum = self.hprNum + 1
|
||||
else:
|
||||
n = name
|
||||
Interval.__init__(self, n, duration)
|
||||
|
||||
def setT(self, t, entry=0):
|
||||
""" setT(t, entry)
|
||||
Go to time t
|
||||
"""
|
||||
if (t < 0):
|
||||
return
|
||||
elif (entry == 1):
|
||||
self.node.setHpr(self.hpr)
|
Loading…
x
Reference in New Issue
Block a user