Panda3D executing error?

So I made a test program which just shows a textured box and I tried to convert my files into a installation file using packpanda.

It worked fine and I installed my game. But the problem is that whenever I run my game, it closes. I had no errors when running with ppython. And I also tried this with different file but this time, the game was running fine but I couldn’t control my model which worked fine using ppython.

I really don’t know what the problem is. Please help me.

Possible you have absolute paths instead of the relative somewhere, or you load your model as *.egg, though packpanda converts it to the *.bam. In the last case you should use loader.loadModel(‘my_path/my_model’) instead of loader.loadModel(‘my_path/my_model.egg’). Panda automaticaly recognize needed extensions.

Have you checked your log files for errors, and if so, what did you find? (The log files should be located as described on this page.)

What do you mean when you say that you “couldn’t control [your] model”? What should have been happening, and what, if anything, was actually happening?

I changed my ‘box.egg.pz’ to ‘box’ and it didn’t work.

And what I mean by ‘I couldn’t control’ is that I put key acceptions to my cube so that I can control my cube.

    if keys.keyMap['w'] == True:
        self.box2.setY(self.box2, 0.1 * dt)
    if keys.keyMap['s'] == True:
        self.box2.setY(self.box2, -0.1 * dt)
    if keys.keyMap['a'] == True:
        self.box2.setX(self.box2, -0.1 * dt)
    if keys.keyMap['d'] == True:
        self.box2.setX(self.box2, 0.1 * dt)

    if keys.keyMap['escape'] == True:
        sys.exit()

which didn’t work even thought it works perfectly fine in ppython.

Ahh, fair enough. Before speculating further or moving on to examining code, however, are any errors being reported in the log file (as I asked previously)?

There was no errors recorded and I tried few stuffs which didn’t work.

This is my full codes…it’s little dirty

‘main.py’

import direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject
from panda3d.core import WindowProperties
from pandac.PandaModules import CollisionNode
from pandac.PandaModules import CollisionTraverser
from pandac.PandaModules import CollisionHandlerPusher
from pandac.PandaModules import CollisionBox
from pandac.PandaModules import CollisionHandlerQueue

from pandac.PandaModules import CollisionSphere

import sys
import settings
import environment
import keys


# default variables/settings

dt = settings.dt
keys = keys.Keys()
wProps = WindowProperties()
wProps.setCursorHidden(True)
base.win.requestProperties(wProps)

cPosX = base.camera.getX()
cPosY = base.camera.getY()
cPosZ = base.camera.getZ()
# classes/functions

class Box(DirectObject):
    def __init__(self):
        #base.disableMouse()

        self.init_collision()

        self.box1 = loader.loadModel('resources/box.egg.pz')
        self.box1.reparentTo(render)
        self.box1.setScale(5, 5, 5)
        self.box1.setPos(0, 0, 0)

        self.box2 = loader.loadModel('resources/box.egg.pz')
        self.box2.reparentTo(render)
        self.box2.setScale(10, 10, 10)
        self.box2.setPos(2, 30, -5)

        # collision detection

        self.cBox1N = CollisionNode('cBox1N')
        self.cBox1 = CollisionSphere(0.5, 0.5, 0.5, 0.5)
        self.cBox1N.addSolid(self.cBox1)
        self.cBox1N = render.attachNewNode(self.cBox1N)
        self.cBox1N.reparentTo(self.box1)
        self.cBox1N.show()

        self.cBox2N = CollisionNode('cBox2N')
        self.cBox2 = CollisionSphere(0.5, 0.5, 0.5, 0.5)
        self.cBox2N.addSolid(self.cBox2)
        self.cBox2N = render.attachNewNode(self.cBox2N)
        self.cBox2N.setPos(0, 0, 0)
        self.cBox2N.reparentTo(self.box2)
        self.cBox2N.show()

        base.cTrav.addCollider(self.cBox2N, self.cHan)
        #base.pusher.addCollider(self.ObjBox1, self.box1)

        taskMgr.add(self.boxMoveControl, 'boxMoveControl')

    def init_collision(self):
        base.cTrav = CollisionTraverser()
        base.pusher = CollisionHandlerPusher()
        self.cHan = CollisionHandlerQueue()

    def boxMoveControl(self, task):
        if dt > 0.60:
            return task.cont

        #self.box1.setY(self.box1, 0.1 * dt)

        print self.cHan.getNumEntries()

        if keys.keyMap['w'] == True:
            self.box1.setY(self.box1, 0.1 * dt)
        if keys.keyMap['s'] == True:
            self.box1.setY(self.box1, -0.1 * dt)
        if keys.keyMap['a'] == True:
            self.box1.setX(self.box1, -0.1 * dt)
        if keys.keyMap['d'] == True:
            self.box1.setX(self.box1, 0.1 * dt)

        if keys.keyMap['escape'] == True:
            sys.exit()

        #if base.mouseWatcherNode.hasMouse() == True:
            #mpos = base.mouseWatcherNode.getMouse()
            #base.camera.setP(mpos.getY() * 30)
            #base.camera.setH(mpos.getX() * -30)

        return task.cont


