Refactoring: tabs replaced by spaces in blender importer sources. (4 spaces for each tab)

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10401 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
Kae..pl 12 years ago
parent 9f4544a3a8
commit ecc8d8387b
  1. 36
      engine/src/blender/com/jme3/asset/BlenderKey.java
  2. 3
      engine/src/blender/com/jme3/asset/GeneratedTextureKey.java
  3. 6
      engine/src/blender/com/jme3/scene/plugins/blender/AbstractBlenderHelper.java
  4. 1
      engine/src/blender/com/jme3/scene/plugins/blender/BlenderContext.java
  5. 3
      engine/src/blender/com/jme3/scene/plugins/blender/constraints/BoneConstraint.java
  6. 3
      engine/src/blender/com/jme3/scene/plugins/blender/constraints/SkeletonConstraint.java
  7. 6
      engine/src/blender/com/jme3/scene/plugins/blender/constraints/SpatialConstraint.java
  8. 13
      engine/src/blender/com/jme3/scene/plugins/blender/constraints/definitions/ConstraintDefinition.java
  9. 77
      engine/src/blender/com/jme3/scene/plugins/blender/constraints/definitions/ConstraintDefinitionShrinkWrap.java
  10. 8
      engine/src/blender/com/jme3/scene/plugins/blender/curves/BezierCurve.java
  11. 13
      engine/src/blender/com/jme3/scene/plugins/blender/curves/CurvesHelper.java
  12. 3
      engine/src/blender/com/jme3/scene/plugins/blender/file/BlenderInputStream.java
  13. 15
      engine/src/blender/com/jme3/scene/plugins/blender/file/DnaBlockData.java
  14. 3
      engine/src/blender/com/jme3/scene/plugins/blender/file/FileBlockHeader.java
  15. 3
      engine/src/blender/com/jme3/scene/plugins/blender/file/Pointer.java
  16. 19
      engine/src/blender/com/jme3/scene/plugins/blender/materials/MaterialContext.java
  17. 3
      engine/src/blender/com/jme3/scene/plugins/blender/materials/MaterialHelper.java
  18. 54
      engine/src/blender/com/jme3/scene/plugins/blender/meshes/MeshBuilder.java
  19. 18
      engine/src/blender/com/jme3/scene/plugins/blender/meshes/MeshContext.java
  20. 4
      engine/src/blender/com/jme3/scene/plugins/blender/meshes/MeshHelper.java
  21. 9
      engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ArmatureModifier.java
  22. 6
      engine/src/blender/com/jme3/scene/plugins/blender/modifiers/MirrorModifier.java
  23. 3
      engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ParticlesModifier.java
  24. 3
      engine/src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java
  25. 3
      engine/src/blender/com/jme3/scene/plugins/blender/textures/CombinedTexture.java
  26. 18
      engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureHelper.java
  27. 4
      engine/src/blender/com/jme3/scene/plugins/blender/textures/TriangulatedTexture.java
  28. 18
      engine/src/blender/com/jme3/scene/plugins/blender/textures/UVCoordinatesGenerator.java
  29. 13
      engine/src/blender/com/jme3/scene/plugins/blender/textures/UVProjectionGenerator.java
  30. 20
      engine/src/blender/com/jme3/scene/plugins/blender/textures/blending/TextureBlenderAWT.java
  31. 6
      engine/src/blender/com/jme3/scene/plugins/blender/textures/blending/TextureBlenderDDS.java
  32. 10
      engine/src/blender/com/jme3/scene/plugins/blender/textures/blending/TextureBlenderLuminance.java
  33. 13
      engine/src/blender/com/jme3/scene/plugins/blender/textures/generating/NoiseGenerator.java
  34. 6
      engine/src/blender/com/jme3/scene/plugins/blender/textures/generating/TextureGenerator.java
  35. 12
      engine/src/blender/com/jme3/scene/plugins/blender/textures/generating/TextureGeneratorWood.java
  36. 14
      engine/src/blender/com/jme3/scene/plugins/blender/textures/io/AWTPixelInputOutput.java

@ -110,7 +110,8 @@ public class BlenderKey extends ModelKey {
/** /**
* Constructor used by serialization mechanisms. * Constructor used by serialization mechanisms.
*/ */
public BlenderKey() {} public BlenderKey() {
}
/** /**
* Constructor. Creates a key for the given file name. * Constructor. Creates a key for the given file name.
@ -175,7 +176,8 @@ public class BlenderKey extends ModelKey {
/** /**
* This method sets the properies loading policy. * This method sets the properies loading policy.
* By default the value is true. * By default the value is true.
* @param loadObjectProperties true to load properties and false to suspend their loading * @param loadObjectProperties
* true to load properties and false to suspend their loading
*/ */
public void setLoadObjectProperties(boolean loadObjectProperties) { public void setLoadObjectProperties(boolean loadObjectProperties) {
this.loadObjectProperties = loadObjectProperties; this.loadObjectProperties = loadObjectProperties;
@ -205,7 +207,8 @@ public class BlenderKey extends ModelKey {
/** /**
* This method sets the maximum texture size. * This method sets the maximum texture size.
* @param maxTextureSize the maximum texture size * @param maxTextureSize
* the maximum texture size
*/ */
public void setMaxTextureSize(int maxTextureSize) { public void setMaxTextureSize(int maxTextureSize) {
this.maxTextureSize = maxTextureSize; this.maxTextureSize = maxTextureSize;
@ -213,7 +216,8 @@ public class BlenderKey extends ModelKey {
/** /**
* This method sets the flag that toggles the generated textures loading. * This method sets the flag that toggles the generated textures loading.
* @param loadGeneratedTextures <b>true</b> if generated textures should be loaded and <b>false</b> otherwise * @param loadGeneratedTextures
* <b>true</b> if generated textures should be loaded and <b>false</b> otherwise
*/ */
public void setLoadGeneratedTextures(boolean loadGeneratedTextures) { public void setLoadGeneratedTextures(boolean loadGeneratedTextures) {
this.loadGeneratedTextures = loadGeneratedTextures; this.loadGeneratedTextures = loadGeneratedTextures;
@ -323,7 +327,8 @@ public class BlenderKey extends ModelKey {
/** /**
* This method sets the generated textures resolution. * This method sets the generated textures resolution.
* @param generatedTexturePPU the generated textures resolution * @param generatedTexturePPU
* the generated textures resolution
*/ */
public void setGeneratedTexturePPU(int generatedTexturePPU) { public void setGeneratedTexturePPU(int generatedTexturePPU) {
this.generatedTexturePPU = generatedTexturePPU; this.generatedTexturePPU = generatedTexturePPU;
@ -496,16 +501,11 @@ public class BlenderKey extends ModelKey {
} }
/** /**
* This enum tells the importer if the mipmaps for textures will be generated by jme. * This enum tells the importer if the mipmaps for textures will be generated by jme. <li>NEVER_GENERATE and ALWAYS_GENERATE are quite understandable <li>GENERATE_WHEN_NEEDED is an option that checks if the texture had 'Generate mipmaps' option set in blender, mipmaps are generated only when the option is set
* <li> NEVER_GENERATE and ALWAYS_GENERATE are quite understandable
* <li> GENERATE_WHEN_NEEDED is an option that checks if the texture had 'Generate mipmaps' option set
* in blender, mipmaps are generated only when the option is set
* @author Marcin Roguski (Kaelthas) * @author Marcin Roguski (Kaelthas)
*/ */
public static enum MipmapGenerationMethod { public static enum MipmapGenerationMethod {
NEVER_GENERATE, NEVER_GENERATE, ALWAYS_GENERATE, GENERATE_WHEN_NEEDED;
ALWAYS_GENERATE,
GENERATE_WHEN_NEEDED;
} }
/** /**
@ -714,10 +714,12 @@ public class BlenderKey extends ModelKey {
} }
@Override @Override
public void updateModelBound() {} public void updateModelBound() {
}
@Override @Override
public void setModelBound(BoundingVolume modelBound) {} public void setModelBound(BoundingVolume modelBound) {
}
@Override @Override
public int getVertexCount() { public int getVertexCount() {
@ -735,10 +737,12 @@ public class BlenderKey extends ModelKey {
} }
@Override @Override
public void depthFirstTraversal(SceneGraphVisitor visitor) {} public void depthFirstTraversal(SceneGraphVisitor visitor) {
}
@Override @Override
protected void breadthFirstTraversal(SceneGraphVisitor visitor, Queue<Spatial> queue) {} protected void breadthFirstTraversal(SceneGraphVisitor visitor, Queue<Spatial> queue) {
}
} }
/** /**

@ -45,7 +45,8 @@ public class GeneratedTextureKey extends TextureKey {
* Constructor. Stores the name. Extension and folder name are empty * Constructor. Stores the name. Extension and folder name are empty
* strings. * strings.
* *
* @param name the name of the texture * @param name
* the name of the texture
*/ */
public GeneratedTextureKey(String name) { public GeneratedTextureKey(String name) {
super(name); super(name);

@ -76,7 +76,8 @@ public abstract class AbstractBlenderHelper {
/** /**
* This method clears the state of the helper so that it can be used for different calculations of another feature. * This method clears the state of the helper so that it can be used for different calculations of another feature.
*/ */
public void clearState() {} public void clearState() {
}
/** /**
* This method should be used to check if the text is blank. Avoid using text.trim().length()==0. This causes that more strings are * This method should be used to check if the text is blank. Avoid using text.trim().length()==0. This causes that more strings are
@ -136,8 +137,7 @@ public abstract class AbstractBlenderHelper {
if (propertyNames != null && propertyNames.size() > 0) { if (propertyNames != null && propertyNames.size() > 0) {
for (String propertyName : propertyNames) { for (String propertyName : propertyNames) {
Object value = properties.findValue(propertyName); Object value = properties.findValue(propertyName);
if(value instanceof Savable || value instanceof Boolean || value instanceof String || if (value instanceof Savable || value instanceof Boolean || value instanceof String || value instanceof Float || value instanceof Integer || value instanceof Long) {
value instanceof Float || value instanceof Integer || value instanceof Long) {
spatial.setUserData(propertyName, value); spatial.setUserData(propertyName, value);
} else if (value instanceof Double) { } else if (value instanceof Double) {
spatial.setUserData(propertyName, ((Double) value).floatValue()); spatial.setUserData(propertyName, ((Double) value).floatValue());

@ -175,6 +175,7 @@ public class BlenderContext {
public DnaBlockData getDnaBlockData() { public DnaBlockData getDnaBlockData() {
return dnaBlockData; return dnaBlockData;
} }
/** /**
* This method sets the scene structure data. * This method sets the scene structure data.
* *

@ -45,8 +45,7 @@ import com.jme3.scene.plugins.ogre.AnimData;
* @throws BlenderFileException * @throws BlenderFileException
* exception thrown when problems with blender file occur * exception thrown when problems with blender file occur
*/ */
public BoneConstraint(Structure constraintStructure, Long ownerOMA, Ipo influenceIpo, BlenderContext blenderContext) public BoneConstraint(Structure constraintStructure, Long ownerOMA, Ipo influenceIpo, BlenderContext blenderContext) throws BlenderFileException {
throws BlenderFileException {
super(constraintStructure, ownerOMA, influenceIpo, blenderContext); super(constraintStructure, ownerOMA, influenceIpo, blenderContext);
} }

@ -33,5 +33,6 @@ import com.jme3.scene.plugins.blender.file.Structure;
} }
@Override @Override
protected void prepareTracksForApplyingConstraints() { } protected void prepareTracksForApplyingConstraints() {
}
} }

@ -36,8 +36,7 @@ import com.jme3.scene.plugins.ogre.AnimData;
/** The target of the constraint. */ /** The target of the constraint. */
private Object target; private Object target;
public SpatialConstraint(Structure constraintStructure, Long ownerOMA, Ipo influenceIpo, BlenderContext blenderContext) public SpatialConstraint(Structure constraintStructure, Long ownerOMA, Ipo influenceIpo, BlenderContext blenderContext) throws BlenderFileException {
throws BlenderFileException {
super(constraintStructure, ownerOMA, influenceIpo, blenderContext); super(constraintStructure, ownerOMA, influenceIpo, blenderContext);
} }
@ -115,8 +114,7 @@ import com.jme3.scene.plugins.ogre.AnimData;
} }
} }
} else { } else {
LOGGER.warning("Couldn't find target object for constraint: " + name + LOGGER.warning("Couldn't find target object for constraint: " + name + ". Make sure that the target is on layer that is defined to be loaded in blender key!");
". Make sure that the target is on layer that is defined to be loaded in blender key!");
} }
} }
} }

