Refactoring: improved the usage and flow of blender context and blender input stream (will make the unit tests implementation easier).

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10953 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
experimental
Kae..pl 11 years ago
parent 6708cf0d7f
commit 1fcd9526b2
  1. 4
      engine/src/blender/com/jme3/scene/plugins/blender/AbstractBlenderHelper.java
  2. 4
      engine/src/blender/com/jme3/scene/plugins/blender/BlenderLoader.java
  3. 14
      engine/src/blender/com/jme3/scene/plugins/blender/animations/ArmatureHelper.java
  4. 2
      engine/src/blender/com/jme3/scene/plugins/blender/animations/BoneContext.java
  5. 8
      engine/src/blender/com/jme3/scene/plugins/blender/animations/IpoHelper.java
  6. 2
      engine/src/blender/com/jme3/scene/plugins/blender/constraints/Constraint.java
  7. 16
      engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintHelper.java
  8. 24
      engine/src/blender/com/jme3/scene/plugins/blender/curves/CurvesHelper.java
  9. 4
      engine/src/blender/com/jme3/scene/plugins/blender/file/Field.java
  10. 17
      engine/src/blender/com/jme3/scene/plugins/blender/file/Pointer.java
  11. 16
      engine/src/blender/com/jme3/scene/plugins/blender/file/Structure.java
  12. 2
      engine/src/blender/com/jme3/scene/plugins/blender/materials/MaterialHelper.java
  13. 2
      engine/src/blender/com/jme3/scene/plugins/blender/meshes/MeshHelper.java
  14. 36
      engine/src/blender/com/jme3/scene/plugins/blender/meshes/builders/FaceMeshBuilder.java
  15. 7
      engine/src/blender/com/jme3/scene/plugins/blender/meshes/builders/LineMeshBuilder.java
  16. 12
      engine/src/blender/com/jme3/scene/plugins/blender/meshes/builders/MeshBuilder.java
  17. 7
      engine/src/blender/com/jme3/scene/plugins/blender/meshes/builders/PointMeshBuilder.java
  18. 26
      engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ArmatureModifier.java
  19. 2
      engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ArrayModifier.java
  20. 2
      engine/src/blender/com/jme3/scene/plugins/blender/modifiers/MirrorModifier.java
  21. 8
      engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ModifierHelper.java
  22. 4
      engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ParticlesModifier.java
  23. 10
      engine/src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java
  24. 14
      engine/src/blender/com/jme3/scene/plugins/blender/objects/Properties.java
  25. 4
      engine/src/blender/com/jme3/scene/plugins/blender/particles/ParticlesHelper.java
  26. 34
      engine/src/blender/com/jme3/scene/plugins/blender/textures/ColorBand.java
  27. 8
      engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureHelper.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);
}

