diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..972d6d8
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+/WorldWindObj/nbproject/private/
+/nbproject/private/
+/build/
+/dist/
+/lib/
+/resources/
\ No newline at end of file
diff --git a/build.xml b/build.xml
new file mode 100644
index 0000000..1b5683b
--- /dev/null
+++ b/build.xml
@@ -0,0 +1,102 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project WorldWindObj.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml
new file mode 100644
index 0000000..7d03cc5
--- /dev/null
+++ b/nbproject/build-impl.xml
@@ -0,0 +1,1824 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set platform.home
+ Must set platform.bootcp
+ Must set platform.java
+ Must set platform.javac
+
+ The J2SE Platform is not correctly set up.
+ Your active platform is: ${platform.active}, but the corresponding property "platforms.${platform.active}.home" is not found in the project's properties files.
+ Either open the project in the IDE and setup the Platform with the same name or add it manually.
+ For example like this:
+ ant -Duser.properties.file=<path_to_property_file> jar (where you put the property "platforms.${platform.active}.home" in a .properties file)
+ or ant -Dplatforms.${platform.active}.home=<path_to_JDK_home> jar (where no properties file is used)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ ${platform.java} -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties
new file mode 100644
index 0000000..6251c38
--- /dev/null
+++ b/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=69da1009
+build.xml.script.CRC32=1c85a09e
+build.xml.stylesheet.CRC32=f85dc8f2@1.89.1.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=69da1009
+nbproject/build-impl.xml.script.CRC32=0e188323
+nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.100.0.48
diff --git a/nbproject/project.properties b/nbproject/project.properties
new file mode 100644
index 0000000..13e5f36
--- /dev/null
+++ b/nbproject/project.properties
@@ -0,0 +1,96 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+application.title=WorldWindObj
+application.vendor=sbodmer
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.modulepath=\
+ ${run.modulepath}
+debug.test.classpath=\
+ ${run.test.classpath}
+debug.test.modulepath=\
+ ${run.test.modulepath}
+# Files in build.classes.dir which should be excluded from distribution jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/WorldWindObj.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+dist.jlink.dir=${dist.dir}/jlink
+dist.jlink.output=${dist.jlink.dir}/WorldWindObj
+endorsed.classpath=
+excludes=
+includes=**
+jar.compress=false
+javac.classpath=\
+ ${libs.worldwind.classpath}
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.external.vm=true
+javac.modulepath=
+javac.processormodulepath=
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.8
+javac.target=1.8
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+javac.test.modulepath=\
+ ${javac.modulepath}
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.html5=false
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+# The jlink additional root modules to resolve
+jlink.additionalmodules=
+# The jlink additional command line parameters
+jlink.additionalparam=
+jlink.launcher=true
+jlink.launcher.name=WorldWindObj
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=true
+platform.active=JDK_1.8__Oracle_
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.modulepath=\
+ ${javac.modulepath}
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+run.test.modulepath=\
+ ${javac.test.modulepath}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/nbproject/project.xml b/nbproject/project.xml
new file mode 100644
index 0000000..a9b0f1b
--- /dev/null
+++ b/nbproject/project.xml
@@ -0,0 +1,19 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ WorldWindObj
+
+
+
+
+
+
+
+
+
+ ./lib/nblibraries.properties
+
+
+
diff --git a/src/osm/map/worldwind/gl/GLRenderable.java b/src/osm/map/worldwind/gl/GLRenderable.java
index 809284f..ea96d76 100644
--- a/src/osm/map/worldwind/gl/GLRenderable.java
+++ b/src/osm/map/worldwind/gl/GLRenderable.java
@@ -1,5 +1,6 @@
package osm.map.worldwind.gl;
+import com.jogamp.opengl.GL2;
import gov.nasa.worldwind.geom.Angle;
import gov.nasa.worldwind.geom.Position;
import gov.nasa.worldwind.geom.Vec4;
@@ -8,7 +9,6 @@
import gov.nasa.worldwind.render.OrderedRenderable;
import gov.nasa.worldwind.render.Renderable;
import java.awt.Point;
-import javax.media.opengl.GL2;
public abstract class GLRenderable implements Renderable {
@@ -25,8 +25,9 @@ public abstract class GLRenderable implements Renderable {
protected Vec4 lightSource = new Vec4(1.0, 0.5, 1.0);
protected double eyeDistance;
protected double eyeDistanceOffset = 0;
+
boolean drawnOnce = false;
-
+
public GLRenderable(Position position) {
this.position = position;
}
@@ -56,7 +57,6 @@ public void myRender(DrawContext dc) {
if (eyeDistance > renderDistance) {
return;
}
-
try {
beginDraw(dc);
draw(dc);
@@ -78,7 +78,7 @@ protected void draw(DrawContext dc) {
}
double localSize = this.computeSize(dc, loc);
- if (dc.getView().getFrustumInModelCoordinates().contains(loc)) {
+ // if (dc.getView().getFrustumInModelCoordinates().contains(loc)) {
dc.getView().pushReferenceCenter(dc, loc);
gl.glRotated(position.getLongitude().degrees, 0, 1, 0);
gl.glRotated(-position.getLatitude().degrees, 1, 0, 0);
@@ -88,7 +88,7 @@ protected void draw(DrawContext dc) {
gl.glScaled(localSize, localSize, localSize);
drawGL(dc);
dc.getView().popReferenceCenter(dc);
- }
+ // }
}
protected abstract void drawGL(DrawContext dc);
diff --git a/src/osm/map/worldwind/gl/fire/Fire.java b/src/osm/map/worldwind/gl/fire/Fire.java
index cd61d4c..edbe32f 100644
--- a/src/osm/map/worldwind/gl/fire/Fire.java
+++ b/src/osm/map/worldwind/gl/fire/Fire.java
@@ -1,12 +1,12 @@
package osm.map.worldwind.gl.fire;
+import com.jogamp.opengl.GL;
import com.jogamp.opengl.util.texture.Texture;
import com.jogamp.opengl.util.texture.TextureIO;
+import com.jogamp.opengl.GL2;
import gov.nasa.worldwind.util.OGLUtil;
import java.awt.Color;
import java.util.ArrayList;
-import javax.media.opengl.GL;
-import javax.media.opengl.GL2;
public class Fire {
diff --git a/src/osm/map/worldwind/gl/fire/FireRenderable.java b/src/osm/map/worldwind/gl/fire/FireRenderable.java
index 1dbbdae..de82b16 100644
--- a/src/osm/map/worldwind/gl/fire/FireRenderable.java
+++ b/src/osm/map/worldwind/gl/fire/FireRenderable.java
@@ -4,7 +4,7 @@
import gov.nasa.worldwind.render.*;
import java.awt.*;
-import javax.media.opengl.GL2;
+import com.jogamp.opengl.GL2;
import osm.map.worldwind.gl.GLRenderable;
public class FireRenderable extends GLRenderable {
diff --git a/src/osm/map/worldwind/gl/obj/MtlLoader.java b/src/osm/map/worldwind/gl/obj/MtlLoader.java
index c6affd0..4c8ed60 100644
--- a/src/osm/map/worldwind/gl/obj/MtlLoader.java
+++ b/src/osm/map/worldwind/gl/obj/MtlLoader.java
@@ -115,7 +115,7 @@ private void loadobject(BufferedReader br) {
}
}
- public class Material {
+ public static class Material {
public String name;
public int mtlnum;
diff --git a/src/osm/map/worldwind/gl/obj/ObjLoader.java b/src/osm/map/worldwind/gl/obj/ObjLoader.java
index 5674a7f..83d8623 100644
--- a/src/osm/map/worldwind/gl/obj/ObjLoader.java
+++ b/src/osm/map/worldwind/gl/obj/ObjLoader.java
@@ -1,7 +1,9 @@
package osm.map.worldwind.gl.obj;
+import com.jogamp.opengl.GL2;
import com.jogamp.opengl.util.texture.Texture;
import com.jogamp.opengl.util.texture.TextureIO;
+import gov.nasa.worldwind.render.Box;
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
@@ -9,7 +11,6 @@
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
-import javax.media.opengl.GL2;
import osm.map.worldwind.gl.obj.MtlLoader.Material;
public class ObjLoader {
@@ -22,15 +23,19 @@ public class ObjLoader {
float toppoint, bottompoint, leftpoint, rightpoint, farpoint, nearpoint;
Map textureCache = new HashMap();
+ //--- Bounding box
+ Box box = null;
+
String basePath;
boolean flipTextureVertically;
- public ObjLoader(String objPath, GL2 gl, boolean centered, boolean flipTextureVertically) {
+ public ObjLoader(String objPath, GL2 gl, boolean centered, boolean flipTextureVertically, ObjLoaderProgressListener listener) {
this.flipTextureVertically = flipTextureVertically;
try {
basePath = new File(objPath).getParent().toString();
FileInputStream r_path1 = new FileInputStream(objPath);
BufferedReader b_read1 = new BufferedReader(new InputStreamReader(r_path1));
+ if (listener != null) listener.objLoading(basePath, "Parsing file");
loadObject(b_read1);
if (centered) {
centerit();
@@ -39,10 +44,12 @@ public ObjLoader(String objPath, GL2 gl, boolean centered, boolean flipTextureVe
cleanup();
r_path1.close();
b_read1.close();
+ if (listener != null) listener.objLoaded(objPath, "Loaded");
} catch (Exception e) {
System.err.println("Error: could not load " + objPath);
e.printStackTrace();
+ if (listener != null) listener.objLoadingFailed(objPath, e.getMessage());
}
}
@@ -69,7 +76,9 @@ private void loadObject(BufferedReader br) {
newline = newline.substring(2, newline.length());
StringTokenizer st = new StringTokenizer(newline, " ");
for (int i = 0; st.hasMoreTokens(); i++) {
- coords[i] = Float.parseFloat(st.nextToken());
+ String tk = st.nextToken();
+ if (tk.equals("\\")) tk = br.readLine();
+ coords[i] = Float.parseFloat(tk);
}
if (firstpass) {
rightpoint = coords[0];
@@ -93,7 +102,9 @@ private void loadObject(BufferedReader br) {
newline = newline.substring(3, newline.length());
StringTokenizer st = new StringTokenizer(newline, " ");
for (int i = 0; st.hasMoreTokens(); i++) {
- coords[i] = Float.parseFloat(st.nextToken());
+ String tk = st.nextToken();
+ if (tk.equals("\\")) tk = br.readLine();
+ coords[i] = Float.parseFloat(tk);
}
vertexSetsTexs.add(coords);
} else //Loads vertex normals coordinates
@@ -102,7 +113,9 @@ private void loadObject(BufferedReader br) {
newline = newline.substring(3, newline.length());
StringTokenizer st = new StringTokenizer(newline, " ");
for (int i = 0; st.hasMoreTokens(); i++) {
- coords[i] = Float.parseFloat(st.nextToken());
+ String tk = st.nextToken();
+ if (tk.equals("\\")) tk = br.readLine();
+ coords[i] = Float.parseFloat(tk);
}
vertexSetsNorms.add(coords);
} else if (newline.startsWith("f ")) { //Loads face coordinates
@@ -137,9 +150,19 @@ private void loadObject(BufferedReader br) {
vn[i] = 0;
}
}
- faces.add(new Face(mtlLoader.getMtl(mtlID), v, vn, vt));
+ if (mtlLoader == null) {
+ MtlLoader.Material mat = new MtlLoader.Material();
+ mat.name = "default";
+ faces.add(new Face(mat, v, vn, vt));
+
+ } else {
+ faces.add(new Face(mtlLoader.getMtl(mtlID), v, vn, vt));
+
+ }
+
} else if (newline.startsWith("mtllib")) { //Loads materials
mtlLoader = new MtlLoader(basePath, newline.substring(newline.indexOf(" ")).trim());
+
} else if (newline.startsWith("usemtl")) { //Uses materials
mtlID = newline.split("\\s+")[1];
}
@@ -199,6 +222,7 @@ private void opengldrawtolist(GL2 gl) {
texture = null;
lastMapKd = "";
}
+
} else if (!lastMapKd.equals(mtl.map_Kd.toString())) { //yes texture, and it changed?
if (texture != null) {
texture.disable(gl);
@@ -308,13 +332,17 @@ public int compareTo(Face face) {
} else if (this.mtl.d < face.mtl.d) {
return 1;
}
-
+
if (this.texture == null && face.texture != null) { //draw non-textured faces first
return -1;
+
} else if (this.texture != null && face.texture == null) {
return 1;
+
} else if (this.texture != null && face.texture != null) { //order by texture name
- return this.mtl.map_Kd.compareTo(face.mtl.map_Kd);
+ if (this.mtl.map_Kd != null) {
+ return this.mtl.map_Kd.compareTo(face.mtl.map_Kd);
+ }
}
return this.mtl.name.compareTo(face.mtl.name); //order by mtl name
}
diff --git a/src/osm/map/worldwind/gl/obj/ObjLoaderProgressListener.java b/src/osm/map/worldwind/gl/obj/ObjLoaderProgressListener.java
new file mode 100644
index 0000000..15e12c8
--- /dev/null
+++ b/src/osm/map/worldwind/gl/obj/ObjLoaderProgressListener.java
@@ -0,0 +1,17 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package osm.map.worldwind.gl.obj;
+
+/**
+ *
+ * @author sbodmer
+ */
+public interface ObjLoaderProgressListener {
+ public void objLoading(String file, String message);
+ public void objLoadingFailed(String file, String message);
+ public void objLoaded(String file, String message);
+
+}
diff --git a/src/osm/map/worldwind/gl/obj/ObjRenderable.java b/src/osm/map/worldwind/gl/obj/ObjRenderable.java
index 4dffe9c..6965c18 100644
--- a/src/osm/map/worldwind/gl/obj/ObjRenderable.java
+++ b/src/osm/map/worldwind/gl/obj/ObjRenderable.java
@@ -1,50 +1,57 @@
package osm.map.worldwind.gl.obj;
+import com.jogamp.opengl.GL2;
import gov.nasa.worldwind.geom.Position;
import gov.nasa.worldwind.render.DrawContext;
-import java.util.HashMap;
-import java.util.Map;
-import javax.media.opengl.GL2;
import osm.map.worldwind.gl.GLRenderable;
public class ObjRenderable extends GLRenderable {
- static Map modelCache = new HashMap();
+ ObjLoader loader = null;
String modelSource;
- boolean centerit = false, flipTextureVertically = false;
+ boolean centerit = false;
+ boolean flipTextureVertically = false;
+ ObjLoaderProgressListener listener = null;
- public ObjRenderable(Position pos, String modelSource) {
+ public ObjRenderable(Position pos, String modelSource, ObjLoaderProgressListener listener) {
super(pos);
this.modelSource = modelSource;
+ this.listener = listener;
}
-
- public ObjRenderable(Position pos, String modelSource, boolean centerit, boolean flipTextureVertically) {
+
+ public ObjRenderable(Position pos, String modelSource, boolean centerit, boolean flipTextureVertically, ObjLoaderProgressListener listener) {
super(pos);
this.modelSource = modelSource;
this.centerit = centerit;
this.flipTextureVertically = flipTextureVertically;
+ this.listener = listener;
}
- protected ObjLoader getModel(final DrawContext dc) {
- String key = modelSource + "#" + dc.hashCode();
- if (modelCache.get(key) == null) {
- modelCache.put(key, new ObjLoader(modelSource, dc.getGL().getGL2(), centerit, flipTextureVertically));
- }
- ObjLoader model = modelCache.get(key);
- eyeDistanceOffset = Math.max(Math.max(model.getXWidth(), model.getYHeight()), model.getZDepth());
- return modelCache.get(key);
+ //**************************************************************************
+ //*** API
+ //**************************************************************************
+ public ObjLoader getLoader() {
+ return loader;
}
- public static void reload() {
- modelCache.clear();
- }
-
+
+ //**************************************************************************
+ //*** GLRenderable
+ //**************************************************************************
@Override
protected void drawGL(DrawContext dc) {
GL2 gl = dc.getGL().getGL2();
- gl.glRotated(90, 1, 0, 0);
- getModel(dc).opengldraw(gl);
+ // gl.glRotated(180, 1, 0, 0);
+ // gl.glRotated(180, 0, 0, 1);
+
+ //--- Loading conmplex objects will freeze the event thread
+ if (loader == null) loader = new ObjLoader(modelSource, dc.getGL().getGL2(), centerit, flipTextureVertically, listener);
+
+ eyeDistanceOffset = Math.max(Math.max(loader.getXWidth(), loader.getYHeight()), loader.getZDepth());
+
+ loader.opengldraw(gl);
+
}
}