physX.inc 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. //-----------------------------------------------------------------------------
  3. // Copyright (c) 2012 GarageGames, LLC
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to
  7. // deal in the Software without restriction, including without limitation the
  8. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9. // sell copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. // IN THE SOFTWARE.
  22. //-----------------------------------------------------------------------------
  23. beginModule( 'physX' );
  24. // Look for the optional global from the project.conf.
  25. global $PHYSX_SDK_PATH;
  26. if (!$PHYSX_SDK_PATH)
  27. {
  28. // First look for an environment var.
  29. $PHYSX_SDK_PATH = getenv( "TORQUE_PHYSX_PATH" );
  30. if (strlen($PHYSX_SDK_PATH) == 0 || !file_exists($PHYSX_SDK_PATH))
  31. {
  32. // Sometimes users get confused and use this var.
  33. $PHYSX_SDK_PATH = getenv( "PHYSX_SDK_PATH" );
  34. if (strlen($PHYSX_SDK_PATH) == 0 || !file_exists($PHYSX_SDK_PATH))
  35. {
  36. // Since neither environment var worked try for
  37. // the default PhysX SDK install location.
  38. $PHYSX_SDK_PATH = getenv("ProgramFiles") . "/NVIDIA Corporation/NVIDIA PhysX SDK/v2.8.4_win";
  39. // Last channce... try the x86 default install path.
  40. if (!file_exists($PHYSX_SDK_PATH))
  41. $PHYSX_SDK_PATH = getenv("ProgramFiles(x86)") . "/NVIDIA Corporation/NVIDIA PhysX SDK/v2.8.4_win";
  42. }
  43. }
  44. // We need forward slashes for paths.
  45. $PHYSX_SDK_PATH = str_replace( "\\", "/", $PHYSX_SDK_PATH);
  46. // Remove trailing slashes.
  47. $PHYSX_SDK_PATH = rtrim($PHYSX_SDK_PATH, " /");
  48. }
  49. // If we still don't have the SDK path then let the user know.
  50. if (!file_exists($PHYSX_SDK_PATH))
  51. {
  52. trigger_error(
  53. "\n*******************************************************************".
  54. "\n".
  55. "\n We were not able to find a valid path to the PhysX SDK!".
  56. "\n".
  57. "\n You must install the latest PhysX SDK and set the path via a".
  58. "\n \$PHYSX_SDK_PATH variable in your buildFiles/project.conf file".
  59. "\n or by setting the TORQUE_PHYSX_PATH system environment variable".
  60. "\n (may require a reboot).".
  61. "\n".
  62. "\n*******************************************************************".
  63. "\n", E_USER_ERROR );
  64. }
  65. addProjectDefine( "TORQUE_PHYSICS_PHYSX" );
  66. addProjectDefine( "TORQUE_PHYSICS_ENABLED" );
  67. // Source
  68. addEngineSrcDir( "T3D/physics/physX" );
  69. // Includes
  70. addIncludePath( $PHYSX_SDK_PATH . "/SDKs/Physics/include" );
  71. addIncludePath( $PHYSX_SDK_PATH . "/SDKs/Foundation/include" );
  72. addIncludePath( $PHYSX_SDK_PATH . "/SDKs/PhysXLoader/include" );
  73. addIncludePath( $PHYSX_SDK_PATH . "/SDKs/Cooking/include" );
  74. addIncludePath( $PHYSX_SDK_PATH . "/SDKs/NxCharacter/include" );
  75. addIncludePath( $PHYSX_SDK_PATH . "/Tools/NxuStream2" );
  76. // Libs
  77. addProjectLibDir( $PHYSX_SDK_PATH . "/SDKs/lib/Win32" );
  78. addProjectLibInput( "PhysXCooking.lib" );
  79. addProjectLibInput( "PhysXLoader.lib" );
  80. // File Copy
  81. copyFileToProject( $PHYSX_SDK_PATH . "/Bin/win32/cudart32_30_9.dll", "/game/cudart32_30_9.dll" );
  82. copyFileToProject( $PHYSX_SDK_PATH . "/Bin/win32/PhysXCooking.dll", "/game/PhysXCooking.dll" );
  83. copyFileToProject( $PHYSX_SDK_PATH . "/Bin/win32/PhysXCore.dll", "/game/PhysXCore.dll" );
  84. copyFileToProject( $PHYSX_SDK_PATH . "/Bin/win32/PhysXDevice.dll", "/game/PhysXDevice.dll" );
  85. copyFileToProject( $PHYSX_SDK_PATH . "/Bin/win32/PhysXLoader.dll", "/game/PhysXLoader.dll" );
  86. // For PhysX support.
  87. includeLib( 'nxCharacter' );
  88. includeLib( 'nxuStream' );
  89. if (inProjectConfig())
  90. {
  91. addProjectDependency( 'nxCharacter' );
  92. addProjectDependency( 'nxuStream' );
  93. addSolutionProjectRef( 'nxCharacter' );
  94. addSolutionProjectRef( 'nxuStream' );
  95. }
  96. endModule();
  97. ?>