Browse Source

speedtree for makepanda

David Rose 15 years ago
parent
commit
4a2cf37182
3 changed files with 110 additions and 0 deletions
  1. 6 0
      makepanda/confauto.in
  2. 77 0
      makepanda/makepanda.py
  3. 27 0
      makepanda/makepandacore.py

+ 6 - 0
makepanda/confauto.in

@@ -110,3 +110,9 @@ paranoid-clock 1
 # and don't specify an extension.
 # and don't specify an extension.
 
 
 default-model-extension .egg
 default-model-extension .egg
+
+# If we have the SpeedTree library available, we'll want to use it for
+# loading compiled SpeedTree tree objects, and SpeedTree forest
+# tables.
+#st#load-file-type srt pandaspeedtree
+#st#load-file-type stf pandaspeedtree

+ 77 - 0
makepanda/makepanda.py

@@ -57,6 +57,7 @@ PkgListSet(["PYTHON", "DIRECT",                        # Python support
   "OPENGL"] + DXVERSIONS + ["TINYDISPLAY", "NVIDIACG", # 3D graphics
   "OPENGL"] + DXVERSIONS + ["TINYDISPLAY", "NVIDIACG", # 3D graphics
   "OPENAL", "FMODEX", "FFMPEG",                        # Multimedia
   "OPENAL", "FMODEX", "FFMPEG",                        # Multimedia
   "ODE", "PHYSX",                                      # Physics
   "ODE", "PHYSX",                                      # Physics
+  "SPEEDTREE",                                         # SpeedTree
   "ZLIB", "PNG", "JPEG", "TIFF", "SQUISH", "FREETYPE", # 2D Formats support
   "ZLIB", "PNG", "JPEG", "TIFF", "SQUISH", "FREETYPE", # 2D Formats support
   ] + MAYAVERSIONS + MAXVERSIONS + [ "FCOLLADA",       # 3D Formats support
   ] + MAYAVERSIONS + MAXVERSIONS + [ "FCOLLADA",       # 3D Formats support
   "VRPN", "OPENSSL",                                   # Transport
   "VRPN", "OPENSSL",                                   # Transport
@@ -293,11 +294,13 @@ SdkLocatePython(RTDIST)
 SdkLocateVisualStudio()
 SdkLocateVisualStudio()
 SdkLocateMSPlatform()
 SdkLocateMSPlatform()
 SdkLocatePhysX()
 SdkLocatePhysX()
+SdkLocateSpeedTree()
 
 
 SdkAutoDisableDirectX()
 SdkAutoDisableDirectX()
 SdkAutoDisableMaya()
 SdkAutoDisableMaya()
 SdkAutoDisableMax()
 SdkAutoDisableMax()
 SdkAutoDisablePhysX()
 SdkAutoDisablePhysX()
+SdkAutoDisableSpeedTree()
 
 
 if (RTDIST and SDK["PYTHONVERSION"] != "python2.6" and DISTRIBUTOR == "cmu"):
 if (RTDIST and SDK["PYTHONVERSION"] != "python2.6" and DISTRIBUTOR == "cmu"):
     exit("The CMU rtdist distribution must be built against Python 2.6!")
     exit("The CMU rtdist distribution must be built against Python 2.6!")
@@ -454,6 +457,18 @@ if (COMPILER=="MSVC"):
         IncDirectory("PHYSX", SDK["PHYSX"] + "/Cooking/include")
         IncDirectory("PHYSX", SDK["PHYSX"] + "/Cooking/include")
         # We need to be able to find NxCharacter.dll when importing code library libpandaphysx
         # We need to be able to find NxCharacter.dll when importing code library libpandaphysx
         AddToPathEnv("PATH", SDK["PHYSX"]+"/../Bin/win32/")
         AddToPathEnv("PATH", SDK["PHYSX"]+"/../Bin/win32/")
+    if (PkgSkip("SPEEDTREE")==0):
+        libdir = SDK["SPEEDTREE"] + "/Lib/Windows/VC9/"
+        debugext = ''
+        if (GetOptimize() <= 2 and sys.platform.startswith("win")): debugext = "_d"
+        libsuffix = "_v%s_VC90MT_Static%s.lib" % (SDK["SPEEDTREEVERSION"], debugext)
+        LibName("SPEEDTREE", "%sSpeedTreeCore%s" % (libdir, libsuffix))
+        LibName("SPEEDTREE", "%sSpeedTreeForest%s" % (libdir, libsuffix))
+        LibName("SPEEDTREE", "%sSpeedTree%sRenderer%s" % (libdir, SDK["SPEEDTREEAPI"], libsuffix))
+        LibName("SPEEDTREE", "%sSpeedTreeRenderInterface%s" % (libdir, libsuffix))
+        if (SDK["SPEEDTREEAPI"] == "OpenGL"):
+            LibName("SPEEDTREE",  "%sglew32.lib" % (libdir))
+        IncDirectory("SPEEDTREE", SDK["SPEEDTREE"] + "/Include")
 
 
 if (COMPILER=="LINUX"):
 if (COMPILER=="LINUX"):
     PkgDisable("AWESOMIUM")
     PkgDisable("AWESOMIUM")
@@ -1423,6 +1438,7 @@ PRC_PARAMETERS=[
 def WriteConfigSettings():
 def WriteConfigSettings():
     dtool_config={}
     dtool_config={}
     prc_parameters={}
     prc_parameters={}
+    speedtree_parameters={}
     plugin_config={}
     plugin_config={}
 
 
     if (sys.platform.startswith("win")):
     if (sys.platform.startswith("win")):
@@ -1527,6 +1543,16 @@ def WriteConfigSettings():
     else:
     else:
         dtool_config["USE_GENERIC_DXERR_LIBRARY"] = "UNDEF"
         dtool_config["USE_GENERIC_DXERR_LIBRARY"] = "UNDEF"
 
 
+    if (PkgSkip("SPEEDTREE")==0):
+        speedtree_parameters["SPEEDTREE_OPENGL"] = "UNDEF"
+        speedtree_parameters["SPEEDTREE_DIRECTX9"] = "UNDEF"
+        if SDK["SPEEDTREEAPI"] == "OpenGL":
+            speedtree_parameters["SPEEDTREE_OPENGL"] = "1"
+        elif SDK["SPEEDTREEAPI"] == "DirectX9":
+            speedtree_parameters["SPEEDTREE_DIRECTX9"] = "1"
+            
+        speedtree_parameters["SPEEDTREE_BIN_DIR"] = (SDK["SPEEDTREE"] + "/Bin")
+        
     conf = "/* prc_parameters.h.  Generated automatically by makepanda.py */\n"
     conf = "/* prc_parameters.h.  Generated automatically by makepanda.py */\n"
     for key in prc_parameters.keys():
     for key in prc_parameters.keys():
         if ((key == "DEFAULT_PRC_DIR") or (key[:4]=="PRC_")):
         if ((key == "DEFAULT_PRC_DIR") or (key[:4]=="PRC_")):
@@ -1553,6 +1579,15 @@ def WriteConfigSettings():
             del plugin_config[key]
             del plugin_config[key]
         ConditionalWriteFile(GetOutputDir() + '/include/p3d_plugin_config.h', conf)
         ConditionalWriteFile(GetOutputDir() + '/include/p3d_plugin_config.h', conf)
 
 
+    if (PkgSkip("SPEEDTREE")==0):
+        conf = "/* speedtree_parameters.h.  Generated automatically by makepanda.py */\n"
+        for key in speedtree_parameters.keys():
+            val = OverrideValue(key, speedtree_parameters[key])
+            if (val == 'UNDEF'): conf = conf + "#undef " + key + "\n"
+            else:                conf = conf + "#define " + key + " \"" + val.replace("\\", "\\\\") + "\"\n"
+            del speedtree_parameters[key]
+        ConditionalWriteFile(GetOutputDir() + '/include/speedtree_parameters.h', conf)
+
     for x in PkgListGet():
     for x in PkgListGet():
         if (PkgSkip(x)): ConditionalWriteFile(GetOutputDir() + '/tmp/dtool_have_'+x.lower()+'.dat',"0\n")
         if (PkgSkip(x)): ConditionalWriteFile(GetOutputDir() + '/tmp/dtool_have_'+x.lower()+'.dat',"0\n")
         else:            ConditionalWriteFile(GetOutputDir() + '/tmp/dtool_have_'+x.lower()+'.dat',"1\n")
         else:            ConditionalWriteFile(GetOutputDir() + '/tmp/dtool_have_'+x.lower()+'.dat',"1\n")
@@ -1756,6 +1791,13 @@ if (PkgSkip("PYTHON")==0 and PkgSkip("DIRECT")==0):
 ##########################################################################################
 ##########################################################################################
 
 
 confautoprc=ReadFile("makepanda/confauto.in")
 confautoprc=ReadFile("makepanda/confauto.in")
+if (PkgSkip("SPEEDTREE")==0):
+    # If SpeedTree is available, enable it in the config file
+    confautoprc = confautoprc.replace('#st#', '')
+else:
+    # otherwise, disable it.
+    confautoprc = confautoprc.replace('#st#', '#')
+
 if (os.path.isfile("makepanda/myconfig.in")):
 if (os.path.isfile("makepanda/myconfig.in")):
   configprc=ReadFile("makepanda/myconfig.in")
   configprc=ReadFile("makepanda/myconfig.in")
 else:
 else:
@@ -1827,10 +1869,19 @@ CopyTree(GetOutputDir()+'/include/parser-inc','dtool/src/parser-inc')
 MakeDirectory(GetOutputDir()+'/include/parser-inc/openssl')
 MakeDirectory(GetOutputDir()+'/include/parser-inc/openssl')
 MakeDirectory(GetOutputDir()+'/include/parser-inc/netinet')
 MakeDirectory(GetOutputDir()+'/include/parser-inc/netinet')
 MakeDirectory(GetOutputDir()+'/include/parser-inc/Cg')
 MakeDirectory(GetOutputDir()+'/include/parser-inc/Cg')
+MakeDirectory(GetOutputDir()+'/include/parser-inc/Core')
+MakeDirectory(GetOutputDir()+'/include/parser-inc/Forest')
+MakeDirectory(GetOutputDir()+'/include/parser-inc/Renderers')
+MakeDirectory(GetOutputDir()+'/include/parser-inc/Renderers/OpenGL')
+MakeDirectory(GetOutputDir()+'/include/parser-inc/Renderers/DirectX9')
 CopyAllFiles(GetOutputDir()+'/include/parser-inc/openssl/','dtool/src/parser-inc/')
 CopyAllFiles(GetOutputDir()+'/include/parser-inc/openssl/','dtool/src/parser-inc/')
 CopyAllFiles(GetOutputDir()+'/include/parser-inc/netinet/','dtool/src/parser-inc/')
 CopyAllFiles(GetOutputDir()+'/include/parser-inc/netinet/','dtool/src/parser-inc/')
 CopyFile(GetOutputDir()+'/include/parser-inc/Cg/','dtool/src/parser-inc/cg.h')
 CopyFile(GetOutputDir()+'/include/parser-inc/Cg/','dtool/src/parser-inc/cg.h')
 CopyFile(GetOutputDir()+'/include/parser-inc/Cg/','dtool/src/parser-inc/cgGL.h')
 CopyFile(GetOutputDir()+'/include/parser-inc/Cg/','dtool/src/parser-inc/cgGL.h')
+CopyFile(GetOutputDir()+'/include/parser-inc/Core/','dtool/src/parser-inc/Core.h')
+CopyFile(GetOutputDir()+'/include/parser-inc/Forest/','dtool/src/parser-inc/Forest.h')
+CopyFile(GetOutputDir()+'/include/parser-inc/Renderers/OpenGL/','dtool/src/parser-inc/OpenGLRenderer.h')
+CopyFile(GetOutputDir()+'/include/parser-inc/Renderers/DirectX9/','dtool/src/parser-inc/DirectX9Renderer.h')
 DeleteCVS(GetOutputDir()+'/include/parser-inc')
 DeleteCVS(GetOutputDir()+'/include/parser-inc')
 
 
 ########################################################################
 ########################################################################
@@ -1935,6 +1986,9 @@ if (PkgSkip("PHYSX")==0):
     CopyAllHeaders('panda/src/physx')
     CopyAllHeaders('panda/src/physx')
     CopyAllHeaders('panda/metalibs/pandaphysx')
     CopyAllHeaders('panda/metalibs/pandaphysx')
 
 
+if (PkgSkip("SPEEDTREE")==0):
+    CopyAllHeaders('panda/src/speedtree')
+
 if (PkgSkip("DIRECT")==0):
 if (PkgSkip("DIRECT")==0):
     CopyAllHeaders('direct/src/directbase')
     CopyAllHeaders('direct/src/directbase')
     CopyAllHeaders('direct/src/dcparser')
     CopyAllHeaders('direct/src/dcparser')
@@ -3349,6 +3403,29 @@ if (not RUNTIME):
   TargetAdd('libpandaphysics.dll', input=COMMON_PANDA_LIBS)
   TargetAdd('libpandaphysics.dll', input=COMMON_PANDA_LIBS)
   TargetAdd('libpandaphysics.dll', opts=['ADVAPI'])
   TargetAdd('libpandaphysics.dll', opts=['ADVAPI'])
 
 
+#
+# DIRECTORY: panda/src/speedtree/
+#
+
+if (PkgSkip("SPEEDTREE")==0):
+  OPTS=['DIR:panda/src/speedtree', 'BUILDING:PANDASPEEDTREE', 'SPEEDTREE']
+  TargetAdd('pandaspeedtree_composite1.obj', opts=OPTS, input='pandaspeedtree_composite1.cxx')
+  IGATEFILES=GetDirectoryContents('panda/src/speedtree', ["*.h", "*_composite.cxx"])
+  TargetAdd('libpandaspeedtree.in', opts=OPTS, input=IGATEFILES)
+  TargetAdd('libpandaspeedtree.in', opts=['IMOD:pandaspeedtree', 'ILIB:libpandaspeedtree', 'SRCDIR:panda/src/speedtree'])
+  TargetAdd('libpandaspeedtree_igate.obj', input='libpandaspeedtree.in', opts=["DEPENDENCYONLY"])
+  TargetAdd('libpandaspeedtree_module.obj', input='libpandaspeedtree.in')
+  TargetAdd('libpandaspeedtree_module.obj', opts=OPTS)
+  TargetAdd('libpandaspeedtree_module.obj', opts=['IMOD:pandaspeedtree', 'ILIB:libpandaspeedtree'])
+  TargetAdd('libpandaspeedtree.dll', input='pandaspeedtree_composite1.obj')
+  TargetAdd('libpandaspeedtree.dll', input='libpandaspeedtree_igate.obj')
+  TargetAdd('libpandaspeedtree.dll', input=COMMON_PANDA_LIBS)
+  TargetAdd('libpandaspeedtree.dll', opts=['SPEEDTREE'])
+  if SDK["SPEEDTREEAPI"] == 'OpenGL':
+      TargetAdd('libpandaspeedtree.dll', opts=['OPENGL', 'NVIDIACG', 'CGGL'])
+  elif SDK["SPEEDTREEAPI"] == 'OpenGL':
+      TargetAdd('libpandaspeedtree.dll', opts=['DX9',  'NVIDIACG', 'CGDX9'])
+
 #
 #
 # DIRECTORY: panda/src/testbed/
 # DIRECTORY: panda/src/testbed/
 #
 #

+ 27 - 0
makepanda/makepandacore.py

@@ -75,6 +75,7 @@ CONFLICTING_FILES=["dtool/src/dtoolutil/pandaVersion.h",
                    "dtool/src/dtoolutil/checkPandaVersion.h",
                    "dtool/src/dtoolutil/checkPandaVersion.h",
                    "dtool/src/dtoolutil/checkPandaVersion.cxx",
                    "dtool/src/dtoolutil/checkPandaVersion.cxx",
                    "dtool/src/prc/prc_parameters.h",
                    "dtool/src/prc/prc_parameters.h",
+                   "panda/src/speedtree/speedtree_parameters.h",
                    "direct/src/plugin/p3d_plugin_config.h",
                    "direct/src/plugin/p3d_plugin_config.h",
                    "direct/src/plugin_activex/P3DActiveX.rc",
                    "direct/src/plugin_activex/P3DActiveX.rc",
                    "direct/src/plugin_npapi/nppanda3d.rc",
                    "direct/src/plugin_npapi/nppanda3d.rc",
@@ -1486,6 +1487,26 @@ def SdkLocatePhysX():
                 SDK["PHYSXVERSION"] = ver
                 SDK["PHYSXVERSION"] = ver
                 SDK["PHYSXLIBS"] = libpath
                 SDK["PHYSXLIBS"] = libpath
 
 
+def SdkLocateSpeedTree():
+    # Look for all of the SpeedTree SDK directories within the
+    # thirdparty dir, and pick the highest-numbered one.
+    speedtrees = []
+    dir = GetThirdpartyDir()
+    for dirname in os.listdir(dir):
+        if dirname.startswith('SpeedTree SDK v'):
+            version = dirname[15:].split()[0]
+            version = map(int, version.split('.'))
+            speedtrees.append((version, dirname))
+    if not speedtrees:
+        # No installed SpeedTree SDK.
+        return
+    
+    speedtrees.sort()
+    version, dirname = speedtrees[-1]
+    SDK["SPEEDTREE"] = os.path.join(dir, dirname)
+    SDK["SPEEDTREEAPI"] = "OpenGL"
+    SDK["SPEEDTREEVERSION"] = '%s.%s' % (version[0], version[1])
+            
 ########################################################################
 ########################################################################
 ##
 ##
 ## SDK Auto-Disables
 ## SDK Auto-Disables
@@ -1532,6 +1553,12 @@ def SdkAutoDisablePhysX():
         WARNINGS.append("I cannot locate SDK for PhysX")
         WARNINGS.append("I cannot locate SDK for PhysX")
         WARNINGS.append("I have automatically added this command-line option: --no-physx")
         WARNINGS.append("I have automatically added this command-line option: --no-physx")
 
 
+def SdkAutoDisableSpeedTree():
+    if ("SPEEDTREE" not in SDK) and (PkgSkip("SPEEDTREE")==0):
+        PkgDisable("SPEEDTREE")
+        WARNINGS.append("I cannot locate SDK for SpeedTree")
+        WARNINGS.append("I have automatically added this command-line option: --no-speedtree")
+
 ########################################################################
 ########################################################################
 ##
 ##
 ## Visual Studio comes with a script called VSVARS32.BAT, which
 ## Visual Studio comes with a script called VSVARS32.BAT, which