Full support for loading mirror modifier added.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7678 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
Kae..pl 14 years ago
parent 0b02438f96
commit 88584ea76c
  1. 24
      engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ModifierHelper.java
  2. BIN
      engine/src/test-data/Blender/2.4x/modifiers.blend

@ -32,6 +32,7 @@
package com.jme3.scene.plugins.blender.helpers.v249; package com.jme3.scene.plugins.blender.helpers.v249;
import java.nio.FloatBuffer; import java.nio.FloatBuffer;
import java.nio.ShortBuffer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -551,13 +552,14 @@ public class ModifierHelper extends AbstractBlenderHelper {
Mesh clone = mesh.deepClone(); Mesh clone = mesh.deepClone();
// getting buffers // getting buffers
FloatBuffer position = (FloatBuffer) mesh.getBuffer(Type.Position).getData(); FloatBuffer position = mesh.getFloatBuffer(Type.Position);
FloatBuffer bindPosePosition = (FloatBuffer) mesh.getBuffer(Type.BindPosePosition).getData(); FloatBuffer bindPosePosition = mesh.getFloatBuffer(Type.BindPosePosition);
FloatBuffer clonePosition = (FloatBuffer) clone.getBuffer(Type.Position).getData(); FloatBuffer clonePosition = clone.getFloatBuffer(Type.Position);
FloatBuffer cloneBindPosePosition = (FloatBuffer) clone.getBuffer(Type.BindPosePosition).getData(); FloatBuffer cloneBindPosePosition = clone.getFloatBuffer(Type.BindPosePosition);
FloatBuffer cloneNormals = (FloatBuffer) clone.getBuffer(Type.Normal).getData(); FloatBuffer cloneNormals = clone.getFloatBuffer(Type.Normal);
FloatBuffer cloneBindPoseNormals = (FloatBuffer) clone.getBuffer(Type.BindPoseNormal).getData(); FloatBuffer cloneBindPoseNormals = clone.getFloatBuffer(Type.BindPoseNormal);
ShortBuffer cloneIndexes = (ShortBuffer) clone.getBuffer(Type.Index).getData();
// modyfying data // modyfying data
for (int i = mirrorIndex; i < clonePosition.limit(); i += 3) { for (int i = mirrorIndex; i < clonePosition.limit(); i += 3) {
@ -575,6 +577,14 @@ public class ModifierHelper extends AbstractBlenderHelper {
} }
cloneNormals.put(i, -cloneNormals.get(i)); cloneNormals.put(i, -cloneNormals.get(i));
cloneBindPoseNormals.put(i, -cloneNormals.get(i)); cloneBindPoseNormals.put(i, -cloneNormals.get(i));
//modifying clone indexes
int vertexIndex = (i - mirrorIndex) / 3;
if(vertexIndex % 3 == 0) {
short index = cloneIndexes.get(vertexIndex + 2);
cloneIndexes.put(vertexIndex + 2, cloneIndexes.get(vertexIndex + 1));
cloneIndexes.put(vertexIndex + 1, index);
}
} }
if(mirrorU) { if(mirrorU) {

Loading…
Cancel
Save