Browse Source

- account for flipped textures in material->j3m creation

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7192 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
nor..67 14 years ago
parent
commit
1b8f5f42d9

+ 12 - 5
jme3-materialeditor/src/com/jme3/gde/materials/MaterialProperty.java

@@ -4,6 +4,8 @@
  */
  */
 package com.jme3.gde.materials;
 package com.jme3.gde.materials;
 
 
+import com.jme3.asset.AssetKey;
+import com.jme3.asset.TextureKey;
 import com.jme3.material.MatParam;
 import com.jme3.material.MatParam;
 import com.jme3.math.ColorRGBA;
 import com.jme3.math.ColorRGBA;
 import com.jme3.texture.Texture2D;
 import com.jme3.texture.Texture2D;
@@ -33,13 +35,18 @@ public class MaterialProperty {
         Object obj = param.getValue();
         Object obj = param.getValue();
         this.value = obj.toString();
         this.value = obj.toString();
         //TODO: change to correct string
         //TODO: change to correct string
-        if(obj instanceof ColorRGBA){
+        if (obj instanceof ColorRGBA) {
             value = value.replaceAll("Color\\[([^\\]]*)\\]", "$1");
             value = value.replaceAll("Color\\[([^\\]]*)\\]", "$1");
             value = value.replaceAll(",", "");
             value = value.replaceAll(",", "");
-        }
-        else if(obj instanceof Texture2D)
-        {
-            value = value.replaceAll("Texture2D\\[name=([^,]*)\\,([^\\]]*)]", "$1");
+        } else if (obj instanceof Texture2D) {
+            AssetKey key = ((Texture2D) obj).getKey();
+            String flip = "";
+            if (key instanceof TextureKey) {
+                if (((TextureKey) key).isFlipY()) {
+                    flip = "Flip ";
+                }
+            }
+            value = value.replaceAll("Texture2D\\[name=([^,]*)\\,([^\\]]*)]", flip + "$1");
         }
         }
     }
     }