*** empty log message ***

This commit is contained in:
Mark Mine 2001-03-14 04:24:20 +00:00
parent f2242f06d9
commit 15a155032c
3 changed files with 112 additions and 2 deletions

View File

@ -27,6 +27,7 @@ def lerpBackgroundColor(r,g,b,duration):
Q_EPSILON = 1e-10 Q_EPSILON = 1e-10
# Quaternion interpolation
def qSlerp(startQuat, endQuat, t): def qSlerp(startQuat, endQuat, t):
startQ = Quat(startQuat) startQ = Quat(startQuat)
destQuat = Quat.identQuat() destQuat = Quat.identQuat()
@ -79,3 +80,25 @@ def qSlerp(startQuat, endQuat, t):
destQuat.setK(startScale * startQ.getK() + destQuat.setK(startScale * startQ.getK() +
endScale * endQuat.getK()) endScale * endQuat.getK())
return destQuat 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

View File

@ -106,6 +106,93 @@
else: else:
return [self] 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 # private methods
def __getBlend(self, blendType): def __getBlend(self, blendType):

View File

@ -47,7 +47,7 @@ class PosInterval(Interval):
self.posNum = self.posNum + 1 self.posNum = self.posNum + 1
else: else:
n = name n = name
Interval.__init__(n, duration) Interval.__init__(self, n, duration)
def setT(self, t, entry=0): def setT(self, t, entry=0):
""" setT(t, entry) """ setT(t, entry)
@ -74,7 +74,7 @@ class HprInterval(Interval):
self.hprNum = self.hprNum + 1 self.hprNum = self.hprNum + 1
else: else:
n = name n = name
Interval.__init__(n, duration) Interval.__init__(self, n, duration)
def setT(self, t, entry=0): def setT(self, t, entry=0):
""" setT(t, entry) """ setT(t, entry)