Scene Editing

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. :frowning:

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?

Hi there,
I dunnoo if this is where you found CMU’s level editor, though I can tell you that the most recent version I know of is here:

you can find one of the most recent level editor here

One of the reasons you had trouble finding it is that it’s still under development (though keep in mind under development and unusable are two completely different things, in fact a lot of it is just finding bugs, so if you do find any be sure to let us know :wink: )

Now on to your issues running the code,
the following import lines should fix all problems for you, simply put them at the very top of your file that you’re running

import direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject
from pandac.PandaModules import *

note that the “pandac.PandaModules import *” line will cause your load times to be huge, (about a minute, or less) so if you want to speed up load times a bit, simply look at your errors like for instance:

NameError: name 'LightAttrib' is not defined 

simply means that you should import LightAttrib, the “pandac.PandaModules import *” will import every panda module, basically, (except for DirectStart and DirectObject, which are the two lines I gave you above :wink: )

in the case of the error above you would put

from pandac.PandaModules import LightAttrib

simply changing adding that line multiple times until python stops complaining that you’re missing things, and then your loads times will be uber fast :wink:

Otherwise I’d suggest the simple and easy fix

from pandac.PandaModules import *

that takes care of like 70% of panda’s modules for you, keep in mind that it is loading 70% of panda’s modules though, so load times can become hectic, okay?

Good luck! :wink:

Well from pandac.PandaModules import * doesnt seam to slow loading time for me even for a second. What about you guys?

strange, that’s always slowed my startup time quiet a bit. Though I do develop on netbooks and weknow how slow those hard drives run :smiley:

~powerpup118

Well, adding those 3 lines to the very top of the ‘scene’ file I was importing did the trick.

I basically just had to stop trying last night because I was tired, and was getting all kinds of weird results trying to do what you said(like having the scene come up in a separate window, lol).

So I started again fresh today, made sure I was trying everything with new files, and it loaded the scene into the current window like I wanted. Although I didn’t notice much of a slow down with all the modules being loaded. Only thing I’ve noticed is that the scene I’m loading has had some funky effects on the camera (I’m using the most recent for of this FPS setup ) But I think I can work it out.

Thanks a lot for the help. :slight_smile:

As for that newish Level Editor, I had a problem getting it started. Posted in that thread about it.