diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/AbstractBlenderHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/AbstractBlenderHelper.java index 6cab22b91..4338d08d4 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/AbstractBlenderHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/AbstractBlenderHelper.java @@ -69,7 +69,7 @@ public abstract class AbstractBlenderHelper { public AbstractBlenderHelper(String blenderVersion, BlenderContext blenderContext) { this.blenderVersion = Integer.parseInt(blenderVersion); this.blenderContext = blenderContext; - this.fixUpAxis = blenderContext.getBlenderKey().isFixUpAxis(); + fixUpAxis = blenderContext.getBlenderKey().isFixUpAxis(); if (fixUpAxis) { upAxisRotationQuaternion = new Quaternion().fromAngles(-FastMath.HALF_PI, 0, 0); } @@ -91,7 +91,7 @@ public abstract class AbstractBlenderHelper { if (id != null) { Pointer pProperties = (Pointer) id.getFieldValue("properties"); if (pProperties.isNotNull()) { - Structure propertiesStructure = pProperties.fetchData(blenderContext.getInputStream()).get(0); + Structure propertiesStructure = pProperties.fetchData().get(0); properties = new Properties(); properties.load(propertiesStructure, blenderContext); } diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/BlenderLoader.java b/engine/src/blender/com/jme3/scene/plugins/blender/BlenderLoader.java index b7219e841..4b398d166 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/BlenderLoader.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/BlenderLoader.java @@ -183,11 +183,11 @@ public class BlenderLoader implements AssetLoader { ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class); Node result = new Node(structure.getName()); try { - List base = ((Structure) structure.getFieldValue("base")).evaluateListBase(blenderContext); + List base = ((Structure) structure.getFieldValue("base")).evaluateListBase(); for (Structure b : base) { Pointer pObject = (Pointer) b.getFieldValue("object"); if (pObject.isNotNull()) { - Structure objectStructure = pObject.fetchData(blenderContext.getInputStream()).get(0); + Structure objectStructure = pObject.fetchData().get(0); Object object = objectHelper.toObject(objectStructure, blenderContext); if (object instanceof LightNode) { diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/animations/ArmatureHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/animations/ArmatureHelper.java index 6903c2165..2c87d9c0f 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/animations/ArmatureHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/animations/ArmatureHelper.java @@ -109,11 +109,11 @@ public class ArmatureHelper extends AbstractBlenderHelper { * this exception is thrown when the blender file is somehow * corrupted */ - public Map getGroupToBoneIndexMap(Structure defBaseStructure, Skeleton skeleton, BlenderContext blenderContext) throws BlenderFileException { + public Map getGroupToBoneIndexMap(Structure defBaseStructure, Skeleton skeleton) throws BlenderFileException { Map result = null; if (skeleton.getBoneCount() != 0) { result = new HashMap(); - List deformGroups = defBaseStructure.evaluateListBase(blenderContext);// bDeformGroup + List deformGroups = defBaseStructure.evaluateListBase();// bDeformGroup int groupIndex = 0; for (Structure deformGroup : deformGroups) { String deformGroupName = deformGroup.getFieldValue("name").toString(); @@ -165,19 +165,19 @@ public class ArmatureHelper extends AbstractBlenderHelper { IpoHelper ipoHelper = blenderContext.getHelper(IpoHelper.class); int fps = blenderContext.getBlenderKey().getFps(); Structure groups = (Structure) actionStructure.getFieldValue("groups"); - List actionGroups = groups.evaluateListBase(blenderContext);// bActionGroup + List actionGroups = groups.evaluateListBase();// bActionGroup List tracks = new ArrayList(); for (Structure actionGroup : actionGroups) { String name = actionGroup.getFieldValue("name").toString(); int boneIndex = skeleton.getBoneIndex(name); if (boneIndex >= 0) { - List channels = ((Structure) actionGroup.getFieldValue("channels")).evaluateListBase(blenderContext); + List channels = ((Structure) actionGroup.getFieldValue("channels")).evaluateListBase(); BezierCurve[] bezierCurves = new BezierCurve[channels.size()]; int channelCounter = 0; for (Structure c : channels) { int type = ipoHelper.getCurveType(c, blenderContext); Pointer pBezTriple = (Pointer) c.getFieldValue("bezt"); - List bezTriples = pBezTriple.fetchData(blenderContext.getInputStream()); + List bezTriples = pBezTriple.fetchData(); bezierCurves[channelCounter++] = new BezierCurve(type, bezTriples, 2); } @@ -208,7 +208,7 @@ public class ArmatureHelper extends AbstractBlenderHelper { IpoHelper ipoHelper = blenderContext.getHelper(IpoHelper.class); int fps = blenderContext.getBlenderKey().getFps(); Structure chanbase = (Structure) actionStructure.getFieldValue("chanbase"); - List actionChannels = chanbase.evaluateListBase(blenderContext);// bActionChannel + List actionChannels = chanbase.evaluateListBase();// bActionChannel List tracks = new ArrayList(); for (Structure bActionChannel : actionChannels) { String name = bActionChannel.getFieldValue("name").toString(); @@ -216,7 +216,7 @@ public class ArmatureHelper extends AbstractBlenderHelper { if (boneIndex >= 0) { Pointer p = (Pointer) bActionChannel.getFieldValue("ipo"); if (!p.isNull()) { - Structure ipoStructure = p.fetchData(blenderContext.getInputStream()).get(0); + Structure ipoStructure = p.fetchData().get(0); Bone bone = skeleton.getBone(boneIndex); Ipo ipo = ipoHelper.fromIpoStructure(ipoStructure, blenderContext); diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/animations/BoneContext.java b/engine/src/blender/com/jme3/scene/plugins/blender/animations/BoneContext.java index 92705620f..6b14d8097 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/animations/BoneContext.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/animations/BoneContext.java @@ -110,7 +110,7 @@ public class BoneContext { globalBoneMatrix = armatureWorldMatrix.mult(globalBoneMatrix); // create the children - List childbase = ((Structure) boneStructure.getFieldValue("childbase")).evaluateListBase(blenderContext); + List childbase = ((Structure) boneStructure.getFieldValue("childbase")).evaluateListBase(); for (Structure child : childbase) { children.add(new BoneContext(child, armatureObjectOMA, this, blenderContext)); } diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/animations/IpoHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/animations/IpoHelper.java index 7ad363989..260a59575 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/animations/IpoHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/animations/IpoHelper.java @@ -55,13 +55,13 @@ public class IpoHelper extends AbstractBlenderHelper { // preparing bezier curves Ipo result = null; - List curves = curvebase.evaluateListBase(blenderContext);// IpoCurve + List curves = curvebase.evaluateListBase();// IpoCurve if (curves.size() > 0) { BezierCurve[] bezierCurves = new BezierCurve[curves.size()]; int frame = 0; for (Structure curve : curves) { Pointer pBezTriple = (Pointer) curve.getFieldValue("bezt"); - List bezTriples = pBezTriple.fetchData(blenderContext.getInputStream()); + List bezTriples = pBezTriple.fetchData(); int type = ((Number) curve.getFieldValue("adrcode")).intValue(); bezierCurves[frame++] = new BezierCurve(type, bezTriples, 2); } @@ -87,13 +87,13 @@ public class IpoHelper extends AbstractBlenderHelper { */ public Ipo fromAction(Structure actionStructure, BlenderContext blenderContext) throws BlenderFileException { Ipo result = null; - List curves = ((Structure) actionStructure.getFieldValue("curves")).evaluateListBase(blenderContext);// FCurve + List curves = ((Structure) actionStructure.getFieldValue("curves")).evaluateListBase();// FCurve if (curves.size() > 0) { BezierCurve[] bezierCurves = new BezierCurve[curves.size()]; int frame = 0; for (Structure curve : curves) { Pointer pBezTriple = (Pointer) curve.getFieldValue("bezt"); - List bezTriples = pBezTriple.fetchData(blenderContext.getInputStream()); + List bezTriples = pBezTriple.fetchData(); int type = this.getCurveType(curve, blenderContext); bezierCurves[frame++] = new BezierCurve(type, bezTriples, 2); } diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/Constraint.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/Constraint.java index f4fe3452e..99f5ac4b1 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/Constraint.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/Constraint.java @@ -63,7 +63,7 @@ public abstract class Constraint { name = constraintStructure.getFieldValue("name").toString(); Pointer pData = (Pointer) constraintStructure.getFieldValue("data"); if (pData.isNotNull()) { - Structure data = pData.fetchData(blenderContext.getInputStream()).get(0); + Structure data = pData.fetchData().get(0); constraintDefinition = ConstraintDefinitionFactory.createConstraintDefinition(data, ownerOMA, blenderContext); Pointer pTar = (Pointer) data.getFieldValue("tar"); if (pTar != null && pTar.isNotNull()) { diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintHelper.java index a2a100ae0..97b6889ff 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintHelper.java @@ -67,19 +67,19 @@ public class ConstraintHelper extends AbstractBlenderHelper { Map> constraintsIpos = new HashMap>(); Pointer pActions = (Pointer) objectStructure.getFieldValue("action"); if (pActions.isNotNull()) { - List actions = pActions.fetchData(blenderContext.getInputStream()); + List actions = pActions.fetchData(); for (Structure action : actions) { Structure chanbase = (Structure) action.getFieldValue("chanbase"); - List actionChannels = chanbase.evaluateListBase(blenderContext); + List actionChannels = chanbase.evaluateListBase(); for (Structure actionChannel : actionChannels) { Map ipos = new HashMap(); Structure constChannels = (Structure) actionChannel.getFieldValue("constraintChannels"); - List constraintChannels = constChannels.evaluateListBase(blenderContext); + List constraintChannels = constChannels.evaluateListBase(); for (Structure constraintChannel : constraintChannels) { Pointer pIpo = (Pointer) constraintChannel.getFieldValue("ipo"); if (pIpo.isNotNull()) { String constraintName = constraintChannel.getFieldValue("name").toString(); - Ipo ipo = ipoHelper.fromIpoStructure(pIpo.fetchData(blenderContext.getInputStream()).get(0), blenderContext); + Ipo ipo = ipoHelper.fromIpoStructure(pIpo.fetchData().get(0), blenderContext); ipos.put(constraintName, ipo); } } @@ -92,7 +92,7 @@ public class ConstraintHelper extends AbstractBlenderHelper { // loading constraints connected with the object's bones Pointer pPose = (Pointer) objectStructure.getFieldValue("pose"); if (pPose.isNotNull()) { - List poseChannels = ((Structure) pPose.fetchData(blenderContext.getInputStream()).get(0).getFieldValue("chanbase")).evaluateListBase(blenderContext); + List poseChannels = ((Structure) pPose.fetchData().get(0).getFieldValue("chanbase")).evaluateListBase(); for (Structure poseChannel : poseChannels) { List constraintsList = new ArrayList(); Long boneOMA = Long.valueOf(((Pointer) poseChannel.getFieldValue("bone")).getOldMemoryAddress()); @@ -100,7 +100,7 @@ public class ConstraintHelper extends AbstractBlenderHelper { // the name is read directly from structure because bone might // not yet be loaded String name = blenderContext.getFileBlock(boneOMA).getStructure(blenderContext).getFieldValue("name").toString(); - List constraints = ((Structure) poseChannel.getFieldValue("constraints")).evaluateListBase(blenderContext); + List constraints = ((Structure) poseChannel.getFieldValue("constraints")).evaluateListBase(); for (Structure constraint : constraints) { String constraintName = constraint.getFieldValue("name").toString(); Map ipoMap = constraintsIpos.get(name); @@ -116,10 +116,10 @@ public class ConstraintHelper extends AbstractBlenderHelper { } // loading constraints connected with the object itself - List constraints = ((Structure) objectStructure.getFieldValue("constraints")).evaluateListBase(blenderContext); + List constraints = ((Structure) objectStructure.getFieldValue("constraints")).evaluateListBase(); if (constraints != null && constraints.size() > 0) { Pointer pData = (Pointer) objectStructure.getFieldValue("data"); - String dataType = pData.isNotNull() ? pData.fetchData(blenderContext.getInputStream()).get(0).getType() : null; + String dataType = pData.isNotNull() ? pData.fetchData().get(0).getType() : null; List constraintsList = new ArrayList(constraints.size()); for (Structure constraint : constraints) { diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/curves/CurvesHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/curves/CurvesHelper.java index 5c36fcbdb..3e889368f 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/curves/CurvesHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/curves/CurvesHelper.java @@ -119,7 +119,7 @@ public class CurvesHelper extends AbstractBlenderHelper { } // reading nurbs (and sorting them by material) - List nurbStructures = ((Structure) curveStructure.getFieldValue("nurb")).evaluateListBase(blenderContext); + List nurbStructures = ((Structure) curveStructure.getFieldValue("nurb")).evaluateListBase(); Map> nurbs = new HashMap>(); for (Structure nurb : nurbStructures) { Number matNumber = (Number) nurb.getFieldValue("mat_nr"); @@ -148,8 +148,8 @@ public class CurvesHelper extends AbstractBlenderHelper { List bevelObject = null; Pointer pBevelObject = (Pointer) curveStructure.getFieldValue("bevobj"); if (pBevelObject.isNotNull()) { - Pointer pBevelStructure = (Pointer) pBevelObject.fetchData(blenderContext.getInputStream()).get(0).getFieldValue("data"); - Structure bevelStructure = pBevelStructure.fetchData(blenderContext.getInputStream()).get(0); + Pointer pBevelStructure = (Pointer) pBevelObject.fetchData().get(0).getFieldValue("data"); + Structure bevelStructure = pBevelStructure.fetchData().get(0); bevelObject = this.toCurve(bevelStructure, blenderContext); } else { int bevResol = ((Number) curveStructure.getFieldValue("bevresol")).intValue(); @@ -205,9 +205,9 @@ public class CurvesHelper extends AbstractBlenderHelper { Spline taperObject = null; Pointer pTaperObject = (Pointer) curveStructure.getFieldValue("taperobj"); if (bevelObject != null && pTaperObject.isNotNull()) { - Pointer pTaperStructure = (Pointer) pTaperObject.fetchData(blenderContext.getInputStream()).get(0).getFieldValue("data"); - Structure taperStructure = pTaperStructure.fetchData(blenderContext.getInputStream()).get(0); - taperObject = this.loadTaperObject(taperStructure, blenderContext); + Pointer pTaperStructure = (Pointer) pTaperObject.fetchData().get(0).getFieldValue("data"); + Structure taperStructure = pTaperStructure.fetchData().get(0); + taperObject = this.loadTaperObject(taperStructure); } Vector3f loc = this.getLoc(curveStructure); @@ -275,7 +275,7 @@ public class CurvesHelper extends AbstractBlenderHelper { boolean cyclic = (((Number) nurb.getFieldValue("flagu")).intValue() & 0x01) != 0; // creating the curve object - BezierCurve bezierCurve = new BezierCurve(0, pBezierTriple.fetchData(blenderContext.getInputStream()), 3); + BezierCurve bezierCurve = new BezierCurve(0, pBezierTriple.fetchData(), 3); List controlPoints = bezierCurve.getControlPoints(); if (fixUpAxis) { for (Vector3f v : controlPoints) { @@ -361,7 +361,7 @@ public class CurvesHelper extends AbstractBlenderHelper { // loading control points and their weights int pntsU = ((Number) nurb.getFieldValue("pntsu")).intValue(); int pntsV = ((Number) nurb.getFieldValue("pntsv")).intValue(); - List bPoints = ((Pointer) nurb.getFieldValue("bp")).fetchData(blenderContext.getInputStream()); + List bPoints = ((Pointer) nurb.getFieldValue("bp")).fetchData(); List> controlPoints = new ArrayList>(pntsV); for (int i = 0; i < pntsV; ++i) { List uControlPoints = new ArrayList(pntsU); @@ -793,19 +793,17 @@ public class CurvesHelper extends AbstractBlenderHelper { * * @param taperStructure * the taper structure - * @param blenderContext - * the blender context * @return the taper object * @throws BlenderFileException */ - protected Spline loadTaperObject(Structure taperStructure, BlenderContext blenderContext) throws BlenderFileException { + protected Spline loadTaperObject(Structure taperStructure) throws BlenderFileException { // reading nurbs - List nurbStructures = ((Structure) taperStructure.getFieldValue("nurb")).evaluateListBase(blenderContext); + List nurbStructures = ((Structure) taperStructure.getFieldValue("nurb")).evaluateListBase(); for (Structure nurb : nurbStructures) { Pointer pBezierTriple = (Pointer) nurb.getFieldValue("bezt"); if (pBezierTriple.isNotNull()) { // creating the curve object - BezierCurve bezierCurve = new BezierCurve(0, pBezierTriple.fetchData(blenderContext.getInputStream()), 3); + BezierCurve bezierCurve = new BezierCurve(0, pBezierTriple.fetchData(), 3); List controlPoints = bezierCurve.getControlPoints(); // removing the first and last handles controlPoints.remove(0); diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/file/Field.java b/engine/src/blender/com/jme3/scene/plugins/blender/file/Field.java index 322eadac1..81cfdcde8 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/file/Field.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/file/Field.java @@ -180,13 +180,13 @@ class Field implements Cloneable { case STRUCTURE: if (dataToRead == 1) { Structure structure = blenderContext.getDnaBlockData().getStructure(type); - structure.fill(blenderInputStream); + structure.fill(blenderContext.getInputStream()); value = structure; } else { Structure[] data = new Structure[dataToRead]; for (int i = 0; i < dataToRead; ++i) { Structure structure = blenderContext.getDnaBlockData().getStructure(type); - structure.fill(blenderInputStream); + structure.fill(blenderContext.getInputStream()); data[i] = structure; } value = new DynamicArray(tableSizes, data); diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/file/Pointer.java b/engine/src/blender/com/jme3/scene/plugins/blender/file/Pointer.java index 7c72d59ec..c5a662325 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/file/Pointer.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/file/Pointer.java @@ -31,11 +31,11 @@ */ package com.jme3.scene.plugins.blender.file; -import com.jme3.scene.plugins.blender.BlenderContext; - import java.util.ArrayList; import java.util.List; +import com.jme3.scene.plugins.blender.BlenderContext; + /** * A class that represents a pointer of any level that can be stored in the file. * @author Marcin Roguski @@ -78,13 +78,11 @@ public class Pointer { /** * This method fetches the data stored under the given address. - * @param inputStream - * the stream we read data from * @return the data read from the file * @throws BlenderFileException * this exception is thrown when the blend file structure is somehow invalid or corrupted */ - public List fetchData(BlenderInputStream inputStream) throws BlenderFileException { + public List fetchData() throws BlenderFileException { if (oldMemoryAddress == 0) { throw new NullPointerException("The pointer points to nothing!"); } @@ -93,18 +91,19 @@ public class Pointer { if (dataFileBlock == null) { throw new BlenderFileException("No data stored for address: " + oldMemoryAddress + ". Make sure you did not open the newer blender file with older blender version."); } + BlenderInputStream inputStream = blenderContext.getInputStream(); if (pointerLevel > 1) { int pointersAmount = dataFileBlock.getSize() / inputStream.getPointerSize() * dataFileBlock.getCount(); for (int i = 0; i < pointersAmount; ++i) { inputStream.setPosition(dataFileBlock.getBlockPosition() + inputStream.getPointerSize() * i); long oldMemoryAddress = inputStream.readPointer(); if (oldMemoryAddress != 0L) { - Pointer p = new Pointer(pointerLevel - 1, this.function, blenderContext); + Pointer p = new Pointer(pointerLevel - 1, function, blenderContext); p.oldMemoryAddress = oldMemoryAddress; if (structures == null) { - structures = p.fetchData(inputStream); + structures = p.fetchData(); } else { - structures.addAll(p.fetchData(inputStream)); + structures.addAll(p.fetchData()); } } else { // it is necessary to put null's if the pointer is null, ie. in materials array that is attached to the mesh, the index @@ -120,7 +119,7 @@ public class Pointer { structures = new ArrayList(dataFileBlock.getCount()); for (int i = 0; i < dataFileBlock.getCount(); ++i) { Structure structure = blenderContext.getDnaBlockData().getStructure(dataFileBlock.getSdnaIndex()); - structure.fill(inputStream); + structure.fill(blenderContext.getInputStream()); structures.add(structure); } return structures; diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/file/Structure.java b/engine/src/blender/com/jme3/scene/plugins/blender/file/Structure.java index 9e70efc9f..af8c17f5b 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/file/Structure.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/file/Structure.java @@ -45,8 +45,6 @@ import com.jme3.scene.plugins.blender.BlenderContext; */ public class Structure implements Cloneable { - /** The blender context. */ - private BlenderContext blenderContext; /** The address of the block that fills the structure. */ private transient Long oldMemoryAddress; /** The type of the structure. */ @@ -60,18 +58,15 @@ public class Structure implements Cloneable { * Constructor that copies the data of the structure. * @param structure * the structure to copy. - * @param blenderContext - * the blender context of the structure * @throws CloneNotSupportedException * this exception should never be thrown */ - private Structure(Structure structure, BlenderContext blenderContext) throws CloneNotSupportedException { + private Structure(Structure structure) throws CloneNotSupportedException { type = structure.type; fields = new Field[structure.fields.length]; for (int i = 0; i < fields.length; ++i) { fields[i] = (Field) structure.fields[i].clone(); } - this.blenderContext = blenderContext; oldMemoryAddress = structure.oldMemoryAddress; } @@ -91,7 +86,6 @@ public class Structure implements Cloneable { public Structure(BlenderInputStream inputStream, String[] names, String[] types, BlenderContext blenderContext) throws BlenderFileException { int nameIndex = inputStream.readShort(); type = types[nameIndex]; - this.blenderContext = blenderContext; int fieldsAmount = inputStream.readShort(); if (fieldsAmount < 0) { throw new BlenderFileException("The amount of fields of " + type + " structure cannot be negative!"); @@ -165,15 +159,13 @@ public class Structure implements Cloneable { /** * This methos should be used on structures that are of a 'ListBase' type. It creates a List of structures that are * held by this structure within the blend file. - * @param blenderContext - * the blender context * @return a list of filled structures * @throws BlenderFileException * this exception is thrown when the blend file structure is somehow invalid or corrupted * @throws IllegalArgumentException * this exception is thrown if the type of the structure is not 'ListBase' */ - public List evaluateListBase(BlenderContext blenderContext) throws BlenderFileException { + public List evaluateListBase() throws BlenderFileException { if (!"ListBase".equals(type)) { throw new IllegalStateException("This structure is not of type: 'ListBase'"); } @@ -184,7 +176,7 @@ public class Structure implements Cloneable { List result = new LinkedList(); while (currentAddress != lastAddress) { currentAddress = first.getOldMemoryAddress(); - Structure structure = first.fetchData(blenderContext.getInputStream()).get(0); + Structure structure = first.fetchData().get(0); result.add(structure); first = (Pointer) structure.getFlatFieldValue("next"); } @@ -264,7 +256,7 @@ public class Structure implements Cloneable { @Override public Object clone() throws CloneNotSupportedException { - return new Structure(this, blenderContext); + return new Structure(this); } /** diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/materials/MaterialHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/materials/MaterialHelper.java index a26ca5f4a..f4fff839c 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/materials/MaterialHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/materials/MaterialHelper.java @@ -241,7 +241,7 @@ public class MaterialHelper extends AbstractBlenderHelper { Pointer ppMaterials = (Pointer) structureWithMaterials.getFieldValue("mat"); MaterialContext[] materials = null; if (ppMaterials.isNotNull()) { - List materialStructures = ppMaterials.fetchData(blenderContext.getInputStream()); + List materialStructures = ppMaterials.fetchData(); if (materialStructures != null && materialStructures.size() > 0) { MaterialHelper materialHelper = blenderContext.getHelper(MaterialHelper.class); materials = new MaterialContext[materialStructures.size()]; diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/meshes/MeshHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/meshes/MeshHelper.java index 8b96df307..3d10c1ecc 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/meshes/MeshHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/meshes/MeshHelper.java @@ -136,7 +136,7 @@ public class MeshHelper extends AbstractBlenderHelper { LOGGER.fine("Reading vertices groups (from the Object structure)."); Structure parent = blenderContext.peekParent(); Structure defbase = (Structure) parent.getFieldValue("defbase"); - List defs = defbase.evaluateListBase(blenderContext); + List defs = defbase.evaluateListBase(); String[] verticesGroups = new String[defs.size()]; int defIndex = 0; for (Structure def : defs) { diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/meshes/builders/FaceMeshBuilder.java b/engine/src/blender/com/jme3/scene/plugins/blender/meshes/builders/FaceMeshBuilder.java index f3c4916b2..0d694ed80 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/meshes/builders/FaceMeshBuilder.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/meshes/builders/FaceMeshBuilder.java @@ -76,9 +76,9 @@ import com.jme3.util.BufferUtils; MeshHelper meshHelper = blenderContext.getHelper(MeshHelper.class); if (meshHelper.isBMeshCompatible(structure)) { - this.readBMesh(structure, blenderContext); + this.readBMesh(structure); } else { - this.readTraditionalFaces(structure, blenderContext); + this.readTraditionalFaces(structure); } } @@ -138,22 +138,20 @@ import com.jme3.util.BufferUtils; * * @param meshStructure * the mesh structure - * @param blenderContext - * the blender context * @throws BlenderFileException * an exception is thrown when there are problems with the * blender file */ - private void readBMesh(Structure meshStructure, BlenderContext blenderContext) throws BlenderFileException { + private void readBMesh(Structure meshStructure) throws BlenderFileException { LOGGER.fine("Reading BMesh."); Pointer pMLoop = (Pointer) meshStructure.getFieldValue("mloop"); Pointer pMPoly = (Pointer) meshStructure.getFieldValue("mpoly"); Map uvCoordinatesForFace = new HashMap(); if (pMPoly.isNotNull() && pMLoop.isNotNull()) { - Map> uvs = this.loadUVCoordinates(meshStructure, true, blenderContext); - List polys = pMPoly.fetchData(blenderContext.getInputStream()); - List loops = pMLoop.fetchData(blenderContext.getInputStream()); + Map> uvs = this.loadUVCoordinates(meshStructure, true); + List polys = pMPoly.fetchData(); + List loops = pMLoop.fetchData(); int[] vertexColorIndex = verticesColors == null ? null : new int[3]; for (Structure poly : polys) { int materialNumber = ((Number) poly.getFieldValue("mat_nr")).intValue(); @@ -202,19 +200,17 @@ import com.jme3.util.BufferUtils; * * @param meshStructure * the mesh structure - * @param blenderContext - * the blender context * @throws BlenderFileException * an exception is thrown when there are problems with the * blender file */ - private void readTraditionalFaces(Structure meshStructure, BlenderContext blenderContext) throws BlenderFileException { + private void readTraditionalFaces(Structure meshStructure) throws BlenderFileException { LOGGER.fine("Reading traditional faces."); Pointer pMFace = (Pointer) meshStructure.getFieldValue("mface"); - List mFaces = pMFace.isNotNull() ? pMFace.fetchData(blenderContext.getInputStream()) : null; + List mFaces = pMFace.isNotNull() ? pMFace.fetchData() : null; if (mFaces != null && mFaces.size() > 0) { // indicates if the material with the specified number should have a texture attached - Map> uvs = this.loadUVCoordinates(meshStructure, false, blenderContext); + Map> uvs = this.loadUVCoordinates(meshStructure, false); Map uvCoordinatesForFace = new HashMap(); int[] vertexColorIndex = verticesColors == null ? null : new int[3]; for (int i = 0; i < mFaces.size(); ++i) { @@ -406,25 +402,23 @@ import com.jme3.util.BufferUtils; * the mesh structure * @param useBMesh * tells if we should load the coordinates from loops of from faces - * @param blenderContext - * the blender context * @return a map that sorts UV coordinates between different UV sets * @throws BlenderFileException * an exception is thrown when problems with blend file occur */ @SuppressWarnings("unchecked") - private Map> loadUVCoordinates(Structure meshStructure, boolean useBMesh, BlenderContext blenderContext) throws BlenderFileException { + private Map> loadUVCoordinates(Structure meshStructure, boolean useBMesh) throws BlenderFileException { Map> result = new HashMap>(); if (useBMesh) { // in this case the UV's are assigned to vertices (an array is the same length as the vertex array) Structure loopData = (Structure) meshStructure.getFieldValue("ldata"); Pointer pLoopDataLayers = (Pointer) loopData.getFieldValue("layers"); - List loopDataLayers = pLoopDataLayers.fetchData(blenderContext.getInputStream()); + List loopDataLayers = pLoopDataLayers.fetchData(); for (Structure structure : loopDataLayers) { Pointer p = (Pointer) structure.getFieldValue("data"); if (p.isNotNull() && ((Number) structure.getFieldValue("type")).intValue() == MeshHelper.UV_DATA_LAYER_TYPE_BMESH) { String uvSetName = structure.getFieldValue("name").toString(); - List uvsStructures = p.fetchData(blenderContext.getInputStream()); + List uvsStructures = p.fetchData(); List uvs = new ArrayList(uvsStructures.size()); for (Structure uvStructure : uvsStructures) { DynamicArray loopUVS = (DynamicArray) uvStructure.getFieldValue("uv"); @@ -437,12 +431,12 @@ import com.jme3.util.BufferUtils; // in this case UV's are assigned to faces (the array has the same legnth as the faces count) Structure facesData = (Structure) meshStructure.getFieldValue("fdata"); Pointer pFacesDataLayers = (Pointer) facesData.getFieldValue("layers"); - List facesDataLayers = pFacesDataLayers.fetchData(blenderContext.getInputStream()); + List facesDataLayers = pFacesDataLayers.fetchData(); for (Structure structure : facesDataLayers) { Pointer p = (Pointer) structure.getFieldValue("data"); if (p.isNotNull() && ((Number) structure.getFieldValue("type")).intValue() == MeshHelper.UV_DATA_LAYER_TYPE_FMESH) { String uvSetName = structure.getFieldValue("name").toString(); - List uvsStructures = p.fetchData(blenderContext.getInputStream()); + List uvsStructures = p.fetchData(); List uvs = new ArrayList(uvsStructures.size()); for (Structure uvStructure : uvsStructures) { DynamicArray mFaceUVs = (DynamicArray) uvStructure.getFieldValue("uv"); @@ -477,7 +471,7 @@ import com.jme3.util.BufferUtils; // so we need to put them right boolean useBGRA = blenderContext.getBlenderVersion() < 263; if (pMCol.isNotNull()) { - List mCol = pMCol.fetchData(blenderContext.getInputStream()); + List mCol = pMCol.fetchData(); verticesColors = new ArrayList(mCol.size()); for (Structure color : mCol) { byte r = ((Number) color.getFieldValue("r")).byteValue(); diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/meshes/builders/LineMeshBuilder.java b/engine/src/blender/com/jme3/scene/plugins/blender/meshes/builders/LineMeshBuilder.java index ee3dff683..4191484d4 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/meshes/builders/LineMeshBuilder.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/meshes/builders/LineMeshBuilder.java @@ -13,7 +13,6 @@ import com.jme3.scene.VertexBuffer; import com.jme3.scene.VertexBuffer.Format; import com.jme3.scene.VertexBuffer.Type; import com.jme3.scene.VertexBuffer.Usage; -import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.file.BlenderFileException; import com.jme3.scene.plugins.blender.file.Pointer; import com.jme3.scene.plugins.blender.file.Structure; @@ -58,17 +57,15 @@ import com.jme3.util.BufferUtils; * The method reads the mesh. It loads only edges that are marked as not belonging to any face in their flag field. * @param meshStructure * the mesh structure - * @param blenderContext - * the blender context * @throws BlenderFileException * an exception thrown when reading from the blend file fails */ - public void readMesh(Structure meshStructure, BlenderContext blenderContext) throws BlenderFileException { + public void readMesh(Structure meshStructure) throws BlenderFileException { LOGGER.fine("Reading line mesh."); Pointer pMEdge = (Pointer) meshStructure.getFieldValue("medge"); if (pMEdge.isNotNull()) { - List edges = pMEdge.fetchData(blenderContext.getInputStream()); + List edges = pMEdge.fetchData(); int vertexIndex = 0;//vertex index in the result mesh for (Structure edge : edges) { int flag = ((Number) edge.getFieldValue("flag")).intValue(); diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/meshes/builders/MeshBuilder.java b/engine/src/blender/com/jme3/scene/plugins/blender/meshes/builders/MeshBuilder.java index 9aca51f53..12cfe4920 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/meshes/builders/MeshBuilder.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/meshes/builders/MeshBuilder.java @@ -30,14 +30,14 @@ public class MeshBuilder { public MeshBuilder(Structure meshStructure, MaterialContext[] materials, BlenderContext blenderContext) throws BlenderFileException { fixUpAxis = blenderContext.getBlenderKey().isFixUpAxis(); - Vector3f[][] verticesAndNormals = this.getVerticesAndNormals(meshStructure, blenderContext); + Vector3f[][] verticesAndNormals = this.getVerticesAndNormals(meshStructure); faceMeshBuilder = new FaceMeshBuilder(verticesAndNormals, this.areGeneratedTexturesPresent(materials)); faceMeshBuilder.readMesh(meshStructure, blenderContext); lineMeshBuilder = new LineMeshBuilder(verticesAndNormals); - lineMeshBuilder.readMesh(meshStructure, blenderContext); + lineMeshBuilder.readMesh(meshStructure); pointMeshBuilder = new PointMeshBuilder(verticesAndNormals); - pointMeshBuilder.readMesh(meshStructure, blenderContext); + pointMeshBuilder.readMesh(meshStructure); } public Map> buildMeshes() { @@ -111,14 +111,12 @@ public class MeshBuilder { * * @param meshStructure * the structure containing the mesh data - * @param blenderContext - * the blender context * @return a list of two - element arrays, the first element is the vertex and the second - its normal * @throws BlenderFileException * this exception is thrown when the blend file structure is somehow invalid or corrupted */ @SuppressWarnings("unchecked") - private Vector3f[][] getVerticesAndNormals(Structure meshStructure, BlenderContext blenderContext) throws BlenderFileException { + private Vector3f[][] getVerticesAndNormals(Structure meshStructure) throws BlenderFileException { int count = ((Number) meshStructure.getFieldValue("totvert")).intValue(); Vector3f[][] result = new Vector3f[count][2]; if (count == 0) { @@ -126,7 +124,7 @@ public class MeshBuilder { } Pointer pMVert = (Pointer) meshStructure.getFieldValue("mvert"); - List mVerts = pMVert.fetchData(blenderContext.getInputStream()); + List mVerts = pMVert.fetchData(); if (fixUpAxis) { for (int i = 0; i < count; ++i) { DynamicArray coordinates = (DynamicArray) mVerts.get(i).getFieldValue("co"); diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/meshes/builders/PointMeshBuilder.java b/engine/src/blender/com/jme3/scene/plugins/blender/meshes/builders/PointMeshBuilder.java index 3695a0652..57e99100b 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/meshes/builders/PointMeshBuilder.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/meshes/builders/PointMeshBuilder.java @@ -15,7 +15,6 @@ import com.jme3.scene.VertexBuffer; import com.jme3.scene.VertexBuffer.Format; import com.jme3.scene.VertexBuffer.Type; import com.jme3.scene.VertexBuffer.Usage; -import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.file.BlenderFileException; import com.jme3.scene.plugins.blender.file.Pointer; import com.jme3.scene.plugins.blender.file.Structure; @@ -59,19 +58,17 @@ import com.jme3.util.BufferUtils; * anywhere or not, we need to check all vertices and use here only those that are not used. * @param meshStructure * the mesh structure - * @param blenderContext - * the blender context * @throws BlenderFileException * an exception thrown when reading from the blend file fails */ - public void readMesh(Structure meshStructure, BlenderContext blenderContext) throws BlenderFileException { + public void readMesh(Structure meshStructure) throws BlenderFileException { LOGGER.fine("Reading points mesh."); Pointer pMEdge = (Pointer) meshStructure.getFieldValue("medge"); if (pMEdge.isNotNull()) { int count = ((Number) meshStructure.getFieldValue("totvert")).intValue(); Set usedVertices = new HashSet(count); - List edges = pMEdge.fetchData(blenderContext.getInputStream()); + List edges = pMEdge.fetchData(); for (Structure edge : edges) { int v1 = ((Number) edge.getFieldValue("v1")).intValue(); diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ArmatureModifier.java b/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ArmatureModifier.java index c6b8a36c6..258a2c8aa 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ArmatureModifier.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ArmatureModifier.java @@ -76,17 +76,17 @@ import com.jme3.util.TempVars; * corrupted */ public ArmatureModifier(Structure objectStructure, Structure modifierStructure, BlenderContext blenderContext) throws BlenderFileException { - Structure meshStructure = ((Pointer) objectStructure.getFieldValue("data")).fetchData(blenderContext.getInputStream()).get(0); + Structure meshStructure = ((Pointer) objectStructure.getFieldValue("data")).fetchData().get(0); if (this.validate(modifierStructure, blenderContext)) { Pointer pArmatureObject = (Pointer) modifierStructure.getFieldValue("object"); if (pArmatureObject.isNotNull()) { ArmatureHelper armatureHelper = blenderContext.getHelper(ArmatureHelper.class); - armatureObject = pArmatureObject.fetchData(blenderContext.getInputStream()).get(0); + armatureObject = pArmatureObject.fetchData().get(0); // load skeleton - Structure armatureStructure = ((Pointer) armatureObject.getFieldValue("data")).fetchData(blenderContext.getInputStream()).get(0); - List bonebase = ((Structure) armatureStructure.getFieldValue("bonebase")).evaluateListBase(blenderContext); + Structure armatureStructure = ((Pointer) armatureObject.getFieldValue("data")).fetchData().get(0); + List bonebase = ((Structure) armatureStructure.getFieldValue("bonebase")).evaluateListBase(); List bonesList = new ArrayList(); for (int i = 0; i < bonebase.size(); ++i) { armatureHelper.buildBones(armatureObject.getOldMemoryAddress(), bonebase.get(i), null, bonesList, objectStructure.getOldMemoryAddress(), blenderContext); @@ -130,7 +130,7 @@ import com.jme3.util.TempVars; // fetching action defined in object Pointer pAction = (Pointer) objectStructure.getFieldValue("action"); if (pAction.isNotNull()) { - Structure actionStructure = pAction.fetchData(blenderContext.getInputStream()).get(0); + Structure actionStructure = pAction.fetchData().get(0); String actionName = actionStructure.getName(); BoneTrack[] tracks = armatureHelper.getTracks(actionStructure, skeleton, blenderContext); @@ -235,9 +235,9 @@ import com.jme3.util.TempVars; ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class); ConstraintHelper constraintHelper = blenderContext.getHelper(ConstraintHelper.class); - Structure pose = pPose.fetchData(blenderContext.getInputStream()).get(0); + Structure pose = pPose.fetchData().get(0); Structure chanbase = (Structure) pose.getFieldValue("chanbase"); - List chans = chanbase.evaluateListBase(blenderContext); + List chans = chanbase.evaluateListBase(); Transform transform = new Transform(); for (Structure poseChannel : chans) { Pointer pBone = (Pointer) poseChannel.getFieldValue("bone"); @@ -290,11 +290,11 @@ import com.jme3.util.TempVars; 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 groupToBoneIndexMap = armatureHelper.getGroupToBoneIndexMap(defBase, skeleton, blenderContext); + Map groupToBoneIndexMap = armatureHelper.getGroupToBoneIndexMap(defBase, skeleton); 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); } /** @@ -318,15 +318,13 @@ import com.jme3.util.TempVars; * @param groupToBoneIndexMap * this object maps the group index (to which a vertices in * blender belong) to bone index of the model - * @param blenderContext - * the blender context * @return arrays of vertices weights and their bone indices and (as an * output parameter) the maximum amount of weights for a vertex * @throws BlenderFileException * this exception is thrown when the blend file structure is * somehow invalid or corrupted */ - private VertexBuffer[] getBoneWeightAndIndexBuffer(Structure meshStructure, int vertexListSize, int[] bonesGroups, Map> vertexReferenceMap, Map groupToBoneIndexMap, BlenderContext blenderContext) throws BlenderFileException { + private VertexBuffer[] getBoneWeightAndIndexBuffer(Structure meshStructure, int vertexListSize, int[] bonesGroups, Map> vertexReferenceMap, Map groupToBoneIndexMap) throws BlenderFileException { bonesGroups[0] = 0; Pointer pDvert = (Pointer) meshStructure.getFieldValue("dvert");// dvert // = @@ -337,7 +335,7 @@ import com.jme3.util.TempVars; if (pDvert.isNotNull()) {// assigning weights and bone indices boolean warnAboutTooManyVertexWeights = false; // dverts.size() = verticesAmount (one dvert per vertex in blender) - List dverts = pDvert.fetchData(blenderContext.getInputStream()); + List dverts = pDvert.fetchData(); int vertexIndex = 0; // use tree map to sort weights from the lowest to the highest ones TreeMap weightToIndexMap = new TreeMap(); @@ -352,7 +350,7 @@ import com.jme3.util.TempVars; if (totweight > 0 && groupToBoneIndexMap != null) { weightToIndexMap.clear(); int weightIndex = 0; - List dw = pDW.fetchData(blenderContext.getInputStream()); + List dw = pDW.fetchData(); for (Structure deformWeight : dw) { Integer boneIndex = groupToBoneIndexMap.get(((Number) deformWeight.getFieldValue("def_nr")).intValue()); float weight = ((Number) deformWeight.getFieldValue("weight")).floatValue(); diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ArrayModifier.java b/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ArrayModifier.java index a362f0b31..1c6b52b5f 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ArrayModifier.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ArrayModifier.java @@ -67,7 +67,7 @@ import java.util.logging.Logger; Pointer pCurveOb = (Pointer) modifierStructure.getFieldValue("curve_ob"); float length = 0; if (pCurveOb.isNotNull()) { - Structure curveStructure = pCurveOb.fetchData(blenderContext.getInputStream()).get(0); + Structure curveStructure = pCurveOb.fetchData().get(0); ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class); Node curveObject = (Node) objectHelper.toObject(curveStructure, blenderContext); Set referencesToCurveLengths = new HashSet(curveObject.getChildren().size()); diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/MirrorModifier.java b/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/MirrorModifier.java index f36486611..aba576020 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/MirrorModifier.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/MirrorModifier.java @@ -91,7 +91,7 @@ import com.jme3.scene.plugins.blender.objects.ObjectHelper; if (pMirrorObject.isNotNull()) { Structure objectStructure; try { - objectStructure = pMirrorObject.fetchData(blenderContext.getInputStream()).get(0); + objectStructure = pMirrorObject.fetchData().get(0); ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class); Node object = (Node) objectHelper.toObject(objectStructure, blenderContext); if (object != null) { diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ModifierHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ModifierHelper.java index da174e089..a0ad5c8ef 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ModifierHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ModifierHelper.java @@ -84,7 +84,7 @@ public class ModifierHelper extends AbstractBlenderHelper { Set alreadyReadModifiers = new HashSet(); Collection result = new ArrayList(); Structure modifiersListBase = (Structure) objectStructure.getFieldValue("modifiers"); - List modifiers = modifiersListBase.evaluateListBase(blenderContext); + List modifiers = modifiersListBase.evaluateListBase(); for (Structure modifierStructure : modifiers) { String modifierType = modifierStructure.getType(); if (!Modifier.canBeAppliedMultipleTimes(modifierType) && alreadyReadModifiers.contains(modifierType)) { @@ -146,7 +146,7 @@ public class ModifierHelper extends AbstractBlenderHelper { Pointer pIpo = (Pointer) objectStructure.getFieldValue("ipo"); if (pIpo.isNotNull()) { IpoHelper ipoHelper = blenderContext.getHelper(IpoHelper.class); - Structure ipoStructure = pIpo.fetchData(blenderContext.getInputStream()).get(0); + Structure ipoStructure = pIpo.fetchData().get(0); Ipo ipo = ipoHelper.fromIpoStructure(ipoStructure, blenderContext); if (ipo != null) { result = new ObjectAnimationModifier(ipo, objectStructure.getName(), objectStructure.getOldMemoryAddress(), blenderContext); @@ -172,10 +172,10 @@ public class ModifierHelper extends AbstractBlenderHelper { Modifier result = null; Pointer pAnimData = (Pointer) objectStructure.getFieldValue("adt"); if (pAnimData.isNotNull()) { - Structure animData = pAnimData.fetchData(blenderContext.getInputStream()).get(0); + Structure animData = pAnimData.fetchData().get(0); Pointer pAction = (Pointer) animData.getFieldValue("action"); if (pAction.isNotNull()) { - Structure actionStructure = pAction.fetchData(blenderContext.getInputStream()).get(0); + Structure actionStructure = pAction.fetchData().get(0); IpoHelper ipoHelper = blenderContext.getHelper(IpoHelper.class); Ipo ipo = ipoHelper.fromAction(actionStructure, blenderContext); if (ipo != null) {// ipo can be null if it has no curves applied, ommit such modifier then diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ParticlesModifier.java b/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ParticlesModifier.java index 66cc6955b..bda881a05 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ParticlesModifier.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ParticlesModifier.java @@ -48,8 +48,8 @@ import java.util.logging.Logger; Pointer pParticleSystem = (Pointer) modifierStructure.getFieldValue("psys"); if (pParticleSystem.isNotNull()) { ParticlesHelper particlesHelper = blenderContext.getHelper(ParticlesHelper.class); - Structure particleSystem = pParticleSystem.fetchData(blenderContext.getInputStream()).get(0); - particleEmitter = particlesHelper.toParticleEmitter(particleSystem, blenderContext); + Structure particleSystem = pParticleSystem.fetchData().get(0); + particleEmitter = particlesHelper.toParticleEmitter(particleSystem); } } } diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java index 2443a125e..cf1835095 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java @@ -143,7 +143,7 @@ public class ObjectHelper extends AbstractBlenderHelper { Pointer pParent = (Pointer) objectStructure.getFieldValue("parent"); Object parent = blenderContext.getLoadedFeature(pParent.getOldMemoryAddress(), LoadedFeatureDataType.LOADED_FEATURE); if (parent == null && pParent.isNotNull()) { - Structure parentStructure = pParent.fetchData(blenderContext.getInputStream()).get(0); + Structure parentStructure = pParent.fetchData().get(0); parent = this.toObject(parentStructure, blenderContext); } @@ -162,7 +162,7 @@ public class ObjectHelper extends AbstractBlenderHelper { result = new Node(name); MeshHelper meshHelper = blenderContext.getHelper(MeshHelper.class); Pointer pMesh = (Pointer) objectStructure.getFieldValue("data"); - List meshesArray = pMesh.fetchData(blenderContext.getInputStream()); + List meshesArray = pMesh.fetchData(); List geometries = meshHelper.toMesh(meshesArray.get(0), blenderContext); if (geometries != null) { for (Geometry geometry : geometries) { @@ -176,7 +176,7 @@ public class ObjectHelper extends AbstractBlenderHelper { Pointer pCurve = (Pointer) objectStructure.getFieldValue("data"); if (pCurve.isNotNull()) { CurvesHelper curvesHelper = blenderContext.getHelper(CurvesHelper.class); - Structure curveData = pCurve.fetchData(blenderContext.getInputStream()).get(0); + Structure curveData = pCurve.fetchData().get(0); List curves = curvesHelper.toCurve(curveData, blenderContext); for (Geometry curve : curves) { result.attachChild(curve); @@ -187,7 +187,7 @@ public class ObjectHelper extends AbstractBlenderHelper { Pointer pLamp = (Pointer) objectStructure.getFieldValue("data"); if (pLamp.isNotNull()) { LightHelper lightHelper = blenderContext.getHelper(LightHelper.class); - List lampsArray = pLamp.fetchData(blenderContext.getInputStream()); + List lampsArray = pLamp.fetchData(); result = lightHelper.toLight(lampsArray.get(0), blenderContext); } break; @@ -195,7 +195,7 @@ public class ObjectHelper extends AbstractBlenderHelper { Pointer pCamera = (Pointer) objectStructure.getFieldValue("data"); if (pCamera.isNotNull()) { CameraHelper cameraHelper = blenderContext.getHelper(CameraHelper.class); - List camerasArray = pCamera.fetchData(blenderContext.getInputStream()); + List camerasArray = pCamera.fetchData(); result = cameraHelper.toCamera(camerasArray.get(0), blenderContext); } break; diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/objects/Properties.java b/engine/src/blender/com/jme3/scene/plugins/blender/objects/Properties.java index 246f167e8..c1f867543 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/objects/Properties.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/objects/Properties.java @@ -119,7 +119,7 @@ public class Properties implements Cloneable { } case IDP_GROUP: Structure group = (Structure) data.getFieldValue("group"); - List dataList = group.evaluateListBase(blenderContext); + List dataList = group.evaluateListBase(); List subProperties = new ArrayList(len); for (Structure d : dataList) { Properties properties = new Properties(); @@ -136,14 +136,14 @@ public class Properties implements Cloneable { break; case IDP_IDPARRAY: { Pointer pointer = (Pointer) data.getFieldValue("pointer"); - List arrays = pointer.fetchData(blenderContext.getInputStream()); + List arrays = pointer.fetchData(); List result = new ArrayList(arrays.size()); Properties temp = new Properties(); for (Structure array : arrays) { temp.load(array, blenderContext); result.add(temp.value); } - this.value = result; + value = result; break; } case IDP_NUMTYPES: @@ -180,8 +180,8 @@ public class Properties implements Cloneable { @SuppressWarnings("unchecked") public List getSubPropertiesNames() { List result = null; - if (this.type == IDP_GROUP) { - List properties = (List) this.value; + if (type == IDP_GROUP) { + List properties = (List) value; if (properties != null && properties.size() > 0) { result = new ArrayList(properties.size()); for (Properties property : properties) { @@ -272,8 +272,8 @@ public class Properties implements Cloneable { */ @SuppressWarnings("unchecked") protected void completeLoading() { - if (this.type == IDP_GROUP) { - List groupProperties = (List) this.value; + if (type == IDP_GROUP) { + List groupProperties = (List) value; Properties rnaUI = null; for (Properties properties : groupProperties) { if (properties.name.equals(RNA_PROPERTY_NAME) && properties.type == IDP_GROUP) { diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/particles/ParticlesHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/particles/ParticlesHelper.java index 255fe8c82..85c093f66 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/particles/ParticlesHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/particles/ParticlesHelper.java @@ -95,11 +95,11 @@ public class ParticlesHelper extends AbstractBlenderHelper { } @SuppressWarnings("unchecked") - public ParticleEmitter toParticleEmitter(Structure particleSystem, BlenderContext blenderContext) throws BlenderFileException { + public ParticleEmitter toParticleEmitter(Structure particleSystem) throws BlenderFileException { ParticleEmitter result = null; Pointer pParticleSettings = (Pointer) particleSystem.getFieldValue("part"); if (pParticleSettings.isNotNull()) { - Structure particleSettings = pParticleSettings.fetchData(blenderContext.getInputStream()).get(0); + Structure particleSettings = pParticleSettings.fetchData().get(0); int totPart = ((Number) particleSettings.getFieldValue("totpart")).intValue(); diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/textures/ColorBand.java b/engine/src/blender/com/jme3/scene/plugins/blender/textures/ColorBand.java index 4c029903d..d8298e867 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/textures/ColorBand.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/textures/ColorBand.java @@ -95,7 +95,7 @@ public class ColorBand { cursorsAmount = colors.size(); this.ipoType = ipoType; this.resultSize = resultSize; - data = new ColorBandData[this.cursorsAmount]; + data = new ColorBandData[cursorsAmount]; for (int i = 0; i < cursorsAmount; ++i) { data[i] = new ColorBandData(colors.get(i), positions.get(i)); } @@ -112,12 +112,12 @@ public class ColorBand { if ((flag & GeneratedTexture.TEX_COLORBAND) != 0) { Pointer pColorband = (Pointer) tex.getFieldValue("coba"); try { - Structure colorbandStructure = pColorband.fetchData(blenderContext.getInputStream()).get(0); - this.cursorsAmount = ((Number) colorbandStructure.getFieldValue("tot")).intValue(); - this.ipoType = ((Number) colorbandStructure.getFieldValue("ipotype")).intValue(); - this.data = new ColorBandData[this.cursorsAmount]; + Structure colorbandStructure = pColorband.fetchData().get(0); + cursorsAmount = ((Number) colorbandStructure.getFieldValue("tot")).intValue(); + ipoType = ((Number) colorbandStructure.getFieldValue("ipotype")).intValue(); + data = new ColorBandData[cursorsAmount]; DynamicArray data = (DynamicArray) colorbandStructure.getFieldValue("data"); - for (int i = 0; i < this.cursorsAmount; ++i) { + for (int i = 0; i < cursorsAmount; ++i) { this.data[i] = new ColorBandData(data.get(i)); } } catch (BlenderFileException e) { @@ -372,11 +372,11 @@ public class ColorBand { * Copy constructor. */ private ColorBandData(ColorBandData data) { - this.r = data.r; - this.g = data.g; - this.b = data.b; - this.a = data.a; - this.pos = data.pos; + r = data.r; + g = data.g; + b = data.b; + a = data.a; + pos = data.pos; } /** @@ -386,16 +386,16 @@ public class ColorBand { * the structure containing the CBData object */ public ColorBandData(Structure cbdataStructure) { - this.r = ((Number) cbdataStructure.getFieldValue("r")).floatValue(); - this.g = ((Number) cbdataStructure.getFieldValue("g")).floatValue(); - this.b = ((Number) cbdataStructure.getFieldValue("b")).floatValue(); - this.a = ((Number) cbdataStructure.getFieldValue("a")).floatValue(); - this.pos = (int) (((Number) cbdataStructure.getFieldValue("pos")).floatValue() * 1000.0f); + r = ((Number) cbdataStructure.getFieldValue("r")).floatValue(); + g = ((Number) cbdataStructure.getFieldValue("g")).floatValue(); + b = ((Number) cbdataStructure.getFieldValue("b")).floatValue(); + a = ((Number) cbdataStructure.getFieldValue("a")).floatValue(); + pos = (int) (((Number) cbdataStructure.getFieldValue("pos")).floatValue() * 1000.0f); } @Override public String toString() { - return "P: " + this.pos + " [" + this.r + ", " + this.g + ", " + this.b + ", " + this.a + "]"; + return "P: " + pos + " [" + r + ", " + g + ", " + b + ", " + a + "]"; } } } diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureHelper.java index 61a384ef7..f7a6aad3a 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureHelper.java @@ -141,7 +141,7 @@ public class TextureHelper extends AbstractBlenderHelper { case TEX_IMAGE:// (it is first because probably this will be most commonly used) Pointer pImage = (Pointer) tex.getFieldValue("ima"); if (pImage.isNotNull()) { - Structure image = pImage.fetchData(blenderContext.getInputStream()).get(0); + Structure image = pImage.fetchData().get(0); Texture loadedTexture = this.loadTexture(image, imaflag, blenderContext); if (loadedTexture != null) { result = loadedTexture; @@ -232,7 +232,7 @@ public class TextureHelper extends AbstractBlenderHelper { result = this.loadImageFromFile(texturePath, imaflag, blenderContext); } else { LOGGER.fine("Packed texture. Reading directly from the blend file!"); - Structure packedFile = pPackedFile.fetchData(blenderContext.getInputStream()).get(0); + Structure packedFile = pPackedFile.fetchData().get(0); Pointer pData = (Pointer) packedFile.getFieldValue("data"); FileBlockHeader dataFileBlock = blenderContext.getFileBlock(pData.getOldMemoryAddress()); blenderContext.getInputStream().setPosition(dataFileBlock.getBlockPosition()); @@ -533,7 +533,7 @@ public class TextureHelper extends AbstractBlenderHelper { Pointer p = mtexsArray.get(i); if (p.isNotNull() && (separatedTextures & 1 << i) == 0) { TextureData textureData = new TextureData(); - textureData.mtex = p.fetchData(blenderContext.getInputStream()).get(0); + textureData.mtex = p.fetchData().get(0); textureData.uvCoordinatesType = skyTexture ? UVCoordinatesType.TEXCO_ORCO.blenderValue : ((Number) textureData.mtex.getFieldValue("texco")).intValue(); textureData.projectionType = ((Number) textureData.mtex.getFieldValue("mapping")).intValue(); textureData.uvCoordinatesName = textureData.mtex.getFieldValue("uvName").toString(); @@ -543,7 +543,7 @@ public class TextureHelper extends AbstractBlenderHelper { Pointer pTex = (Pointer) textureData.mtex.getFieldValue("tex"); if (pTex.isNotNull()) { - Structure tex = pTex.fetchData(blenderContext.getInputStream()).get(0); + Structure tex = pTex.fetchData().get(0); textureData.textureStructure = tex; texturesList.add(textureData); }