aboutsummaryrefslogtreecommitdiffstats
path: root/ardor3d-extras/src
diff options
context:
space:
mode:
authorJulien Gouesse <[email protected]>2014-02-11 20:49:47 +0100
committerJulien Gouesse <[email protected]>2014-02-11 20:49:47 +0100
commit8dcb4daee7e165e62778658e9506a631b925b6ba (patch)
tree05b15bef2597ad67ff05df080c56b2c2fb8f1c36 /ardor3d-extras/src
parent4e9076e06e45a8b8e68019a7e825bb02c6a4de2c (diff)
Fixes a spelling mistake in a for loop causing an ArrayIndexOutOfBoundsException when parsing the texture coordinates of a MD3 model
Diffstat (limited to 'ardor3d-extras/src')
-rw-r--r--ardor3d-extras/src/main/java/com/ardor3d/extension/model/md3/Md3Importer.java38
1 files changed, 37 insertions, 1 deletions
diff --git a/ardor3d-extras/src/main/java/com/ardor3d/extension/model/md3/Md3Importer.java b/ardor3d-extras/src/main/java/com/ardor3d/extension/model/md3/Md3Importer.java
index 5136390..c86eada 100644
--- a/ardor3d-extras/src/main/java/com/ardor3d/extension/model/md3/Md3Importer.java
+++ b/ardor3d-extras/src/main/java/com/ardor3d/extension/model/md3/Md3Importer.java
@@ -21,12 +21,45 @@ import com.ardor3d.scenegraph.Node;
import com.ardor3d.util.Ardor3dException;
import com.ardor3d.util.LittleEndianRandomAccessDataInput;
import com.ardor3d.util.geom.BufferUtils;
+import com.ardor3d.util.resource.ResourceLocator;
+import com.ardor3d.util.resource.ResourceLocatorTool;
import com.ardor3d.util.resource.ResourceSource;
+/**
+ * http://education.mit.edu/starlogo-tng/shapes-tutorial/shapetutorial.html
+ */
public class Md3Importer {
private static final float XYZ_SCALE = 1.0f / 64;
+ private ResourceLocator _modelLocator;
+
+ public void setModelLocator(final ResourceLocator locator) {
+ _modelLocator = locator;
+ }
+
+ /**
+ * Reads a MD3 file from the given resource
+ *
+ * @param resource
+ * the name of the resource to find.
+ * @return an ObjGeometryStore data object containing the scene and other useful elements.
+ */
+ public Md3DataStore load(final String resource) {
+ final ResourceSource source;
+ if (_modelLocator == null) {
+ source = ResourceLocatorTool.locateResource(ResourceLocatorTool.TYPE_MODEL, resource);
+ } else {
+ source = _modelLocator.locateResource(resource);
+ }
+
+ if (source == null) {
+ throw new Error("Unable to locate '" + resource + "'");
+ }
+
+ return load(source);
+ }
+
/**
* Reads an MD3 file from the given resource
*
@@ -111,7 +144,7 @@ public class Md3Importer {
}
// Parse out texture coordinates
bis.seek(surfaceStart + surfaces[i]._offsetTexCoords);
- for (final int j = 0; j < surfaces[i]._texCoords.length; i++) {
+ for (int j = 0; j < surfaces[i]._texCoords.length; j++) {
surfaces[i]._texCoords[j] = new Vector2(bis.readFloat(), bis.readFloat());
}
// Parse out vertices
@@ -160,6 +193,9 @@ public class Md3Importer {
store.getFrameNames().add(frame._name);
}
+ // TODO load the animation configuration file (animation.cfg): [sex f/m][first frame, num frames, looping
+ // frames, frames per second]
+
/**
* TODO there is one .skin file per MD3 file, it contains at most one line per surface (?) with the name and
* the texture filename (.jpg or .tga) and a tag per attachment to another MD3 file