* 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
This commit is contained in:
parent
7ea8687e4a
commit
a43e52a384
@ -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){
|
float lightComputeSpecular(in vec3 norm, in vec3 viewdir, in vec3 lightdir, in float shiny){
|
||||||
|
if (shiny <= 1.0){
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
#ifdef LOW_QUALITY
|
#ifdef LOW_QUALITY
|
||||||
// Blinn-Phong
|
// Blinn-Phong
|
||||||
// Note: preferably, H should be computed in the vertex shader
|
// 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 diffuseFactor = lightComputeDiffuse(wvNorm, wvLightDir, wvViewDir);
|
||||||
float specularFactor = lightComputeSpecular(wvNorm, wvViewDir, wvLightDir, m_Shininess);
|
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
|
#ifdef HQ_ATTENUATION
|
||||||
float att = clamp(1.0 - g_LightPosition.w * length(lightVec), 0.0, 1.0);
|
float att = clamp(1.0 - g_LightPosition.w * length(lightVec), 0.0, 1.0);
|
||||||
#else
|
#else
|
||||||
|
@ -350,19 +350,7 @@ public class BinaryExporter implements JmeExporter {
|
|||||||
BinaryClassObject bco = new BinaryClassObject();
|
BinaryClassObject bco = new BinaryClassObject();
|
||||||
bco.alias = generateTag();
|
bco.alias = generateTag();
|
||||||
bco.nameFields = new HashMap<String, BinaryClassField>();
|
bco.nameFields = new HashMap<String, BinaryClassField>();
|
||||||
|
bco.classHierarchyVersions = SavableClassUtil.getSavableVersions(clazz);
|
||||||
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;
|
|
||||||
|
|
||||||
classes.put(clazz.getName(), bco);
|
classes.put(clazz.getName(), bco);
|
||||||
|
|
||||||
|
@ -42,9 +42,8 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import com.jme3.material.MatParamTexture;
|
import com.jme3.material.MatParamTexture;
|
||||||
import com.jme3.scene.Spatial;
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Type;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -95,6 +94,21 @@ public class SavableClassUtil {
|
|||||||
return false;
|
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{
|
public static int getSavableVersion(Class<? extends Savable> clazz) throws IOException{
|
||||||
try {
|
try {
|
||||||
Field field = clazz.getField("SAVABLE_VERSION");
|
Field field = clazz.getField("SAVABLE_VERSION");
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
|
|
||||||
package com.jme3.system.lwjgl;
|
package com.jme3.system.lwjgl;
|
||||||
|
|
||||||
import com.jme3.input.TouchInput;
|
|
||||||
import com.jme3.system.JmeContext.Type;
|
import com.jme3.system.JmeContext.Type;
|
||||||
import org.lwjgl.LWJGLException;
|
import org.lwjgl.LWJGLException;
|
||||||
import org.lwjgl.opengl.Display;
|
import org.lwjgl.opengl.Display;
|
||||||
@ -110,14 +109,21 @@ public class LwjglDisplay extends LwjglAbstractDisplay {
|
|||||||
pixelFormat = pf;
|
pixelFormat = pf;
|
||||||
|
|
||||||
Display.setTitle(settings.getTitle());
|
Display.setTitle(settings.getTitle());
|
||||||
if (displayMode != null)
|
if (displayMode != null){
|
||||||
|
if (settings.isFullscreen()){
|
||||||
|
Display.setDisplayModeAndFullscreen(displayMode);
|
||||||
|
}else{
|
||||||
|
Display.setFullscreen(false);
|
||||||
Display.setDisplayMode(displayMode);
|
Display.setDisplayMode(displayMode);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
Display.setFullscreen(settings.isFullscreen());
|
||||||
|
}
|
||||||
|
|
||||||
if (settings.getIcons() != null) {
|
if (settings.getIcons() != null) {
|
||||||
Display.setIcon(imagesToByteBuffers(settings.getIcons()));
|
Display.setIcon(imagesToByteBuffers(settings.getIcons()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Display.setFullscreen(settings.isFullscreen());
|
|
||||||
Display.setVSyncEnabled(settings.isVSync());
|
Display.setVSyncEnabled(settings.isVSync());
|
||||||
|
|
||||||
if (!created.get() || pixelFormatChanged){
|
if (!created.get() || pixelFormatChanged){
|
||||||
|
@ -36,6 +36,7 @@ import com.jme3.export.JmeExporter;
|
|||||||
import com.jme3.export.OutputCapsule;
|
import com.jme3.export.OutputCapsule;
|
||||||
import com.jme3.export.Savable;
|
import com.jme3.export.Savable;
|
||||||
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;
|
||||||
import com.jme3.util.IntMap.Entry;
|
import com.jme3.util.IntMap.Entry;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -484,6 +485,18 @@ public class DOMOutputCapsule implements OutputCapsule {
|
|||||||
el.setAttribute("ref", refID);
|
el.setAttribute("ref", refID);
|
||||||
} else {
|
} else {
|
||||||
el = appendElement(name);
|
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);
|
writtenSavables.put(object, el);
|
||||||
object.write(exporter);
|
object.write(exporter);
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,8 @@ import com.jme3.asset.AssetManager;
|
|||||||
import com.jme3.export.JmeImporter;
|
import com.jme3.export.JmeImporter;
|
||||||
import com.jme3.export.InputCapsule;
|
import com.jme3.export.InputCapsule;
|
||||||
import com.jme3.export.Savable;
|
import com.jme3.export.Savable;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
@ -56,7 +58,6 @@ public class XMLImporter implements JmeImporter {
|
|||||||
public XMLImporter() {
|
public XMLImporter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: .......
|
|
||||||
public int getFormatVersion() {
|
public int getFormatVersion() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -77,6 +78,17 @@ public class XMLImporter implements JmeImporter {
|
|||||||
return obj;
|
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 {
|
public Savable load(InputStream f) throws IOException {
|
||||||
try {
|
try {
|
||||||
domIn = new DOMInputCapsule(DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(f), this);
|
domIn = new DOMInputCapsule(DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(f), this);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user