Geometry.copyTextureCoordinates() allows only the same scale factor for all dimension.
Index: src/com/jme/scene/Geometry.java
===================================================================
--- src/com/jme/scene/Geometry.java (revision 4390)
+++ src/com/jme/scene/Geometry.java (working copy)
@@ -398,6 +398,36 @@
return;
}
+ TexCoords src = texBuf.get(fromIndex);
+ float[] factors = new float[src.perVert];
+ for (int i = 0; i < factors.length; i++) {
+ factors[i] = factor;
+ }
+ copyTextureCoordinates(fromIndex, toIndex, factors);
+
+ }
+
+ /**
+ * <code>copyTextureCoords</code> copys the texture coordinates of a given
+ * texture unit to another location. If the texture unit is not valid, then
+ * the coordinates are ignored. Coords are multiplied by the given factor.
+ *
+ * @param fromIndex
+ * the coordinates to copy.
+ * @param toIndex
+ * the texture unit to set them to.
+ * @param factor
+ * a multiple to apply when copying
+ */
+ public void copyTextureCoordinates(int fromIndex, int toIndex, float[] factor) {
+ if (texBuf == null)
+ return;
+
+ if (fromIndex < 0 || fromIndex >= texBuf.size()
+ || texBuf.get(fromIndex) == null) {
+ return;
+ }
+
if (toIndex < 0 || toIndex == fromIndex) {
return;
}
@@ -416,8 +446,10 @@
dest.coords.clear();
int oldLimit = src.coords.limit();
src.coords.clear();
- for (int i = 0, len = dest.coords.capacity(); i < len; i++) {
- dest.coords.put(factor * src.coords.get());
+ for (int i = 0, len = dest.coords.capacity(); i < len; i+=dest.perVert) {
+ for (int j = 0; j < dest.perVert; j++) {
+ dest.coords.put(factor[j] * src.coords.get());
+ }
}
src.coords.limit(oldLimit);
dest.coords.limit(oldLimit);
Index: src/com/jme/scene/SharedMesh.java
===================================================================
--- src/com/jme/scene/SharedMesh.java (revision 4390)
+++ src/com/jme/scene/SharedMesh.java (working copy)
@@ -373,12 +373,28 @@
* the coordinates to copy.
* @param toIndex
* the texture unit to set them to.
+ * @param factor scale factor to be multiplied to texture coordinate
*/
@Override
public void copyTextureCoordinates(int fromIndex, int toIndex, float factor) {
logger.warning("SharedMesh does not allow the manipulation"
+ "of the the mesh data.");
}
+
+ /**
+ * <code>copyTextureCoords</code> is not supported by SharedMesh.
+ *
+ * @param fromIndex
+ * the coordinates to copy.
+ * @param toIndex
+ * the texture unit to set them to.
+ * @param factor scale factor to be multiplied to texture coordinate
+ */
+ @Override
+ public void copyTextureCoordinates(int fromIndex, int toIndex, float[] factor) {
+ logger.warning("SharedMesh does not allow the manipulation"
+ + "of the the mesh data.");
+ }
/**
* <code>getTextureBuffers</code> retrieves the target geometry's texture