@ -137,9 +137,7 @@ public abstract class ConstraintDefinition {
private BoneTrack boneTrack; private BoneTrack boneTrack;
/** /**
* Constructs the object using the given track. The track must be of one of the types: * Constructs the object using the given track. The track must be of one of the types: <li>BoneTrack <li>SpatialTrack
* <li> BoneTrack
* <li> SpatialTrack
* *
* @param track * @param track
* the animation track * the animation track
@ -206,8 +204,7 @@ public abstract class ConstraintDefinition {
* @param scales * @param scales
* the scale of the bone for each frame * the scale of the bone for each frame
*/ */
public void setKeyframes(float[] times, Vector3f[] translations, public void setKeyframes(float[] times, Vector3f[] translations, Quaternion[] rotations, Vector3f[] scales) {
Quaternion[] rotations, Vector3f[] scales) {
if (boneTrack != null) { if (boneTrack != null) {
boneTrack.setKeyframes(times, translations, rotations, scales); boneTrack.setKeyframes(times, translations, rotations, scales);
} else { } else {
@ -223,8 +220,7 @@ public abstract class ConstraintDefinition {
// no need to implement this one (the TrackWrapper is used internally and never serialized) // no need to implement this one (the TrackWrapper is used internally and never serialized)
} }
public void setTime(float time, float weight, AnimControl control, public void setTime(float time, float weight, AnimControl control, AnimChannel channel, TempVars vars) {
AnimChannel channel, TempVars vars) {
if (boneTrack != null) { if (boneTrack != null) {
boneTrack.setTime(time, weight, control, channel, vars); boneTrack.setTime(time, weight, control, channel, vars);
} else { } else {
@ -233,8 +229,7 @@ public abstract class ConstraintDefinition {
} }
public float getLength() { public float getLength() {
return spatialTrack == null ? boneTrack.getLength() : spatialTrack return spatialTrack == null ? boneTrack.getLength() : spatialTrack.getLength();
.getLength();
} }
@Override @Override

@ -17,45 +17,44 @@ import com.jme3.scene.plugins.blender.file.Structure;
@Override @Override
public void bake(Transform ownerTransform, Transform targetTransform, float influence) { public void bake(Transform ownerTransform, Transform targetTransform, float influence) {
// loading mesh points (blender ensures that the target is a mesh-object) // loading mesh points (blender ensures that the target is a mesh-object)
/*List<Vector3f> pts = new ArrayList<Vector3f>(); /*
Node target = (Node) this.target.getObject(); * List<Vector3f> pts = new ArrayList<Vector3f>();
for(Spatial spatial : target.getChildren()) { * Node target = (Node) this.target.getObject();
if(spatial instanceof Geometry) { * for(Spatial spatial : target.getChildren()) {
Mesh mesh = ((Geometry) spatial).getMesh(); * if(spatial instanceof Geometry) {
FloatBuffer floatBuffer = mesh.getFloatBuffer(Type.Position); * Mesh mesh = ((Geometry) spatial).getMesh();
for(int i=0;i<floatBuffer.limit();i+=3) { * FloatBuffer floatBuffer = mesh.getFloatBuffer(Type.Position);
pts.add(new Vector3f(floatBuffer.get(i), floatBuffer.get(i + 1), floatBuffer.get(i + 2))); * for(int i=0;i<floatBuffer.limit();i+=3) {
} * pts.add(new Vector3f(floatBuffer.get(i), floatBuffer.get(i + 1), floatBuffer.get(i + 2)));
} * }
} * }
* }
AnimData animData = blenderContext.getAnimData(this.owner.getOma()); * AnimData animData = blenderContext.getAnimData(this.owner.getOma());
if(animData != null) { * if(animData != null) {
Object owner = this.owner.getObject(); * Object owner = this.owner.getObject();
for(Animation animation : animData.anims) { * for(Animation animation : animData.anims) {
BlenderTrack track = this.getTrack(owner, animData.skeleton, animation); * BlenderTrack track = this.getTrack(owner, animData.skeleton, animation);
Vector3f[] translations = track.getTranslations(); * Vector3f[] translations = track.getTranslations();
Quaternion[] rotations = track.getRotations(); * Quaternion[] rotations = track.getRotations();
int maxFrames = translations.length; * int maxFrames = translations.length;
for (int frame = 0; frame < maxFrames; ++frame) { * for (int frame = 0; frame < maxFrames; ++frame) {
Vector3f currentTranslation = translations[frame]; * Vector3f currentTranslation = translations[frame];
* //looking for minimum distanced point
//looking for minimum distanced point * Vector3f minDistancePoint = null;
Vector3f minDistancePoint = null; * float distance = Float.MAX_VALUE;
float distance = Float.MAX_VALUE; * for(Vector3f p : pts) {
for(Vector3f p : pts) { * float temp = currentTranslation.distance(p);
float temp = currentTranslation.distance(p); * if(temp < distance) {
if(temp < distance) { * distance = temp;
distance = temp; * minDistancePoint = p;
minDistancePoint = p; * }
} * }
} * translations[frame] = minDistancePoint.clone();
translations[frame] = minDistancePoint.clone(); * }
} * track.setKeyframes(track.getTimes(), translations, rotations, track.getScales());
* }
track.setKeyframes(track.getTimes(), translations, rotations, track.getScales()); * }
} */
}*/
// TODO: static constraint for spatials // TODO: static constraint for spatials
} }

@ -138,13 +138,9 @@ public class BezierCurve {
*/ */
private String toStringBezTriple(int tripleIndex) { private String toStringBezTriple(int tripleIndex) {
if (this.dimension == 2) { if (this.dimension == 2) {
return "[(" + bezierPoints[tripleIndex][0][0] + ", " + bezierPoints[tripleIndex][0][1] + ") (" return "[(" + bezierPoints[tripleIndex][0][0] + ", " + bezierPoints[tripleIndex][0][1] + ") (" + bezierPoints[tripleIndex][1][0] + ", " + bezierPoints[tripleIndex][1][1] + ") (" + bezierPoints[tripleIndex][2][0] + ", " + bezierPoints[tripleIndex][2][1] + ")]";
+ bezierPoints[tripleIndex][1][0] + ", " + bezierPoints[tripleIndex][1][1] + ") ("
+ bezierPoints[tripleIndex][2][0] + ", " + bezierPoints[tripleIndex][2][1] + ")]";
} else { } else {
return "[(" + bezierPoints[tripleIndex][0][0] + ", " + bezierPoints[tripleIndex][0][1] + ", " + bezierPoints[tripleIndex][0][2] + ") (" return "[(" + bezierPoints[tripleIndex][0][0] + ", " + bezierPoints[tripleIndex][0][1] + ", " + bezierPoints[tripleIndex][0][2] + ") (" + bezierPoints[tripleIndex][1][0] + ", " + bezierPoints[tripleIndex][1][1] + ", " + bezierPoints[tripleIndex][1][2] + ") (" + bezierPoints[tripleIndex][2][0] + ", " + bezierPoints[tripleIndex][2][1] + ", " + bezierPoints[tripleIndex][2][2] + ")]";
+ bezierPoints[tripleIndex][1][0] + ", " + bezierPoints[tripleIndex][1][1] + ", " + bezierPoints[tripleIndex][1][2] + ") ("
+ bezierPoints[tripleIndex][2][0] + ", " + bezierPoints[tripleIndex][2][1] + ", " + bezierPoints[tripleIndex][2][2] + ")]";
} }
} }
} }

@ -195,9 +195,7 @@ public class CurvesHelper extends AbstractBlenderHelper {
bevelObject = new ArrayList<Geometry>(1); bevelObject = new ArrayList<Geometry>(1);
bevelObject.add(new Geometry("", bevelCurve)); bevelObject.add(new Geometry("", bevelCurve));
} else if (extrude > 0.0f) { } else if (extrude > 0.0f) {
Spline bevelSpline = new Spline(SplineType.Linear, new Vector3f[]{ Spline bevelSpline = new Spline(SplineType.Linear, new Vector3f[] { new Vector3f(0, 0, -extrude), new Vector3f(0, 0, extrude) }, 1, false);
new Vector3f(0, 0, -extrude), new Vector3f(0, 0, extrude)
}, 1, false);
Curve bevelCurve = new Curve(bevelSpline, bevResol); Curve bevelCurve = new Curve(bevelSpline, bevResol);
bevelObject = new ArrayList<Geometry>(1); bevelObject = new ArrayList<Geometry>(1);
bevelObject.add(new Geometry("", bevelCurve)); bevelObject.add(new Geometry("", bevelCurve));
@ -267,8 +265,7 @@ public class CurvesHelper extends AbstractBlenderHelper {
* @throws BlenderFileException * @throws BlenderFileException
* an exception is thrown when there are problems with the blender file * an exception is thrown when there are problems with the blender file
*/ */
protected List<Geometry> loadBezierCurve(Vector3f loc, Structure nurb, List<Geometry> bevelObject, Spline taperObject, protected List<Geometry> loadBezierCurve(Vector3f loc, Structure nurb, List<Geometry> bevelObject, Spline taperObject, BlenderContext blenderContext) throws BlenderFileException {
BlenderContext blenderContext) throws BlenderFileException {
Pointer pBezierTriple = (Pointer) nurb.getFieldValue("bezt"); Pointer pBezierTriple = (Pointer) nurb.getFieldValue("bezt");
List<Geometry> result = new ArrayList<Geometry>(); List<Geometry> result = new ArrayList<Geometry>();
if (pBezierTriple.isNotNull()) { if (pBezierTriple.isNotNull()) {
@ -337,8 +334,7 @@ public class CurvesHelper extends AbstractBlenderHelper {
* an exception is throw when problems with blender loaded data occurs * an exception is throw when problems with blender loaded data occurs
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected List<Geometry> loadNurb(Vector3f loc, Structure nurb, List<Geometry> bevelObject, Spline taperObject, protected List<Geometry> loadNurb(Vector3f loc, Structure nurb, List<Geometry> bevelObject, Spline taperObject, BlenderContext blenderContext) throws BlenderFileException {
BlenderContext blenderContext) throws BlenderFileException {
// loading the knots // loading the knots
List<Float>[] knots = new List[2]; List<Float>[] knots = new List[2];
Pointer[] pKnots = new Pointer[] { (Pointer) nurb.getFieldValue("knotsu"), (Pointer) nurb.getFieldValue("knotsv") }; Pointer[] pKnots = new Pointer[] { (Pointer) nurb.getFieldValue("knotsu"), (Pointer) nurb.getFieldValue("knotsv") };
@ -463,8 +459,7 @@ public class CurvesHelper extends AbstractBlenderHelper {
* the blender context * the blender context
* @return a list of geometries representing the beveled and/or tapered curve * @return a list of geometries representing the beveled and/or tapered curve
*/ */
protected List<Geometry> applyBevelAndTaper(Curve curve, List<Geometry> bevelObject, Spline taperObject, protected List<Geometry> applyBevelAndTaper(Curve curve, List<Geometry> bevelObject, Spline taperObject, boolean smooth, BlenderContext blenderContext) {
boolean smooth, BlenderContext blenderContext) {
Vector3f[] curvePoints = BufferUtils.getVector3Array(curve.getFloatBuffer(Type.Position)); Vector3f[] curvePoints = BufferUtils.getVector3Array(curve.getFloatBuffer(Type.Position));
Vector3f subtractResult = new Vector3f(); Vector3f subtractResult = new Vector3f();
float curveLength = curve.getLength(); float curveLength = curve.getLength();

@ -146,8 +146,7 @@ public class BlenderInputStream extends InputStream {
gis = new GZIPInputStream(new ByteArrayInputStream(cachedBuffer)); gis = new GZIPInputStream(new ByteArrayInputStream(cachedBuffer));
this.readStreamToCache(gis); this.readStreamToCache(gis);
} catch (IOException e) { } catch (IOException e) {
throw new IllegalStateException("IO errors occured where they should NOT! " throw new IllegalStateException("IO errors occured where they should NOT! " + "The data is already buffered at this point!", e);
+ "The data is already buffered at this point!", e);
} finally { } finally {
try { try {
if (gis != null) { if (gis != null) {

@ -65,16 +65,14 @@ public class DnaBlockData {
int identifier; int identifier;
// reading 'SDNA' identifier // reading 'SDNA' identifier
identifier = inputStream.readByte() << 24 | inputStream.readByte() << 16 identifier = inputStream.readByte() << 24 | inputStream.readByte() << 16 | inputStream.readByte() << 8 | inputStream.readByte();
| inputStream.readByte() << 8 | inputStream.readByte();
if (identifier != SDNA_ID) { if (identifier != SDNA_ID) {
throw new BlenderFileException("Invalid identifier! '" + this.toString(SDNA_ID) + "' expected and found: " + this.toString(identifier)); throw new BlenderFileException("Invalid identifier! '" + this.toString(SDNA_ID) + "' expected and found: " + this.toString(identifier));
} }
// reading names // reading names
identifier = inputStream.readByte() << 24 | inputStream.readByte() << 16 identifier = inputStream.readByte() << 24 | inputStream.readByte() << 16 | inputStream.readByte() << 8 | inputStream.readByte();
| inputStream.readByte() << 8 | inputStream.readByte();
if (identifier != NAME_ID) { if (identifier != NAME_ID) {
throw new BlenderFileException("Invalid identifier! '" + this.toString(NAME_ID) + "' expected and found: " + this.toString(identifier)); throw new BlenderFileException("Invalid identifier! '" + this.toString(NAME_ID) + "' expected and found: " + this.toString(identifier));
} }
@ -89,8 +87,7 @@ public class DnaBlockData {
// reding types // reding types
inputStream.alignPosition(4); inputStream.alignPosition(4);
identifier = inputStream.readByte() << 24 | inputStream.readByte() << 16 identifier = inputStream.readByte() << 24 | inputStream.readByte() << 16 | inputStream.readByte() << 8 | inputStream.readByte();
| inputStream.readByte() << 8 | inputStream.readByte();
if (identifier != TYPE_ID) { if (identifier != TYPE_ID) {
throw new BlenderFileException("Invalid identifier! '" + this.toString(TYPE_ID) + "' expected and found: " + this.toString(identifier)); throw new BlenderFileException("Invalid identifier! '" + this.toString(TYPE_ID) + "' expected and found: " + this.toString(identifier));
} }
@ -105,8 +102,7 @@ public class DnaBlockData {
// reading lengths // reading lengths
inputStream.alignPosition(4); inputStream.alignPosition(4);
identifier = inputStream.readByte() << 24 | inputStream.readByte() << 16 identifier = inputStream.readByte() << 24 | inputStream.readByte() << 16 | inputStream.readByte() << 8 | inputStream.readByte();
| inputStream.readByte() << 8 | inputStream.readByte();
if (identifier != TLEN_ID) { if (identifier != TLEN_ID) {
throw new BlenderFileException("Invalid identifier! '" + this.toString(TLEN_ID) + "' expected and found: " + this.toString(identifier)); throw new BlenderFileException("Invalid identifier! '" + this.toString(TLEN_ID) + "' expected and found: " + this.toString(identifier));
} }
@ -117,8 +113,7 @@ public class DnaBlockData {
// reading structures // reading structures
inputStream.alignPosition(4); inputStream.alignPosition(4);
identifier = inputStream.readByte() << 24 | inputStream.readByte() << 16 identifier = inputStream.readByte() << 24 | inputStream.readByte() << 16 | inputStream.readByte() << 8 | inputStream.readByte();
| inputStream.readByte() << 8 | inputStream.readByte();
if (identifier != STRC_ID) { if (identifier != STRC_ID) {
throw new BlenderFileException("Invalid identifier! '" + this.toString(STRC_ID) + "' expected and found: " + this.toString(identifier)); throw new BlenderFileException("Invalid identifier! '" + this.toString(STRC_ID) + "' expected and found: " + this.toString(identifier));
} }

@ -85,8 +85,7 @@ public class FileBlockHeader {
*/ */
public FileBlockHeader(BlenderInputStream inputStream, BlenderContext blenderContext) throws BlenderFileException { public FileBlockHeader(BlenderInputStream inputStream, BlenderContext blenderContext) throws BlenderFileException {
inputStream.alignPosition(4); inputStream.alignPosition(4);
code = inputStream.readByte() << 24 | inputStream.readByte() << 16 code = inputStream.readByte() << 24 | inputStream.readByte() << 16 | inputStream.readByte() << 8 | inputStream.readByte();
| inputStream.readByte() << 8 | inputStream.readByte();
size = inputStream.readInt(); size = inputStream.readInt();
oldMemoryAddress = inputStream.readPointer(); oldMemoryAddress = inputStream.readPointer();
sdnaIndex = inputStream.readInt(); sdnaIndex = inputStream.readInt();

@ -91,8 +91,7 @@ public class Pointer {
List<Structure> structures = null; List<Structure> structures = null;
FileBlockHeader dataFileBlock = blenderContext.getFileBlock(oldMemoryAddress); FileBlockHeader dataFileBlock = blenderContext.getFileBlock(oldMemoryAddress);
if (dataFileBlock == null) { if (dataFileBlock == null) {
throw new BlenderFileException("No data stored for address: " +oldMemoryAddress + throw new BlenderFileException("No data stored for address: " + oldMemoryAddress + ". Rarely blender makes mistakes when storing data. Try resaving the model after making minor changes. This usually helps.");
". Rarely blender makes mistakes when storing data. Try resaving the model after making minor changes. This usually helps.");
} }
if (pointerLevel > 1) { if (pointerLevel > 1) {
int pointersAmount = dataFileBlock.getSize() / inputStream.getPointerSize() * dataFileBlock.getCount(); int pointersAmount = dataFileBlock.getSize() / inputStream.getPointerSize() * dataFileBlock.getCount();

@ -133,12 +133,9 @@ public final class MaterialContext {
Texture texture = textureHelper.getTexture(textureData.textureStructure, textureData.mtex, blenderContext); Texture texture = textureHelper.getTexture(textureData.textureStructure, textureData.mtex, blenderContext);
if (texture != null) { if (texture != null) {
int blendType = ((Number) textureData.mtex.getFieldValue("blendtype")).intValue(); int blendType = ((Number) textureData.mtex.getFieldValue("blendtype")).intValue();
float[] color = new float[] { ((Number) textureData.mtex.getFieldValue("r")).floatValue(), float[] color = new float[] { ((Number) textureData.mtex.getFieldValue("r")).floatValue(), ((Number) textureData.mtex.getFieldValue("g")).floatValue(), ((Number) textureData.mtex.getFieldValue("b")).floatValue() };
((Number) textureData.mtex.getFieldValue("g")).floatValue(),
((Number) textureData.mtex.getFieldValue("b")).floatValue() };
float colfac = ((Number) textureData.mtex.getFieldValue("colfac")).floatValue(); float colfac = ((Number) textureData.mtex.getFieldValue("colfac")).floatValue();
TextureBlender textureBlender = TextureBlenderFactory.createTextureBlender(texture.getImage().getFormat(), TextureBlender textureBlender = TextureBlenderFactory.createTextureBlender(texture.getImage().getFormat(), texflag, negateTexture, blendType, diffuseColorArray, color, colfac);
texflag, negateTexture, blendType, diffuseColorArray, color, colfac);
combinedTexture.add(texture, textureBlender, textureData.uvCoordinatesType, textureData.projectionType, textureData.textureStructure, blenderContext); combinedTexture.add(texture, textureBlender, textureData.uvCoordinatesType, textureData.projectionType, textureData.textureStructure, blenderContext);
} }
} }
@ -219,8 +216,7 @@ public final class MaterialContext {
} }
} else if (userDefinedUVCoordinates != null && userDefinedUVCoordinates.size() > 0) { } else if (userDefinedUVCoordinates != null && userDefinedUVCoordinates.size() > 0) {
VertexBuffer uvCoordsBuffer = new VertexBuffer(VertexBuffer.Type.TexCoord); VertexBuffer uvCoordsBuffer = new VertexBuffer(VertexBuffer.Type.TexCoord);
uvCoordsBuffer.setupData(Usage.Static, 2, Format.Float, uvCoordsBuffer.setupData(Usage.Static, 2, Format.Float, BufferUtils.createFloatBuffer(userDefinedUVCoordinates.toArray(new Vector2f[userDefinedUVCoordinates.size()])));
BufferUtils.createFloatBuffer(userDefinedUVCoordinates.toArray(new Vector2f[userDefinedUVCoordinates.size()])));
geometry.getMesh().setBuffer(uvCoordsBuffer); geometry.getMesh().setBuffer(uvCoordsBuffer);
} }
@ -323,7 +319,8 @@ public final class MaterialContext {
/** /**
* This method sets the face cull mode. * This method sets the face cull mode.
* @param faceCullMode the face cull mode * @param faceCullMode
* the face cull mode
*/ */
public void setFaceCullMode(FaceCullMode faceCullMode) { public void setFaceCullMode(FaceCullMode faceCullMode) {
this.faceCullMode = faceCullMode; this.faceCullMode = faceCullMode;
@ -339,8 +336,10 @@ public final class MaterialContext {
/** /**
* This method returns the diffuse color. * This method returns the diffuse color.
* *
* @param materialStructure the material structure * @param materialStructure
* @param diffuseShader the diffuse shader * the material structure
* @param diffuseShader
* the diffuse shader
* @return the diffuse color * @return the diffuse color
*/ */
private ColorRGBA readDiffuseColor(Structure materialStructure, DiffuseShader diffuseShader) { private ColorRGBA readDiffuseColor(Structure materialStructure, DiffuseShader diffuseShader) {

@ -100,7 +100,8 @@ public class MaterialHelper extends AbstractBlenderHelper {
super(blenderVersion, false); super(blenderVersion, false);
// setting alpha masks // setting alpha masks
alphaMasks.put(ALPHA_MASK_NONE, new IAlphaMask() { alphaMasks.put(ALPHA_MASK_NONE, new IAlphaMask() {
public void setImageSize(int width, int height) {} public void setImageSize(int width, int height) {
}
public byte getAlpha(float x, float y) { public byte getAlpha(float x, float y) {
return (byte) 255; return (byte) 255;

@ -22,8 +22,10 @@ import com.jme3.util.BufferUtils;
/** A variable that indicates if the model uses generated textures. */ /** A variable that indicates if the model uses generated textures. */
private boolean usesGeneratedTextures; private boolean usesGeneratedTextures;
/** This map's key is the vertex index from 'vertices 'table and the value are indices from 'vertexList' /**
positions (it simply tells which vertex is referenced where in the result list). */ * This map's key is the vertex index from 'vertices 'table and the value are indices from 'vertexList'
* positions (it simply tells which vertex is referenced where in the result list).
*/
private Map<Integer, Map<Integer, List<Integer>>> globalVertexReferenceMap; private Map<Integer, Map<Integer, List<Integer>>> globalVertexReferenceMap;
/** A map between vertex index and its UV coordinates. */ /** A map between vertex index and its UV coordinates. */
@ -43,8 +45,10 @@ import com.jme3.util.BufferUtils;
* Constructor. Stores the given array (not copying it). * Constructor. Stores the given array (not copying it).
* The second argument describes if the model uses generated textures. If yes then no vertex amount optimisation is applied. * The second argument describes if the model uses generated textures. If yes then no vertex amount optimisation is applied.
* The amount of vertices is always faceCount * 3. * The amount of vertices is always faceCount * 3.
* @param verticesAndNormals the reference vertices and normals array * @param verticesAndNormals
* @param usesGeneratedTextures a variable that indicates if the model uses generated textures or not * the reference vertices and normals array
* @param usesGeneratedTextures
* a variable that indicates if the model uses generated textures or not
*/ */
public MeshBuilder(Vector3f[][] verticesAndNormals, List<byte[]> verticesColors, boolean usesGeneratedTextures) { public MeshBuilder(Vector3f[][] verticesAndNormals, List<byte[]> verticesColors, boolean usesGeneratedTextures) {
this.verticesAndNormals = verticesAndNormals; this.verticesAndNormals = verticesAndNormals;
@ -55,9 +59,12 @@ import com.jme3.util.BufferUtils;
/** /**
* This method adds a point to the mesh. * This method adds a point to the mesh.
* @param coordinates the coordinates of the point * @param coordinates
* @param normal the point's normal vector * the coordinates of the point
* @param materialNumber the material number for this point * @param normal
* the point's normal vector
* @param materialNumber
* the material number for this point
*/ */
public void appendPoint(Vector3f coordinates, Vector3f normal, int materialNumber) { public void appendPoint(Vector3f coordinates, Vector3f normal, int materialNumber) {
LOGGER.warning("Appending single point not yet supported!");// TODO LOGGER.warning("Appending single point not yet supported!");// TODO
@ -65,9 +72,12 @@ import com.jme3.util.BufferUtils;
/** /**
* This method adds a line to the mesh. * This method adds a line to the mesh.
* @param v1 index of the 1'st vertex from the reference vertex table * @param v1
* @param v2 index of the 2'nd vertex from the reference vertex table * index of the 1'st vertex from the reference vertex table
* @param smooth indicates if this face should have smooth shading or flat shading * @param v2
* index of the 2'nd vertex from the reference vertex table
* @param smooth
* indicates if this face should have smooth shading or flat shading
*/ */
public void appendEdge(int v1, int v2, boolean smooth) { public void appendEdge(int v1, int v2, boolean smooth) {
LOGGER.warning("Appending single line not yet supported!");// TODO LOGGER.warning("Appending single line not yet supported!");// TODO
@ -75,14 +85,22 @@ import com.jme3.util.BufferUtils;
/** /**
* This method adds a face to the mesh. * This method adds a face to the mesh.
* @param v1 index of the 1'st vertex from the reference vertex table * @param v1
* @param v2 index of the 2'nd vertex from the reference vertex table * index of the 1'st vertex from the reference vertex table
* @param v3 index of the 3'rd vertex from the reference vertex table * @param v2
* @param smooth indicates if this face should have smooth shading or flat shading * index of the 2'nd vertex from the reference vertex table
* @param materialNumber the material number for this face * @param v3
* @param uvs a 3-element array of vertices UV coordinates * index of the 3'rd vertex from the reference vertex table
* @param quad indicates if the appended face is a part of a quad face (used for creating vertex colors buffer) * @param smooth
* @param faceIndex the face index (used for creating vertex colors buffer) * indicates if this face should have smooth shading or flat shading
* @param materialNumber
* the material number for this face
* @param uvs
* a 3-element array of vertices UV coordinates
* @param quad
* indicates if the appended face is a part of a quad face (used for creating vertex colors buffer)
* @param faceIndex
* the face index (used for creating vertex colors buffer)
*/ */
public void appendFace(int v1, int v2, int v3, boolean smooth, int materialNumber, Vector2f[] uvs, boolean quad, int faceIndex) { public void appendFace(int v1, int v2, int v3, boolean smooth, int materialNumber, Vector2f[] uvs, boolean quad, int faceIndex) {
if (uvs != null && uvs.length != 3) { if (uvs != null && uvs.length != 3) {

@ -27,15 +27,18 @@ public class MeshContext {
/** /**
* Adds a geometry for the specified material index. * Adds a geometry for the specified material index.
* @param materialIndex the material index * @param materialIndex
* @param geometry the geometry * the material index
* @param geometry
* the geometry
*/ */
public void putGeometry(Integer materialIndex, Geometry geometry) { public void putGeometry(Integer materialIndex, Geometry geometry) {
geometries.put(materialIndex, geometry); geometries.put(materialIndex, geometry);
} }
/** /**
* @param materialIndex the material index * @param materialIndex
* the material index
* @return vertices amount that is used by mesh with the specified material * @return vertices amount that is used by mesh with the specified material
*/ */
public int getVertexCount(int materialIndex) { public int getVertexCount(int materialIndex) {
@ -44,9 +47,11 @@ public class MeshContext {
/** /**
* Returns material index for the geometry. * Returns material index for the geometry.
* @param geometry the geometry * @param geometry
* the geometry
* @return material index * @return material index
* @throws IllegalStateException this exception is thrown when no material is found for the specified geometry * @throws IllegalStateException
* this exception is thrown when no material is found for the specified geometry
*/ */
public int getMaterialIndex(Geometry geometry) { public int getMaterialIndex(Geometry geometry) {
for (Entry<Integer, Geometry> entry : geometries.entrySet()) { for (Entry<Integer, Geometry> entry : geometries.entrySet()) {
@ -107,8 +112,7 @@ public class MeshContext {
* @param bindNormalBuffer * @param bindNormalBuffer
* the bind buffer for vertices * the bind buffer for vertices
*/ */
public void setBindNormalBuffer(int materialIndex, public void setBindNormalBuffer(int materialIndex, VertexBuffer bindNormalBuffer) {
VertexBuffer bindNormalBuffer) {
this.bindNormalBuffer.put(materialIndex, bindNormalBuffer); this.bindNormalBuffer.put(materialIndex, bindNormalBuffer);
} }

@ -218,9 +218,7 @@ public class MeshHelper extends AbstractBlenderHelper {
materialContext.applyMaterial(geometry, structure.getOldMemoryAddress(), uvCoordinates, blenderContext); materialContext.applyMaterial(geometry, structure.getOldMemoryAddress(), uvCoordinates, blenderContext);
} else { } else {
geometry.setMaterial(blenderContext.getDefaultMaterial()); geometry.setMaterial(blenderContext.getDefaultMaterial());
LOGGER.warning("The importer came accross mesh that points to a null material. Default material is used to prevent loader from crashing, " + LOGGER.warning("The importer came accross mesh that points to a null material. Default material is used to prevent loader from crashing, " + "but the model might look not the way it should. Sometimes blender does not assign materials properly. " + "Enter the edit mode and assign materials once more to your faces.");
"but the model might look not the way it should. Sometimes blender does not assign materials properly. " +
"Enter the edit mode and assign materials once more to your faces.");
} }
} }
} else { } else {

@ -251,16 +251,14 @@ import com.jme3.util.BufferUtils;
* this exception is thrown when the blend file structure is * this exception is thrown when the blend file structure is
* somehow invalid or corrupted * somehow invalid or corrupted
*/ */
private VertexBuffer[] readVerticesWeightsData(Structure objectStructure, Structure meshStructure, Skeleton skeleton, int materialIndex, private VertexBuffer[] readVerticesWeightsData(Structure objectStructure, Structure meshStructure, Skeleton skeleton, int materialIndex, int[] bonesGroups, BlenderContext blenderContext) throws BlenderFileException {
int[] bonesGroups, BlenderContext blenderContext) throws BlenderFileException {
ArmatureHelper armatureHelper = blenderContext.getHelper(ArmatureHelper.class); ArmatureHelper armatureHelper = blenderContext.getHelper(ArmatureHelper.class);
Structure defBase = (Structure) objectStructure.getFieldValue("defbase"); Structure defBase = (Structure) objectStructure.getFieldValue("defbase");
Map<Integer, Integer> groupToBoneIndexMap = armatureHelper.getGroupToBoneIndexMap(defBase, skeleton, blenderContext); Map<Integer, Integer> groupToBoneIndexMap = armatureHelper.getGroupToBoneIndexMap(defBase, skeleton, blenderContext);
MeshContext meshContext = blenderContext.getMeshContext(meshStructure.getOldMemoryAddress()); MeshContext meshContext = blenderContext.getMeshContext(meshStructure.getOldMemoryAddress());
return this.getBoneWeightAndIndexBuffer(meshStructure, meshContext.getVertexCount(materialIndex), return this.getBoneWeightAndIndexBuffer(meshStructure, meshContext.getVertexCount(materialIndex), bonesGroups, meshContext.getVertexReferenceMap(materialIndex), groupToBoneIndexMap, blenderContext);
bonesGroups, meshContext.getVertexReferenceMap(materialIndex), groupToBoneIndexMap, blenderContext);
} }
/** /**
@ -292,8 +290,7 @@ import com.jme3.util.BufferUtils;
* this exception is thrown when the blend file structure is * this exception is thrown when the blend file structure is
* somehow invalid or corrupted * somehow invalid or corrupted
*/ */
private VertexBuffer[] getBoneWeightAndIndexBuffer(Structure meshStructure, int vertexListSize, int[] bonesGroups, Map<Integer, List<Integer>> vertexReferenceMap, Map<Integer, Integer> groupToBoneIndexMap, BlenderContext blenderContext) private VertexBuffer[] getBoneWeightAndIndexBuffer(Structure meshStructure, int vertexListSize, int[] bonesGroups, Map<Integer, List<Integer>> vertexReferenceMap, Map<Integer, Integer> groupToBoneIndexMap, BlenderContext blenderContext) throws BlenderFileException {
throws BlenderFileException {
bonesGroups[0] = 0; bonesGroups[0] = 0;
Pointer pDvert = (Pointer) meshStructure.getFieldValue("dvert");// dvert = DeformVERTices Pointer pDvert = (Pointer) meshStructure.getFieldValue("dvert");// dvert = DeformVERTices
FloatBuffer weightsFloatData = BufferUtils.createFloatBuffer(vertexListSize * MAXIMUM_WEIGHTS_PER_VERTEX); FloatBuffer weightsFloatData = BufferUtils.createFloatBuffer(vertexListSize * MAXIMUM_WEIGHTS_PER_VERTEX);

@ -71,11 +71,7 @@ import com.jme3.scene.plugins.blender.objects.ObjectHelper;
} }
int flag = ((Number) modifierData.get("flag")).intValue(); int flag = ((Number) modifierData.get("flag")).intValue();
float[] mirrorFactor = new float[]{ float[] mirrorFactor = new float[] { (flag & 0x08) != 0 ? -1.0f : 1.0f, (flag & 0x10) != 0 ? -1.0f : 1.0f, (flag & 0x20) != 0 ? -1.0f : 1.0f };
(flag & 0x08) != 0 ? -1.0f : 1.0f,
(flag & 0x10) != 0 ? -1.0f : 1.0f,
(flag & 0x20) != 0 ? -1.0f : 1.0f
};
if (blenderContext.getBlenderKey().isFixUpAxis()) { if (blenderContext.getBlenderKey().isFixUpAxis()) {
float temp = mirrorFactor[1]; float temp = mirrorFactor[1];
mirrorFactor[1] = mirrorFactor[2]; mirrorFactor[1] = mirrorFactor[2];

@ -80,8 +80,7 @@ import java.util.logging.Logger;
Mesh mesh = ((Geometry) spatial).getMesh(); Mesh mesh = ((Geometry) spatial).getMesh();
if (mesh != null) { if (mesh != null) {
meshes.add(mesh); meshes.add(mesh);
Material material = materialHelper.getParticlesMaterial( Material material = materialHelper.getParticlesMaterial(((Geometry) spatial).getMaterial(), alphaFunction, blenderContext);
((Geometry) spatial).getMaterial(), alphaFunction, blenderContext);
emitter.setMaterial(material);// TODO: divide into several pieces emitter.setMaterial(material);// TODO: divide into several pieces
} }
} }

@ -378,7 +378,6 @@ public class ObjectHelper extends AbstractBlenderHelper {
@Override @Override
public boolean shouldBeLoaded(Structure structure, BlenderContext blenderContext) { public boolean shouldBeLoaded(Structure structure, BlenderContext blenderContext) {
int lay = ((Number) structure.getFieldValue("lay")).intValue(); int lay = ((Number) structure.getFieldValue("lay")).intValue();
return (lay & blenderContext.getBlenderKey().getLayersToLoad()) != 0 return (lay & blenderContext.getBlenderKey().getLayersToLoad()) != 0 && (blenderContext.getBlenderKey().getFeaturesToLoad() & FeaturesToLoad.OBJECTS) != 0;
&& (blenderContext.getBlenderKey().getFeaturesToLoad() & FeaturesToLoad.OBJECTS) != 0;
} }
} }

@ -272,8 +272,7 @@ public class CombinedTexture {
targetSize[0] = imageRectangle[2] - imageRectangle[0]; targetSize[0] = imageRectangle[2] - imageRectangle[0];
targetSize[1] = imageRectangle[3] - imageRectangle[1]; targetSize[1] = imageRectangle[3] - imageRectangle[1];
for (int j = 0; j < 3; ++j) { for (int j = 0; j < 3; ++j) {
partImageUVS.get(j).set((basicUVSOwner.resultTexture.getImage().getWidth() * destinationUVS[j].x - imageRectangle[0]) / targetSize[0], partImageUVS.get(j).set((basicUVSOwner.resultTexture.getImage().getWidth() * destinationUVS[j].x - imageRectangle[0]) / targetSize[0], (basicUVSOwner.resultTexture.getImage().getHeight() * destinationUVS[j].y - imageRectangle[1]) / targetSize[1]);
(basicUVSOwner.resultTexture.getImage().getHeight() * destinationUVS[j].y - imageRectangle[1]) / targetSize[1]);
} }
// source size and UVS (translate UVS to (0,0) and stretch it to // source size and UVS (translate UVS to (0,0) and stretch it to

@ -189,8 +189,7 @@ public class TextureHelper extends AbstractBlenderHelper {
} }
break; break;
default: default:
throw new IllegalStateException("Unknown mipmap generation method: " + throw new IllegalStateException("Unknown mipmap generation method: " + blenderContext.getBlenderKey().getMipmapGenerationMethod());
blenderContext.getBlenderKey().getMipmapGenerationMethod());
} }
if (type != TEX_IMAGE) {// only generated textures should have this key if (type != TEX_IMAGE) {// only generated textures should have this key
@ -427,8 +426,7 @@ public class TextureHelper extends AbstractBlenderHelper {
dataArray.add(BufferUtils.createByteBuffer(bytes)); dataArray.add(BufferUtils.createByteBuffer(bytes));
} }
Image result = depth > 1 ? new Image(Format.RGBA8, image.getWidth(), image.getHeight(), depth, dataArray) : Image result = depth > 1 ? new Image(Format.RGBA8, image.getWidth(), image.getHeight(), depth, dataArray) : new Image(Format.RGBA8, image.getWidth(), image.getHeight(), dataArray.get(0));
new Image(Format.RGBA8, image.getWidth(), image.getHeight(), dataArray.get(0));
if (newMipmapSizes != null) { if (newMipmapSizes != null) {
result.setMipMapSizes(newMipmapSizes); result.setMipMapSizes(newMipmapSizes);
} }
@ -696,9 +694,12 @@ public class TextureHelper extends AbstractBlenderHelper {
* failed load can be reported by the AssetManagers callback methods for * failed load can be reported by the AssetManagers callback methods for
* failed assets. * failed assets.
* *
* @param name the path to the image * @param name
* @param imaflag the image flag * the path to the image
* @param blenderContext the blender context * @param imaflag
* the image flag
* @param blenderContext
* the blender context
* @return the loaded image or null if the image cannot be found * @return the loaded image or null if the image cannot be found
*/ */
protected Texture loadImageFromFile(String name, int imaflag, BlenderContext blenderContext) { protected Texture loadImageFromFile(String name, int imaflag, BlenderContext blenderContext) {
@ -722,8 +723,7 @@ public class TextureHelper extends AbstractBlenderHelper {
generateMipmaps = (imaflag & 0x04) != 0; generateMipmaps = (imaflag & 0x04) != 0;
break; break;
default: default:
throw new IllegalStateException("Unknown mipmap generation method: " + throw new IllegalStateException("Unknown mipmap generation method: " + blenderContext.getBlenderKey().getMipmapGenerationMethod());
blenderContext.getBlenderKey().getMipmapGenerationMethod());
} }
AssetManager assetManager = blenderContext.getAssetManager(); AssetManager assetManager = blenderContext.getAssetManager();

@ -394,9 +394,7 @@ import com.jme3.util.BufferUtils;
TextureHelper textureHelper = blenderContext.getHelper(TextureHelper.class); TextureHelper textureHelper = blenderContext.getHelper(TextureHelper.class);
this.faceIndex = faceIndex; this.faceIndex = faceIndex;
uv = wholeUVList ? uv = wholeUVList ? new Vector2f[] { uvCoordinates.get(faceIndex * 3).clone(), uvCoordinates.get(faceIndex * 3 + 1).clone(), uvCoordinates.get(faceIndex * 3 + 2).clone() } : new Vector2f[] { uvCoordinates.get(0).clone(), uvCoordinates.get(1).clone(), uvCoordinates.get(2).clone() };
new Vector2f[] { uvCoordinates.get(faceIndex * 3).clone(), uvCoordinates.get(faceIndex * 3 + 1).clone(), uvCoordinates.get(faceIndex * 3 + 2).clone() } :
new Vector2f[] { uvCoordinates.get(0).clone(), uvCoordinates.get(1).clone(), uvCoordinates.get(2).clone() };
// be careful here, floating point operations might cause the // be careful here, floating point operations might cause the
// texture positions to be inapropriate // texture positions to be inapropriate

@ -55,23 +55,9 @@ public class UVCoordinatesGenerator {
private static final Logger LOGGER = Logger.getLogger(UVCoordinatesGenerator.class.getName()); private static final Logger LOGGER = Logger.getLogger(UVCoordinatesGenerator.class.getName());
public static enum UVCoordinatesType { public static enum UVCoordinatesType {
TEXCO_ORCO(1), TEXCO_ORCO(1), TEXCO_REFL(2), TEXCO_NORM(4), TEXCO_GLOB(8), TEXCO_UV(16), TEXCO_OBJECT(32), TEXCO_LAVECTOR(64), TEXCO_VIEW(128), TEXCO_STICKY(256), TEXCO_OSA(512), TEXCO_WINDOW(1024), NEED_UV(2048), TEXCO_TANGENT(4096),
TEXCO_REFL(2),
TEXCO_NORM(4),
TEXCO_GLOB(8),
TEXCO_UV(16),
TEXCO_OBJECT(32),
TEXCO_LAVECTOR(64),
TEXCO_VIEW(128),
TEXCO_STICKY(256),
TEXCO_OSA(512),
TEXCO_WINDOW(1024),
NEED_UV(2048),
TEXCO_TANGENT(4096),
// still stored in vertex->accum, 1 D // still stored in vertex->accum, 1 D
TEXCO_PARTICLE_OR_STRAND(8192), TEXCO_PARTICLE_OR_STRAND(8192), TEXCO_STRESS(16384), TEXCO_SPEED(32768);
TEXCO_STRESS(16384),
TEXCO_SPEED(32768);
public final int blenderValue; public final int blenderValue;

@ -18,10 +18,7 @@ import com.jme3.scene.plugins.blender.textures.UVCoordinatesGenerator.BoundingTu
* @author Marcin Roguski (Kaelthas) * @author Marcin Roguski (Kaelthas)
*/ */
public static enum UVProjectionType { public static enum UVProjectionType {
PROJECTION_FLAT(0), PROJECTION_FLAT(0), PROJECTION_CUBE(1), PROJECTION_TUBE(2), PROJECTION_SPHERE(3);
PROJECTION_CUBE(1),
PROJECTION_TUBE(2),
PROJECTION_SPHERE(3);
public final int blenderValue; public final int blenderValue;
@ -166,9 +163,7 @@ import com.jme3.scene.plugins.blender.textures.UVCoordinatesGenerator.BoundingTu
float sgn2 = Math.signum(triangle.get2().x - cx); float sgn2 = Math.signum(triangle.get2().x - cx);
float sgn3 = Math.signum(triangle.get3().x - cx); float sgn3 = Math.signum(triangle.get3().x - cx);
float xSideFactor = sgn1 + sgn2 + sgn3; float xSideFactor = sgn1 + sgn2 + sgn3;
float ySideFactor = Math.signum(triangle.get1().z-cz)+ float ySideFactor = Math.signum(triangle.get1().z - cz) + Math.signum(triangle.get2().z - cz) + Math.signum(triangle.get3().z - cz);
Math.signum(triangle.get2().z-cz)+
Math.signum(triangle.get3().z-cz);
if ((xSideFactor > -3 || xSideFactor < 3) && ySideFactor < 0) {// the triangle is on the splitting plane if ((xSideFactor > -3 || xSideFactor < 3) && ySideFactor < 0) {// the triangle is on the splitting plane
if (sgn1 == 1.0f) { if (sgn1 == 1.0f) {
uvCoordinates[i / 3 * 2] += 1.0f; uvCoordinates[i / 3 * 2] += 1.0f;
@ -227,9 +222,7 @@ import com.jme3.scene.plugins.blender.textures.UVCoordinatesGenerator.BoundingTu
float sgn2 = Math.signum(triangle.get2().x - cx); float sgn2 = Math.signum(triangle.get2().x - cx);
float sgn3 = Math.signum(triangle.get3().x - cx); float sgn3 = Math.signum(triangle.get3().x - cx);
float xSideFactor = sgn1 + sgn2 + sgn3; float xSideFactor = sgn1 + sgn2 + sgn3;
float ySideFactor = Math.signum(triangle.get1().y-cy)+ float ySideFactor = Math.signum(triangle.get1().y - cy) + Math.signum(triangle.get2().y - cy) + Math.signum(triangle.get3().y - cy);
Math.signum(triangle.get2().y-cy)+
Math.signum(triangle.get3().y-cy);
if ((xSideFactor > -3 || xSideFactor < 3) && ySideFactor < 0) {// the triangle is on the splitting plane if ((xSideFactor > -3 || xSideFactor < 3) && ySideFactor < 0) {// the triangle is on the splitting plane
if (sgn1 == 1.0f) { if (sgn1 == 1.0f) {
uvCoordinates[i / 3 * 2] += 1.0f; uvCoordinates[i / 3 * 2] += 1.0f;

@ -43,25 +43,7 @@ import java.nio.ByteBuffer;
import java.util.ArrayList; import java.util.ArrayList;
/** /**
* The class that is responsible for blending the following texture types: * The class that is responsible for blending the following texture types: <li>RGBA8 <li>ABGR8 <li>BGR8 <li>RGB8 Not yet supported (but will be): <li>ARGB4444: <li>RGB10: <li>RGB111110F: <li>RGB16: <li>RGB16F: <li>RGB16F_to_RGB111110F: <li>RGB16F_to_RGB9E5: <li>RGB32F: <li>RGB565: <li>RGB5A1: <li>RGB9E5: <li>RGBA16: <li>RGBA16F
* <li> RGBA8
* <li> ABGR8
* <li> BGR8
* <li> RGB8
* Not yet supported (but will be):
* <li> ARGB4444:
* <li> RGB10:
* <li> RGB111110F:
* <li> RGB16:
* <li> RGB16F:
* <li> RGB16F_to_RGB111110F:
* <li> RGB16F_to_RGB9E5:
* <li> RGB32F:
* <li> RGB565:
* <li> RGB5A1:
* <li> RGB9E5:
* <li> RGBA16:
* <li> RGBA16F
* @author Marcin Roguski (Kaelthas) * @author Marcin Roguski (Kaelthas)
*/ */
public class TextureBlenderAWT extends AbstractTextureBlender { public class TextureBlenderAWT extends AbstractTextureBlender {

@ -12,11 +12,7 @@ import java.util.ArrayList;
import jme3tools.converters.RGB565; import jme3tools.converters.RGB565;
/** /**
* The class that is responsible for blending the following texture types: * The class that is responsible for blending the following texture types: <li>DXT1 <li>DXT1A <li>DXT3 <li>DXT5
* <li> DXT1
* <li> DXT1A
* <li> DXT3
* <li> DXT5
* @author Marcin Roguski (Kaelthas) * @author Marcin Roguski (Kaelthas)
*/ */
public class TextureBlenderDDS extends TextureBlenderAWT { public class TextureBlenderDDS extends TextureBlenderAWT {

@ -14,15 +14,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
/** /**
* The class that is responsible for blending the following texture types: * The class that is responsible for blending the following texture types: <li>Luminance8 <li>Luminance8Alpha8 Not yet supported (but will be): <li>Luminance16: <li>Luminance16Alpha16: <li>Luminance16F: <li>Luminance16FAlpha16F: <li>Luminance32F:
* <li> Luminance8
* <li> Luminance8Alpha8
* Not yet supported (but will be):
* <li> Luminance16:
* <li> Luminance16Alpha16:
* <li> Luminance16F:
* <li> Luminance16FAlpha16F:
* <li> Luminance32F:
* @author Marcin Roguski (Kaelthas) * @author Marcin Roguski (Kaelthas)
*/ */
public class TextureBlenderLuminance extends AbstractTextureBlender { public class TextureBlenderLuminance extends AbstractTextureBlender {

@ -608,14 +608,8 @@ import java.util.logging.Logger;
B = hash[intX + 1] + intY; B = hash[intX + 1] + intY;
BA = hash[B] + intZ; BA = hash[B] + intZ;
BB = hash[B + 1] + intZ; BB = hash[B + 1] + intZ;
return NoiseMath.lerp(floorZ, NoiseMath.lerp(floorY, NoiseMath.lerp(floorX, NoiseMath.grad(hash[AA], x, y, z), return NoiseMath.lerp(floorZ, NoiseMath.lerp(floorY, NoiseMath.lerp(floorX, NoiseMath.grad(hash[AA], x, y, z), NoiseMath.grad(hash[BA], x - 1, y, z)), NoiseMath.lerp(floorX, NoiseMath.grad(hash[AB], x, y - 1, z), NoiseMath.grad(hash[BB], x - 1, y - 1, z))),
NoiseMath.grad(hash[BA], x - 1, y, z)), NoiseMath.lerp(floorY, NoiseMath.lerp(floorX, NoiseMath.grad(hash[AA + 1], x, y, z - 1), NoiseMath.grad(hash[BA + 1], x - 1, y, z - 1)), NoiseMath.lerp(floorX, NoiseMath.grad(hash[AB + 1], x, y - 1, z - 1), NoiseMath.grad(hash[BB + 1], x - 1, y - 1, z - 1))));
NoiseMath.lerp(floorX, NoiseMath.grad(hash[AB], x, y - 1, z),
NoiseMath.grad(hash[BB], x - 1, y - 1, z))),
NoiseMath.lerp(floorY, NoiseMath.lerp(floorX, NoiseMath.grad(hash[AA + 1], x, y, z - 1),
NoiseMath.grad(hash[BA + 1], x - 1, y, z - 1)),
NoiseMath.lerp(floorX, NoiseMath.grad(hash[AB + 1], x, y - 1, z - 1),
NoiseMath.grad(hash[BB + 1], x - 1, y - 1, z - 1))));
} }
public static float noise3Perlin(float x, float y, float z) { public static float noise3Perlin(float x, float y, float z) {
@ -707,8 +701,7 @@ import java.util.logging.Logger;
cn4 = 1.0f - 3.0f * cn4 - 2.0f * cn4 * jx; cn4 = 1.0f - 3.0f * cn4 - 2.0f * cn4 * jx;
cn5 = 1.0f - 3.0f * cn5 - 2.0f * cn5 * jy; cn5 = 1.0f - 3.0f * cn5 - 2.0f * cn5 * jy;
cn6 = 1.0f - 3.0f * cn6 - 2.0f * cn6 * jz; cn6 = 1.0f - 3.0f * cn6 - 2.0f * cn6 * jz;
float[] cn = new float[] {cn1 * cn2 * cn3, cn1 * cn2 * cn6, cn1 * cn5 * cn3, cn1 * cn5 * cn6, float[] cn = new float[] { cn1 * cn2 * cn3, cn1 * cn2 * cn6, cn1 * cn5 * cn3, cn1 * cn5 * cn6, cn4 * cn2 * cn3, cn4 * cn2 * cn6, cn4 * cn5 * cn3, cn4 * cn5 * cn6, };
cn4 * cn2 * cn3, cn4 * cn2 * cn6, cn4 * cn5 * cn3, cn4 * cn5 * cn6,};
int b00 = hash[hash[ix & 0xFF] + (iy & 0xFF)]; int b00 = hash[hash[ix & 0xFF] + (iy & 0xFF)];
int b01 = hash[hash[ix & 0xFF] + (iy + 1 & 0xFF)]; int b01 = hash[hash[ix & 0xFF] + (iy + 1 & 0xFF)];

@ -70,7 +70,8 @@ public abstract class TextureGenerator {
/** /**
* This method applies brightness and contrast for RGB textures. * This method applies brightness and contrast for RGB textures.
* @param tex texture structure * @param tex
* texture structure
* @param texres * @param texres
*/ */
protected void applyBrightnessAndContrast(BrightnessAndContrastData bacd, TexturePixel texres) { protected void applyBrightnessAndContrast(BrightnessAndContrastData bacd, TexturePixel texres) {
@ -116,7 +117,8 @@ public abstract class TextureGenerator {
/** /**
* Constructor reads the required data from the given structure. * Constructor reads the required data from the given structure.
* @param tex texture structure * @param tex
* texture structure
*/ */
public BrightnessAndContrastData(Structure tex) { public BrightnessAndContrastData(Structure tex) {
contrast = ((Number) tex.getFieldValue("contrast")).floatValue(); contrast = ((Number) tex.getFieldValue("contrast")).floatValue();

@ -60,7 +60,8 @@ public class TextureGeneratorWood extends TextureGenerator {
/** /**
* Constructor stores the given noise generator. * Constructor stores the given noise generator.
* @param noiseGenerator the noise generator * @param noiseGenerator
* the noise generator
*/ */
public TextureGeneratorWood(NoiseGenerator noiseGenerator) { public TextureGeneratorWood(NoiseGenerator noiseGenerator) {
super(noiseGenerator, Format.Luminance8); super(noiseGenerator, Format.Luminance8);
@ -119,9 +120,12 @@ public class TextureGeneratorWood extends TextureGenerator {
/** /**
* Computes basic wood intensity value at x,y,z. * Computes basic wood intensity value at x,y,z.
* @param woodIntData * @param woodIntData
* @param x X coordinate of the texture pixel * @param x
* @param y Y coordinate of the texture pixel * X coordinate of the texture pixel
* @param z Z coordinate of the texture pixel * @param y
* Y coordinate of the texture pixel
* @param z
* Z coordinate of the texture pixel
* @return wood intensity at position [x, y, z] * @return wood intensity at position [x, y, z]
*/ */
public float woodIntensity(WoodIntensityData woodIntData, float x, float y, float z) { public float woodIntensity(WoodIntensityData woodIntData, float x, float y, float z) {

@ -46,22 +46,16 @@ import jme3tools.converters.RGB565;
case RGB16F: case RGB16F:
case RGB16F_to_RGB111110F: case RGB16F_to_RGB111110F:
case RGB16F_to_RGB9E5: case RGB16F_to_RGB9E5:
pixel.fromARGB(1, FastMath.convertHalfToFloat(data.getShort(index)), pixel.fromARGB(1, FastMath.convertHalfToFloat(data.getShort(index)), FastMath.convertHalfToFloat(data.getShort(index + 2)), FastMath.convertHalfToFloat(data.getShort(index + 4)));
FastMath.convertHalfToFloat(data.getShort(index + 2)),
FastMath.convertHalfToFloat(data.getShort(index + 4)));
break; break;
case RGBA16F: case RGBA16F:
pixel.fromARGB(FastMath.convertHalfToFloat(data.getShort(index + 6)), FastMath.convertHalfToFloat(data.getShort(index)), pixel.fromARGB(FastMath.convertHalfToFloat(data.getShort(index + 6)), FastMath.convertHalfToFloat(data.getShort(index)), FastMath.convertHalfToFloat(data.getShort(index + 2)), FastMath.convertHalfToFloat(data.getShort(index + 4)));
FastMath.convertHalfToFloat(data.getShort(index + 2)), FastMath.convertHalfToFloat(data.getShort(index + 4)));
break; break;
case RGBA32F: case RGBA32F:
pixel.fromARGB(Float.intBitsToFloat(data.getInt(index + 12)), Float.intBitsToFloat(data.getInt(index)), pixel.fromARGB(Float.intBitsToFloat(data.getInt(index + 12)), Float.intBitsToFloat(data.getInt(index)), Float.intBitsToFloat(data.getInt(index + 4)), Float.intBitsToFloat(data.getInt(index + 8)));
Float.intBitsToFloat(data.getInt(index + 4)), Float.intBitsToFloat(data.getInt(index + 8)));
break; break;
case RGB111110F:// the data is stored as 32-bit unsigned int, that is why we cast the read data to long and remove MSB-bytes to get the positive value case RGB111110F:// the data is stored as 32-bit unsigned int, that is why we cast the read data to long and remove MSB-bytes to get the positive value
pixel.fromARGB(1, (float)Double.longBitsToDouble((long)data.getInt(index) & 0x00000000FFFFFFFF), pixel.fromARGB(1, (float) Double.longBitsToDouble((long) data.getInt(index) & 0x00000000FFFFFFFF), (float) Double.longBitsToDouble((long) data.getInt(index + 4) & 0x00000000FFFFFFFF), (float) Double.longBitsToDouble((long) data.getInt(index + 8) & 0x00000000FFFFFFFF));
(float)Double.longBitsToDouble((long)data.getInt(index + 4) & 0x00000000FFFFFFFF),
(float)Double.longBitsToDouble((long)data.getInt(index + 8) & 0x00000000FFFFFFFF));
break; break;
case RGB10: case RGB10:
case RGB9E5:// TODO: support these case RGB9E5:// TODO: support these

Loading…
Cancel
Save