Browse Source

Added support for $MAIN_DIR in model-path

Josh Yelon 19 years ago
parent
commit
4be8e217f7
2 changed files with 10 additions and 5 deletions
  1. 7 2
      direct/src/showbase/ShowBase.py
  2. 3 3
      doc/makepanda/config.in

+ 7 - 2
direct/src/showbase/ShowBase.py

@@ -27,8 +27,7 @@ from direct.showbase.BufferViewer import BufferViewer
 from direct.task import Task
 from direct.directutil import Verify
 import EventManager
-import math
-import sys
+import math,sys,os
 import Loader
 import time
 from direct.fsm import ClassicFSM
@@ -50,6 +49,12 @@ class ShowBase(DirectObject.DirectObject):
     notify = directNotify.newCategory("ShowBase")
 
     def __init__(self):
+
+        # Locate the directory containing the main program
+        maindir=os.path.abspath(sys.path[0])
+        self.mainDir = Filename.fromOsSpecific(maindir).getFullpath()
+        ExecutionEnvironment.setEnvironmentVariable("MAIN_DIR", self.mainDir)
+
         # Get the dconfig object
         #self.config = ConfigConfigureGetConfigConfigShowbase
         self.config = config

+ 3 - 3
doc/makepanda/config.in

@@ -39,13 +39,13 @@ default-directnotify-level warning
 # a special variable that indicates the same directory as this
 # particular Config.prc file.
 
-model-path    .
+model-path    $MAIN_DIR
 model-path    $THIS_PRC_DIR/..
 model-path    $THIS_PRC_DIR/../models
-sound-path    .
+sound-path    $MAIN_DIR
 sound-path    $THIS_PRC_DIR/..
 sound-path    $THIS_PRC_DIR/../models
-texture-path  .
+texture-path  $MAIN_DIR
 texture-path  $THIS_PRC_DIR/..
 texture-path  $THIS_PRC_DIR/../models