mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
*** empty log message ***
This commit is contained in:
parent
f43853c396
commit
5259b71393
@ -4,6 +4,7 @@ src/actor
|
|||||||
src/directtools
|
src/directtools
|
||||||
src/directdevices
|
src/directdevices
|
||||||
src/directnotify
|
src/directnotify
|
||||||
|
src/directutil
|
||||||
src/distributed
|
src/distributed
|
||||||
src/ffi
|
src/ffi
|
||||||
src/fsm
|
src/fsm
|
||||||
|
60
direct/src/directutil/Mopath.py
Normal file
60
direct/src/directutil/Mopath.py
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
from PandaObject import *
|
||||||
|
from DirectGeometry import *
|
||||||
|
|
||||||
|
import NodePath
|
||||||
|
|
||||||
|
class Mopath(PandaObject):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.maxT = 0.0
|
||||||
|
self.xyzNurbsCurve = None
|
||||||
|
self.hprNurbsCurve = None
|
||||||
|
self.tNurbsCurve = None
|
||||||
|
|
||||||
|
def loadFile(self, filename):
|
||||||
|
nodePath = loader.loadModel(filename)
|
||||||
|
if nodePath:
|
||||||
|
self.__extractCurves(nodePath)
|
||||||
|
if (self.xyzNurbsCurve != None):
|
||||||
|
self.maxT = self.xyzNurbsCurve.getMaxT()
|
||||||
|
elif (self.hprNurbsCurve != None):
|
||||||
|
self.maxT = self.hprNurbsCurve.getMaxT()
|
||||||
|
elif (self.tNurbsCurve != None):
|
||||||
|
self.maxT = self.tNurbsCurve.getMaxT()
|
||||||
|
else:
|
||||||
|
print 'Mopath: no valid curves in file: %s' % filename
|
||||||
|
else:
|
||||||
|
print 'Mopath: no data in file: %s' % filename
|
||||||
|
|
||||||
|
def __extractCurves(self, nodePath):
|
||||||
|
node = nodePath.node()
|
||||||
|
if isinstance(node, ParametricCurve):
|
||||||
|
if node.getCurveType() == PCTXYZ:
|
||||||
|
self.xyzNurbsCurve = node
|
||||||
|
elif node.getCurveType() == PCTHPR:
|
||||||
|
self.hprNurbsCurve = node
|
||||||
|
elif node.getCurveType() == PCTNONE:
|
||||||
|
if (self.xyzNurbsCurve == None):
|
||||||
|
self.xyzNurbsCurve = node
|
||||||
|
else:
|
||||||
|
print 'Mopath: got a PCT_NONE curve and an XYZ Curve!'
|
||||||
|
elif (node.getCurveType() == PCTT):
|
||||||
|
self.tNurbsCurve = node
|
||||||
|
else:
|
||||||
|
# Iterate over children if any
|
||||||
|
for child in nodePath.getChildrenAsList():
|
||||||
|
self.__extractCurves(child)
|
||||||
|
|
||||||
|
def goTo(self, node, time):
|
||||||
|
if (self.xyzNurbsCurve == None) & (self.hprNurbsCurve == None):
|
||||||
|
print 'Mopath: Mopath has no curves'
|
||||||
|
return
|
||||||
|
self.playbackTime = CLAMP(time, 0.0, self.maxT)
|
||||||
|
if (self.xyzNurbsCurve != None):
|
||||||
|
pos = Point3(0)
|
||||||
|
self.xyzNurbsCurve.getPoint(self.playbackTime, pos)
|
||||||
|
node.setPos(pos)
|
||||||
|
if (self.hprNurbsCurve != None):
|
||||||
|
hpr = Point3(0)
|
||||||
|
self.hprNurbsCurve.getPoint(self.playbackTime, hpr)
|
||||||
|
node.setHpr(hpr)
|
@ -163,7 +163,7 @@ class MopathRecorder(AppShell, PandaObject):
|
|||||||
self.accept(event, method)
|
self.accept(event, method)
|
||||||
|
|
||||||
def createInterface(self):
|
def createInterface(self):
|
||||||
interior = self.interior()
|
interior = self.interior()
|
||||||
# FILE MENU
|
# FILE MENU
|
||||||
# Get a handle on the file menu so commands can be inserted
|
# Get a handle on the file menu so commands can be inserted
|
||||||
# before quit item
|
# before quit item
|
||||||
|
Loading…
x
Reference in New Issue
Block a user