diff options
author | Julien Gouesse <[email protected]> | 2014-02-09 19:01:36 +0100 |
---|---|---|
committer | Julien Gouesse <[email protected]> | 2014-02-09 19:01:36 +0100 |
commit | 5e5b7b6f5142c2a05df10c5a88e9df56ed411545 (patch) | |
tree | ac9a333c332b5d0fcbc13458a37b1b4ddd691ab2 | |
parent | 03b39214b9740f3847d11dac76787dd1ae2f5d29 (diff) |
Implements the creation of the meshes in the MD3 importer (the management of .skin files is still missing)
-rw-r--r-- | ardor3d-extras/src/main/java/com/ardor3d/extension/model/md3/Md3DataStore.java | 19 | ||||
-rw-r--r-- | ardor3d-extras/src/main/java/com/ardor3d/extension/model/md3/Md3Importer.java | 29 |
2 files changed, 30 insertions, 18 deletions
diff --git a/ardor3d-extras/src/main/java/com/ardor3d/extension/model/md3/Md3DataStore.java b/ardor3d-extras/src/main/java/com/ardor3d/extension/model/md3/Md3DataStore.java index 2300a5b..3e1f985 100644 --- a/ardor3d-extras/src/main/java/com/ardor3d/extension/model/md3/Md3DataStore.java +++ b/ardor3d-extras/src/main/java/com/ardor3d/extension/model/md3/Md3DataStore.java @@ -12,31 +12,24 @@ package com.ardor3d.extension.model.md3; import java.util.List; -import com.ardor3d.extension.model.util.KeyframeController; -import com.ardor3d.scenegraph.Mesh; +import com.ardor3d.scenegraph.Node; import com.google.common.collect.Lists; public class Md3DataStore { - private final Mesh _mainMesh; - private final KeyframeController<Mesh> _controller; + private final Node _mainNode; private final List<String> _frameNames = Lists.newArrayList(); private final List<String> _skinNames = Lists.newArrayList(); - public Md3DataStore(final Mesh mainMesh, final KeyframeController<Mesh> controller) { + public Md3DataStore(final Node mainNode) { super(); - _mainMesh = mainMesh; - _controller = controller; + _mainNode = mainNode; } - public Mesh getScene() { - return _mainMesh; - } - - public KeyframeController<Mesh> getController() { - return _controller; + public Node getScene() { + return _mainNode; } public List<String> getFrameNames() { 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 34f6601..5136390 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 @@ -12,11 +12,15 @@ package com.ardor3d.extension.model.md3; import java.io.InputStream; +import com.ardor3d.extension.model.util.KeyframeController; import com.ardor3d.math.Matrix3; import com.ardor3d.math.Vector2; import com.ardor3d.math.Vector3; +import com.ardor3d.scenegraph.Mesh; +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.ResourceSource; public class Md3Importer { @@ -126,25 +130,40 @@ public class Md3Importer { } } + final Node node = new Node(header._name); for (int i = 0; i < header._numSurfaces; i++) { final Md3Surface surface = surfaces[i]; - + final KeyframeController<Mesh> controller = new KeyframeController<Mesh>(); + final Mesh morphingMesh = new Mesh(surface._name); + morphingMesh.getMeshData().setIndexBuffer(BufferUtils.createIntBuffer(surface._triIndexes)); + morphingMesh.getMeshData().setVertexBuffer(BufferUtils.createFloatBuffer(surface._verts[0])); + morphingMesh.getMeshData().setNormalBuffer(BufferUtils.createFloatBuffer(surface._norms[0])); + morphingMesh.getMeshData().setTextureBuffer(BufferUtils.createFloatBuffer(surface._texCoords), 0); + node.attachChild(morphingMesh); + controller.setMorphingMesh(morphingMesh); for (int j = 0; j < surface._numFrames; j++) { final Md3Frame frame = frames[j]; - + final Mesh mesh = new Mesh(frame._name); + mesh.getMeshData().setVertexBuffer(BufferUtils.createFloatBuffer(surface._verts[j])); + mesh.getMeshData().setNormalBuffer(BufferUtils.createFloatBuffer(surface._norms[j])); + controller.setKeyframe(j, mesh); } - // TODO + morphingMesh.addController(controller); + // TODO should I add a controller into the node? } // Make a store object to return - final Md3DataStore store = new Md3DataStore(/* mesh, controller */null, null); + final Md3DataStore store = new Md3DataStore(node); // store names for (final Md3Frame frame : frames) { store.getFrameNames().add(frame._name); } - // TODO look for the textures filenames in the .skin files + /** + * 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 + */ return store; } catch (final Exception e) { |