Panda3D's level editor / scene editor

Hello Panda3D community,

I am relatively new to Panda3D and have start working on developing my game with via python scripts. I am currently attempting to use Panda3D’s level editor (in direct/leveleditor). I am having mixed results. Originally, I installed version 1.7.0 and ran ppython then typed in “from direct.leveleditor import LevelEditorStart” and even “from direct.leveleditor import *”. Each time I received an error stating “No module named wx”. As I have little to no experience with python, I spent a few minutes troubleshooting to no avail. I am assuming there is some kind of library or external reference that I don’t have configured properly (similar to not being able to find a header file in C/C++?)

Second attempt, I reverted to uninstalling 1.7 and attempting to run on a more stable version. I installed 1.6.2 and did the same thing. Now I am getting an error that says “No module named otp.avatar”. I am beginning to think there is some additional setup needed to run this editor. I found the wiki page that describes how to use the editor, however it doesn’t explain how to launch it. I found instructional videos in the manual but I believe they are somewhat dated as they refer to launching the “scene editor”.

Anyway, all/any help is much appreciated.

Right, if you haven’t yet you have to install wx, which is a library for user interfaces if I’m not mistaken. I’m also not sure if the editor can be used before 1.7.x.

But wait for someone else to confirm this.

Yes, it appeared that I have to install wxPython before continuing. Working now.

Why don’t you just use Blender with the Chicken exporter? Its interface is much easier to use, and you can export arbitrary tags and empties for object placement.

To get the NodePath to an empty in your level file, just use .find(’**/’). To get a tag value, just use .getTag(’’)

Pretty easy if you ask me.

Unfortunately, I am very much unfamiliar with Blender. I have used it to make an EXTREMELY simple model before but that’s about it. Are there any tutorials or resources you can point me to that use the approach you are describing? I am finding the Panda3D level editor rather useless…

To get set up with this system, you would have to do the following things:

1: Get the chicken exporter

Just download it from sourceforge. It should be just a zip file.

2: Unzip it and put it in your blender scripts directory

This part is slightly difficult to get right. Your scripts folder is under the folder “.blender” and then in “scripts”, which if you’re using Linux, would be normally hidden (Windows should be visible, though). If it is hidden, press Ctrl-H in your file browser. For Windows, it should be in your Program Files under Blender Foundation (I think) and in Linux the “.blender” folder should be right at your home folder.

After looking at your zip file, you should see that it has the exporter script and 2 folders named “bpydata” and “bpymodules”. Your corresponding script folder (called “scripts” in the “.blender” folder) should also have the “bpydata” and “bpymodules” folders. Copy the contents of your zip file to those directories specified by the folder structure in the zip file (I’m making this sound really complicated, but once you get down to it, it’s obvious). You should only be copying files, not folders.

Once it is all in there, fire up Blender. Split up your workspace by right-clicking along a window border, and then change the window type to “Scripts Window” by clicking on the icon in the lower-left corner of the window. Then, go to Scripts -> Export -> Chicken R91 (.egg)… The script should just run, giving you a GUI of some sort.

Actually Setting Up a Level

Normally when you set up a level using this method, you typically only want to export placeholders whereby in the script you can substitute those placeholders for game objects. That way, you are only exporting positions, rotations, and scales instead of all of the vertex, texture, and geometry data. To do this, you need to be able to know how to name your objects and how to add properties to them. To name the object, go the Objects panel (F7), go to the Object and Links pane, and right next to the OB: thing, click it and change the name to whatever is more descriptive. To see the name in your 3d window, click on the Name button under Draw Extra in the same panel (but in the Draw pane).

Any object you use in Blender can be made as a placeholder, but you have to tell the Chicken exporter that this is what you want. To do so, go to the Logic panel (F4) and click on Add Property. Switch the data type to Bool, name it “ForceEmpty”, and mark it True. Now the Chicken exporter will treat that object as an empty, a point in space that’s rotated and scaled.

The “Add Property” button mentioned earlier is also how one can apply tags to their objects. I would usually use Strings, but I’m pretty sure it supports all data types.

To export the level, select everything by pressing A, click “Update Selection” in the Chicken GUI, select your file destination, and click Export. This .egg file how holds your level data.

Accessing Objects from Your Level Data

First, you must load your level .egg file using loader.loadModel(). Then, for debug purposes, you would want to print out the contents of your level file using .ls()

level = loader.loadModel('Level1')
level.ls()

Every node should be listed, and any tags that a node has will be shown as [] on the same line. To get a handle for an object in your level just do the following (using an example):

level = loader.loadModel('Level1')

# Show level
level.ls()

# Load my player
player = loader.loadModel('Player')

# Get my player placeholder in the level (I named my holder "Player Placeholder")
placeholder = level.find('**/PlayerPlaceholder')

# Set my player according to my placeholder
player.setPos(placeholder.getPos())
player.setHpr(placeholder.getHpr())
player.setSx(placeholder.getSx())
player.setSy(placeholder.getSy())
player.setSz(placeholder.getSz())

# Get the the value of my "health" tag from my placeholder
health = placeholder.getTag('health')

If you need clarification, just ask me.
[/code]

Thanks for that amazingly detailed response! That was very helpful. Can I get your input on the following?

I am working on a scrolling “shoot-em” up style game. It’s using 3D models/terrain but gameplay will be very similar to that of older 2D retro games. (3rd person bird’s eye view, character mainly just moves on x,y axis). The way I envision using blender, after your awesome description is to use it to create all the terrain and “static” environment. Then add the place holders into this environment for dynamic objects (powerups, enemy spawn points, etc). Whenever the camera pans over one of these “place holders” an event is triggered (i.e. activate enemy actor). Is this the correct/best setup to use? Or should the terrain/static environment be loaded separately?

Thanks in advance!

Sorry for the slow reply. I’ve been gone all weekend.

You’re describing the exact same method as what I am doing! I usually design the static environment and export that geometry data along with the level. In the script, you would have to load the geometry in somewhere anyway, so you might as well make it convenient for yourself by putting the static geometry in your level file.

For designing your triggers, I would typically just make a box or sphere and scale it while in Object mode. The reason why is because I know that each Blender unit is equal to one Panda unit, and that I know that my box always start with a side length of 2 and for the sphere a radius of 1. What I’m getting at is that you can use the scales to setup the dimensions of the collision shape that you want to create. You can also set the draw type (in the Object (F7) panel) to Wireframe so that you can still see everything else.

Your setup looks good, now it’s just a matter of churning out the levels!

Thanks again for the reply. Working on getting familiar with Blender now (as well as Panda3D!). So much to learn, so little time! :smiley:

If you don’t mind, I may contact you if/when I run across anymore issues.

Thanks again!

No problem. :smiley: You can send me a private message anytime! Yea, it’s hard to make stuff all by yourself… I have yet to finish one yet, and I’ve been at it for more than 3 years!