mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
fix bitrot, add Mopath.draw()
This commit is contained in:
parent
e0323969a5
commit
7d7edee889
@ -1,7 +1,7 @@
|
|||||||
from direct.showbase.DirectObject import DirectObject
|
from direct.showbase.DirectObject import DirectObject
|
||||||
from direct.directtools.DirectGeometry import *
|
from direct.directtools.DirectGeometry import *
|
||||||
|
|
||||||
from pandac.PandaModules import NodePath
|
from panda3d.core import NodePath, LineSegs
|
||||||
|
|
||||||
class Mopath(DirectObject):
|
class Mopath(DirectObject):
|
||||||
|
|
||||||
@ -144,19 +144,34 @@ class Mopath(DirectObject):
|
|||||||
def stop(self):
|
def stop(self):
|
||||||
taskMgr.remove(self.name + '-play')
|
taskMgr.remove(self.name + '-play')
|
||||||
|
|
||||||
def __playTask(self, state):
|
def __playTask(self, task):
|
||||||
time = globalClock.getFrameTime()
|
time = globalClock.getFrameTime()
|
||||||
dTime = time - state.lastTime
|
dTime = time - task.lastTime
|
||||||
state.lastTime = time
|
task.lastTime = time
|
||||||
if (self.loop):
|
if (self.loop):
|
||||||
cTime = (state.currentTime + dTime) % self.getMaxT()
|
cTime = (task.currentTime + dTime) % self.getMaxT()
|
||||||
else:
|
else:
|
||||||
cTime = state.currentTime + dTime
|
cTime = task.currentTime + dTime
|
||||||
if ((self.loop == 0) and (cTime > self.getMaxT())):
|
if ((self.loop == 0) and (cTime > self.getMaxT())):
|
||||||
self.stop()
|
self.stop()
|
||||||
messenger.send(self.name + '-done')
|
messenger.send(self.name + '-done')
|
||||||
self.node = None
|
self.node = None
|
||||||
return Task.done
|
return task.done
|
||||||
self.goTo(self.node, cTime)
|
self.goTo(self.node, cTime)
|
||||||
state.currentTime = cTime
|
task.currentTime = cTime
|
||||||
return Task.cont
|
return task.cont
|
||||||
|
|
||||||
|
def draw(self, subdiv = 1000):
|
||||||
|
""" Draws a quick and cheesy visualization of the Mopath using
|
||||||
|
LineSegs. Returns the NodePath representing the drawing. """
|
||||||
|
|
||||||
|
ls = LineSegs('mopath')
|
||||||
|
p = Point3()
|
||||||
|
for ti in range(subdiv):
|
||||||
|
t = float(ti) / float(subdiv) * self.maxT
|
||||||
|
tp = self.calcTime(t)
|
||||||
|
self.xyzNurbsCurve.getPoint(tp, p)
|
||||||
|
ls.drawTo(p)
|
||||||
|
|
||||||
|
return NodePath(ls.create())
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user