aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/effect/EffectManager.java6
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/ByteBufferData.java14
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/IndexBufferData.java34
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/IntBufferData.java10
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/Mesh.java4
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/MeshData.java6
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/ShortBufferData.java14
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/geom/BufferUtils.java25
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TimedAreaGrapher.java5
-rw-r--r--ardor3d-effects/src/main/java/com/ardor3d/extension/effect/water/ProjectedGrid.java19
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ExportImportExample.java16
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/renderer/DegenerateTrianglesExample.java24
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/renderer/MultiStripExample.java16
-rw-r--r--ardor3d-extras/src/main/java/com/ardor3d/extension/model/util/KeyframeController.java17
-rw-r--r--ardor3d-extras/src/main/java/com/ardor3d/extension/useful/TrailMesh.java8
-rw-r--r--ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/ClipmapLevel.java57
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/border/SolidBorder.java7
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/TextCaret.java2
18 files changed, 183 insertions, 101 deletions
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/effect/EffectManager.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/effect/EffectManager.java
index 8299c14..c5780bd 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/effect/EffectManager.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/effect/EffectManager.java
@@ -18,11 +18,11 @@ import com.ardor3d.framework.DisplaySettings;
import com.ardor3d.image.TextureStoreFormat;
import com.ardor3d.math.Vector3;
import com.ardor3d.renderer.Camera;
-import com.ardor3d.renderer.Renderer;
import com.ardor3d.renderer.Camera.ProjectionMode;
+import com.ardor3d.renderer.Renderer;
import com.ardor3d.renderer.state.RenderState;
-import com.ardor3d.renderer.state.ZBufferState;
import com.ardor3d.renderer.state.RenderState.StateType;
+import com.ardor3d.renderer.state.ZBufferState;
import com.ardor3d.scenegraph.Mesh;
import com.ardor3d.scenegraph.hint.CullHint;
import com.ardor3d.scenegraph.hint.LightCombineMode;
@@ -139,7 +139,7 @@ public class EffectManager {
_fsq = new Mesh("fsq");
_fsq.getMeshData().setVertexBuffer(BufferUtils.createFloatBuffer(-1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1));
_fsq.getMeshData().setTextureBuffer(BufferUtils.createFloatBuffer(0, 0, 1, 0, 1, 1, 0, 1), 0);
- _fsq.getMeshData().setIndexBuffer(BufferUtils.createIntBuffer(0, 1, 3, 1, 2, 3));
+ _fsq.getMeshData().setIndices(BufferUtils.createIndexBufferData(new int[] { 0, 1, 3, 1, 2, 3 }, 3));
_fsq.getSceneHints().setCullHint(CullHint.Never);
_fsq.getSceneHints().setLightCombineMode(LightCombineMode.Off);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/ByteBufferData.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/ByteBufferData.java
index 89d516e..4091e06 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/ByteBufferData.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/ByteBufferData.java
@@ -106,6 +106,20 @@ public class ByteBufferData extends IndexBufferData<ByteBuffer> implements Savab
}
@Override
+ public void put(final int[] array) {
+ for (int i = 0; i < array.length; i++) {
+ put(array[i]);
+ }
+ }
+
+ @Override
+ public void put(final int[] array, final int offset, final int length) {
+ for (int i = offset, max = offset + length; i < max; i++) {
+ put(array[i]);
+ }
+ }
+
+ @Override
public int getByteCount() {
return 1;
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/IndexBufferData.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/IndexBufferData.java
index 9c39fae..4ca77b5 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/IndexBufferData.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/IndexBufferData.java
@@ -66,6 +66,26 @@ public abstract class IndexBufferData<T extends Buffer> extends AbstractBufferDa
public abstract void put(IndexBufferData<?> buf);
/**
+ * Write the contents of the given int array into this IndexBufferData. Note that data conversion is handled using
+ * the get/put methods in IndexBufferData.
+ *
+ * @param array
+ * the source int array.
+ */
+ public abstract void put(int[] array);
+
+ /**
+ * Write the contents of the given int array into this IndexBufferData. Note that data conversion is handled using
+ * the get/put methods in IndexBufferData.
+ *
+ * @param array
+ * the source int array.
+ * @param offset
+ * @param length
+ */
+ public abstract void put(int[] array, int offset, int length);
+
+ /**
* Get the underlying nio buffer.
*/
@Override
@@ -121,6 +141,20 @@ public abstract class IndexBufferData<T extends Buffer> extends AbstractBufferDa
}
/**
+ * @see Buffer#flip();
+ */
+ public void flip() {
+ getBuffer().flip();
+ }
+
+ /**
+ * @see Buffer#clear();
+ */
+ public void clear() {
+ getBuffer().clear();
+ }
+
+ /**
* @see Buffer#reset();
*/
public void reset() {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/IntBufferData.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/IntBufferData.java
index 4e4cf04..219a729 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/IntBufferData.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/IntBufferData.java
@@ -105,6 +105,16 @@ public class IntBufferData extends IndexBufferData<IntBuffer> implements Savable
}
@Override
+ public void put(final int[] array) {
+ _buffer.put(array);
+ }
+
+ @Override
+ public void put(final int[] array, final int offset, final int length) {
+ _buffer.put(array, offset, length);
+ }
+
+ @Override
public int getByteCount() {
return 4;
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Mesh.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Mesh.java
index d97c844..b81eb1c 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Mesh.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Mesh.java
@@ -336,7 +336,7 @@ public class Mesh extends Spatial implements Renderable, Pickable {
}
renderer.setupVertexData(meshData.getVertexCoords());
- if (meshData.getIndexBuffer() != null) {
+ if (meshData.getIndices() != null) {
renderer.drawElements(meshData.getIndices(), meshData.getIndexLengths(), meshData.getIndexModes(),
primcount);
} else {
@@ -390,7 +390,7 @@ public class Mesh extends Spatial implements Renderable, Pickable {
renderer.setupVertexDataVBO(meshData.getVertexCoords());
}
- if (meshData.getIndexBuffer() != null) {
+ if (meshData.getIndices() != null) {
// TODO: Maybe ask for the IndexBuffer's dynamic/static type and fall back to arrays for indices?
renderer.drawElementsVBO(meshData.getIndices(), meshData.getIndexLengths(), meshData.getIndexModes(),
primcount);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/MeshData.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/MeshData.java
index 8516f48..90a5a8b 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/MeshData.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/MeshData.java
@@ -794,7 +794,7 @@ public class MeshData implements Savable {
}
for (int i = 0; i < rSize; i++) {
- if (getIndexBuffer() != null) {
+ if (getIndices() != null) {
result[i] = getIndices().get(getVertexIndex(primitiveIndex, i, section));
} else {
result[i] = getVertexIndex(primitiveIndex, i, section);
@@ -833,7 +833,7 @@ public class MeshData implements Savable {
if (result[i] == null) {
result[i] = new Vector3();
}
- if (getIndexBuffer() != null) {
+ if (getIndices() != null) {
// indexed geometry
BufferUtils.populateFromBuffer(result[i], getVertexBuffer(),
getIndices().get(getVertexIndex(primitiveIndex, i, section)));
@@ -960,7 +960,7 @@ public class MeshData implements Savable {
// Now, based on IndexMode, pick a point on that primitive
final IndexMode mode = getIndexMode(section);
- final boolean hasIndices = getIndexBuffer() != null;
+ final boolean hasIndices = getIndices() != null;
switch (mode) {
case Triangles:
case TriangleFan:
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/ShortBufferData.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/ShortBufferData.java
index 95016bf..5d8f8f8 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/ShortBufferData.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/ShortBufferData.java
@@ -106,6 +106,20 @@ public class ShortBufferData extends IndexBufferData<ShortBuffer> implements Sav
}
@Override
+ public void put(final int[] array) {
+ for (int i = 0; i < array.length; i++) {
+ put(array[i]);
+ }
+ }
+
+ @Override
+ public void put(final int[] array, final int offset, final int length) {
+ for (int i = offset, max = offset + length; i < max; i++) {
+ put(array[i]);
+ }
+ }
+
+ @Override
public int getByteCount() {
return 2;
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/geom/BufferUtils.java b/ardor3d-core/src/main/java/com/ardor3d/util/geom/BufferUtils.java
index 6017a8b..a0a3478 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/geom/BufferUtils.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/geom/BufferUtils.java
@@ -1552,6 +1552,31 @@ public final class BufferUtils {
}
/**
+ * Create a new IndexBufferData large enough to fit the contents of the given array. The specific implementation
+ * will be chosen based on the max value you need to store in your buffer. If that value is less than 2^8, a
+ * ByteBufferData is used. If it is less than 2^16, a ShortBufferData is used. Otherwise an IntBufferData is used.
+ *
+ * @param contents
+ * an array of index values to store in your newly created IndexBufferData.
+ * @param maxValue
+ * the largest value you will need to store in your buffer. Often this is equal to
+ * ("size of vertex buffer" - 1).
+ * @return the new IndexBufferData
+ */
+ public static IndexBufferData<?> createIndexBufferData(final int[] contents, final int maxValue) {
+ final IndexBufferData<?> buffer;
+ if (maxValue < 256) { // 2^8
+ buffer = createIndexBufferData(contents.length, ByteBufferData.class);
+ } else if (maxValue < 65536) { // 2^16
+ buffer = createIndexBufferData(contents.length, ShortBufferData.class);
+ } else {
+ buffer = createIndexBufferData(contents.length, IntBufferData.class);
+ }
+ buffer.put(contents);
+ return buffer;
+ }
+
+ /**
* Create a new IndexBufferData of the specified size and class.
*
* @param size
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TimedAreaGrapher.java b/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TimedAreaGrapher.java
index 4b0e5d2..73637b8 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TimedAreaGrapher.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TimedAreaGrapher.java
@@ -272,11 +272,6 @@ public class TimedAreaGrapher extends AbstractStatGrapher implements TableLinkab
area = new Mesh("a");
area.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(maxSamples * 2));
- area.getMeshData().setIndexBuffer(BufferUtils.createIntBuffer(maxSamples * 2));
- for (int i = 0; i < maxSamples * 2; i++) {
- area.getMeshData().getIndices().put(i);
- }
- area.getMeshData().getIndexBuffer().rewind();
area.getSceneHints().setRenderBucketType(RenderBucketType.Ortho);
area.getMeshData().setIndexMode(IndexMode.LineStrip);
diff --git a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/water/ProjectedGrid.java b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/water/ProjectedGrid.java
index 9667b81..d23c48a 100644
--- a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/water/ProjectedGrid.java
+++ b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/water/ProjectedGrid.java
@@ -11,7 +11,6 @@
package com.ardor3d.extension.effect.water;
import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
import java.util.Stack;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
@@ -33,6 +32,7 @@ import com.ardor3d.math.type.ReadOnlyVector2;
import com.ardor3d.math.type.ReadOnlyVector3;
import com.ardor3d.renderer.Camera;
import com.ardor3d.renderer.Renderer;
+import com.ardor3d.scenegraph.IndexBufferData;
import com.ardor3d.scenegraph.Mesh;
import com.ardor3d.util.ExtendedCamera;
import com.ardor3d.util.Timer;
@@ -52,7 +52,6 @@ public class ProjectedGrid extends Mesh {
private FloatBuffer vertBuf;
private final FloatBuffer normBuf;
private final FloatBuffer texs;
- private IntBuffer indexBuffer;
private final ExtendedCamera mainCamera = new ExtendedCamera();
private final Camera projectorCamera = new Camera();
@@ -593,8 +592,8 @@ public class ProjectedGrid extends Mesh {
// set up the indices
final int triangleQuantity = ((sizeX - 1) * (sizeY - 1)) * 2;
- indexBuffer = BufferUtils.createIntBuffer(triangleQuantity * 3);
- _meshData.setIndexBuffer(indexBuffer);
+ final IndexBufferData<?> indices = BufferUtils.createIndexBufferData(triangleQuantity * 3, vertexCount - 1);
+ _meshData.setIndices(indices);
// go through entire array up to the second to last column.
for (int i = 0; i < (sizeX * (sizeY - 1)); i++) {
@@ -606,17 +605,17 @@ public class ProjectedGrid extends Mesh {
// logger.info("i: "+i);
}
// set the top left corner.
- indexBuffer.put(i);
+ indices.put(i);
// set the bottom right corner.
- indexBuffer.put((1 + sizeX) + i);
+ indices.put((1 + sizeX) + i);
// set the top right corner.
- indexBuffer.put(1 + i);
+ indices.put(1 + i);
// set the top left corner
- indexBuffer.put(i);
+ indices.put(i);
// set the bottom left corner
- indexBuffer.put(sizeX + i);
+ indices.put(sizeX + i);
// set the bottom right corner
- indexBuffer.put((1 + sizeX) + i);
+ indices.put((1 + sizeX) + i);
}
}
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ExportImportExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ExportImportExample.java
index c6f3872..11fe9f4 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ExportImportExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ExportImportExample.java
@@ -13,7 +13,6 @@ package com.ardor3d.example.pipeline;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -25,6 +24,7 @@ import com.ardor3d.math.Vector3;
import com.ardor3d.renderer.IndexMode;
import com.ardor3d.renderer.state.TextureState;
import com.ardor3d.renderer.state.WireframeState;
+import com.ardor3d.scenegraph.IndexBufferData;
import com.ardor3d.scenegraph.Mesh;
import com.ardor3d.scenegraph.MeshData;
import com.ardor3d.scenegraph.Node;
@@ -177,20 +177,20 @@ public class ExportImportExample extends ExampleBase {
meshData.setVertexBuffer(vertexBuffer);
- final IntBuffer indexBuffer = BufferUtils.createIntBuffer(18);
+ final IndexBufferData<?> indices = BufferUtils.createIndexBufferData(18, vertexBuffer.capacity() - 1);
// Strips
- indexBuffer.put(0).put(3).put(1).put(2);
- indexBuffer.put(4).put(7).put(5).put(6);
+ indices.put(0).put(3).put(1).put(2);
+ indices.put(4).put(7).put(5).put(6);
// Quad
- indexBuffer.put(8).put(9).put(10).put(11);
+ indices.put(8).put(9).put(10).put(11);
// Triangles
- indexBuffer.put(12).put(13).put(15);
- indexBuffer.put(13).put(15).put(14);
+ indices.put(12).put(13).put(15);
+ indices.put(13).put(15).put(14);
- meshData.setIndexBuffer(indexBuffer);
+ meshData.setIndices(indices);
// Setting sub primitive data
final int[] indexLengths = new int[] { 4, 4, 4, 6 };
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/DegenerateTrianglesExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/DegenerateTrianglesExample.java
index 361c39c..c9a859d 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/DegenerateTrianglesExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/DegenerateTrianglesExample.java
@@ -11,7 +11,6 @@
package com.ardor3d.example.renderer;
import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
import com.ardor3d.example.ExampleBase;
import com.ardor3d.example.Purpose;
@@ -28,6 +27,7 @@ import com.ardor3d.math.Vector3;
import com.ardor3d.renderer.IndexMode;
import com.ardor3d.renderer.queue.RenderBucketType;
import com.ardor3d.renderer.state.TextureState;
+import com.ardor3d.scenegraph.IndexBufferData;
import com.ardor3d.scenegraph.Mesh;
import com.ardor3d.scenegraph.MeshData;
import com.ardor3d.scenegraph.hint.CullHint;
@@ -128,7 +128,8 @@ public class DegenerateTrianglesExample extends ExampleBase {
final FloatBuffer normalBuffer = BufferUtils.createVector3Buffer(totalSize);
final FloatBuffer textureBuffer = BufferUtils.createVector2Buffer(totalSize);
- final IntBuffer indexBuffer = BufferUtils.createIntBuffer((ySize - 1) * xSize * 2);
+ final IndexBufferData<?> indices = BufferUtils.createIndexBufferData((ySize - 1) * xSize * 2,
+ vertexBuffer.capacity() - 1);
final int[] indexLengths = new int[ySize - 1];
for (int y = 0; y < ySize; y++) {
@@ -142,8 +143,8 @@ public class DegenerateTrianglesExample extends ExampleBase {
for (int y = 0; y < ySize - 1; y++) {
for (int x = 0; x < xSize; x++) {
final int index = y * xSize + x;
- indexBuffer.put(index);
- indexBuffer.put(index + xSize);
+ indices.put(index);
+ indices.put(index + xSize);
}
indexLengths[y] = xSize * 2;
}
@@ -152,7 +153,7 @@ public class DegenerateTrianglesExample extends ExampleBase {
meshData.setNormalBuffer(normalBuffer);
meshData.setTextureBuffer(textureBuffer, 0);
- meshData.setIndexBuffer(indexBuffer);
+ meshData.setIndices(indices);
meshData.setIndexLengths(indexLengths);
meshData.setIndexMode(IndexMode.TriangleStrip);
@@ -167,7 +168,8 @@ public class DegenerateTrianglesExample extends ExampleBase {
final FloatBuffer normalBuffer = BufferUtils.createVector3Buffer(totalSize);
final FloatBuffer textureBuffer = BufferUtils.createVector2Buffer(totalSize);
- final IntBuffer indexBuffer = BufferUtils.createIntBuffer((ySize - 1) * xSize * 2 + (ySize - 1) * 2);
+ final IndexBufferData<?> indices = BufferUtils.createIndexBufferData((ySize - 1) * xSize * 2 + (ySize - 1) * 2,
+ vertexBuffer.capacity() - 1);
for (int y = 0; y < ySize; y++) {
for (int x = 0; x < xSize; x++) {
@@ -180,20 +182,20 @@ public class DegenerateTrianglesExample extends ExampleBase {
for (int y = 0; y < ySize - 1; y++) {
for (int x = 0; x < xSize; x++) {
final int index = y * xSize + x;
- indexBuffer.put(index);
- indexBuffer.put(index + xSize);
+ indices.put(index);
+ indices.put(index + xSize);
}
final int index = (y + 1) * xSize;
- indexBuffer.put(index + xSize - 1);
- indexBuffer.put(index);
+ indices.put(index + xSize - 1);
+ indices.put(index);
}
meshData.setVertexBuffer(vertexBuffer);
meshData.setNormalBuffer(normalBuffer);
meshData.setTextureBuffer(textureBuffer, 0);
- meshData.setIndexBuffer(indexBuffer);
+ meshData.setIndices(indices);
meshData.setIndexMode(IndexMode.TriangleStrip);
return mesh;
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/MultiStripExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/MultiStripExample.java
index 310e39d..35486ce 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/MultiStripExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/MultiStripExample.java
@@ -11,7 +11,6 @@
package com.ardor3d.example.renderer;
import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
import com.ardor3d.example.ExampleBase;
import com.ardor3d.example.Purpose;
@@ -19,6 +18,7 @@ import com.ardor3d.intersection.PickData;
import com.ardor3d.intersection.PrimitivePickResults;
import com.ardor3d.math.Vector3;
import com.ardor3d.renderer.IndexMode;
+import com.ardor3d.scenegraph.IndexBufferData;
import com.ardor3d.scenegraph.Mesh;
import com.ardor3d.scenegraph.MeshData;
import com.ardor3d.util.geom.BufferUtils;
@@ -91,20 +91,20 @@ public class MultiStripExample extends ExampleBase {
meshData.setVertexBuffer(vertexBuffer);
- final IntBuffer indexBuffer = BufferUtils.createIntBuffer(18);
+ final IndexBufferData<?> indices = BufferUtils.createIndexBufferData(18, vertexBuffer.capacity() - 1);
// Strips
- indexBuffer.put(0).put(3).put(1).put(2);
- indexBuffer.put(4).put(7).put(5).put(6);
+ indices.put(0).put(3).put(1).put(2);
+ indices.put(4).put(7).put(5).put(6);
// Quad
- indexBuffer.put(8).put(9).put(10).put(11);
+ indices.put(8).put(9).put(10).put(11);
// Triangles
- indexBuffer.put(12).put(13).put(15);
- indexBuffer.put(13).put(14).put(15);
+ indices.put(12).put(13).put(15);
+ indices.put(13).put(14).put(15);
- meshData.setIndexBuffer(indexBuffer);
+ meshData.setIndices(indices);
// Setting sub primitive data
final int[] indexLengths = new int[] { 4, 4, 4, 6 };
diff --git a/ardor3d-extras/src/main/java/com/ardor3d/extension/model/util/KeyframeController.java b/ardor3d-extras/src/main/java/com/ardor3d/extension/model/util/KeyframeController.java
index 887f415..6609544 100644
--- a/ardor3d-extras/src/main/java/com/ardor3d/extension/model/util/KeyframeController.java
+++ b/ardor3d-extras/src/main/java/com/ardor3d/extension/model/util/KeyframeController.java
@@ -12,11 +12,11 @@ package com.ardor3d.extension.model.util;
import java.io.IOException;
import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
import java.util.ArrayList;
import java.util.logging.Logger;
import com.ardor3d.scenegraph.FloatBufferData;
+import com.ardor3d.scenegraph.IndexBufferData;
import com.ardor3d.scenegraph.Mesh;
import com.ardor3d.scenegraph.Spatial;
import com.ardor3d.scenegraph.controller.ComplexSpatialController;
@@ -379,17 +379,18 @@ public class KeyframeController<T extends Spatial> extends ComplexSpatialControl
dcNorms.put(mmNorms);
dcNorms.flip();
}
- if (_morphMesh.getMeshData().getIndexBuffer() != null) {
- IntBuffer dcInds = (IntBuffer) dataCopy.getMeshData().getIndexBuffer();
+ if (_morphMesh.getMeshData().getIndices() != null) {
+ IndexBufferData<?> dcInds = dataCopy.getMeshData().getIndices();
if (dcInds != null) {
- dcInds.clear();
+ dcInds.rewind();
}
- final IntBuffer mmInds = (IntBuffer) _morphMesh.getMeshData().getIndexBuffer();
+ final IndexBufferData<?> mmInds = _morphMesh.getMeshData().getIndices();
mmInds.clear();
- if (dcInds == null || dcInds.capacity() != mmInds.capacity()) {
- dcInds = BufferUtils.createIntBuffer(mmInds.capacity());
+ if (dcInds == null || dcInds.capacity() != mmInds.capacity() || dcInds.getClass() != mmInds.getClass()) {
+ dcInds = BufferUtils.createIndexBufferData(mmInds.capacity(), _morphMesh.getMeshData()
+ .getVertexBuffer().capacity() - 1);
dcInds.clear();
- dataCopy.getMeshData().setIndexBuffer(dcInds);
+ dataCopy.getMeshData().setIndices(dcInds);
}
dcInds.put(mmInds);
diff --git a/ardor3d-extras/src/main/java/com/ardor3d/extension/useful/TrailMesh.java b/ardor3d-extras/src/main/java/com/ardor3d/extension/useful/TrailMesh.java
index 8a9f483..558d9fb 100644
--- a/ardor3d-extras/src/main/java/com/ardor3d/extension/useful/TrailMesh.java
+++ b/ardor3d-extras/src/main/java/com/ardor3d/extension/useful/TrailMesh.java
@@ -19,7 +19,6 @@ import com.ardor3d.math.Vector3;
import com.ardor3d.math.type.ReadOnlyVector3;
import com.ardor3d.renderer.IndexMode;
import com.ardor3d.scenegraph.FloatBufferData;
-import com.ardor3d.scenegraph.IndexBufferData;
import com.ardor3d.scenegraph.Mesh;
import com.ardor3d.util.export.InputCapsule;
import com.ardor3d.util.export.OutputCapsule;
@@ -299,13 +298,6 @@ public class TrailMesh extends Mesh {
private void setIndexData() {
getMeshData().setIndexMode(IndexMode.TriangleStrip);
- if (getMeshData().getIndexBuffer() == null) {
- getMeshData().setIndexBuffer(BufferUtils.createIntBuffer(trailVertices));
- final IndexBufferData<?> indexBuf = getMeshData().getIndices();
- for (int i = 0; i < trailVertices; i++) {
- indexBuf.put(i);
- }
- }
}
@Override
diff --git a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/ClipmapLevel.java b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/ClipmapLevel.java
index a642655..6817b5e 100644
--- a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/ClipmapLevel.java
+++ b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/ClipmapLevel.java
@@ -11,7 +11,6 @@
package com.ardor3d.extension.terrain.client;
import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
import java.util.Set;
import com.ardor3d.bounding.BoundingBox;
@@ -20,9 +19,10 @@ import com.ardor3d.extension.terrain.util.Tile;
import com.ardor3d.math.MathUtils;
import com.ardor3d.math.Vector3;
import com.ardor3d.renderer.Camera;
-import com.ardor3d.renderer.IndexMode;
import com.ardor3d.renderer.Camera.FrustumIntersect;
+import com.ardor3d.renderer.IndexMode;
import com.ardor3d.scenegraph.FloatBufferData;
+import com.ardor3d.scenegraph.IndexBufferData;
import com.ardor3d.scenegraph.Mesh;
import com.ardor3d.scenegraph.event.DirtyType;
import com.ardor3d.util.geom.BufferUtils;
@@ -181,9 +181,9 @@ public class ClipmapLevel extends Mesh {
// getMeshData().setTextureBuffer(textureCoords, 0);
final int indicesSize = 4 * (3 * frameSize * frameSize + clipSideSize * clipSideSize / 2 + 4 * frameSize - 10);
- final IntBuffer indices = BufferUtils.createIntBuffer(indicesSize);
+ final IndexBufferData<?> indices = BufferUtils.createIndexBufferData(indicesSize, vertices.capacity() - 1);
tmpIndices = new int[indicesSize];
- getMeshData().setIndexBuffer(indices);
+ getMeshData().setIndices(indices);
// Go through all rows and fill them with vertexindices.
for (int z = 0; z < clipSideSize - 1; z++) {
@@ -332,9 +332,8 @@ public class ClipmapLevel extends Mesh {
clipRegion.getTop(), clipRegion.getTop() + frameDistance);
// MxM Block 4
- fillBlock(clipRegion.getRight() - frameDistance, clipRegion.getRight(), clipRegion.getTop(), clipRegion
- .getTop()
- + frameDistance);
+ fillBlock(clipRegion.getRight() - frameDistance, clipRegion.getRight(), clipRegion.getTop(),
+ clipRegion.getTop() + frameDistance);
// MxM Block 5
fillBlock(clipRegion.getLeft(), clipRegion.getLeft() + frameDistance, clipRegion.getTop() + frameDistance,
@@ -357,14 +356,12 @@ public class ClipmapLevel extends Mesh {
clipRegion.getBottom());
// MxM Block 10
- fillBlock(clipRegion.getLeft() + frameDistance, clipRegion.getLeft() + 2 * frameDistance, clipRegion
- .getBottom()
- - frameDistance, clipRegion.getBottom());
+ fillBlock(clipRegion.getLeft() + frameDistance, clipRegion.getLeft() + 2 * frameDistance,
+ clipRegion.getBottom() - frameDistance, clipRegion.getBottom());
// MxM Block 11
- fillBlock(clipRegion.getRight() - 2 * frameDistance, clipRegion.getRight() - frameDistance, clipRegion
- .getBottom()
- - frameDistance, clipRegion.getBottom());
+ fillBlock(clipRegion.getRight() - 2 * frameDistance, clipRegion.getRight() - frameDistance,
+ clipRegion.getBottom() - frameDistance, clipRegion.getBottom());
// MxM Block 12
fillBlock(clipRegion.getRight() - frameDistance, clipRegion.getRight(), clipRegion.getBottom() - frameDistance,
@@ -392,14 +389,12 @@ public class ClipmapLevel extends Mesh {
// Upper Left L Shape
// Up
- fillBlock(clipRegion.getLeft() + frameDistance, clipRegion.getRight() - frameDistance, clipRegion
- .getTop()
- + frameDistance, clipRegion.getTop() + frameDistance + vertexDistance);
+ fillBlock(clipRegion.getLeft() + frameDistance, clipRegion.getRight() - frameDistance,
+ clipRegion.getTop() + frameDistance, clipRegion.getTop() + frameDistance + vertexDistance);
// Left
fillBlock(clipRegion.getLeft() + frameDistance, clipRegion.getLeft() + frameDistance
- + vertexDistance, clipRegion.getTop() + frameDistance + vertexDistance, clipRegion
- .getBottom()
- - frameDistance);
+ + vertexDistance, clipRegion.getTop() + frameDistance + vertexDistance,
+ clipRegion.getBottom() - frameDistance);
} else {
// Lower Left L Shape
@@ -409,23 +404,21 @@ public class ClipmapLevel extends Mesh {
- frameDistance - vertexDistance);
// Bottom
- fillBlock(clipRegion.getLeft() + frameDistance, clipRegion.getRight() - frameDistance, clipRegion
- .getBottom()
- - frameDistance - vertexDistance, clipRegion.getBottom() - frameDistance);
+ fillBlock(clipRegion.getLeft() + frameDistance, clipRegion.getRight() - frameDistance,
+ clipRegion.getBottom() - frameDistance - vertexDistance, clipRegion.getBottom()
+ - frameDistance);
}
} else {
if ((nextFinerLevel.clipRegion.getY() - clipRegion.getY()) / vertexDistance == frameSize) {
// Upper Right L Shape
// Up
- fillBlock(clipRegion.getLeft() + frameDistance, clipRegion.getRight() - frameDistance, clipRegion
- .getTop()
- + frameDistance, clipRegion.getTop() + frameDistance + vertexDistance);
+ fillBlock(clipRegion.getLeft() + frameDistance, clipRegion.getRight() - frameDistance,
+ clipRegion.getTop() + frameDistance, clipRegion.getTop() + frameDistance + vertexDistance);
// Right
fillBlock(clipRegion.getRight() - frameDistance - vertexDistance, clipRegion.getRight()
- - frameDistance, clipRegion.getTop() + frameDistance + vertexDistance, clipRegion
- .getBottom()
- - frameDistance);
+ - frameDistance, clipRegion.getTop() + frameDistance + vertexDistance,
+ clipRegion.getBottom() - frameDistance);
} else {
// Lower Right L Shape
@@ -435,9 +428,9 @@ public class ClipmapLevel extends Mesh {
- frameDistance - vertexDistance);
// Bottom
- fillBlock(clipRegion.getLeft() + frameDistance, clipRegion.getRight() - frameDistance, clipRegion
- .getBottom()
- - frameDistance - vertexDistance, clipRegion.getBottom() - frameDistance);
+ fillBlock(clipRegion.getLeft() + frameDistance, clipRegion.getRight() - frameDistance,
+ clipRegion.getBottom() - frameDistance - vertexDistance, clipRegion.getBottom()
+ - frameDistance);
}
}
}
@@ -457,7 +450,7 @@ public class ClipmapLevel extends Mesh {
clipRegion.getTop() + frameDistance + clipSideSize / 2, clipRegion.getBottom() - frameDistance);
}
- final IntBuffer indices = (IntBuffer) getMeshData().getIndexBuffer();
+ final IndexBufferData<?> indices = getMeshData().getIndices();
indices.clear();
indices.put(tmpIndices, 0, getStripIndex());
indices.flip();
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/border/SolidBorder.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/border/SolidBorder.java
index 45fbebd..5a079b9 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/border/SolidBorder.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/border/SolidBorder.java
@@ -18,11 +18,12 @@ import com.ardor3d.math.type.ReadOnlyColorRGBA;
import com.ardor3d.renderer.IndexMode;
import com.ardor3d.renderer.Renderer;
import com.ardor3d.renderer.state.BlendState;
-import com.ardor3d.renderer.state.ShadingState;
import com.ardor3d.renderer.state.BlendState.DestinationFunction;
import com.ardor3d.renderer.state.BlendState.SourceFunction;
+import com.ardor3d.renderer.state.ShadingState;
import com.ardor3d.renderer.state.ShadingState.ShadingMode;
import com.ardor3d.scenegraph.FloatBufferData;
+import com.ardor3d.scenegraph.IndexBufferData;
import com.ardor3d.scenegraph.Mesh;
import com.ardor3d.util.geom.BufferUtils;
@@ -198,7 +199,9 @@ public class SolidBorder extends UIBorder {
mesh.getMeshData().setVertexCoords(new FloatBufferData(BufferUtils.createVector2Buffer(8), 2));
mesh.getMeshData().setColorBuffer(BufferUtils.createColorBuffer(8));
mesh.getMeshData().setIndexMode(IndexMode.TriangleStrip);
- mesh.getMeshData().setIndexBuffer(BufferUtils.createIntBuffer(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 0, 1 }));
+ final IndexBufferData<?> indices = BufferUtils.createIndexBufferData(10, 7);
+ indices.put(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 0, 1 });
+ mesh.getMeshData().setIndices(indices);
// set up alpha blending.
final BlendState blend = new BlendState();
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/TextCaret.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/TextCaret.java
index 4e30461..bd987b5 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/TextCaret.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/TextCaret.java
@@ -37,7 +37,7 @@ public class TextCaret {
public TextCaret() {
final MeshData md = _strip.getMeshData();
md.setVertexBuffer(BufferUtils.createVector3Buffer(4));
- md.setIndexBuffer(BufferUtils.createIntBuffer(new int[] { 0, 1, 3, 2 }));
+ md.setIndices(BufferUtils.createIndexBufferData(new int[] { 0, 1, 3, 2 }, 3));
md.setIndexMode(IndexMode.TriangleStrip);
final float[] vals = new float[] { 0, 0, 0, //
1, 0, 0, //