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.
*/
public BlenderKey() {}
public BlenderKey() {
}
/**
* 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.
* 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) {
this.loadObjectProperties = loadObjectProperties;
@ -205,7 +207,8 @@ public class BlenderKey extends ModelKey {
/**
* This method sets the maximum texture size.
* @param maxTextureSize the maximum texture size
* @param maxTextureSize
* the maximum texture size
*/
public void setMaxTextureSize(int maxTextureSize) {
this.maxTextureSize = maxTextureSize;
@ -213,7 +216,8 @@ public class BlenderKey extends ModelKey {
/**
* 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) {
this.loadGeneratedTextures = loadGeneratedTextures;
@ -323,7 +327,8 @@ public class BlenderKey extends ModelKey {
/**
* This method sets the generated textures resolution.
* @param generatedTexturePPU the generated textures resolution
* @param generatedTexturePPU
* the generated textures resolution
*/
public void setGeneratedTexturePPU(int 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.
* <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
* 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
* @author Marcin Roguski (Kaelthas)
*/
public static enum MipmapGenerationMethod {
NEVER_GENERATE,
ALWAYS_GENERATE,
GENERATE_WHEN_NEEDED;
NEVER_GENERATE, ALWAYS_GENERATE, GENERATE_WHEN_NEEDED;
}
/**
@ -714,10 +714,12 @@ public class BlenderKey extends ModelKey {
}
@Override
public void updateModelBound() {}
public void updateModelBound() {
}
@Override
public void setModelBound(BoundingVolume modelBound) {}
public void setModelBound(BoundingVolume modelBound) {
}
@Override
public int getVertexCount() {
@ -735,10 +737,12 @@ public class BlenderKey extends ModelKey {
}
@Override
public void depthFirstTraversal(SceneGraphVisitor visitor) {}
public void depthFirstTraversal(SceneGraphVisitor visitor) {
}
@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
* strings.
*
* @param name the name of the texture
* @param name
* the name of the texture
*/
public GeneratedTextureKey(String 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.
*/
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
@ -136,8 +137,7 @@ public abstract class AbstractBlenderHelper {
if (propertyNames != null && propertyNames.size() > 0) {
for (String propertyName : propertyNames) {
Object value = properties.findValue(propertyName);
if(value instanceof Savable || value instanceof Boolean || value instanceof String ||
value instanceof Float || value instanceof Integer || value instanceof Long) {
if (value instanceof Savable || value instanceof Boolean || value instanceof String || value instanceof Float || value instanceof Integer || value instanceof Long) {
spatial.setUserData(propertyName, value);
} else if (value instanceof Double) {
spatial.setUserData(propertyName, ((Double) value).floatValue());

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

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

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

@ -36,8 +36,7 @@ import com.jme3.scene.plugins.ogre.AnimData;
/** The target of the constraint. */
private Object target;
public SpatialConstraint(Structure constraintStructure, Long ownerOMA, Ipo influenceIpo, BlenderContext blenderContext)
throws BlenderFileException {
public SpatialConstraint(Structure constraintStructure, Long ownerOMA, Ipo influenceIpo, BlenderContext blenderContext) throws BlenderFileException {
super(constraintStructure, ownerOMA, influenceIpo, blenderContext);
}
@ -115,8 +114,7 @@ import com.jme3.scene.plugins.ogre.AnimData;
}
}
} else {
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!");
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!");
}
}
}

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

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

@ -138,13 +138,9 @@ public class BezierCurve {
*/
private String toStringBezTriple(int tripleIndex) {
if (this.dimension == 2) {
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] + ")]";
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] + ")]";
} else {
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] + ")]";
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] + ")]";
}
}
}

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

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

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

@ -91,8 +91,7 @@ public class Pointer {
List<Structure> structures = null;
FileBlockHeader dataFileBlock = blenderContext.getFileBlock(oldMemoryAddress);
if (dataFileBlock == null) {
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.");
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.");
}
if (pointerLevel > 1) {
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);
if (texture != null) {
int blendType = ((Number) textureData.mtex.getFieldValue("blendtype")).intValue();
float[] color = new float[] { ((Number) textureData.mtex.getFieldValue("r")).floatValue(),
((Number) textureData.mtex.getFieldValue("g")).floatValue(),
((Number) textureData.mtex.getFieldValue("b")).floatValue() };
float[] color = new float[] { ((Number) textureData.mtex.getFieldValue("r")).floatValue(), ((Number) textureData.mtex.getFieldValue("g")).floatValue(), ((Number) textureData.mtex.getFieldValue("b")).floatValue() };
float colfac = ((Number) textureData.mtex.getFieldValue("colfac")).floatValue();
TextureBlender textureBlender = TextureBlenderFactory.createTextureBlender(texture.getImage().getFormat(),
texflag, negateTexture, blendType, diffuseColorArray, color, colfac);
TextureBlender textureBlender = TextureBlenderFactory.createTextureBlender(texture.getImage().getFormat(), texflag, negateTexture, blendType, diffuseColorArray, color, colfac);
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) {
VertexBuffer uvCoordsBuffer = new VertexBuffer(VertexBuffer.Type.TexCoord);
uvCoordsBuffer.setupData(Usage.Static, 2, Format.Float,
BufferUtils.createFloatBuffer(userDefinedUVCoordinates.toArray(new Vector2f[userDefinedUVCoordinates.size()])));
uvCoordsBuffer.setupData(Usage.Static, 2, Format.Float, BufferUtils.createFloatBuffer(userDefinedUVCoordinates.toArray(new Vector2f[userDefinedUVCoordinates.size()])));
geometry.getMesh().setBuffer(uvCoordsBuffer);
}
@ -323,7 +319,8 @@ public final class MaterialContext {
/**
* This method sets the face cull mode.
* @param faceCullMode the face cull mode
* @param faceCullMode
* the face cull mode
*/
public void setFaceCullMode(FaceCullMode faceCullMode) {
this.faceCullMode = faceCullMode;
@ -339,8 +336,10 @@ public final class MaterialContext {
/**
* This method returns the diffuse color.
*
* @param materialStructure the material structure
* @param diffuseShader the diffuse shader
* @param materialStructure
* the material structure
* @param diffuseShader
* the diffuse shader
* @return the diffuse color
*/
private ColorRGBA readDiffuseColor(Structure materialStructure, DiffuseShader diffuseShader) {

@ -100,7 +100,8 @@ public class MaterialHelper extends AbstractBlenderHelper {
super(blenderVersion, false);
// setting alpha masks
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) {
return (byte) 255;

@ -22,8 +22,10 @@ import com.jme3.util.BufferUtils;
/** A variable that indicates if the model uses generated textures. */
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;
/** 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).
* 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.
* @param verticesAndNormals the reference vertices and normals array
* @param usesGeneratedTextures a variable that indicates if the model uses generated textures or not
* @param verticesAndNormals
* 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) {
this.verticesAndNormals = verticesAndNormals;
@ -55,9 +59,12 @@ import com.jme3.util.BufferUtils;
/**
* This method adds a point to the mesh.
* @param coordinates the coordinates of the point
* @param normal the point's normal vector
* @param materialNumber the material number for this point
* @param coordinates
* the coordinates of the 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) {
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.
* @param v1 index of the 1'st vertex from the reference vertex table
* @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
* @param v1
* index of the 1'st vertex from the reference vertex table
* @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) {
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.
* @param v1 index of the 1'st vertex from the reference vertex table
* @param v2 index of the 2'nd vertex from the reference vertex table
* @param v3 index of the 3'rd vertex from the reference vertex table
* @param smooth 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)
* @param v1
* index of the 1'st vertex from the reference vertex table
* @param v2
* index of the 2'nd vertex from the reference vertex table
* @param v3
* index of the 3'rd vertex from the reference vertex table
* @param smooth
* 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) {
if (uvs != null && uvs.length != 3) {

@ -27,15 +27,18 @@ public class MeshContext {
/**
* Adds a geometry for the specified material index.
* @param materialIndex the material index
* @param geometry the geometry
* @param materialIndex
* the material index
* @param geometry
* the geometry
*/
public void putGeometry(Integer materialIndex, Geometry 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
*/
public int getVertexCount(int materialIndex) {
@ -44,9 +47,11 @@ public class MeshContext {
/**
* Returns material index for the geometry.
* @param geometry the geometry
* @param geometry
* the geometry
* @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) {
for (Entry<Integer, Geometry> entry : geometries.entrySet()) {
@ -107,8 +112,7 @@ public class MeshContext {
* @param bindNormalBuffer
* the bind buffer for vertices
*/
public void setBindNormalBuffer(int materialIndex,
VertexBuffer bindNormalBuffer) {
public void setBindNormalBuffer(int materialIndex, VertexBuffer bindNormalBuffer) {
this.bindNormalBuffer.put(materialIndex, bindNormalBuffer);
}

@ -218,9 +218,7 @@ public class MeshHelper extends AbstractBlenderHelper {
materialContext.applyMaterial(geometry, structure.getOldMemoryAddress(), uvCoordinates, blenderContext);
} else {
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, " +
"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.");
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.");
}
}
} else {

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

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

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

@ -272,8 +272,7 @@ public class CombinedTexture {
targetSize[0] = imageRectangle[2] - imageRectangle[0];
targetSize[1] = imageRectangle[3] - imageRectangle[1];
for (int j = 0; j < 3; ++j) {
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]);
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]);
}
// source size and UVS (translate UVS to (0,0) and stretch it to

@ -189,8 +189,7 @@ public class TextureHelper extends AbstractBlenderHelper {
}
break;
default:
throw new IllegalStateException("Unknown mipmap generation method: " +
blenderContext.getBlenderKey().getMipmapGenerationMethod());
throw new IllegalStateException("Unknown mipmap generation method: " + blenderContext.getBlenderKey().getMipmapGenerationMethod());
}
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));
}
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));
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));
if (newMipmapSizes != null) {
result.setMipMapSizes(newMipmapSizes);
}
@ -696,9 +694,12 @@ public class TextureHelper extends AbstractBlenderHelper {
* failed load can be reported by the AssetManagers callback methods for
* failed assets.
*
* @param name the path to the image
* @param imaflag the image flag
* @param blenderContext the blender context
* @param name
* the path to the image
* @param imaflag
* the image flag
* @param blenderContext
* the blender context
* @return the loaded image or null if the image cannot be found
*/
protected Texture loadImageFromFile(String name, int imaflag, BlenderContext blenderContext) {
@ -722,8 +723,7 @@ public class TextureHelper extends AbstractBlenderHelper {
generateMipmaps = (imaflag & 0x04) != 0;
break;
default:
throw new IllegalStateException("Unknown mipmap generation method: " +
blenderContext.getBlenderKey().getMipmapGenerationMethod());
throw new IllegalStateException("Unknown mipmap generation method: " + blenderContext.getBlenderKey().getMipmapGenerationMethod());
}
AssetManager assetManager = blenderContext.getAssetManager();

@ -394,9 +394,7 @@ import com.jme3.util.BufferUtils;
TextureHelper textureHelper = blenderContext.getHelper(TextureHelper.class);
this.faceIndex = faceIndex;
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() };
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() };
// be careful here, floating point operations might cause the
// texture positions to be inapropriate

