Home    Features    Download    Screenshots    Manual    Reference    Forums    License    Contact   
 
  Panda3D Manual: DirectStart
  <<prev top next>>     

An overview of DirectStart

If you are already up to speed with Python, the following code may look like a black box:

import direct.directbase.DirectStart
run()

This section provide some key details on the function of this import statement.

DirectStart creates and instance of the class ShowBase, which itself inherits DirectObject. Under Linux, the relevant file can be found:

/usr/share/panda3d/direct/src/showbase

On Windows, the code is (by default) located in:

C:\Panda3D-1.X.X\direct\src\showbase

An important item created meanwhile is a base task manager as taskMgr. The function run() is in fact a single call to launch this task manager.

Apparent global variables created

Some key variables used in all Panda3D scripts are actually attributes of the ShowBase instance. Here is the relevant code making these attribute global in scope:

        __builtin__.base = self
        __builtin__.render2d = self.render2d
        __builtin__.aspect2d = self.aspect2d
        __builtin__.render = self.render
        __builtin__.hidden = self.hidden
        __builtin__.camera = self.camera
        __builtin__.loader = self.loader
        __builtin__.taskMgr = self.taskMgr
        __builtin__.jobMgr = self.jobMgr
        __builtin__.eventMgr = self.eventMgr
        __builtin__.messenger = self.messenger
        __builtin__.bboard = self.bboard
        __builtin__.run = self.run
        __builtin__.ostream = Notify.out()
        __builtin__.directNotify = directNotify
        __builtin__.giveNotify = giveNotify
        __builtin__.globalClock = globalClock
        __builtin__.vfs = vfs
        __builtin__.cpMgr = ConfigPageManager.getGlobalPtr()
        __builtin__.cvMgr = ConfigVariableManager.getGlobalPtr()
        __builtin__.pandaSystem = PandaSystem.getGlobalPtr()

This is where the commonly used objects base, render, render2d, camera, messenger, taskMgr are created. There are more such variables added to __builtin__. Consult the code if you want to find them all.

Note that this way of exposing these attributes make them available globaly even though these will not be returned by a call to the built-in function dir().

  <<prev top next>>     
.
screenshot
Disney's Pirates of the Caribbean Online
screenshot
Psychedelic Flythrough of the Mind of a Computer
screenshot
Disney Pinball: real physics and cool settings