@ -183,11 +183,11 @@ public class BlenderLoader implements AssetLoader {
ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class);
Node result = new Node(structure.getName());
try {
List<Structure> base = ((Structure) structure.getFieldValue("base")).evaluateListBase(blenderContext);
List<Structure> 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) {

@ -109,11 +109,11 @@ public class ArmatureHelper extends AbstractBlenderHelper {
* this exception is thrown when the blender file is somehow
* corrupted
*/
public Map<Integer, Integer> getGroupToBoneIndexMap(Structure defBaseStructure, Skeleton skeleton, BlenderContext blenderContext) throws BlenderFileException {
public Map<Integer, Integer> getGroupToBoneIndexMap(Structure defBaseStructure, Skeleton skeleton) throws BlenderFileException {
Map<Integer, Integer> result = null;
if (skeleton.getBoneCount() != 0) {
result = new HashMap<Integer, Integer>();
List<Structure> deformGroups = defBaseStructure.evaluateListBase(blenderContext);// bDeformGroup
List<Structure> 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<Structure> actionGroups = groups.evaluateListBase(blenderContext);// bActionGroup
List<Structure> actionGroups = groups.evaluateListBase();// bActionGroup
List<BoneTrack> tracks = new ArrayList<BoneTrack>();
for (Structure actionGroup : actionGroups) {
String name = actionGroup.getFieldValue("name").toString();
int boneIndex = skeleton.getBoneIndex(name);
if (boneIndex >= 0) {
List<Structure> channels = ((Structure) actionGroup.getFieldValue("channels")).evaluateListBase(blenderContext);
List<Structure> 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<Structure> bezTriples = pBezTriple.fetchData(blenderContext.getInputStream());
List<Structure> 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<Structure> actionChannels = chanbase.evaluateListBase(blenderContext);// bActionChannel
List<Structure> actionChannels = chanbase.evaluateListBase();// bActionChannel
List<BoneTrack> tracks = new ArrayList<BoneTrack>();
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);

@ -110,7 +110,7 @@ public class BoneContext {
globalBoneMatrix = armatureWorldMatrix.mult(globalBoneMatrix);
// create the children
List<Structure> childbase = ((Structure) boneStructure.getFieldValue("childbase")).evaluateListBase(blenderContext);
List<Structure> childbase = ((Structure) boneStructure.getFieldValue("childbase")).evaluateListBase();
for (Structure child : childbase) {
children.add(new BoneContext(child, armatureObjectOMA, this, blenderContext));
}

@ -55,13 +55,13 @@ public class IpoHelper extends AbstractBlenderHelper {
// preparing bezier curves
Ipo result = null;
List<Structure> curves = curvebase.evaluateListBase(blenderContext);// IpoCurve
List<Structure> 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<Structure> bezTriples = pBezTriple.fetchData(blenderContext.getInputStream());
List<Structure> 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<Structure> curves = ((Structure) actionStructure.getFieldValue("curves")).evaluateListBase(blenderContext);// FCurve
List<Structure> 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<Structure> bezTriples = pBezTriple.fetchData(blenderContext.getInputStream());
List<Structure> bezTriples = pBezTriple.fetchData();
int type = this.getCurveType(curve, blenderContext);
bezierCurves[frame++] = new BezierCurve(type, bezTriples, 2);
}

@ -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()) {

@ -67,19 +67,19 @@ public class ConstraintHelper extends AbstractBlenderHelper {
Map<String, Map<String, Ipo>> constraintsIpos = new HashMap<String, Map<String, Ipo>>();
Pointer pActions = (Pointer) objectStructure.getFieldValue("action");
if (pActions.isNotNull()) {
List<Structure> actions = pActions.fetchData(blenderContext.getInputStream());
List<Structure> actions = pActions.fetchData();
for (Structure action : actions) {
Structure chanbase = (Structure) action.getFieldValue("chanbase");
List<Structure> actionChannels = chanbase.evaluateListBase(blenderContext);
List<Structure> actionChannels = chanbase.evaluateListBase();
for (Structure actionChannel : actionChannels) {
Map<String, Ipo> ipos = new HashMap<String, Ipo>();
Structure constChannels = (Structure) actionChannel.getFieldValue("constraintChannels");
List<Structure> constraintChannels = constChannels.evaluateListBase(blenderContext);
List<Structure> 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<Structure> poseChannels = ((Structure) pPose.fetchData(blenderContext.getInputStream()).get(0).getFieldValue("chanbase")).evaluateListBase(blenderContext);
List<Structure> poseChannels = ((Structure) pPose.fetchData().get(0).getFieldValue("chanbase")).evaluateListBase();
for (Structure poseChannel : poseChannels) {
List<Constraint> constraintsList = new ArrayList<Constraint>();
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<Structure> constraints = ((Structure) poseChannel.getFieldValue("constraints")).evaluateListBase(blenderContext);
List<Structure> constraints = ((Structure) poseChannel.getFieldValue("constraints")).evaluateListBase();
for (Structure constraint : constraints) {
String constraintName = constraint.getFieldValue("name").toString();
Map<String, Ipo> ipoMap = constraintsIpos.get(name);
@ -116,10 +116,10 @@ public class ConstraintHelper extends AbstractBlenderHelper {
}
// loading constraints connected with the object itself
List<Structure> constraints = ((Structure) objectStructure.getFieldValue("constraints")).evaluateListBase(blenderContext);
List<Structure> 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<Constraint> constraintsList = new ArrayList<Constraint>(constraints.size());
for (Structure constraint : constraints) {

@ -119,7 +119,7 @@ public class CurvesHelper extends AbstractBlenderHelper {
}
// reading nurbs (and sorting them by material)
List<Structure> nurbStructures = ((Structure) curveStructure.getFieldValue("nurb")).evaluateListBase(blenderContext);
List<Structure> nurbStructures = ((Structure) curveStructure.getFieldValue("nurb")).evaluateListBase();
Map<Number, List<Structure>> nurbs = new HashMap<Number, List<Structure>>();
for (Structure nurb : nurbStructures) {
Number matNumber = (Number) nurb.getFieldValue("mat_nr");
@ -148,8 +148,8 @@ public class CurvesHelper extends AbstractBlenderHelper {
List<Geometry> 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<Vector3f> 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<Structure> bPoints = ((Pointer) nurb.getFieldValue("bp")).fetchData(blenderContext.getInputStream());
List<Structure> bPoints = ((Pointer) nurb.getFieldValue("bp")).fetchData();
List<List<Vector4f>> controlPoints = new ArrayList<List<Vector4f>>(pntsV);
for (int i = 0; i < pntsV; ++i) {
List<Vector4f> uControlPoints = new ArrayList<Vector4f>(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<Structure> nurbStructures = ((Structure) taperStructure.getFieldValue("nurb")).evaluateListBase(blenderContext);
List<Structure> 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<Vector3f> controlPoints = bezierCurve.getControlPoints();
// removing the first and last handles
controlPoints.remove(0);

@ -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<Structure>(tableSizes, data);

@ -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<Structure> fetchData(BlenderInputStream inputStream) throws BlenderFileException {
public List<Structure> 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<Structure>(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;

@ -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<Structure> evaluateListBase(BlenderContext blenderContext) throws BlenderFileException {
public List<Structure> 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<Structure> result = new LinkedList<Structure>();
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);
}
/**

@ -241,7 +241,7 @@ public class MaterialHelper extends AbstractBlenderHelper {
Pointer ppMaterials = (Pointer) structureWithMaterials.getFieldValue("mat");
MaterialContext[] materials = null;
if (ppMaterials.isNotNull()) {
List<Structure> materialStructures = ppMaterials.fetchData(blenderContext.getInputStream());
List<Structure> materialStructures = ppMaterials.fetchData();
if (materialStructures != null && materialStructures.size() > 0) {
MaterialHelper materialHelper = blenderContext.getHelper(MaterialHelper.class);
materials = new MaterialContext[materialStructures.size()];

@ -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<Structure> defs = defbase.evaluateListBase(blenderContext);
List<Structure> defs = defbase.evaluateListBase();
String[] verticesGroups = new String[defs.size()];
int defIndex = 0;
for (Structure def : defs) {

@ -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<String, Vector2f[]> uvCoordinatesForFace = new HashMap<String, Vector2f[]>();
if (pMPoly.isNotNull() && pMLoop.isNotNull()) {
Map<String, List<Vector2f>> uvs = this.loadUVCoordinates(meshStructure, true, blenderContext);
List<Structure> polys = pMPoly.fetchData(blenderContext.getInputStream());
List<Structure> loops = pMLoop.fetchData(blenderContext.getInputStream());
Map<String, List<Vector2f>> uvs = this.loadUVCoordinates(meshStructure, true);
List<Structure> polys = pMPoly.fetchData();
List<Structure> 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<Structure> mFaces = pMFace.isNotNull() ? pMFace.fetchData(blenderContext.getInputStream()) : null;
List<Structure> 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<String, List<Vector2f>> uvs = this.loadUVCoordinates(meshStructure, false, blenderContext);
Map<String, List<Vector2f>> uvs = this.loadUVCoordinates(meshStructure, false);
Map<String, Vector2f[]> uvCoordinatesForFace = new HashMap<String, Vector2f[]>();
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<String, List<Vector2f>> loadUVCoordinates(Structure meshStructure, boolean useBMesh, BlenderContext blenderContext) throws BlenderFileException {
private Map<String, List<Vector2f>> loadUVCoordinates(Structure meshStructure, boolean useBMesh) throws BlenderFileException {
Map<String, List<Vector2f>> result = new HashMap<String, List<Vector2f>>();
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<Structure> loopDataLayers = pLoopDataLayers.fetchData(blenderContext.getInputStream());
List<Structure> 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<Structure> uvsStructures = p.fetchData(blenderContext.getInputStream());
List<Structure> uvsStructures = p.fetchData();
List<Vector2f> uvs = new ArrayList<Vector2f>(uvsStructures.size());
for (Structure uvStructure : uvsStructures) {
DynamicArray<Number> loopUVS = (DynamicArray<Number>) 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<Structure> facesDataLayers = pFacesDataLayers.fetchData(blenderContext.getInputStream());
List<Structure> 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<Structure> uvsStructures = p.fetchData(blenderContext.getInputStream());
List<Structure> uvsStructures = p.fetchData();
List<Vector2f> uvs = new ArrayList<Vector2f>(uvsStructures.size());
for (Structure uvStructure : uvsStructures) {
DynamicArray<Number> mFaceUVs = (DynamicArray<Number>) 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<Structure> mCol = pMCol.fetchData(blenderContext.getInputStream());
List<Structure> mCol = pMCol.fetchData();
verticesColors = new ArrayList<byte[]>(mCol.size());
for (Structure color : mCol) {
byte r = ((Number) color.getFieldValue("r")).byteValue();

@ -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<Structure> edges = pMEdge.fetchData(blenderContext.getInputStream());
List<Structure> edges = pMEdge.fetchData();
int vertexIndex = 0;//vertex index in the result mesh
for (Structure edge : edges) {
int flag = ((Number) edge.getFieldValue("flag")).intValue();

@ -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<Integer, List<Mesh>> 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<Structure> mVerts = pMVert.fetchData(blenderContext.getInputStream());
List<Structure> mVerts = pMVert.fetchData();
if (fixUpAxis) {
for (int i = 0; i < count; ++i) {
DynamicArray<Number> coordinates = (DynamicArray<Number>) mVerts.get(i).getFieldValue("co");

@ -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<Vector3f> usedVertices = new HashSet<Vector3f>(count);
List<Structure> edges = pMEdge.fetchData(blenderContext.getInputStream());
List<Structure> edges = pMEdge.fetchData();
for (Structure edge : edges) {
int v1 = ((Number) edge.getFieldValue("v1")).intValue();

@ -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<Structure> bonebase = ((Structure) armatureStructure.getFieldValue("bonebase")).evaluateListBase(blenderContext);
Structure armatureStructure = ((Pointer) armatureObject.getFieldValue("data")).fetchData().get(0);
List<Structure> bonebase = ((Structure) armatureStructure.getFieldValue("bonebase")).evaluateListBase();
List<Bone> bonesList = new ArrayList<Bone>();
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<Structure> chans = chanbase.evaluateListBase(blenderContext);
List<Structure> 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<Integer, Integer> groupToBoneIndexMap = armatureHelper.getGroupToBoneIndexMap(defBase, skeleton, blenderContext);
Map<Integer, Integer> 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<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) 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<Structure> dverts = pDvert.fetchData(blenderContext.getInputStream());
List<Structure> dverts = pDvert.fetchData();
int vertexIndex = 0;
// use tree map to sort weights from the lowest to the highest ones
TreeMap<Float, Integer> weightToIndexMap = new TreeMap<Float, Integer>();
@ -352,7 +350,7 @@ import com.jme3.util.TempVars;
if (totweight > 0 && groupToBoneIndexMap != null) {
weightToIndexMap.clear();
int weightIndex = 0;
List<Structure> dw = pDW.fetchData(blenderContext.getInputStream());
List<Structure> dw = pDW.fetchData();
for (Structure deformWeight : dw) {
Integer boneIndex = groupToBoneIndexMap.get(((Number) deformWeight.getFieldValue("def_nr")).intValue());
float weight = ((Number) deformWeight.getFieldValue("weight")).floatValue();

@ -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<Number> referencesToCurveLengths = new HashSet<Number>(curveObject.getChildren().size());

@ -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) {

@ -84,7 +84,7 @@ public class ModifierHelper extends AbstractBlenderHelper {
Set<String> alreadyReadModifiers = new HashSet<String>();
Collection<Modifier> result = new ArrayList<Modifier>();
Structure modifiersListBase = (Structure) objectStructure.getFieldValue("modifiers");
List<Structure> modifiers = modifiersListBase.evaluateListBase(blenderContext);
List<Structure> 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

@ -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);
}
}
}

@ -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<Structure> meshesArray = pMesh.fetchData(blenderContext.getInputStream());
List<Structure> meshesArray = pMesh.fetchData();
List<Geometry> 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<Geometry> 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<Structure> lampsArray = pLamp.fetchData(blenderContext.getInputStream());
List<Structure> 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<Structure> camerasArray = pCamera.fetchData(blenderContext.getInputStream());
List<Structure> camerasArray = pCamera.fetchData();
result = cameraHelper.toCamera(camerasArray.get(0), blenderContext);
}
break;

@ -119,7 +119,7 @@ public class Properties implements Cloneable {
}
case IDP_GROUP:
Structure group = (Structure) data.getFieldValue("group");
List<Structure> dataList = group.evaluateListBase(blenderContext);
List<Structure> dataList = group.evaluateListBase();
List<Properties> subProperties = new ArrayList<Properties>(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<Structure> arrays = pointer.fetchData(blenderContext.getInputStream());
List<Structure> arrays = pointer.fetchData();
List<Object> result = new ArrayList<Object>(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<String> getSubPropertiesNames() {
List<String> result = null;
if (this.type == IDP_GROUP) {
List<Properties> properties = (List<Properties>) this.value;
if (type == IDP_GROUP) {
List<Properties> properties = (List<Properties>) value;
if (properties != null && properties.size() > 0) {
result = new ArrayList<String>(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<Properties> groupProperties = (List<Properties>) this.value;
if (type == IDP_GROUP) {
List<Properties> groupProperties = (List<Properties>) value;
Properties rnaUI = null;
for (Properties properties : groupProperties) {
if (properties.name.equals(RNA_PROPERTY_NAME) && properties.type == IDP_GROUP) {

@ -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();

@ -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<Structure> data = (DynamicArray<Structure>) 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 + "]";
}
}
}

@ -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);
}

Loading…
Cancel
Save