From 4a2cf37182c2e2cb34f66277c7bc2df22922454e Mon Sep 17 00:00:00 2001 From: David Rose Date: Sat, 9 Oct 2010 00:16:51 +0000 Subject: [PATCH] speedtree for makepanda --- makepanda/confauto.in | 6 +++ makepanda/makepanda.py | 77 ++++++++++++++++++++++++++++++++++++++ makepanda/makepandacore.py | 27 +++++++++++++ 3 files changed, 110 insertions(+) diff --git a/makepanda/confauto.in b/makepanda/confauto.in index 386225b716..a2342963b2 100755 --- a/makepanda/confauto.in +++ b/makepanda/confauto.in @@ -110,3 +110,9 @@ paranoid-clock 1 # and don't specify an extension. 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 diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index ec32e8f29e..af3c5e66f7 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -57,6 +57,7 @@ PkgListSet(["PYTHON", "DIRECT", # Python support "OPENGL"] + DXVERSIONS + ["TINYDISPLAY", "NVIDIACG", # 3D graphics "OPENAL", "FMODEX", "FFMPEG", # Multimedia "ODE", "PHYSX", # Physics + "SPEEDTREE", # SpeedTree "ZLIB", "PNG", "JPEG", "TIFF", "SQUISH", "FREETYPE", # 2D Formats support ] + MAYAVERSIONS + MAXVERSIONS + [ "FCOLLADA", # 3D Formats support "VRPN", "OPENSSL", # Transport @@ -293,11 +294,13 @@ SdkLocatePython(RTDIST) SdkLocateVisualStudio() SdkLocateMSPlatform() SdkLocatePhysX() +SdkLocateSpeedTree() SdkAutoDisableDirectX() SdkAutoDisableMaya() SdkAutoDisableMax() SdkAutoDisablePhysX() +SdkAutoDisableSpeedTree() if (RTDIST and SDK["PYTHONVERSION"] != "python2.6" and DISTRIBUTOR == "cmu"): 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") # We need to be able to find NxCharacter.dll when importing code library libpandaphysx 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"): PkgDisable("AWESOMIUM") @@ -1423,6 +1438,7 @@ PRC_PARAMETERS=[ def WriteConfigSettings(): dtool_config={} prc_parameters={} + speedtree_parameters={} plugin_config={} if (sys.platform.startswith("win")): @@ -1527,6 +1543,16 @@ def WriteConfigSettings(): else: 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" for key in prc_parameters.keys(): if ((key == "DEFAULT_PRC_DIR") or (key[:4]=="PRC_")): @@ -1553,6 +1579,15 @@ def WriteConfigSettings(): del plugin_config[key] 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(): if (PkgSkip(x)): ConditionalWriteFile(GetOutputDir() + '/tmp/dtool_have_'+x.lower()+'.dat',"0\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") +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")): configprc=ReadFile("makepanda/myconfig.in") 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/netinet') 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/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/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') ######################################################################## @@ -1935,6 +1986,9 @@ if (PkgSkip("PHYSX")==0): CopyAllHeaders('panda/src/physx') CopyAllHeaders('panda/metalibs/pandaphysx') +if (PkgSkip("SPEEDTREE")==0): + CopyAllHeaders('panda/src/speedtree') + if (PkgSkip("DIRECT")==0): CopyAllHeaders('direct/src/directbase') CopyAllHeaders('direct/src/dcparser') @@ -3349,6 +3403,29 @@ if (not RUNTIME): TargetAdd('libpandaphysics.dll', input=COMMON_PANDA_LIBS) 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/ # diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index ea4174c250..093fcd3f17 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -75,6 +75,7 @@ CONFLICTING_FILES=["dtool/src/dtoolutil/pandaVersion.h", "dtool/src/dtoolutil/checkPandaVersion.h", "dtool/src/dtoolutil/checkPandaVersion.cxx", "dtool/src/prc/prc_parameters.h", + "panda/src/speedtree/speedtree_parameters.h", "direct/src/plugin/p3d_plugin_config.h", "direct/src/plugin_activex/P3DActiveX.rc", "direct/src/plugin_npapi/nppanda3d.rc", @@ -1486,6 +1487,26 @@ def SdkLocatePhysX(): SDK["PHYSXVERSION"] = ver 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 @@ -1532,6 +1553,12 @@ def SdkAutoDisablePhysX(): WARNINGS.append("I cannot locate SDK for 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