Browse Source

* XMLImporter can now read directly from file
* XML representation of savable now writes version (no reading yet)
* Initial attempt of fixing "frozen after app restart" bug
* Fixed NVIDIA shininess bug (!!!) - No longer need to set m_Shininess on materials!

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7734 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

sha..rd 14 years ago
parent
commit
a43e52a384

+ 3 - 3
engine/src/core-data/Common/MatDefs/Light/Lighting.frag

@@ -77,6 +77,9 @@ float lightComputeDiffuse(in vec3 norm, in vec3 lightdir, in vec3 viewdir){
 }
 
 float lightComputeSpecular(in vec3 norm, in vec3 viewdir, in vec3 lightdir, in float shiny){
+    if (shiny <= 1.0){
+        return 0.0;
+    }
     #ifdef LOW_QUALITY
        // Blinn-Phong
        // Note: preferably, H should be computed in the vertex shader
@@ -102,9 +105,6 @@ vec2 computeLighting(in vec3 wvPos, in vec3 wvNorm, in vec3 wvViewDir, in vec3 w
    float diffuseFactor = lightComputeDiffuse(wvNorm, wvLightDir, wvViewDir);
    float specularFactor = lightComputeSpecular(wvNorm, wvViewDir, wvLightDir, m_Shininess);
 
-   // if shininess is == 0, spec == 0, if shininess > 1, spec == 1
-   specularFactor *= min(1.0, m_Shininess); 
-
    #ifdef HQ_ATTENUATION
     float att = clamp(1.0 - g_LightPosition.w * length(lightVec), 0.0, 1.0);
    #else

+ 1 - 13
engine/src/core-plugins/com/jme3/export/binary/BinaryExporter.java

@@ -350,19 +350,7 @@ public class BinaryExporter implements JmeExporter {
         BinaryClassObject bco = new BinaryClassObject();
         bco.alias = generateTag();
         bco.nameFields = new HashMap<String, BinaryClassField>();
-        
-        ArrayList<Integer> versionList = new ArrayList<Integer>();
-        Class superclass = clazz;
-        do {
-            versionList.add(SavableClassUtil.getSavableVersion(superclass));
-            superclass = superclass.getSuperclass();
-        } while (superclass != null && SavableClassUtil.isImplementingSavable(superclass));
-        
-        int[] versions = new int[versionList.size()];
-        for (int i = 0; i < versionList.size(); i++){
-            versions[i] = versionList.get(i);
-        }
-        bco.classHierarchyVersions = versions;
+        bco.classHierarchyVersions = SavableClassUtil.getSavableVersions(clazz);
         
         classes.put(clazz.getName(), bco);
             

+ 16 - 2
engine/src/core/com/jme3/export/SavableClassUtil.java

@@ -42,9 +42,8 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import com.jme3.material.MatParamTexture;
-import com.jme3.scene.Spatial;
 import java.lang.reflect.Field;
-import java.lang.reflect.Type;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 
@@ -95,6 +94,21 @@ public class SavableClassUtil {
         return false;
     }
 
+    public static int[] getSavableVersions(Class<? extends Savable> clazz) throws IOException{
+        ArrayList<Integer> versionList = new ArrayList<Integer>();
+        Class superclass = clazz;
+        do {
+            versionList.add(getSavableVersion(superclass));
+            superclass = superclass.getSuperclass();
+        } while (superclass != null && SavableClassUtil.isImplementingSavable(superclass));
+        
+        int[] versions = new int[versionList.size()];
+        for (int i = 0; i < versionList.size(); i++){
+            versions[i] = versionList.get(i);
+        }
+        return versions;
+    }
+    
     public static int getSavableVersion(Class<? extends Savable> clazz) throws IOException{
         try {
             Field field = clazz.getField("SAVABLE_VERSION");

+ 1 - 1
engine/src/lwjgl-ogl/com/jme3/system/lwjgl/LwjglAbstractDisplay.java

@@ -142,7 +142,7 @@ public abstract class LwjglAbstractDisplay extends LwjglContext implements Runna
             throw new IllegalStateException();
 
         listener.update();
-
+       
         // All this does is call swap buffers
         // If the canvas is not active, there's no need to waste time
         // doing that ..

+ 11 - 5
engine/src/lwjgl-ogl/com/jme3/system/lwjgl/LwjglDisplay.java

@@ -32,7 +32,6 @@
 
 package com.jme3.system.lwjgl;
 
-import com.jme3.input.TouchInput;
 import com.jme3.system.JmeContext.Type;
 import org.lwjgl.LWJGLException;
 import org.lwjgl.opengl.Display;
@@ -110,14 +109,21 @@ public class LwjglDisplay extends LwjglAbstractDisplay {
         pixelFormat = pf;
         
         Display.setTitle(settings.getTitle());
-        if (displayMode != null)
-            Display.setDisplayMode(displayMode);
+        if (displayMode != null){
+            if (settings.isFullscreen()){
+                Display.setDisplayModeAndFullscreen(displayMode);
+            }else{
+                Display.setFullscreen(false);
+                Display.setDisplayMode(displayMode);
+            }
+        }else{
+            Display.setFullscreen(settings.isFullscreen());
+        }
 
         if (settings.getIcons() != null) {
             Display.setIcon(imagesToByteBuffers(settings.getIcons()));
         }
-
-        Display.setFullscreen(settings.isFullscreen());
+        
         Display.setVSyncEnabled(settings.isVSync());
 
         if (!created.get() || pixelFormatChanged){

+ 13 - 0
engine/src/xml/com/jme3/export/xml/DOMOutputCapsule.java

@@ -36,6 +36,7 @@ import com.jme3.export.JmeExporter;
 import com.jme3.export.OutputCapsule;
 import com.jme3.export.Savable;
 import com.jme3.export.Savable;
+import com.jme3.export.SavableClassUtil;
 import com.jme3.util.IntMap;
 import com.jme3.util.IntMap.Entry;
 import java.io.IOException;
@@ -484,6 +485,18 @@ public class DOMOutputCapsule implements OutputCapsule {
             el.setAttribute("ref", refID);
         } else {
             el = appendElement(name);
+            
+            // jME3 NEW: Append version number(s)
+            int[] versions = SavableClassUtil.getSavableVersions(object.getClass());
+            StringBuilder sb = new StringBuilder();
+            for (int i = 0; i < versions.length; i++){
+                sb.append(versions[i]);
+                if (i != versions.length - 1){
+                    sb.append(", ");
+                }
+            }
+            el.setAttribute("savable_version", sb.toString());
+            
             writtenSavables.put(object, el);
             object.write(exporter);
         }

+ 2 - 2
engine/src/xml/com/jme3/export/xml/XMLExporter.java

@@ -63,8 +63,8 @@ public class XMLExporter implements JmeExporter{
 
     public boolean save(Savable object, OutputStream f) throws IOException {
         try {
-        	//Initialize Document when saving so we don't retain state of previous exports
-        	this.domOut = new DOMOutputCapsule(DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(), this);
+            //Initialize Document when saving so we don't retain state of previous exports
+            this.domOut = new DOMOutputCapsule(DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(), this);
             domOut.write(object, object.getClass().getName(), null);
             DOMSerializer serializer = new DOMSerializer();
             serializer.serialize(domOut.getDoc(), f);

+ 13 - 1
engine/src/xml/com/jme3/export/xml/XMLImporter.java

@@ -37,6 +37,8 @@ import com.jme3.asset.AssetManager;
 import com.jme3.export.JmeImporter;
 import com.jme3.export.InputCapsule;
 import com.jme3.export.Savable;
+import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -56,7 +58,6 @@ public class XMLImporter implements JmeImporter {
     public XMLImporter() {
     }
 
-// TODO: .......
     public int getFormatVersion() {
         return 0;
     }
@@ -76,6 +77,17 @@ public class XMLImporter implements JmeImporter {
         in.close();
         return obj;
     }
+    
+    public Savable load(File f) throws IOException {
+        FileInputStream fis = null; 
+        try {
+            fis = new FileInputStream(f);
+            Savable sav = load(fis);
+            return sav;
+        } finally {
+            if (fis != null) fis.close();
+        }
+    }
 
     public Savable load(InputStream f) throws IOException {
         try {