Hello,
I’m making the Panda3d tutorial’s and changing some things.
This is the base code of “Panda3D Manual: Loading and Animating the Panda Model”:
import direct.directbase.DirectStart
from direct.task import Task
from direct.actor import Actor
import math
#Load the first environment model
environ = loader.loadModel("models/environment")
environ.reparentTo(render)
environ.setScale(0.25,0.25,0.25)
environ.setPos(-8,42,0)
#Task to move the camera
def SpinCameraTask(task):
angledegrees = task.time * 6.0
angleradians = angledegrees * (math.pi / 180.0)
base.camera.setPos(20*math.sin(angleradians),-20.0*math.cos(angleradians),3)
base.camera.setHpr(angledegrees, 0, 0)
return Task.cont
taskMgr.add(SpinCameraTask, "SpinCameraTask")
#Load the panda actor, and loop its animation
pandaActor = Actor.Actor("models/panda-model",{"walk":"models/panda-walk4"})
pandaActor.setScale(0.005,0.005,0.005)
pandaActor.reparentTo(render)
pandaActor.loop("walk")
run()
Of course, it’s work.
So, I tryed to change some things, nothing big, check the last lines:
import direct.directbase.DirectStart
from direct.task import Task
from direct.actor import Actor
import math
#carregando ambiente
ambiente = loader.loadModel("models/environment")
ambiente.setScale(0.25,0.25,0.25)
ambiente.setPos(-8,42,0)
ambiente.reparentTo(render)
#fim carrega ambiente
#Task (rotina(?)) para mover a camera
def SpinCameraTask(task):
angGraus = task.time *6.0
angRadianos = angGraus * (math.pi / 180.0)
base.camera.setPos(20.0*math.sin(angRadianos),
-20.0*math.cos(angRadianos),
3)
base.camera.setHpr(angGraus,0,0)
return Task.cont
#fim Task Camera
taskMgr.add(SpinCameraTask,"CameraTask")
def AddPanda():
pandaActor = Actor.Actor("models/panda-model",
{"walk":"models/panda-walk4"})
pandaActor.setScale(0.005,0.005,0.005)
pandaActor.reparentTo(render)
pandaActor.loop("walk")
#print (pandaActor.getCurrentAnim())
AddPanda()
run()
And, of course, something wrong happened: My Actor isn’t walking.
Sorry if i’m making a stupdy question, but: Is the “Panda Actor” object destroyed after the method and I’m rendering only the model? I really dont understood…
Sorry about my poor english.
Thanks and Peace,
Amauri Silva