Przeglądaj źródła

Fixed bug in win32 ScanDir implementation, which did not scan subdirs if filter was not *.*.
Added Extras directory for contributions which are not strictly Urho3D core.
Added OgreBatchConverter utility from Carlo Carollo, modified to use Urho3D classes to be crossplatform compatible.

Lasse Öörni 12 lat temu
rodzic
commit
6e90c6ea13

+ 1 - 1
Bin/ConvertDocsToWiki.bat

@@ -1 +1 @@
-DocConverter ..\Docs ..\..\urho3dwiki Urho3D
+DocConverter ..\Docs ..\..\wiki Urho3D

+ 4 - 0
CMakeLists.txt

@@ -183,3 +183,7 @@ if (NOT USE_OPENGL)
     add_subdirectory (ThirdParty/MojoShader)
     add_subdirectory (Tools/ShaderCompiler)
 endif ()
+
+# Urho3D extras. Uncomment to enable
+add_subdirectory (Extras/OgreBatchConverter)
+

+ 1 - 0
Docs/Urho3D.dox

@@ -49,6 +49,7 @@ For release history and major changes, see \ref History.
 Urho3D development, contributions and bugfixes by:
 - Lasse Öörni ([email protected], AgentC at GameDev.net)
 - Colin Barrett
+- Carlo Carollo
 - Alex Fuller
 - Jason Kinzer
 - Miika Santala

+ 9 - 6
Engine/IO/FileSystem.cpp

@@ -501,10 +501,13 @@ void FileSystem::ScanDirInternal(Vector<String>& result, String path, const Stri
     if (path.Length() > startPath.Length())
         deltaPath = path.Substring(startPath.Length());
     
+    String filterExtension = filter.Substring(filter.Find('.'));
+    if (filterExtension.Contains('*'))
+        filterExtension.Clear();
+    
     #ifdef WIN32
-    String pathAndFilter = GetNativePath(path + filter);
     WIN32_FIND_DATAW info;
-    HANDLE handle = FindFirstFileW(WString(pathAndFilter).CString(), &info);
+    HANDLE handle = FindFirstFileW(WString(path + "*").CString(), &info);
     if (handle != INVALID_HANDLE_VALUE)
     {
         do
@@ -522,7 +525,10 @@ void FileSystem::ScanDirInternal(Vector<String>& result, String path, const Stri
                         ScanDirInternal(result, path + fileName, startPath, filter, flags, recursive);
                 }
                 else if (flags & SCAN_FILES)
-                    result.Push(deltaPath + fileName);
+                {
+                    if (filterExtension.Empty() || fileName.EndsWith(filterExtension))
+                        result.Push(deltaPath + fileName);
+                }
             }
         } 
         while (FindNextFileW(handle, &info));
@@ -530,9 +536,6 @@ void FileSystem::ScanDirInternal(Vector<String>& result, String path, const Stri
         FindClose(handle);
     }
     #else
-    String filterExtension = filter.Substring(filter.Find('.'));
-    if (filterExtension.Contains('*'))
-        filterExtension.Clear();
     DIR *dir;
     struct dirent *de;
     struct stat st;

+ 1 - 1
Engine/UI/FileSelector.cpp

@@ -319,7 +319,7 @@ void FileSelector::RefreshFiles()
     
     Vector<String> directories;
     Vector<String> files;
-    fileSystem->ScanDir(directories, path_, "*.*", SCAN_DIRS, false);
+    fileSystem->ScanDir(directories, path_, "*", SCAN_DIRS, false);
     fileSystem->ScanDir(files, path_, GetFilter(), SCAN_FILES, false);
     
     fileEntries_.Reserve(directories.Size() + files.Size());

+ 13 - 0
Extras/OgreBatchConverter/CMakeLists.txt

@@ -0,0 +1,13 @@
+# Define target name
+set (TARGET_NAME OgreBatchConverter)
+
+# Define source files
+file (GLOB CPP_FILES *.cpp)
+file (GLOB H_FILES *.h)
+set (SOURCE_FILES ${CPP_FILES} ${H_FILES})
+
+# Define dependency libs
+set (LIBS ../../Engine/Container ../../Engine/Core ../../Engine/IO ../../Engine/Math)
+
+# Setup target
+setup_executable ()

+ 55 - 0
Extras/OgreBatchConverter/OgreBatchConverter.cpp

@@ -0,0 +1,55 @@
+// OgreBatchConverter.cpp : Defines the entry point for the console application.
+//
+
+#include "Context.h"
+#include "FileSystem.h"
+#include "ProcessUtils.h"
+
+#include <stdio.h>
+
+using namespace Urho3D;
+
+SharedPtr<Context> context(new Context());
+SharedPtr<FileSystem> fileSystem(new FileSystem(context));
+
+int main(int argc, char** argv)
+{
+    // Take in account args and place on OgreImporter args
+    const Vector<String>& args = ParseArguments(argc, argv);
+    Vector<String> files;
+    String currentDir = fileSystem->GetCurrentDir();
+    
+    // Try to execute OgreImporter from same directory as this executable
+    String ogreImporterName = fileSystem->GetProgramDir() + "OgreImporter";
+    
+    printf("\n\nOgreBatchConverter requires OgreImporter.exe on same directory");
+    printf("\nSearching Ogre file in Xml format in %s\n" ,currentDir.CString());
+    fileSystem->ScanDir(files, currentDir, "*.xml", SCAN_FILES, true);
+    printf("\nFound %d files\n", files.Size());
+    #ifdef WIN32
+    if (files.Size()) fileSystem->SystemCommand("pause");
+    #endif
+    
+    for (unsigned i = 0 ; i < files.Size(); i++)
+    {
+        Vector<String> cmdArgs;
+        cmdArgs.Push(files[i]);
+        cmdArgs.Push(ReplaceExtension(files[i], ".mdl"));
+        cmdArgs.Push(args);
+        
+        String cmdPreview = ogreImporterName;
+        for (unsigned j = 0; j < cmdArgs.Size(); j++)
+            cmdPreview += " " + cmdArgs[j];
+        
+        printf("\n%s", cmdPreview.CString());
+        fileSystem->SystemRun(ogreImporterName, cmdArgs);
+    }
+    
+    printf("\nExit\n");
+    #ifdef WIN32
+    fileSystem->SystemCommand("pause");
+    #endif
+    
+    return 0;
+}
+

+ 5 - 0
Extras/Readme.txt

@@ -0,0 +1,5 @@
+OgreBatchConverter
+
+- Contributed by Carlo Carollo. Converts multiple Ogre .mesh.xml files (also from 
+  subdirectories) by invoking the OgreImporter tool.
+- Enable in build by uncommenting at the bottom of the Urho3D root CMakeLists.txt

+ 1 - 0
Readme.txt

@@ -12,6 +12,7 @@ Credits
 Urho3D development, contributions and bugfixes by:
 - Lasse Öörni ([email protected])
 - Colin Barrett
+- Carlo Carollo
 - Alex Fuller
 - Jason Kinzer
 - Miika Santala