Walt Disney Internet Group- VR Studio
Entertainment Technology Center, Carnegie Mellon University
Yi Hong Lin
Panda3D, or Platform Agnostic Networked Display Architecture, is a powerful rendering engine for SGI, Linux, Sun, and Windows. It was originally developed by the Walt Disney Imagineering VR Studio and has been used for their massively multiplayer online game Toontown Online. It has since been generously made available to the open source community. The core of the engine is in C++. Panda3D/DIRECT provides a Python scripting interface and utility code.
In this paper, we present an overview of Panda3D technology for developing real time interactive games and VR experiences using Python scripting. We also delineate the various tools and features of the engine and describe some notable projects based in Panda3D as case studies. In conclusion, we discuss plans for the future development of Panda3D.
2) Panda3D Technology
3) Panda and Python
4) Case Studies
5) Future Plans
Panda3D was originally developed at the Disney VR Studio. The VR Studio used a proprietary IRIX-specific system called DWD (Disney's World Designer) to create several DisneyQuest Virtual Reality Attractions, such as "Aladdin's Magic Carpet VR Adventure," "Hercules in the Underworld," and "Pirates of the Caribbean: Battle for the Buccaneer Gold," between 1997 and 2000. In 2000, the VR Studio embarked on the Toontown Online project, and decided to build a new engine that contained many of the DWD design principles, but would be more modular. This would let it be ported to more platforms and more easily changed over time. The new engine was dubbed "Panda3D," ostensibly standing for "Platform Agnostic Networked Display Architecture."
In 2002, the VR Studio decided to make the engine open source, so they could more easily work with universities on Virtual Reality research projects. The system, although quite usable by the team that developed it, was not quite "open source ready." There were several interested users, but building and installing the system was incredibly complex, and there was little in the way of documentation or sample code, so there was no significant open source community right away.
In 2002, Jesse Schell left the VR Studio to join the faculty of the Carnegie Mellon Entertainment Technology Center (ETC). The ETC was looking for something like Panda3D: a 3D engine powerful enough to create compelling experiences, but also open and flexible. Since then, ETC students have been working to make Panda3D usable at the ETC and by the world at large.
Panda3D’s official web site is http://www.etc.cmu.edu/panda3d.
2) Panda3D Technology:
Panda leverages the power of underlying C/C++ framework and a higher level Python-based scripting interface to provide a best of both worlds. Python's late-binding architecture allows programmers to edit their code while it is running. This gives Panda3D its basis for rapid prototyping. Also, it is possible to extend Panda3D's features by using other Python modules in your program. This lets programmers find an already-created module to add the features they want, without having to re-invent the wheel.
Here is a feature list:
- Multiple underlying rendering APIs: DirectX/OpenGL
- Python scripting interface
- Programming on the fly using interactive scripting in the Python shell
- Extensibility using Python modules
- Custom 3D file format, Egg, with exporters for 3D Studio Max and Maya
- Soft skin animation and a sophisticated actor interface for character animation
- DIRECT Tools for GUI-based scene editing
- Particle Effects API and GUI-based particle panel
- Lighting, fog, and animated textures
- Sound using the FMOD library
- Multithreading, event handling, message passing, and finite state machines
- Functions for interpolation, sequencing, and parallelization
- Modules for magnetic tracking for virtual reality
- Input device interfaces
- Extensive scenegraph manipulation modules
3) Panda and Python
There are a number of Panda features that are built on top of Python as augmented tools to assist in rapidly building games and simulations. We briefly discuss them below. We also discuss how the original C/C++ code is built into Python modules, specifically the "Interrogate" program.
Panda3D includes a simple Task scheduling system for the developer's convenience. A Task consists of a function and its associated data that may be called for each frame of the simulation. It is not related to multithreading; the entire Python process is single-threaded, and each scheduled Task is simply run once per frame in round-robin fashion, with "do-later" Tasks deferred in a priority queue.
Events such as mouse clicks or keyboard strokes are managed through one global messenger. Events are used for broadcasting capability through code and as a guarding mechanism to control when responses will be executed. Mouse and keyboard events may be accepted on depression and release. One may also send user-defined events and pass a parameter list with them.
Sequences and Parallels:
Sequences and Parallels allow for more control over when interpolations and functions begin. Any Interval may be included in a Sequence or Parallel. Sequences start the Intervals in the order they are called. The next Interval in line will not begin until the one before it is complete. Parallels run several Intervals at the same time. Interval objects can be played with specific durations or combined into a series of effects performed on a timeline. Intervals can also be paused, resumed, and restarted. It is even possible to jump to any point in the Interval instead of playing them straight through.
There various types of intervals are defined below:
- Lerp Interval – Interval for linearly interpolating NodePaths or functions
(position, rotation, scale, color, etc)
- Actor Interval – Interval for playing animations on Actors
- Mopath Interval – Interval for moving an object along a spline motion path
- Sound Interval – Interval for playing back a sound effect
- Particle Interval – Interval for playing back particle effects
- Function Interval – Interval for executing functions
- Wait Interval – Interval that waits for a specified time and is useful for complex sequences
DIRECT, Panda's level editing and tools system, uses Tk and Pmw extensively for its panel based GUI. It also has features for rendering GUI widgets with Panda itself. Tk and Pmw are used to build all the parameter panels for the various utilities such as the particle panel and the motion path recorder.
One of the truly powerful features of Panda3D is that you can stop a simulation, redefine a method, and start from that point again. This is done using Python features. Panda3D recursively digs through namespaces to find the definition of the class or methods and then swaps them for the new, thus rebinding the new version. There is also special code written to dig out all the stored function pointers, such as events and tasks, and replace those as well.
A key advantage of Panda3D is that it provides developers with the ability to use both C++ and Python simultaneously. Essentially, Panda3D gives programmers the best of both worlds, as they are able to take advantage of the high performance and low-level programming found in C++ in addition to the flexibility, interactive scripting, and rapid-prototyping capabilities of Python. This feature is made possible due to Python’s ability to call C libraries, and ultimately make use of Panda3D’s Interrogate System: an automated C++ Extension Module generation utility similar to SWIG. Although Python is the favored scripting language of Panda3D, the engine is highly extensible in this aspect, as any language that has a foreign function interface can make use of the Interrogate System.
The Interrogate System works like a compiler by scanning and parsing C++ code for the Panda3D-specific, “PUBLISHED” keyword. This keyword marks the particular methods of a class that are to be exposed within a C++ Extension Module for that class which is eventually generated. One benefit of using the “PUBLISHED” keyword is that it alleviates the need for an interface file that provides function prototypes for the class methods that will be exposed within the extension module, as is the case with SWIG. Interrogate turns a class into a loose collection of Python interface wrapper functions that make up the C++ Extension Module. In addition to creating the module, Interrogate generates a table of class relationships, which is then read by the Python FFI (Foreign Function Interface) layer that automatically generates a true object-oriented interface and makes the C++ classes appear to be Python classes.
There are a number of reasons why Interrogate was chosen over SWIG when Panda3D moved to Python as its scripting language of choice. First and foremost, Interrogate had already been written at the time of the change, and it was already capable of reading the existing C++ code and generating object-oriented interfaces within Squeak. When the decision was made to change languages, SWIG was looked at; however, its support for C++ was not quite as robust as Interrogate at the time. Namely, it was not able to support all of the complicated C++ features that were being used, such as templates, nested classes, and function overloading. Another issue that cropped up was that SWIG requires an interface file for each class that needs to expose functions within the C++ Extension Module, and it would have been a daunting task to build an interface file for each Panda class. Overall, it seemed easier to write the Python-based FFI layer that was needed for interrogate than to deal with a new set of issues that would be encountered with a new parser.
Once all of the Python classes have been generated by the Python FFI layer, the Squeeze utility is used to create one single package to store all of the Panda modules. Loading python modules on the Win32 platforms introduces certain amount of latency depending on the CPU. Panda has some 800 python modules. Since these latencies accrue to an unacceptable delay, Squeeze is used to create one large module, greatly reducing the hit. In addition, every file is hashed via md5 when Tootown starts in order to detect hacked, corrupted, or out-of-date files. It is much quicker to md5 one huge file than 800 small files, which is certainly an added benefit.
4) Case Studies:
Screenshots from Toontown Online
Level Editor and DIRECT Tools for Toontown
Disney's massively multiplayer online role playing game (MMORPG) Toontown Online
was built using Panda3D. It was developed using Python scripting. Toontown can
be downloaded online and is less than 30MB compressed. The users are typically
able to play the game after the first few megabytes have been downloaded. The
decision to change over to Python as the scripting language was made some 6
months into the project. These reasons are:
- Well documented, mature language with a well established community.
- Clean syntax and familiar concepts (to C++)
- Easy to extend/embed
- Dynamic/late binding/typeless, making it easy to prototype quickly with it
- No performance or code management problems
- Small and modular
- Cross platform
Toontown was named MMORPG of the year 2003 by Computer Gaming World.
Building Virtual Worlds:
Student projects from the Building Virtual Worlds class
In the Building Virtual Worlds class at the Entertainment Technology Center,
interdisciplinary teams of 4 or 5 students build interactive virtual reality
experiences in two or three weeks. These experiences use Head-Mounted Displays
and magnetic tracking. While 3DS Max, Maya, Deep UV and Deep Paint 3D are used
for content creation, the experience is based in Panda3D. All the scripting
is done in Python. Issues tackled in scripting are:
- Interfacing with the head mount tracking system
- Loading and rendering digital content such as models, animations and sounds
- Collision detection
- Programming interactivity
- Scripting events, states, message handling, input device interfacing etc.
The use of Panda3D produced stunning results in the class.
Airblade- A game demo built by 3 students in 8 weeks with Panda3D
Airblade is a game demo built in Panda by a group of three students in 8 weeks
at the Entertainment Technology Center. It demonstrates the basics of developing
sophisticated games using Panda3D. Some of the Panda3D features it showcases
- Finite state machines
- Animated texture map explosions
- Particle effects
- Complex collision detection and raycasting
- Using a model pool
- Creating a heads-up display using GUI features
- Using tasks for interactive animation
- Using the interval system for prototyping the experience
The demo and source code for Airblade are available at http://www.etc.cmu.edu/panda3d/projects/Airblade
5) Future Plans:
At the Entertainment Technology Center, the Panda project is trying to make
Panda3D an out-of-the-box development tool for games and simulations. It works
closely with Walt Disney VR Studio in improving Panda3D. A major part of the
Panda project at the ETC is also to create extensive documentation for Panda3D
and develop a comprehensive set of tutorials for it.
Some future developments may include:
- Integrating state of the art rendering technology, such as programmable shaders
- General-purpose server side networking code to complement existing client side code released by Disney.
- An easy to use but powerful and generic scene/level editing tool
Panda is also being used at the ETC for a number of game and simulation projects. At the same time the folks at Walt Disney VR Studio are using Panda to develop new content for Toontown Online and their new massively multiplayer online game. We hope that strong interest from the Python community and the open source movement will help make Panda the rapid prototyping tool of choice for games and simulations.
 Panda 3D Website, Entertainment Technology Center, Carnegie Mellon University, http://www.etc.cmu.edu/panda3d.
 Goslin M.,"Postmortem: Disney Online's Toontown by Mike Goslin [01.28.04]", http://www.gamasutra.com/features/20040128/goslin_01.shtml.
 Goslin M., Shochet J. and Schell J.,"Toontown Online:Building Massively Multiplayer Games for the Masses."
 Designing Interactive Theme Park Rides. Jesse Schell and Joe Shochet. IEEE Computer Graphics and Applications. July/August 2001.
 Designing Interactive Theme Park Rides: Lessons Learned Creating Disney’s Pirates of the Caribbean: Battle for the Buccaneer Gold. Jesse Schell and Joe Shochet. Game Developer’s Conference 2001.
 Building an LBE Attraction: Hercules in the Underworld, A Case Study. Joe Shochet and Noah Dudley. Game Developer’s Conference, 1999.