Is this maybe a bug in the engine, or have I mistyped something? My code:
import direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject
from direct.gui.OnscreenText import OnscreenText
from direct.task import Task
from direct.actor import Actor
import math
import sys
class Asset:
def __init__(self):
self.mUID="316.10-1"
#this function does load the mesh, but the animation doesn't work.
#the code is identical to the code in the main class, other than
#replacing the strings with variables.
def Load(self, path, parentNode):
self.mesh = Actor.Actor(path,{"Rotation":path})
self.mesh.setScale(1.0,1.0,1.0)
self.mesh.reparentTo(parentNode)
self.mesh.loop("Rotation")
class Core(DirectObject):
# Temporary task to move the camera
def SpinCameraTask(self, task):
angledegrees = task.time * 6.0
angleradians = angledegrees * (math.pi / 180.0)
base.camera.setPos(20*math.sin(angleradians),-20.0*math.cos(angleradians),6)
base.camera.setHpr(angledegrees, 0, 0)
return Task.cont
def __init__(self):
self.title = OnscreenText(text="Panda3D: Tutorial - Actors",
style=1, fg=(1,1,1,0.5),
pos=(0.8,-0.95), scale = .07)
[color=red]
This code that’s been commented out works perfectly, the mesh animates as it’s supposed to.
#Load the panda actor, and loop its animation
#self.pandaActor = Actor.Actor("content/test/earth",{"Rotation":"content/test/earth"})
#self.pandaActor.setScale(1.0,1.0,1.0)
#self.pandaActor.reparentTo(render)
#self.pandaActor.loop("Rotation")
[color=red]This code calls the class listed up top.
n=Asset()
n.Load("content/test/earth.x",render)
# keyboard assignments
self.accept('escape', sys.exit)
taskMgr.add(self.SpinCameraTask, "SpinCameraTask")
#Set the camera in a fixed position
base.disableMouse()
camera.setPosHpr(14.5, -15.4, 14, 45, -14, 0)
base.setBackgroundColor( 0, 0, 0 )
# the bottom, root, everything starts here.
#------------------------------------------
theCore = Core()
run()
I’ve only been playing with the Panda3D engine for a little while now, but it seems to be a good fit for the project I’m working on. However, this bug’s got me stumped. Anyone have any suggestions?