mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
*** empty log message ***
This commit is contained in:
parent
f2242f06d9
commit
15a155032c
@ -27,6 +27,7 @@ def lerpBackgroundColor(r,g,b,duration):
|
||||
|
||||
Q_EPSILON = 1e-10
|
||||
|
||||
# Quaternion interpolation
|
||||
def qSlerp(startQuat, endQuat, t):
|
||||
startQ = Quat(startQuat)
|
||||
destQuat = Quat.identQuat()
|
||||
@ -79,3 +80,25 @@ def qSlerp(startQuat, endQuat, t):
|
||||
destQuat.setK(startScale * startQ.getK() +
|
||||
endScale * endQuat.getK())
|
||||
return destQuat
|
||||
|
||||
# File data util
|
||||
def getFileData(filename, separator = ','):
|
||||
"""
|
||||
Open the specified file and strip out unwanted whitespace and
|
||||
empty lines. Return file as list of lists, one file line per element,
|
||||
list elements based upon separator
|
||||
"""
|
||||
f = open(filename.toOsSpecific(), 'r')
|
||||
rawData = f.readlines()
|
||||
f.close()
|
||||
fileData = []
|
||||
for line in rawData:
|
||||
# First strip whitespace from both ends of line
|
||||
l = string.strip(line)
|
||||
if l:
|
||||
# If its a valid line, split on separator and
|
||||
# strip leading/trailing whitespace from each element
|
||||
data = map(string.strip, l.split(separator))
|
||||
fileData.append(data)
|
||||
return fileData
|
||||
|
||||
|
@ -106,6 +106,93 @@
|
||||
else:
|
||||
return [self]
|
||||
|
||||
def pprintPos(self, sd = 2):
|
||||
""" Pretty print a node path's pos """
|
||||
from PandaObject import *
|
||||
formatString = '%0.' + '%d' % sd + 'f'
|
||||
pos = self.getPos()
|
||||
print (self.getName() + '.setPos(' +
|
||||
formatString % pos[0] + ', ' +
|
||||
formatString % pos[1] + ', ' +
|
||||
formatString % pos[2] +
|
||||
')\n')
|
||||
|
||||
def pprintHpr(self, sd = 2):
|
||||
""" Pretty print a node path's hpr """
|
||||
from PandaObject import *
|
||||
formatString = '%0.' + '%d' % sd + 'f'
|
||||
hpr = self.getHpr()
|
||||
print (self.getName() + '.setHpr(' +
|
||||
formatString % hpr[0] + ', ' +
|
||||
formatString % hpr[1] + ', ' +
|
||||
formatString % hpr[2] +
|
||||
')\n')
|
||||
|
||||
def pprintScale(self, sd = 2):
|
||||
""" Pretty print a node path's scale """
|
||||
from PandaObject import *
|
||||
formatString = '%0.' + '%d' % sd + 'f'
|
||||
scale = self.getScale()
|
||||
print (self.getName() + '.setScale(' +
|
||||
formatString % scale[0] + ', ' +
|
||||
formatString % scale[1] + ', ' +
|
||||
formatString % scale[2] +
|
||||
')\n')
|
||||
|
||||
def pprintPosHpr(self, 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(' +
|
||||
formatString % pos[0] + ', ' +
|
||||
formatString % pos[1] + ', ' +
|
||||
formatString % pos[2] + ', ' +
|
||||
formatString % hpr[0] + ', ' +
|
||||
formatString % hpr[1] + ', ' +
|
||||
formatString % hpr[2] +
|
||||
')\n')
|
||||
|
||||
def pprintPosHprScale(self, 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(' +
|
||||
formatString % pos[0] + ', ' +
|
||||
formatString % pos[1] + ', ' +
|
||||
formatString % pos[2] + ', ' +
|
||||
formatString % hpr[0] + ', ' +
|
||||
formatString % hpr[1] + ', ' +
|
||||
formatString % hpr[2] + ', ' +
|
||||
formatString % scale[0] + ', ' +
|
||||
formatString % scale[1] + ', ' +
|
||||
formatString % scale[2] +
|
||||
')\n')
|
||||
|
||||
def zeroPos(self):
|
||||
""" Set node path's pos to 0,0,0 """
|
||||
self.setPos(0,0,0)
|
||||
|
||||
def zeroHpr(self):
|
||||
""" Set node path's hpr to 0,0,0 """
|
||||
self.setHpr(0,0,0)
|
||||
|
||||
def unitScale(self):
|
||||
""" SEt node path's scale to 1,1,1 """
|
||||
self.setScale(1,1,1)
|
||||
|
||||
def zeroPosHpr(self):
|
||||
""" Set node path's pos and hpr to 0,0,0 """
|
||||
self.setPosHpr(0,0,0,0,0,0)
|
||||
|
||||
def reset(self):
|
||||
""" 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)
|
||||
|
||||
# private methods
|
||||
|
||||
def __getBlend(self, blendType):
|
||||
|
@ -47,7 +47,7 @@ class PosInterval(Interval):
|
||||
self.posNum = self.posNum + 1
|
||||
else:
|
||||
n = name
|
||||
Interval.__init__(n, duration)
|
||||
Interval.__init__(self, n, duration)
|
||||
|
||||
def setT(self, t, entry=0):
|
||||
""" setT(t, entry)
|
||||
@ -74,7 +74,7 @@ class HprInterval(Interval):
|
||||
self.hprNum = self.hprNum + 1
|
||||
else:
|
||||
n = name
|
||||
Interval.__init__(n, duration)
|
||||
Interval.__init__(self, n, duration)
|
||||
|
||||
def setT(self, t, entry=0):
|
||||
""" setT(t, entry)
|
||||
|
Loading…
x
Reference in New Issue
Block a user