Browse Source

Make the editor's cube map save path setting relative to the scene resource path, instead of being a relative filesystem path. Ensure that the generated cube map XML does not have double slashes and uses resource path relative filenames. Minor code cleanup.

Lasse Öörni 10 years ago
parent
commit
dc7eb0d17a
2 changed files with 14 additions and 26 deletions
  1. 2 2
      bin/Data/Scripts/Editor.as
  2. 12 24
      bin/Data/Scripts/Editor/EditorCubeCapture.as

+ 2 - 2
bin/Data/Scripts/Editor.as

@@ -299,13 +299,13 @@ void LoadConfig()
     if (!cubeMapElem.isNull)
     if (!cubeMapElem.isNull)
     {
     {
         cubeMapGen_Name = cubeMapElem.HasAttribute("name") ? cubeMapElem.GetAttribute("name") : "";
         cubeMapGen_Name = cubeMapElem.HasAttribute("name") ? cubeMapElem.GetAttribute("name") : "";
-        cubeMapGen_Path = cubeMapElem.HasAttribute("path") ? cubeMapElem.GetAttribute("path") : "Data/Textures/Cubemaps";
+        cubeMapGen_Path = cubeMapElem.HasAttribute("path") ? cubeMapElem.GetAttribute("path") : cubemapDefaultOutputPath;
         cubeMapGen_Size = cubeMapElem.HasAttribute("size") ? cubeMapElem.GetInt("size") : 128;
         cubeMapGen_Size = cubeMapElem.HasAttribute("size") ? cubeMapElem.GetInt("size") : 128;
     }
     }
     else
     else
     {
     {
         cubeMapGen_Name = "";
         cubeMapGen_Name = "";
-        cubeMapGen_Path = "Data/Textures/Cubemaps";
+        cubeMapGen_Path = cubemapDefaultOutputPath;
         cubeMapGen_Size = 128;
         cubeMapGen_Size = 128;
     }
     }
 }
 }

+ 12 - 24
bin/Data/Scripts/Editor/EditorCubeCapture.as

@@ -7,7 +7,7 @@ int cubeMapGen_Size;
 Array<EditorCubeCapture@> activeCubeCapture; // Editor capture tasks in progress, Stop() method of EditorCubeCapture moves forward through the queue as captures are finished
 Array<EditorCubeCapture@> activeCubeCapture; // Editor capture tasks in progress, Stop() method of EditorCubeCapture moves forward through the queue as captures are finished
 Array<Zone@> cloneZones; // Duplicate zones constructed to prevent IBL doubling
 Array<Zone@> cloneZones; // Duplicate zones constructed to prevent IBL doubling
 Array<Zone@> disabledZones; // Zones that were disabled to prevent IBL doubling
 Array<Zone@> disabledZones; // Zones that were disabled to prevent IBL doubling
-String cubemapOutputPath = "Data/Textures/Cubemaps";
+const String cubemapDefaultOutputPath = "Textures/Cubemaps";
 
 
 void PrepareZonesForCubeRendering()
 void PrepareZonesForCubeRendering()
 {
 {
@@ -91,8 +91,8 @@ class EditorCubeCapture : ScriptObject // script object in order to get events
         
         
         // Store name and path because if we have a lot of zones it could take long enough to queue another go, and it may have different settings
         // Store name and path because if we have a lot of zones it could take long enough to queue another go, and it may have different settings
         name_ = cubeMapGen_Name;
         name_ = cubeMapGen_Name;
-        path_ = cubeMapGen_Path;
-    
+        path_ = sceneResourcePath + cubeMapGen_Path;
+
         updateCycle_ = 0;
         updateCycle_ = 0;
     
     
         target_ = forZone;
         target_ = forZone;
@@ -178,35 +178,23 @@ class EditorCubeCapture : ScriptObject // script object in order to get events
     private void WriteXML()
     private void WriteXML()
     {
     {
         String sceneName = editorScene.name.length > 0 ? "/" + editorScene.name + "/" : "";
         String sceneName = editorScene.name.length > 0 ? "/" + editorScene.name + "/" : "";
-        String basePath = path_ + sceneName;
+        String basePath = AddTrailingSlash(path_ + sceneName);
         String cubeName = name_.length > 0 ? (name_ + "_") : "";
         String cubeName = name_.length > 0 ? (name_ + "_") : "";
         String xmlPath = basePath + "/" + name_ + String(target_.id) + ".xml";
         String xmlPath = basePath + "/" + name_ + String(target_.id) + ".xml";
         XMLFile@ file = XMLFile();
         XMLFile@ file = XMLFile();
         XMLElement rootElem = file.CreateRoot("cubemap");
         XMLElement rootElem = file.CreateRoot("cubemap");
         
         
-        XMLElement posXElem = rootElem.CreateChild("face");
-        posXElem.SetAttribute("name", basePath + "/" + cubeName + String(target_.id) + "_" + GetFaceName(FACE_POSITIVE_X) + ".png");
-        
-        XMLElement negXElem = rootElem.CreateChild("face");
-        negXElem.SetAttribute("name", basePath + "/" + cubeName + String(target_.id) + "_" + GetFaceName(FACE_NEGATIVE_X) + ".png");
-        
-        XMLElement posYElem = rootElem.CreateChild("face");
-        posYElem.SetAttribute("name", basePath + "/" + cubeName + String(target_.id) + "_" + GetFaceName(FACE_POSITIVE_Y) + ".png");
-        
-        XMLElement negYElem = rootElem.CreateChild("face");
-        negYElem.SetAttribute("name", basePath + "/" + cubeName + String(target_.id) + "_" + GetFaceName(FACE_NEGATIVE_Y) + ".png");
-        
-        XMLElement posZElem = rootElem.CreateChild("face");
-        posZElem.SetAttribute("name", basePath + "/" + cubeName + String(target_.id) + "_" + GetFaceName(FACE_POSITIVE_Z) + ".png");
-        
-        XMLElement negZElem = rootElem.CreateChild("face");
-        negZElem.SetAttribute("name", basePath + "/" + cubeName + String(target_.id) + "_" + GetFaceName(FACE_NEGATIVE_Z) + ".png");
-        
+        for (int i = 0; i < 6; ++i)
+        {
+            XMLElement faceElem = rootElem.CreateChild("face");
+            faceElem.SetAttribute("name", GetResourceNameFromFullName(basePath + cubeName + String(target_.id) + "_" + GetFaceName(CubeMapFace(i)) + ".png"));
+        }
+
         file.Save(File(xmlPath, FILE_WRITE), "    ");
         file.Save(File(xmlPath, FILE_WRITE), "    ");
-        
+
         ResourceRef ref;
         ResourceRef ref;
         ref.type = StringHash("TextureCube");
         ref.type = StringHash("TextureCube");
-        ref.name = xmlPath;
+        ref.name = GetResourceNameFromFullName(xmlPath);
         target_.SetAttribute("Zone Texture", Variant(ref));
         target_.SetAttribute("Zone Texture", Variant(ref));
     }
     }