Hi everyone, thought I’d ask about something as I’m trying to get up to speed with Panda.
I’m currently trying out the CMU’s Scene Editor, and I can’t get past the first video tutorial. I can save the .py just fine, but I can’t seem to actually import it into my code. The guy in the video has an odd sort of command line setup, so somehow he is able to tell panda to import and instantiate the class through the CL (which he never shows how to do, and its not in the manual). I tried manually putting it into my code, but I keep getting a error about DirectObject.
Here’s the code doing the import and instaniation:
import direct.directbase.DirectStart from pandac.PandaModules import * from direct.gui.OnscreenText import OnscreenText import sys # Import TestScene.py script from TestScene import * # Instantiate of the SavedScene class from TestScene.py SavedScene () #But even with them, it gives me an error saying 'DirectObject' is not defined
Then I get an error from the console like this when I attempt running it:
DirectStart: Starting the game. Known pipe types: wglGraphicsPipe (all display modules loaded.) Traceback (most recent call last): File "fps.py", line 13, in <module> from TestScene import * File "E:\My Dropbox\Data\Scripts\TestScene.py", line 28, in <module> class SavedScene(DirectObject): # We inherit from DirectObject so that we ca n use self.accept method to catch messages NameError: name 'DirectObject' is not defined Press any key to continue . . .
I’m not sure what I’m doing wrong (total python noob here). Unfortunately the tutorial doesn’t help with this.
Edit: I just double checked with a freshly exported .py for a scene, and double checked my path variables. It seems the problem is related to the python files the editor itself puts out, since I get the same error running them directly.
I tried adding the following to the list of imported modules that the scene editor automatically puts in a .py that it generates:
from direct.showbase import DirectObject
I then get this output from the console:
DirectStart: Starting the game. Known pipe types: wglGraphicsPipe (all display modules loaded.) Traceback (most recent call last): File "TestScene.py", line 30, in <module> class SavedScene(DirectObject): # We inherit from DirectObject so that we ca n use self.accept method to catch messages File "TestScene.py", line 66, in SavedScene lightAttrib = LightAttrib.makeAllOff()# Initialize lighting NameError: name 'LightAttrib' is not defined Press any key to continue . . .
So it seems like the scene editor isn’t handling things properly. Did I miss something somewhere that this editor shouldn’t be used with Panda 1.7.0?
Edit2: and Rdb seemed to suggest in IRC that there are other scene editors, but I don’t know where they are (or if they are any good). What’s everyone’s preferred way of dealing with scene data in their games?