Can anyone spot a problem in my code?
Problems:
BoxMan_stand seems to be ‘stuck’ on frame 1.
BoxMan_walk does not work at all- for some reason it plays BoxMan.egg (the rigging pose which isn’t animated at all)
I haven’t set any collision flags in maya.
BoxMan is a character in the rigging position, BoxMan_stand is an idle animation and BoxMan_walk is a walking animation. These are all seperate files converted from three .mb files using:
maya2egg2008 -a both -o “eggModels/FILE.egg” “mayaModels/FILE.mb”
(Where FILE is whichever scene I’m converting)
I’ve checked each .egg in pview and they all play correctly.
import direct.directbase.DirectStart
from pandac.PandaModules import *
from direct.showbase.DirectObject import DirectObject
from direct.task import Task
from direct.actor import Actor
from direct.interval.IntervalGlobal import *
import math, sys
environ = loader.loadModel("models/environment")
environ.reparentTo(render)
environ.setScale(0.25,0.25,0.25)
environ.setPos(-8,42,0)
box1 = loader.loadModel("eggModels/box")
box1.reparentTo(render)
box1.setScale(1,1,1)
box1.setPos(-8,0,0)
box2 = loader.loadModel("eggModels/box")
box2.reparentTo(render)
box2.setScale(1,1,1)
box2.setPos(-8,0,3.9)
class World(DirectObject):
def __init__(self):
self.BoxMan = Actor.Actor("eggModels/BoxMan",
{"stand":"eggModels/BoxMan_stand",
"walk":"eggModels/BoxMan_walk"})
self.BoxMan.reparentTo(render)
self.BoxMan.setPos(0,-10,0)
#self.BoxMan.loop("stand")
self.BoxMan.keyMap = {"forward":0}
self.accept("escape", sys.exit)
self.accept("arrow_up", self.setKey, ["forward", 1])
self.accept("arrow_up-up", self.setKey, ["forward", 0])
taskMgr.add(self.UpdateBox, "UpdateBox")
def setKey(self, key, value):
self.BoxMan.keyMap[key] = value
def UpdateBox(self, task):
if self.BoxMan.keyMap["forward"]==1:
self.BoxMan.setPos(0,-10,0)
self.BoxMan.stop()
self.BoxMan.loop("walk")
else:
self.BoxMan.setPos(0,0,0)
self.BoxMan.stop()
self.BoxMan.loop("stand")
return task.cont
base.camera.setPos(10,10,0)
w = World()
run()