@ -55,23 +55,9 @@ public class UVCoordinatesGenerator {
private static final Logger LOGGER = Logger.getLogger(UVCoordinatesGenerator.class.getName());
public static enum UVCoordinatesType {
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_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),
// still stored in vertex->accum, 1 D
TEXCO_PARTICLE_OR_STRAND(8192),
TEXCO_STRESS(16384),
TEXCO_SPEED(32768);
TEXCO_PARTICLE_OR_STRAND(8192), TEXCO_STRESS(16384), TEXCO_SPEED(32768);
public final int blenderValue;

@ -18,10 +18,7 @@ import com.jme3.scene.plugins.blender.textures.UVCoordinatesGenerator.BoundingTu
* @author Marcin Roguski (Kaelthas)
*/
public static enum UVProjectionType {
PROJECTION_FLAT(0),
PROJECTION_CUBE(1),
PROJECTION_TUBE(2),
PROJECTION_SPHERE(3);
PROJECTION_FLAT(0), PROJECTION_CUBE(1), PROJECTION_TUBE(2), PROJECTION_SPHERE(3);
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 sgn3 = Math.signum(triangle.get3().x - cx);
float xSideFactor = sgn1 + sgn2 + sgn3;
float ySideFactor = Math.signum(triangle.get1().z-cz)+
Math.signum(triangle.get2().z-cz)+
Math.signum(triangle.get3().z-cz);
float ySideFactor = Math.signum(triangle.get1().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 (sgn1 == 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 sgn3 = Math.signum(triangle.get3().x - cx);
float xSideFactor = sgn1 + sgn2 + sgn3;
float ySideFactor = Math.signum(triangle.get1().y-cy)+
Math.signum(triangle.get2().y-cy)+
Math.signum(triangle.get3().y-cy);
float ySideFactor = Math.signum(triangle.get1().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 (sgn1 == 1.0f) {
uvCoordinates[i / 3 * 2] += 1.0f;

@ -43,25 +43,7 @@ import java.nio.ByteBuffer;
import java.util.ArrayList;
/**
* 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
* 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
* @author Marcin Roguski (Kaelthas)
*/
public class TextureBlenderAWT extends AbstractTextureBlender {

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

@ -14,15 +14,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
/**
* 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:
* 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:
* @author Marcin Roguski (Kaelthas)
*/
public class TextureBlenderLuminance extends AbstractTextureBlender {

@ -608,14 +608,8 @@ import java.util.logging.Logger;
B = hash[intX + 1] + intY;
BA = hash[B] + intZ;
BB = hash[B + 1] + intZ;
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.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))));
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.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) {
@ -707,8 +701,7 @@ import java.util.logging.Logger;
cn4 = 1.0f - 3.0f * cn4 - 2.0f * cn4 * jx;
cn5 = 1.0f - 3.0f * cn5 - 2.0f * cn5 * jy;
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,
cn4 * cn2 * cn3, cn4 * cn2 * cn6, cn4 * cn5 * cn3, cn4 * 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, };
int b00 = hash[hash[ix & 0xFF] + (iy & 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.
* @param tex texture structure
* @param tex
* texture structure
* @param 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.
* @param tex texture structure
* @param tex
* texture structure
*/
public BrightnessAndContrastData(Structure tex) {
contrast = ((Number) tex.getFieldValue("contrast")).floatValue();

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

@ -46,22 +46,16 @@ import jme3tools.converters.RGB565;
case RGB16F:
case RGB16F_to_RGB111110F:
case RGB16F_to_RGB9E5:
pixel.fromARGB(1, FastMath.convertHalfToFloat(data.getShort(index)),
FastMath.convertHalfToFloat(data.getShort(index + 2)),
FastMath.convertHalfToFloat(data.getShort(index + 4)));
pixel.fromARGB(1, FastMath.convertHalfToFloat(data.getShort(index)), FastMath.convertHalfToFloat(data.getShort(index + 2)), FastMath.convertHalfToFloat(data.getShort(index + 4)));
break;
case RGBA16F:
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)));
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)));
break;
case RGBA32F:
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)));
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)));
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
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));
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));
break;
case RGB10:
case RGB9E5:// TODO: support these

Loading…
Cancel
Save