--- classes/FileUtil.php	Thu Jan 15 03:14:12 1970
+++ classes/FileUtil.php	Thu Jan 15 03:14:12 1970
@@ -94,6 +94,11 @@
    
    static function isAbsolutePath( $path )
    {
+      // check for VC++ environment variables and consider
+      // them absolute paths
+      if(strcasecmp(substr($path, 0, 2), '$(') == 0)
+         return true;
+
       // This looks complex, but its really fairly simple.
       //
       // We're detecting existing absolute paths in the include
@@ -107,5 +112,32 @@
       $absPath = FileUtil::normalizeSlashes( realpath( $path ) );
       return strcasecmp( $orgPath, $absPath ) == 0;
    }
+
+	static function isEnvVarPath($path, &$envVar, &$envValue, &$envPath)
+	{
+		// parsing expression for matching:
+		//   $(ENVVARNAME)/Path/to/something
+		//   ${ENVVARNAME}/Path/to/something
+		$exp = '/^.*\$(\(|\{)(.+)(\)|\})(.+)$/';
+		$res = array();
+
+		if(preg_match($exp, $path, $res) != 1)
+			return false;
+
+		$envVar =  '$' . $res[1] . $res[2] . $res[3];
+		$envPath = $res[4];
+		$envValue = getenv($res[2]);
+
+		return true;
+	}
+
+	static function repackEnvVarPath($envVar, $envValue, $absPath)
+	{
+		// yes this cheating a bit
+		$trail = substr($absPath, strlen($envValue));
+
+		return $envVar . $trail;
+	}
+
 }
 ?>
--- classes/Project.php	Thu Jan 15 03:14:12 1970
+++ classes/Project.php	Thu Jan 15 03:14:12 1970
@@ -208,6 +208,16 @@
                   $curPath = Generator::$absPath . "/". str_replace("../", "", $curPath);
             }
 
+			// check to see if path is actually an enclosed environment variable
+			$envVarName = '';
+			$realPath = '';
+			if(($isEnvVar = FileUtil::isEnvVarPath($curPath, $envVarName, $realPath, $curPath)))
+			{
+				$curPath = $realPath . $curPath;
+
+				$envPath = FileUtil::repackEnvVarPath($envVarName, $realPath, $curPath);
+			}
+
             // Check if its a file or a directory.
             // If its a file just add it directly and build a containng filter/folder structure,
             // for it else if a dir add all files in it.
@@ -260,6 +270,9 @@
                         if( $curFile == '.' || $curFile == '..' || $curFile == '.svn' || $curFile == 'CVS' )
                             continue;
 
+                        if($isEnvVar)
+                            $newEntry = $this->createFileEntry( $output, $envPath, $curFile );
+                        else
                         $newEntry = $this->createFileEntry( $output, $curPath, $curFile );
 
                         if( $newEntry )
--- modules/physX.inc	Thu Jan 15 03:14:12 1970
+++ modules/physX.inc	Thu Jan 15 03:14:12 1970
@@ -1,40 +1,101 @@
 <?php
 
+function checkEnvVar($evar)
+{
+	// does the environment variable exist?
+	if(!($value = getenv($evar)))
+		return false; // nope
+
+	// verify that the environment variable is set to an existing path
+	if(!file_exists($value))
+		return false; // no such path
+
+	// environment variable checks out, return it
+	return $evar;
+}
+
+
 beginModule( 'physX' );
 
-   // Look for the optional global from the project.conf.
+	// default to failure
+	$isValid = false;
+	$isAbsPath = false;
+
+	// Look for the optional global variable from the project.conf file.
    global $PHYSX_SDK_PATH;
-   if (!$PHYSX_SDK_PATH)
+
+	if(isset($PHYSX_SDK_PATH))
+	{
+		// Validate the provided file path given to us via project.conf file
+		if(file_exists($PHYSX_SDK_PATH))
    {
-      // First look for an environment var.
-      $PHYSX_SDK_PATH = getenv( "TORQUE_PHYSX_PATH" );
+			$isValid = true;
+			$isAbsPath = true;
+			break;
+		}
+	} else
+	{
+		// Absolute path wasn't provided for us in the project.conf file, so
+		// we'll search for it ourselves.
 
-      if (strlen($PHYSX_SDK_PATH) == 0 || !file_exists($PHYSX_SDK_PATH))
+		// this is not for looping, but for an easy escape vector
+		while(true)
+		{
+			// check for the environment variable
+			if(($PHYSX_SDK_PATH = checkEnvVar("TORQUE_PHYSX_PATH")));
       {
-         // Sometimes users get confused and use this var.
-         $PHYSX_SDK_PATH = getenv( "PHYSX_SDK_PATH" );
+				$isValid = true;
+				break;
+			}
 
-         if (strlen($PHYSX_SDK_PATH) == 0 || !file_exists($PHYSX_SDK_PATH))
+			// check for the alternative environment variable
+			if(($PHYSX_SDK_PATH = checkEnvVar("PHYSX_SDK_PATH")));
          {
-            // Since neither environment var worked try for 
-            // the default PhysX SDK install location.
+				$isValid = true;
+				break;
+			}
+
+			// check for the common path (Windows)
             $PHYSX_SDK_PATH = getenv("ProgramFiles") . "/NVIDIA Corporation/NVIDIA PhysX SDK/v2.8.4_win";
+			if(file_exists($PHYSX_SDK_PATH))
+			{
+				$isValid = true;
+				$isAbsPath = true;
+				break;
+			}
 
-            // Last channce... try the x86 default install path.
-            if (!file_exists($PHYSX_SDK_PATH))
+			// check for the common 32bit path on 64bit OS (Windows)
                $PHYSX_SDK_PATH = getenv("ProgramFiles(x86)") . "/NVIDIA Corporation/NVIDIA PhysX SDK/v2.8.4_win";
+			if(file_exists($PHYSX_SDK_PATH))
+			{
+				$isValid = true;
+				$isAbsPath = true;
+				break;
+			}
+
+			break;
          }
       }
 
+	if($isValid)
+	{
+		if($isAbsPath)
+		{
       // We need forward slashes for paths.
       $PHYSX_SDK_PATH = str_replace( "\\", "/", $PHYSX_SDK_PATH);
 
       // Remove trailing slashes.
       $PHYSX_SDK_PATH = rtrim($PHYSX_SDK_PATH, " /");
+		} else
+		{
+//			$PHYSX_SDK_PATH = getenv($PHYSX_SDK_PATH);
+			$PHYSX_SDK_PATH = '$('. $PHYSX_SDK_PATH .')';
    }
+	}
+
 
    // If we still don't have the SDK path then let the user know.
-   if (!file_exists($PHYSX_SDK_PATH))
+   if(!$isValid)
    {
       trigger_error( 
             "\n*******************************************************************".