print('delta time : ', float(dt))
print cPosX, cPosY, cPosZ

settings = settings.Settings()

#environ = environment.Environ()
box = Box()

settings.desettings()

run()

I have few different modules(import keys, import settings etc.) but I’m pretty sure this is not a problem.

so…any suggestions?

Erm, would you edit your post to place that between “code” tags, please? That should preserve the indentation, making the code rather easier to read and preventing indentation-related issues from going unnoticed, as well as leaving your post shorter.

I indented it. Do you think I have to post my other modules? (import keys, import settings etc)

Please attach full packed example if you not mind.

Are the models packed with the p3d? Are you packing the egg module when building the p3d? I think you also may need the models package if you want to use the default models that ship with panda.
I think the log would be much help. You can find the log in the ‘log’ folder:
on windows:
Documents and Settings<your name>\Local Settings\Application Data\Panda3D
or
\Users<your name>\AppData\Local\Panda3D
(the names may change if you use non-english windows)
on mac:
/Users//Library/Caches/Panda3D
on linux:
~/.panda3d

I do notice one thing:

In the function “boxMoveControl”, you have the following:

        if dt > 0.60:
            return task.cont

Have you checked (perhaps with a simple print-statement in that location) that your “dt” value isn’t exceeding 0.6?

Otherwise it might be helpful to see your “keys” and “settings” files.

That’s a good point, actually–and note that the “default models” include elements used by DirectRadioButton and DirectDialog.

Ok, rather than just posting my codes here, I will leave a link to my files…

dropbox.com/s/qe3o6fvdpswte … g.zip?dl=0

Try packpanda my files…

Guys I found a little clue. Today I ran my main.py with ppython and I couldn’t control my cube which was the exact same error with packpanda. But I still don’t know why it’s not working.

    keys = keys.Keys().keyMap

    def boxMoveControl(self, task):
        if dt > 0.60:
            return task.cont

        #self.box1.setY(self.box1, 0.1 * dt)

        print self.cHan.getNumEntries()

        if keys['w'] == True:
            self.box1.setY(self.box1, 0.1 * dt)
        if keys['s'] == True:
            self.box1.setY(self.box1, -0.1 * dt)
        if keys['a'] == True:
            self.box1.setX(self.box1, -0.1 * dt)
        if keys['d'] == True:
            self.box1.setX(self.box1, 0.1 * dt)

        if keys['escape'] == True:
            sys.exit()

‘keys.py’

from direct.showbase.DirectObject import DirectObject

class Keys(DirectObject):
    def __init__(self):
        self.keyMap = {'w':False,
        's':False,
        'a':False,
        'd': False,
        'up':False,
        'escape':False}

        self.accept('w', self.setKey, ['w', True])
        self.accept('s', self.setKey, ['s', True])
        self.accept('a', self.setKey, ['a', True])
        self.accept('d', self.setKey, ['d', True])
        self.accept('escape', self.setKey, ['escape', True])
        self.accept('w-up', self.setKey, ['w', False])
        self.accept('s-up', self.setKey, ['s', False])
        self.accept('a-up', self.setKey, ['a', False])
        self.accept('d-up', self.setKey, ['d', False])


    def setKey(self, key, value):
        self.keyMap[key] = value

maybe try loading your models like

self.box1 = loader.loadModel('resources/box')

rather than

self.box1 = loader.loadModel('resources/box.egg.pz')

Oh my Jesus Christ. I found a solution. Thaumaturge was correct.

if dt > 0.60:
            return task.cont

This piece of code ruined my game…my delta time was higher than 0.60 so it was just looping this code forever…

I guess ppython is faster than executed version.

Anyways…thanks for the answers guys!