Browse Source

Use the new model format in OgreImporter.

Lasse Öörni 9 years ago
parent
commit
c48b25abca

+ 3 - 1
Source/Tools/OgreImporter/OgreImporter.cpp

@@ -847,6 +847,8 @@ void LoadMesh(const String& inputFileName, bool generateTangents, bool splitSubM
 
 void WriteOutput(const String& outputFileName, bool exportAnimations, bool rotationsOnly, bool saveMaterialList)
 {
+    /// \todo Use save functions of Model & Animation classes
+
     // Begin serialization
     {
         File dest(context_);
@@ -854,7 +856,7 @@ void WriteOutput(const String& outputFileName, bool exportAnimations, bool rotat
             ErrorExit("Could not open output file " + outputFileName);
 
         // ID
-        dest.WriteFileID("UMDL");
+        dest.WriteFileID("UMD2");
 
         // Vertexbuffers
         dest.WriteUInt(vertexBuffers_.Size());

+ 12 - 1
Source/Tools/OgreImporter/OgreImporterUtils.h

@@ -25,6 +25,7 @@
 #include <Urho3D/Graphics/Animation.h>
 #include <Urho3D/Math/BoundingBox.h>
 #include <Urho3D/Graphics/Graphics.h>
+#include <Urho3D/Graphics/VertexBuffer.h>
 #include <Urho3D/IO/Serializer.h>
 #include <Urho3D/Math/Matrix3x4.h>
 
@@ -118,7 +119,17 @@ struct ModelVertexBuffer
     void WriteData(Serializer& dest)
     {
         dest.WriteUInt(vertices_.Size());
-        dest.WriteUInt(elementMask_);
+        
+        PODVector<VertexElement> elements = VertexBuffer::GetElements(elementMask_);
+        dest.WriteUInt(elements.Size());
+        for (unsigned j = 0; j < elements.Size(); ++j)
+        {
+            unsigned elementDesc = ((unsigned)elements[j].type_) |
+                (((unsigned)elements[j].semantic_) << 8) |
+                (((unsigned)elements[j].index_) << 16);
+            dest.WriteUInt(elementDesc);
+        }
+
         dest.WriteUInt(morphStart_);
         dest.WriteUInt(morphCount_);