From ba57377795cdb87e1eef7e84269d31513ef14d4d Mon Sep 17 00:00:00 2001 From: "Kae..pl" Date: Sun, 11 Sep 2011 21:53:02 +0000 Subject: [PATCH] Refactoring: renaming 'DataRepository' to 'BlenderContext'. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8244 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../blender/AbstractBlenderHelper.java | 18 ++-- ...ataRepository.java => BlenderContext.java} | 4 +- .../scene/plugins/blender/BlenderLoader.java | 60 +++++++------- .../plugins/blender/BlenderModelLoader.java | 2 +- .../scene/plugins/blender/JmeConverter.java | 48 +++++------ .../blender/animations/ArmatureHelper.java | 68 +++++++-------- .../plugins/blender/animations/IpoHelper.java | 16 ++-- .../plugins/blender/cameras/CameraHelper.java | 6 +- .../blender/constraints/Constraint.java | 30 +++---- .../blender/constraints/ConstraintAction.java | 10 +-- .../constraints/ConstraintChildOf.java | 10 +-- .../constraints/ConstraintClampTo.java | 10 +-- .../constraints/ConstraintDistLimit.java | 10 +-- .../constraints/ConstraintFactory.java | 48 +++++------ .../constraints/ConstraintFollowPath.java | 10 +-- .../blender/constraints/ConstraintHelper.java | 40 ++++----- .../ConstraintInverseKinematics.java | 18 ++-- .../constraints/ConstraintLocLike.java | 10 +-- .../constraints/ConstraintLocLimit.java | 10 +-- .../constraints/ConstraintLockTrack.java | 10 +-- .../blender/constraints/ConstraintMinMax.java | 10 +-- .../blender/constraints/ConstraintNull.java | 10 +-- .../blender/constraints/ConstraintPython.java | 10 +-- .../constraints/ConstraintRigidBodyJoint.java | 10 +-- .../constraints/ConstraintRotLike.java | 10 +-- .../constraints/ConstraintRotLimit.java | 10 +-- .../constraints/ConstraintShrinkWrap.java | 12 +-- .../constraints/ConstraintSizeLike.java | 10 +-- .../constraints/ConstraintSizeLimit.java | 10 +-- .../constraints/ConstraintStretchTo.java | 10 +-- .../constraints/ConstraintTransform.java | 10 +-- .../plugins/blender/curves/CurvesHelper.java | 78 +++++++++--------- .../plugins/blender/file/DnaBlockData.java | 10 +-- .../scene/plugins/blender/file/Field.java | 26 +++--- .../plugins/blender/file/FileBlockHeader.java | 24 +++--- .../scene/plugins/blender/file/Pointer.java | 18 ++-- .../scene/plugins/blender/file/Structure.java | 42 +++++----- .../plugins/blender/lights/LightHelper.java | 12 +-- .../blender/materials/MaterialContext.java | 8 +- .../blender/materials/MaterialHelper.java | 60 +++++++------- .../plugins/blender/meshes/MeshHelper.java | 60 +++++++------- .../blender/modifiers/ArmatureModifier.java | 66 +++++++-------- .../blender/modifiers/ArrayModifier.java | 36 ++++---- .../blender/modifiers/MirrorModifier.java | 16 ++-- .../plugins/blender/modifiers/Modifier.java | 8 +- .../blender/modifiers/ModifierHelper.java | 26 +++--- .../modifiers/ObjectAnimationModifier.java | 30 +++---- .../blender/modifiers/ParticlesModifier.java | 20 ++--- .../plugins/blender/objects/ObjectHelper.java | 74 ++++++++--------- .../plugins/blender/objects/Properties.java | 24 +++--- .../blender/particles/ParticlesHelper.java | 10 +-- .../blender/textures/NoiseGenerator.java | 6 +- .../blender/textures/TextureGenerator.java | 20 ++--- .../textures/TextureGeneratorBlend.java | 6 +- .../textures/TextureGeneratorClouds.java | 6 +- .../textures/TextureGeneratorDistnoise.java | 6 +- .../textures/TextureGeneratorMagic.java | 6 +- .../textures/TextureGeneratorMarble.java | 6 +- .../textures/TextureGeneratorMusgrave.java | 6 +- .../textures/TextureGeneratorNoise.java | 6 +- .../textures/TextureGeneratorStucci.java | 6 +- .../textures/TextureGeneratorVoronoi.java | 6 +- .../textures/TextureGeneratorWood.java | 6 +- .../blender/textures/TextureHelper.java | 82 +++++++++---------- 64 files changed, 683 insertions(+), 683 deletions(-) rename engine/src/blender/com/jme3/scene/plugins/blender/{DataRepository.java => BlenderContext.java} (96%) 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 e14bf4a27..4b30922e3 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/AbstractBlenderHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/AbstractBlenderHelper.java @@ -109,21 +109,21 @@ public abstract class AbstractBlenderHelper { * This method loads the properties if they are available and defined for the structure. * @param structure * the structure we read the properties from - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @return loaded properties or null if they are not available * @throws BlenderFileException * an exception is thrown when the blend file is somehow corrupted */ - protected Properties loadProperties(Structure structure, DataRepository dataRepository) throws BlenderFileException { + protected Properties loadProperties(Structure structure, BlenderContext blenderContext) throws BlenderFileException { Properties properties = null; Structure id = (Structure) structure.getFieldValue("ID"); if (id != null) { Pointer pProperties = (Pointer) id.getFieldValue("properties"); if (pProperties.isNotNull()) { - Structure propertiesStructure = pProperties.fetchData(dataRepository.getInputStream()).get(0); + Structure propertiesStructure = pProperties.fetchData(blenderContext.getInputStream()).get(0); properties = new Properties(); - properties.load(propertiesStructure, dataRepository); + properties.load(propertiesStructure, blenderContext); } } return properties; @@ -131,12 +131,12 @@ public abstract class AbstractBlenderHelper { /** * This method analyzes the given structure and the data contained within - * data repository and decides if the feature should be loaded. + * blender context and decides if the feature should be loaded. * @param structure * structure to be analyzed - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @return true if the feature should be loaded and false otherwise */ - public abstract boolean shouldBeLoaded(Structure structure, DataRepository dataRepository); + public abstract boolean shouldBeLoaded(Structure structure, BlenderContext blenderContext); } diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/DataRepository.java b/engine/src/blender/com/jme3/scene/plugins/blender/BlenderContext.java similarity index 96% rename from engine/src/blender/com/jme3/scene/plugins/blender/DataRepository.java rename to engine/src/blender/com/jme3/scene/plugins/blender/BlenderContext.java index da627f14f..027c4b5ef 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/DataRepository.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/BlenderContext.java @@ -55,9 +55,9 @@ import com.jme3.scene.plugins.blender.modifiers.Modifier; /** * The class that stores temporary data and manages it during loading the belnd file. This class is intended to be used * in a single loading thread. It holds the state of loading operations. - * @author Marcin Roguski + * @author Marcin Roguski (Kaelthas) */ -public class DataRepository { +public class BlenderContext { /** The blender key. */ private BlenderKey blenderKey; 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 e64ca23fb..2d8a1580d 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/BlenderLoader.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/BlenderLoader.java @@ -75,8 +75,8 @@ public class BlenderLoader implements AssetLoader { /** Converter for blender structures. */ protected JmeConverter converter; - /** The data repository. */ - protected DataRepository dataRepository; + /** The blender context. */ + protected BlenderContext blenderContext; /** The blender key to use. */ protected BlenderKey blenderKey; /** The blocks read from the file. */ @@ -94,7 +94,7 @@ public class BlenderLoader implements AssetLoader { for (FileBlockHeader block : blocks) { switch (block.getCode()) { case FileBlockHeader.BLOCK_OB00:// Object - Object object = converter.toObject(block.getStructure(dataRepository)); + Object object = converter.toObject(block.getStructure(blenderContext)); if (object instanceof Node) { if ((blenderKey.getFeaturesToLoad() & FeaturesToLoad.OBJECTS) != 0) { LOGGER.log(Level.INFO, "{0}: {1}--> {2}", new Object[] { ((Node) object).getName(), ((Node) object).getLocalTranslation().toString(), ((Node) object).getParent() == null ? "null" : ((Node) object).getParent().getName() }); @@ -114,17 +114,17 @@ public class BlenderLoader implements AssetLoader { break; case FileBlockHeader.BLOCK_MA00:// Material if (blenderKey.isLoadUnlinkedAssets() && (blenderKey.getFeaturesToLoad() & FeaturesToLoad.MATERIALS) != 0) { - loadingResults.addMaterial(converter.toMaterial(block.getStructure(dataRepository))); + loadingResults.addMaterial(converter.toMaterial(block.getStructure(blenderContext))); } break; case FileBlockHeader.BLOCK_SC00:// Scene if ((blenderKey.getFeaturesToLoad() & FeaturesToLoad.SCENES) != 0) { - loadingResults.addScene(converter.toScene(block.getStructure(dataRepository))); + loadingResults.addScene(converter.toScene(block.getStructure(blenderContext))); } break; case FileBlockHeader.BLOCK_WO00:// World if (blenderKey.isLoadUnlinkedAssets() && worldData == null) {// onlu one world data is used - Structure worldStructure = block.getStructure(dataRepository); + Structure worldStructure = block.getStructure(blenderContext); String worldName = worldStructure.getName(); if (blenderKey.getUsedWorld() == null || blenderKey.getUsedWorld().equals(worldName)) { worldData = converter.toWorldData(worldStructure); @@ -171,39 +171,39 @@ public class BlenderLoader implements AssetLoader { // reading blocks blocks = new ArrayList(); FileBlockHeader fileBlock; - dataRepository = new DataRepository(); - dataRepository.setAssetManager(assetInfo.getManager()); - dataRepository.setInputStream(inputStream); - dataRepository.setBlenderKey(blenderKey); + blenderContext = new BlenderContext(); + blenderContext.setAssetManager(assetInfo.getManager()); + blenderContext.setInputStream(inputStream); + blenderContext.setBlenderKey(blenderKey); // creating helpers - dataRepository.putHelper(ArmatureHelper.class, new ArmatureHelper(inputStream.getVersionNumber())); - dataRepository.putHelper(TextureHelper.class, new TextureHelper(inputStream.getVersionNumber())); - dataRepository.putHelper(MeshHelper.class, new MeshHelper(inputStream.getVersionNumber())); - dataRepository.putHelper(ObjectHelper.class, new ObjectHelper(inputStream.getVersionNumber())); - dataRepository.putHelper(CurvesHelper.class, new CurvesHelper(inputStream.getVersionNumber())); - dataRepository.putHelper(LightHelper.class, new LightHelper(inputStream.getVersionNumber())); - dataRepository.putHelper(CameraHelper.class, new CameraHelper(inputStream.getVersionNumber())); - dataRepository.putHelper(ModifierHelper.class, new ModifierHelper(inputStream.getVersionNumber())); - dataRepository.putHelper(MaterialHelper.class, new MaterialHelper(inputStream.getVersionNumber())); - dataRepository.putHelper(ConstraintHelper.class, new ConstraintHelper(inputStream.getVersionNumber(), dataRepository)); - dataRepository.putHelper(IpoHelper.class, new IpoHelper(inputStream.getVersionNumber())); - dataRepository.putHelper(ParticlesHelper.class, new ParticlesHelper(inputStream.getVersionNumber())); + blenderContext.putHelper(ArmatureHelper.class, new ArmatureHelper(inputStream.getVersionNumber())); + blenderContext.putHelper(TextureHelper.class, new TextureHelper(inputStream.getVersionNumber())); + blenderContext.putHelper(MeshHelper.class, new MeshHelper(inputStream.getVersionNumber())); + blenderContext.putHelper(ObjectHelper.class, new ObjectHelper(inputStream.getVersionNumber())); + blenderContext.putHelper(CurvesHelper.class, new CurvesHelper(inputStream.getVersionNumber())); + blenderContext.putHelper(LightHelper.class, new LightHelper(inputStream.getVersionNumber())); + blenderContext.putHelper(CameraHelper.class, new CameraHelper(inputStream.getVersionNumber())); + blenderContext.putHelper(ModifierHelper.class, new ModifierHelper(inputStream.getVersionNumber())); + blenderContext.putHelper(MaterialHelper.class, new MaterialHelper(inputStream.getVersionNumber())); + blenderContext.putHelper(ConstraintHelper.class, new ConstraintHelper(inputStream.getVersionNumber(), blenderContext)); + blenderContext.putHelper(IpoHelper.class, new IpoHelper(inputStream.getVersionNumber())); + blenderContext.putHelper(ParticlesHelper.class, new ParticlesHelper(inputStream.getVersionNumber())); // setting additional data to helpers if (blenderKey.isFixUpAxis()) { - ObjectHelper objectHelper = dataRepository.getHelper(ObjectHelper.class); + ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class); objectHelper.setyIsUpAxis(true); - CurvesHelper curvesHelper = dataRepository.getHelper(CurvesHelper.class); + CurvesHelper curvesHelper = blenderContext.getHelper(CurvesHelper.class); curvesHelper.setyIsUpAxis(true); } - MaterialHelper materialHelper = dataRepository.getHelper(MaterialHelper.class); + MaterialHelper materialHelper = blenderContext.getHelper(MaterialHelper.class); materialHelper.setFaceCullMode(blenderKey.getFaceCullMode()); - // reading the blocks (dna block is automatically saved in the data repository when found)//TODO: zmienić to + // reading the blocks (dna block is automatically saved in the blender context when found)//TODO: zmienić to FileBlockHeader sceneFileBlock = null; do { - fileBlock = new FileBlockHeader(inputStream, dataRepository); + fileBlock = new FileBlockHeader(inputStream, blenderContext); if (!fileBlock.isDnaBlock()) { blocks.add(fileBlock); // save the scene's file block @@ -214,10 +214,10 @@ public class BlenderLoader implements AssetLoader { } while (!fileBlock.isLastBlock()); // VERIFY LAYERS TO BE LOADED BEFORE LOADING FEATURES if (sceneFileBlock != null) { - int lay = ((Number) sceneFileBlock.getStructure(dataRepository).getFieldValue("lay")).intValue(); - dataRepository.getBlenderKey().setLayersToLoad(lay);// load only current layer + int lay = ((Number) sceneFileBlock.getStructure(blenderContext).getFieldValue("lay")).intValue(); + blenderContext.getBlenderKey().setLayersToLoad(lay);// load only current layer } - converter = new JmeConverter(dataRepository); + converter = new JmeConverter(blenderContext); } } diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/BlenderModelLoader.java b/engine/src/blender/com/jme3/scene/plugins/blender/BlenderModelLoader.java index e6b4115f3..8ec24e5e5 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/BlenderModelLoader.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/BlenderModelLoader.java @@ -61,7 +61,7 @@ public class BlenderModelLoader extends BlenderLoader { for (FileBlockHeader block : blocks) { if (block.getCode() == FileBlockHeader.BLOCK_OB00) { - Object object = converter.toObject(block.getStructure(dataRepository)); + Object object = converter.toObject(block.getStructure(blenderContext)); if (object instanceof Node) { LOGGER.log(Level.INFO, "{0}: {1}--> {2}", new Object[]{((Node) object).getName(), ((Node) object).getLocalTranslation().toString(), ((Node) object).getParent() == null ? "null" : ((Node) object).getParent().getName()}); if (((Node) object).getParent() == null) { diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/JmeConverter.java b/engine/src/blender/com/jme3/scene/plugins/blender/JmeConverter.java index 65813c7ce..799dee732 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/JmeConverter.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/JmeConverter.java @@ -56,32 +56,32 @@ import com.jme3.scene.plugins.blender.objects.ObjectHelper; */ /* package */class JmeConverter { - private final DataRepository dataRepository; + private final BlenderContext blenderContext; /** * Constructor. Creates the loader and checks if the given data is correct. - * @param dataRepository - * the data repository; it should have the following field set: - asset manager - blender key - dna block + * @param blenderContext + * the blender context; it should have the following field set: - asset manager - blender key - dna block * data - blender input stream Otherwise IllegalArgumentException will be thrown. * @param featuresToLoad * bitwise flag describing what features are to be loaded * @see FeaturesToLoad FeaturesToLoad */ - public JmeConverter(DataRepository dataRepository) { + public JmeConverter(BlenderContext blenderContext) { // validating the given data first - if (dataRepository.getAssetManager() == null) { + if (blenderContext.getAssetManager() == null) { throw new IllegalArgumentException("Cannot find asset manager!"); } - if (dataRepository.getBlenderKey() == null) { + if (blenderContext.getBlenderKey() == null) { throw new IllegalArgumentException("Cannot find blender key!"); } - if (dataRepository.getDnaBlockData() == null) { + if (blenderContext.getDnaBlockData() == null) { throw new IllegalArgumentException("Cannot find dna block!"); } - if (dataRepository.getInputStream() == null) { + if (blenderContext.getInputStream() == null) { throw new IllegalArgumentException("Cannot find blender file stream!"); } - this.dataRepository = dataRepository; + this.blenderContext = blenderContext; } /** @@ -91,7 +91,7 @@ import com.jme3.scene.plugins.blender.objects.ObjectHelper; * @return scene's node */ public Node toScene(Structure structure) {// TODO: import the scene - if ((dataRepository.getBlenderKey().getFeaturesToLoad() & FeaturesToLoad.SCENES) == 0) { + if ((blenderContext.getBlenderKey().getFeaturesToLoad() & FeaturesToLoad.SCENES) == 0) { return null; } return new Node(structure.getName()); @@ -104,8 +104,8 @@ import com.jme3.scene.plugins.blender.objects.ObjectHelper; * @return camera's node */ public Camera toCamera(Structure structure) throws BlenderFileException { - CameraHelper cameraHelper = dataRepository.getHelper(CameraHelper.class); - if (cameraHelper.shouldBeLoaded(structure, dataRepository)) { + CameraHelper cameraHelper = blenderContext.getHelper(CameraHelper.class); + if (cameraHelper.shouldBeLoaded(structure, blenderContext)) { return cameraHelper.toCamera(structure); } return null; @@ -118,9 +118,9 @@ import com.jme3.scene.plugins.blender.objects.ObjectHelper; * @return light's node */ public Light toLight(Structure structure) throws BlenderFileException { - LightHelper lightHelper = dataRepository.getHelper(LightHelper.class); - if (lightHelper.shouldBeLoaded(structure, dataRepository)) { - return lightHelper.toLight(structure, dataRepository); + LightHelper lightHelper = blenderContext.getHelper(LightHelper.class); + if (lightHelper.shouldBeLoaded(structure, blenderContext)) { + return lightHelper.toLight(structure, blenderContext); } return null; } @@ -132,9 +132,9 @@ import com.jme3.scene.plugins.blender.objects.ObjectHelper; * @return object's node */ public Object toObject(Structure structure) throws BlenderFileException { - ObjectHelper objectHelper = dataRepository.getHelper(ObjectHelper.class); - if (objectHelper.shouldBeLoaded(structure, dataRepository)) { - return objectHelper.toObject(structure, dataRepository); + ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class); + if (objectHelper.shouldBeLoaded(structure, blenderContext)) { + return objectHelper.toObject(structure, blenderContext); } return null; } @@ -146,9 +146,9 @@ import com.jme3.scene.plugins.blender.objects.ObjectHelper; * @return list of geometries */ public List toMesh(Structure structure) throws BlenderFileException { - MeshHelper meshHelper = dataRepository.getHelper(MeshHelper.class); - if (meshHelper.shouldBeLoaded(structure, dataRepository)) { - return meshHelper.toMesh(structure, dataRepository); + MeshHelper meshHelper = blenderContext.getHelper(MeshHelper.class); + if (meshHelper.shouldBeLoaded(structure, blenderContext)) { + return meshHelper.toMesh(structure, blenderContext); } return null; } @@ -160,9 +160,9 @@ import com.jme3.scene.plugins.blender.objects.ObjectHelper; * @return material's node */ public Material toMaterial(Structure structure) throws BlenderFileException { - MaterialHelper materialHelper = dataRepository.getHelper(MaterialHelper.class); - if (materialHelper.shouldBeLoaded(structure, dataRepository)) { - return materialHelper.toMaterial(structure, dataRepository); + MaterialHelper materialHelper = blenderContext.getHelper(MaterialHelper.class); + if (materialHelper.shouldBeLoaded(structure, blenderContext)) { + return materialHelper.toMaterial(structure, blenderContext); } return null; } 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 0c3894655..3893b6ab6 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 @@ -43,7 +43,7 @@ import com.jme3.animation.BoneTrack; import com.jme3.math.Matrix4f; import com.jme3.math.Vector3f; import com.jme3.scene.plugins.blender.AbstractBlenderHelper; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.curves.BezierCurve; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.BlenderInputStream; @@ -104,11 +104,11 @@ public class ArmatureHelper extends AbstractBlenderHelper { * @throws BlenderFileException * this exception is thrown when the blender file is somehow corrupted */ - public Map getGroupToBoneIndexMap(Structure defBaseStructure, DataRepository dataRepository) throws BlenderFileException { + public Map getGroupToBoneIndexMap(Structure defBaseStructure, BlenderContext blenderContext) throws BlenderFileException { Map result = null; if (bonesMap != null && bonesMap.size() != 0) { result = new HashMap(); - List deformGroups = defBaseStructure.evaluateListBase(dataRepository);//bDeformGroup + List deformGroups = defBaseStructure.evaluateListBase(blenderContext);//bDeformGroup int groupIndex = 0; for (Structure deformGroup : deformGroups) { String deformGroupName = deformGroup.getFieldValue("name").toString(); @@ -146,14 +146,14 @@ public class ArmatureHelper extends AbstractBlenderHelper { * a structure containing the bone data * @param parent * the bone parent; if null then we read the root bone - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @return the bone transformation data; contains bone chierarchy and the bone's matrices * @throws BlenderFileException * this exception is thrown when the blender file is somehow corrupted */ @SuppressWarnings("unchecked") - public BoneTransformationData readBoneAndItsChildren(Structure boneStructure, BoneTransformationData parent, DataRepository dataRepository) throws BlenderFileException { + public BoneTransformationData readBoneAndItsChildren(Structure boneStructure, BoneTransformationData parent, BlenderContext blenderContext) throws BlenderFileException { String name = boneStructure.getFieldValue("name").toString(); Bone bone = new Bone(name); int bonesAmount = bonesOMAs.size(); @@ -165,12 +165,12 @@ public class ArmatureHelper extends AbstractBlenderHelper { DynamicArray sizeArray = (DynamicArray) boneStructure.getFieldValue("size"); Vector3f size = new Vector3f(sizeArray.get(0), sizeArray.get(1), sizeArray.get(2)); BoneTransformationData boneTransformationData = new BoneTransformationData(boneArmatureMatrix, size, bone, parent); - dataRepository.addLoadedFeatures(boneStructure.getOldMemoryAddress(), name, boneStructure, bone); + blenderContext.addLoadedFeatures(boneStructure.getOldMemoryAddress(), name, boneStructure, bone); Structure childbase = (Structure) boneStructure.getFieldValue("childbase"); - List children = childbase.evaluateListBase(dataRepository);//Bone + List children = childbase.evaluateListBase(blenderContext);//Bone for (Structure boneChild : children) { - this.readBoneAndItsChildren(boneChild, boneTransformationData, dataRepository); + this.readBoneAndItsChildren(boneChild, boneTransformationData, blenderContext); } return boneTransformationData; } @@ -293,7 +293,7 @@ public class ArmatureHelper extends AbstractBlenderHelper { } @Override - public boolean shouldBeLoaded(Structure structure, DataRepository dataRepository) { + public boolean shouldBeLoaded(Structure structure, BlenderContext blenderContext) { return true; } @@ -302,8 +302,8 @@ public class ArmatureHelper extends AbstractBlenderHelper { * * @param actionStructure * the structure containing the tracks - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @param objectName * the name of the object that will use these tracks * @param animationName @@ -313,11 +313,11 @@ public class ArmatureHelper extends AbstractBlenderHelper { * an exception is thrown when there are problems with the blend * file */ - public BoneTrack[] getTracks(Structure actionStructure, DataRepository dataRepository, String objectName, String animationName) throws BlenderFileException { + public BoneTrack[] getTracks(Structure actionStructure, BlenderContext blenderContext, String objectName, String animationName) throws BlenderFileException { if (blenderVersion < 250) { - return this.getTracks249(actionStructure, dataRepository, objectName, animationName); + return this.getTracks249(actionStructure, blenderContext, objectName, animationName); } else { - return this.getTracks250(actionStructure, dataRepository, objectName, animationName); + return this.getTracks250(actionStructure, blenderContext, objectName, animationName); } } @@ -326,8 +326,8 @@ public class ArmatureHelper extends AbstractBlenderHelper { * * @param actionStructure * the structure containing the tracks - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @param objectName * the name of the object that will use these tracks * @param animationName @@ -337,12 +337,12 @@ public class ArmatureHelper extends AbstractBlenderHelper { * an exception is thrown when there are problems with the blend * file */ - private BoneTrack[] getTracks250(Structure actionStructure, DataRepository dataRepository, String objectName, String animationName) throws BlenderFileException { + private BoneTrack[] getTracks250(Structure actionStructure, BlenderContext blenderContext, String objectName, String animationName) throws BlenderFileException { LOGGER.log(Level.INFO, "Getting tracks!"); - int fps = dataRepository.getBlenderKey().getFps(); - int[] animationFrames = dataRepository.getBlenderKey().getAnimationFrames(objectName, animationName); + int fps = blenderContext.getBlenderKey().getFps(); + int[] animationFrames = blenderContext.getBlenderKey().getAnimationFrames(objectName, animationName); Structure groups = (Structure) actionStructure.getFieldValue("groups"); - List actionGroups = groups.evaluateListBase(dataRepository);//bActionGroup + List actionGroups = groups.evaluateListBase(blenderContext);//bActionGroup if (actionGroups != null && actionGroups.size() > 0 && (bonesMap == null || bonesMap.size() == 0)) { throw new IllegalStateException("No bones found! Cannot proceed to calculating tracks!"); } @@ -352,15 +352,15 @@ public class ArmatureHelper extends AbstractBlenderHelper { String name = actionGroup.getFieldValue("name").toString(); Integer boneIndex = bonesMap.get(name); if (boneIndex != null) { - List channels = ((Structure) actionGroup.getFieldValue("channels")).evaluateListBase(dataRepository); + List channels = ((Structure) actionGroup.getFieldValue("channels")).evaluateListBase(blenderContext); BezierCurve[] bezierCurves = new BezierCurve[channels.size()]; int channelCounter = 0; for (Structure c : channels) { //reading rna path first - BlenderInputStream bis = dataRepository.getInputStream(); + BlenderInputStream bis = blenderContext.getInputStream(); int currentPosition = bis.getPosition(); Pointer pRnaPath = (Pointer) c.getFieldValue("rna_path"); - FileBlockHeader dataFileBlock = dataRepository.getFileBlock(pRnaPath.getOldMemoryAddress()); + FileBlockHeader dataFileBlock = blenderContext.getFileBlock(pRnaPath.getOldMemoryAddress()); bis.setPosition(dataFileBlock.getBlockPosition()); String rnaPath = bis.readString(); bis.setPosition(currentPosition); @@ -368,7 +368,7 @@ public class ArmatureHelper extends AbstractBlenderHelper { int type = this.getCurveType(rnaPath, arrayIndex); Pointer pBezTriple = (Pointer) c.getFieldValue("bezt"); - List bezTriples = pBezTriple.fetchData(dataRepository.getInputStream()); + List bezTriples = pBezTriple.fetchData(blenderContext.getInputStream()); bezierCurves[channelCounter++] = new BezierCurve(type, bezTriples, 2); } @@ -384,8 +384,8 @@ public class ArmatureHelper extends AbstractBlenderHelper { * * @param actionStructure * the structure containing the tracks - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @param objectName * the name of the object that will use these tracks * @param animationName @@ -395,13 +395,13 @@ public class ArmatureHelper extends AbstractBlenderHelper { * an exception is thrown when there are problems with the blend * file */ - private BoneTrack[] getTracks249(Structure actionStructure, DataRepository dataRepository, String objectName, String animationName) throws BlenderFileException { + private BoneTrack[] getTracks249(Structure actionStructure, BlenderContext blenderContext, String objectName, String animationName) throws BlenderFileException { LOGGER.log(Level.INFO, "Getting tracks!"); - IpoHelper ipoHelper = dataRepository.getHelper(IpoHelper.class); - int fps = dataRepository.getBlenderKey().getFps(); - int[] animationFrames = dataRepository.getBlenderKey().getAnimationFrames(objectName, animationName); + IpoHelper ipoHelper = blenderContext.getHelper(IpoHelper.class); + int fps = blenderContext.getBlenderKey().getFps(); + int[] animationFrames = blenderContext.getBlenderKey().getAnimationFrames(objectName, animationName); Structure chanbase = (Structure) actionStructure.getFieldValue("chanbase"); - List actionChannels = chanbase.evaluateListBase(dataRepository);//bActionChannel + List actionChannels = chanbase.evaluateListBase(blenderContext);//bActionChannel if (actionChannels != null && actionChannels.size() > 0 && (bonesMap == null || bonesMap.size() == 0)) { throw new IllegalStateException("No bones found! Cannot proceed to calculating tracks!"); } @@ -412,8 +412,8 @@ public class ArmatureHelper extends AbstractBlenderHelper { if (boneIndex != null) { Pointer p = (Pointer) bActionChannel.getFieldValue("ipo"); if (!p.isNull()) { - Structure ipoStructure = p.fetchData(dataRepository.getInputStream()).get(0); - Ipo ipo = ipoHelper.createIpo(ipoStructure, dataRepository); + Structure ipoStructure = p.fetchData(blenderContext.getInputStream()).get(0); + Ipo ipo = ipoHelper.createIpo(ipoStructure, blenderContext); tracks.add(ipo.calculateTrack(boneIndex.intValue(), animationFrames[0], animationFrames[1], fps)); } } 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 b46d48b7a..9b12c3e2b 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 @@ -4,7 +4,7 @@ import java.util.List; import com.jme3.animation.BoneTrack; import com.jme3.scene.plugins.blender.AbstractBlenderHelper; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.curves.BezierCurve; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Pointer; @@ -31,30 +31,30 @@ public class IpoHelper extends AbstractBlenderHelper { * This method creates an ipo object used for interpolation calculations. * @param ipoStructure * the structure with ipo definition - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @return the ipo object * @throws BlenderFileException * this exception is thrown when the blender file is somehow corrupted */ - public Ipo createIpo(Structure ipoStructure, DataRepository dataRepository) throws BlenderFileException { + public Ipo createIpo(Structure ipoStructure, BlenderContext blenderContext) throws BlenderFileException { Structure curvebase = (Structure) ipoStructure.getFieldValue("curve"); //preparing bezier curves Ipo result = null; - List curves = curvebase.evaluateListBase(dataRepository);//IpoCurve + List curves = curvebase.evaluateListBase(blenderContext);//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(dataRepository.getInputStream()); + List bezTriples = pBezTriple.fetchData(blenderContext.getInputStream()); int type = ((Number) curve.getFieldValue("adrcode")).intValue(); bezierCurves[frame++] = new BezierCurve(type, bezTriples, 2); } curves.clear(); result = new Ipo(bezierCurves); - dataRepository.addLoadedFeatures(ipoStructure.getOldMemoryAddress(), ipoStructure.getName(), ipoStructure, result); + blenderContext.addLoadedFeatures(ipoStructure.getOldMemoryAddress(), ipoStructure.getName(), ipoStructure, result); } return result; } @@ -71,7 +71,7 @@ public class IpoHelper extends AbstractBlenderHelper { } @Override - public boolean shouldBeLoaded(Structure structure, DataRepository dataRepository) { + public boolean shouldBeLoaded(Structure structure, BlenderContext blenderContext) { return true; } diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/cameras/CameraHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/cameras/CameraHelper.java index ee90e7aad..19aae9676 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/cameras/CameraHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/cameras/CameraHelper.java @@ -6,7 +6,7 @@ import java.util.logging.Logger; import com.jme3.asset.BlenderKey.FeaturesToLoad; import com.jme3.renderer.Camera; import com.jme3.scene.plugins.blender.AbstractBlenderHelper; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Structure; @@ -112,7 +112,7 @@ public class CameraHelper extends AbstractBlenderHelper { } @Override - public boolean shouldBeLoaded(Structure structure, DataRepository dataRepository) { - return (dataRepository.getBlenderKey().getFeaturesToLoad() & FeaturesToLoad.CAMERAS) != 0; + public boolean shouldBeLoaded(Structure structure, BlenderContext blenderContext) { + return (blenderContext.getBlenderKey().getFeaturesToLoad() & FeaturesToLoad.CAMERAS) != 0; } } 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 37a06fd8d..b3d185ab7 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 @@ -7,8 +7,8 @@ import com.jme3.animation.Skeleton; import com.jme3.math.Quaternion; import com.jme3.math.Vector3f; import com.jme3.scene.Node; -import com.jme3.scene.plugins.blender.DataRepository; -import com.jme3.scene.plugins.blender.DataRepository.LoadedFeatureDataType; +import com.jme3.scene.plugins.blender.BlenderContext; +import com.jme3.scene.plugins.blender.BlenderContext.LoadedFeatureDataType; import com.jme3.scene.plugins.blender.animations.Ipo; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Pointer; @@ -32,7 +32,7 @@ public abstract class Constraint { protected final Structure data; /** The ipo object defining influence. */ protected final Ipo ipo; - protected DataRepository dataRepository; + protected BlenderContext blenderContext; /** * This constructor creates the constraint instance. * @@ -42,14 +42,14 @@ public abstract class Constraint { * the old memory address of the constraint owner * @param influenceIpo * the ipo curve of the influence factor - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception is thrown when the blender file is somehow * corrupted */ public Constraint(Structure constraintStructure, Long boneOMA, - Ipo influenceIpo, DataRepository dataRepository) throws BlenderFileException { + Ipo influenceIpo, BlenderContext blenderContext) throws BlenderFileException { this.name = constraintStructure.getFieldValue("name").toString(); ConstraintType constraintType = ConstraintType.valueOf(((Number)constraintStructure.getFieldValue("type")).intValue()); if(constraintType != this.getType()) { @@ -57,7 +57,7 @@ public abstract class Constraint { } Pointer pData = (Pointer) constraintStructure.getFieldValue("data"); if (pData.isNotNull()) { - data = pData.fetchData(dataRepository.getInputStream()).get(0); + data = pData.fetchData(blenderContext.getInputStream()).get(0); } else { throw new BlenderFileException("The constraint has no data specified!"); } @@ -102,7 +102,7 @@ public abstract class Constraint { * @return the bone track for the bone that is being affected by the constraint */ protected BoneTrack getBoneTrack(Skeleton skeleton, BoneAnimation boneAnimation) { - Bone bone = (Bone) dataRepository.getLoadedFeature(boneOMA, LoadedFeatureDataType.LOADED_FEATURE); + Bone bone = (Bone) blenderContext.getLoadedFeature(boneOMA, LoadedFeatureDataType.LOADED_FEATURE); int boneIndex = bone==null ? 0 : skeleton.getBoneIndex(bone);//bone==null may mean the object animation if (boneIndex != -1) { //searching for track for this bone @@ -124,17 +124,17 @@ public abstract class Constraint { protected Object getTarget(LoadedFeatureDataType loadedFeatureDataType) throws BlenderFileException { //load the feature through objectHelper, this way we are certain the object loads and has //his own constraints applied to traces - ObjectHelper objectHelper = dataRepository.getHelper(ObjectHelper.class); + ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class); //always load the target first Long targetOMA = ((Pointer) data.getFieldValue("tar")).getOldMemoryAddress(); - Structure objectStructure = dataRepository.getFileBlock(targetOMA).getStructure(dataRepository); - Object result = objectHelper.toObject(objectStructure, dataRepository); + Structure objectStructure = blenderContext.getFileBlock(targetOMA).getStructure(blenderContext); + Object result = objectHelper.toObject(objectStructure, blenderContext); //subtarget should be loaded alogn with target Object subtarget = data.getFieldValue("subtarget"); String subtargetName = subtarget==null ? null : subtarget.toString(); if (subtargetName!=null && subtargetName.length() > 0) { - result = dataRepository.getLoadedFeature(subtargetName, loadedFeatureDataType); + result = blenderContext.getLoadedFeature(subtargetName, loadedFeatureDataType); } return result; } @@ -145,7 +145,7 @@ public abstract class Constraint { */ protected Vector3f getTargetLocation() { Long targetOMA = ((Pointer) data.getFieldValue("tar")).getOldMemoryAddress(); - Node targetObject = (Node) dataRepository.getLoadedFeature(targetOMA, LoadedFeatureDataType.LOADED_FEATURE); + Node targetObject = (Node) blenderContext.getLoadedFeature(targetOMA, LoadedFeatureDataType.LOADED_FEATURE); switch (targetSpace) { case CONSTRAINT_SPACE_LOCAL: return targetObject.getLocalTranslation(); @@ -172,7 +172,7 @@ public abstract class Constraint { */ protected Quaternion getTargetRotation() { Long targetOMA = ((Pointer) data.getFieldValue("tar")).getOldMemoryAddress(); - Node targetObject = (Node) dataRepository.getLoadedFeature(targetOMA, LoadedFeatureDataType.LOADED_FEATURE); + Node targetObject = (Node) blenderContext.getLoadedFeature(targetOMA, LoadedFeatureDataType.LOADED_FEATURE); switch (targetSpace) { case CONSTRAINT_SPACE_LOCAL: return targetObject.getLocalRotation(); @@ -189,7 +189,7 @@ public abstract class Constraint { */ protected Vector3f getTargetScale() { Long targetOMA = ((Pointer) data.getFieldValue("tar")).getOldMemoryAddress(); - Node targetObject = (Node) dataRepository.getLoadedFeature(targetOMA, LoadedFeatureDataType.LOADED_FEATURE); + Node targetObject = (Node) blenderContext.getLoadedFeature(targetOMA, LoadedFeatureDataType.LOADED_FEATURE); switch (targetSpace) { case CONSTRAINT_SPACE_LOCAL: return targetObject.getLocalScale(); diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintAction.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintAction.java index 9bf3f715c..ad1f7163c 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintAction.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintAction.java @@ -5,7 +5,7 @@ import java.util.logging.Logger; import com.jme3.animation.BoneAnimation; import com.jme3.animation.Skeleton; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.animations.Ipo; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Structure; @@ -26,15 +26,15 @@ import com.jme3.scene.plugins.blender.file.Structure; * the old memory address of the constraint owner * @param influenceIpo * the ipo curve of the influence factor - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception is thrown when the blender file is somehow * corrupted */ public ConstraintAction(Structure constraintStructure, Long boneOMA, - Ipo influenceIpo, DataRepository dataRepository) throws BlenderFileException { - super(constraintStructure, boneOMA, influenceIpo, dataRepository); + Ipo influenceIpo, BlenderContext blenderContext) throws BlenderFileException { + super(constraintStructure, boneOMA, influenceIpo, blenderContext); } @Override diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintChildOf.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintChildOf.java index 516ec45f3..ea66a01b9 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintChildOf.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintChildOf.java @@ -5,7 +5,7 @@ import java.util.logging.Logger; import com.jme3.animation.BoneAnimation; import com.jme3.animation.Skeleton; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.animations.Ipo; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Structure; @@ -26,15 +26,15 @@ import com.jme3.scene.plugins.blender.file.Structure; * the old memory address of the constraint owner * @param influenceIpo * the ipo curve of the influence factor - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception is thrown when the blender file is somehow * corrupted */ public ConstraintChildOf(Structure constraintStructure, Long boneOMA, - Ipo influenceIpo, DataRepository dataRepository) throws BlenderFileException { - super(constraintStructure, boneOMA, influenceIpo, dataRepository); + Ipo influenceIpo, BlenderContext blenderContext) throws BlenderFileException { + super(constraintStructure, boneOMA, influenceIpo, blenderContext); } @Override diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintClampTo.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintClampTo.java index 92cc0b88a..1a3723ce0 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintClampTo.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintClampTo.java @@ -5,7 +5,7 @@ import java.util.logging.Logger; import com.jme3.animation.BoneAnimation; import com.jme3.animation.Skeleton; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.animations.Ipo; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Structure; @@ -26,16 +26,16 @@ import com.jme3.scene.plugins.blender.file.Structure; * the old memory address of the constraint owner * @param influenceIpo * the ipo curve of the influence factor - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception is thrown when the blender file is somehow * corrupted */ public ConstraintClampTo(Structure constraintStructure, Long boneOMA, - Ipo influenceIpo, DataRepository dataRepository) + Ipo influenceIpo, BlenderContext blenderContext) throws BlenderFileException { - super(constraintStructure, boneOMA, influenceIpo, dataRepository); + super(constraintStructure, boneOMA, influenceIpo, blenderContext); } @Override diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintDistLimit.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintDistLimit.java index 43eba271e..9f6620b2b 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintDistLimit.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintDistLimit.java @@ -4,7 +4,7 @@ import com.jme3.animation.BoneAnimation; import com.jme3.animation.BoneTrack; import com.jme3.animation.Skeleton; import com.jme3.math.Vector3f; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.animations.Ipo; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Structure; @@ -27,15 +27,15 @@ import com.jme3.scene.plugins.blender.file.Structure; * the old memory address of the constraint owner * @param influenceIpo * the ipo curve of the influence factor - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception is thrown when the blender file is somehow * corrupted */ public ConstraintDistLimit(Structure constraintStructure, Long boneOMA, - Ipo influenceIpo, DataRepository dataRepository) throws BlenderFileException { - super(constraintStructure, boneOMA, influenceIpo, dataRepository); + Ipo influenceIpo, BlenderContext blenderContext) throws BlenderFileException { + super(constraintStructure, boneOMA, influenceIpo, blenderContext); } @Override diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintFactory.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintFactory.java index 2b36c55bd..dd58b14fe 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintFactory.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintFactory.java @@ -1,6 +1,6 @@ package com.jme3.scene.plugins.blender.constraints; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.animations.Ipo; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Structure; @@ -21,56 +21,56 @@ import com.jme3.scene.plugins.blender.file.Structure; * the old memory address of the constraint owner * @param influenceIpo * the ipo curve of the influence factor - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception is thrown when the blender file is somehow * corrupted */ - public static Constraint createConstraint(Structure constraintStructure, Long boneOMA, Ipo influenceIpo, DataRepository dataRepository) throws BlenderFileException { + public static Constraint createConstraint(Structure constraintStructure, Long boneOMA, Ipo influenceIpo, BlenderContext blenderContext) throws BlenderFileException { int type = ((Number)constraintStructure.getFieldValue("type")).intValue(); ConstraintType constraintType = ConstraintType.valueOf(type); switch(constraintType) { case CONSTRAINT_TYPE_ACTION: - return new ConstraintAction(constraintStructure, boneOMA, influenceIpo, dataRepository); + return new ConstraintAction(constraintStructure, boneOMA, influenceIpo, blenderContext); case CONSTRAINT_TYPE_CHILDOF: - return new ConstraintChildOf(constraintStructure, boneOMA, influenceIpo, dataRepository); + return new ConstraintChildOf(constraintStructure, boneOMA, influenceIpo, blenderContext); case CONSTRAINT_TYPE_CLAMPTO: - return new ConstraintClampTo(constraintStructure, boneOMA, influenceIpo, dataRepository); + return new ConstraintClampTo(constraintStructure, boneOMA, influenceIpo, blenderContext); case CONSTRAINT_TYPE_DISTLIMIT: - return new ConstraintDistLimit(constraintStructure, boneOMA, influenceIpo, dataRepository); + return new ConstraintDistLimit(constraintStructure, boneOMA, influenceIpo, blenderContext); case CONSTRAINT_TYPE_FOLLOWPATH: - return new ConstraintFollowPath(constraintStructure, boneOMA, influenceIpo, dataRepository); + return new ConstraintFollowPath(constraintStructure, boneOMA, influenceIpo, blenderContext); case CONSTRAINT_TYPE_KINEMATIC: - return new ConstraintInverseKinematics(constraintStructure, boneOMA, influenceIpo, dataRepository); + return new ConstraintInverseKinematics(constraintStructure, boneOMA, influenceIpo, blenderContext); case CONSTRAINT_TYPE_LOCKTRACK: - return new ConstraintLockTrack(constraintStructure, boneOMA, influenceIpo, dataRepository); + return new ConstraintLockTrack(constraintStructure, boneOMA, influenceIpo, blenderContext); case CONSTRAINT_TYPE_LOCLIKE: - return new ConstraintLocLike(constraintStructure, boneOMA, influenceIpo, dataRepository); + return new ConstraintLocLike(constraintStructure, boneOMA, influenceIpo, blenderContext); case CONSTRAINT_TYPE_LOCLIMIT: - return new ConstraintLocLimit(constraintStructure, boneOMA, influenceIpo, dataRepository); + return new ConstraintLocLimit(constraintStructure, boneOMA, influenceIpo, blenderContext); case CONSTRAINT_TYPE_MINMAX: - return new ConstraintMinMax(constraintStructure, boneOMA, influenceIpo, dataRepository); + return new ConstraintMinMax(constraintStructure, boneOMA, influenceIpo, blenderContext); case CONSTRAINT_TYPE_NULL: - return new ConstraintNull(constraintStructure, boneOMA, influenceIpo, dataRepository); + return new ConstraintNull(constraintStructure, boneOMA, influenceIpo, blenderContext); case CONSTRAINT_TYPE_PYTHON: - return new ConstraintPython(constraintStructure, boneOMA, influenceIpo, dataRepository); + return new ConstraintPython(constraintStructure, boneOMA, influenceIpo, blenderContext); case CONSTRAINT_TYPE_RIGIDBODYJOINT: - return new ConstraintRigidBodyJoint(constraintStructure, boneOMA, influenceIpo, dataRepository); + return new ConstraintRigidBodyJoint(constraintStructure, boneOMA, influenceIpo, blenderContext); case CONSTRAINT_TYPE_ROTLIKE: - return new ConstraintRotLike(constraintStructure, boneOMA, influenceIpo, dataRepository); + return new ConstraintRotLike(constraintStructure, boneOMA, influenceIpo, blenderContext); case CONSTRAINT_TYPE_ROTLIMIT: - return new ConstraintRotLimit(constraintStructure, boneOMA, influenceIpo, dataRepository); + return new ConstraintRotLimit(constraintStructure, boneOMA, influenceIpo, blenderContext); case CONSTRAINT_TYPE_SHRINKWRAP: - return new ConstraintShrinkWrap(constraintStructure, boneOMA, influenceIpo, dataRepository); + return new ConstraintShrinkWrap(constraintStructure, boneOMA, influenceIpo, blenderContext); case CONSTRAINT_TYPE_SIZELIKE: - return new ConstraintSizeLike(constraintStructure, boneOMA, influenceIpo, dataRepository); + return new ConstraintSizeLike(constraintStructure, boneOMA, influenceIpo, blenderContext); case CONSTRAINT_TYPE_SIZELIMIT: - return new ConstraintSizeLimit(constraintStructure, boneOMA, influenceIpo, dataRepository); + return new ConstraintSizeLimit(constraintStructure, boneOMA, influenceIpo, blenderContext); case CONSTRAINT_TYPE_STRETCHTO: - return new ConstraintStretchTo(constraintStructure, boneOMA, influenceIpo, dataRepository); + return new ConstraintStretchTo(constraintStructure, boneOMA, influenceIpo, blenderContext); case CONSTRAINT_TYPE_TRANSFORM: - return new ConstraintTransform(constraintStructure, boneOMA, influenceIpo, dataRepository); + return new ConstraintTransform(constraintStructure, boneOMA, influenceIpo, blenderContext); default: throw new IllegalStateException("Unknown constraint type: " + constraintType); } diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintFollowPath.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintFollowPath.java index c0975030d..94d1ae4fc 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintFollowPath.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintFollowPath.java @@ -5,7 +5,7 @@ import java.util.logging.Logger; import com.jme3.animation.BoneAnimation; import com.jme3.animation.Skeleton; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.animations.Ipo; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Structure; @@ -26,15 +26,15 @@ import com.jme3.scene.plugins.blender.file.Structure; * the old memory address of the constraint owner * @param influenceIpo * the ipo curve of the influence factor - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception is thrown when the blender file is somehow * corrupted */ public ConstraintFollowPath(Structure constraintStructure, Long boneOMA, - Ipo influenceIpo, DataRepository dataRepository) throws BlenderFileException { - super(constraintStructure, boneOMA, influenceIpo, dataRepository); + Ipo influenceIpo, BlenderContext blenderContext) throws BlenderFileException { + super(constraintStructure, boneOMA, influenceIpo, blenderContext); } @Override 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 b9737564a..2ec07d5b5 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 @@ -7,7 +7,7 @@ import java.util.Map; import java.util.logging.Logger; import com.jme3.scene.plugins.blender.AbstractBlenderHelper; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.animations.Ipo; import com.jme3.scene.plugins.blender.animations.IpoHelper; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; @@ -29,7 +29,7 @@ public class ConstraintHelper extends AbstractBlenderHelper { * @param blenderVersion * the version read from the blend file */ - public ConstraintHelper(String blenderVersion, DataRepository dataRepository) { + public ConstraintHelper(String blenderVersion, BlenderContext blenderContext) { super(blenderVersion); } @@ -39,34 +39,34 @@ public class ConstraintHelper extends AbstractBlenderHelper { * the owner's old memory address * @param objectStructure * the structure we read constraint's for - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException */ - public Map> loadConstraints(Structure objectStructure, DataRepository dataRepository) throws BlenderFileException { + public Map> loadConstraints(Structure objectStructure, BlenderContext blenderContext) throws BlenderFileException { if (blenderVersion >= 250) {//TODO LOGGER.warning("Loading of constraints not yet implemented for version 2.5x !"); return new HashMap>(0); } // reading influence ipos for the constraints - IpoHelper ipoHelper = dataRepository.getHelper(IpoHelper.class); + IpoHelper ipoHelper = blenderContext.getHelper(IpoHelper.class); Map> constraintsIpos = new HashMap>(); Pointer pActions = (Pointer) objectStructure.getFieldValue("action"); if (pActions.isNotNull()) { - List actions = pActions.fetchData(dataRepository.getInputStream()); + List actions = pActions.fetchData(blenderContext.getInputStream()); for (Structure action : actions) { Structure chanbase = (Structure) action.getFieldValue("chanbase"); - List actionChannels = chanbase.evaluateListBase(dataRepository); + List actionChannels = chanbase.evaluateListBase(blenderContext); for (Structure actionChannel : actionChannels) { Map ipos = new HashMap(); Structure constChannels = (Structure) actionChannel.getFieldValue("constraintChannels"); - List constraintChannels = constChannels.evaluateListBase(dataRepository); + List constraintChannels = constChannels.evaluateListBase(blenderContext); for (Structure constraintChannel : constraintChannels) { Pointer pIpo = (Pointer) constraintChannel.getFieldValue("ipo"); if (pIpo.isNotNull()) { String constraintName = constraintChannel.getFieldValue("name").toString(); - Ipo ipo = ipoHelper.createIpo(pIpo.fetchData(dataRepository.getInputStream()).get(0), dataRepository); + Ipo ipo = ipoHelper.createIpo(pIpo.fetchData(blenderContext.getInputStream()).get(0), blenderContext); ipos.put(constraintName, ipo); } } @@ -81,14 +81,14 @@ public class ConstraintHelper extends AbstractBlenderHelper { //loading constraints connected with the object's bones Pointer pPose = (Pointer) objectStructure.getFieldValue("pose");//TODO: what if the object has two armatures ???? if (pPose.isNotNull()) { - List poseChannels = ((Structure) pPose.fetchData(dataRepository.getInputStream()).get(0).getFieldValue("chanbase")).evaluateListBase(dataRepository); + List poseChannels = ((Structure) pPose.fetchData(blenderContext.getInputStream()).get(0).getFieldValue("chanbase")).evaluateListBase(blenderContext); for (Structure poseChannel : poseChannels) { List constraintsList = new ArrayList(); Long boneOMA = Long.valueOf(((Pointer) poseChannel.getFieldValue("bone")).getOldMemoryAddress()); //the name is read directly from structure because bone might not yet be loaded - String name = dataRepository.getFileBlock(boneOMA).getStructure(dataRepository).getFieldValue("name").toString(); - List constraints = ((Structure) poseChannel.getFieldValue("constraints")).evaluateListBase(dataRepository); + String name = blenderContext.getFileBlock(boneOMA).getStructure(blenderContext).getFieldValue("name").toString(); + List constraints = ((Structure) poseChannel.getFieldValue("constraints")).evaluateListBase(blenderContext); for (Structure constraint : constraints) { String constraintName = constraint.getFieldValue("name").toString(); Map ipoMap = constraintsIpos.get(name); @@ -97,22 +97,22 @@ public class ConstraintHelper extends AbstractBlenderHelper { float enforce = ((Number) constraint.getFieldValue("enforce")).floatValue(); ipo = ipoHelper.createIpo(enforce); } - constraintsList.add(ConstraintFactory.createConstraint(constraint, boneOMA, ipo, dataRepository)); + constraintsList.add(ConstraintFactory.createConstraint(constraint, boneOMA, ipo, blenderContext)); } result.put(boneOMA, constraintsList); - dataRepository.addConstraints(boneOMA, constraintsList); + blenderContext.addConstraints(boneOMA, constraintsList); } } // TODO: reading constraints for objects (implement when object's animation will be available) - List constraintChannels = ((Structure)objectStructure.getFieldValue("constraintChannels")).evaluateListBase(dataRepository); + List constraintChannels = ((Structure)objectStructure.getFieldValue("constraintChannels")).evaluateListBase(blenderContext); for(Structure constraintChannel : constraintChannels) { System.out.println(constraintChannel); } //loading constraints connected with the object itself (TODO: test this) if(!result.containsKey(objectStructure.getOldMemoryAddress())) { - List constraints = ((Structure)objectStructure.getFieldValue("constraints")).evaluateListBase(dataRepository); + List constraints = ((Structure)objectStructure.getFieldValue("constraints")).evaluateListBase(blenderContext); List constraintsList = new ArrayList(constraints.size()); for(Structure constraint : constraints) { @@ -125,16 +125,16 @@ public class ConstraintHelper extends AbstractBlenderHelper { float enforce = ((Number) constraint.getFieldValue("enforce")).floatValue(); ipo = ipoHelper.createIpo(enforce); } - constraintsList.add(ConstraintFactory.createConstraint(constraint, null, ipo, dataRepository)); + constraintsList.add(ConstraintFactory.createConstraint(constraint, null, ipo, blenderContext)); } result.put(objectStructure.getOldMemoryAddress(), constraintsList); - dataRepository.addConstraints(objectStructure.getOldMemoryAddress(), constraintsList); + blenderContext.addConstraints(objectStructure.getOldMemoryAddress(), constraintsList); } return result; } @Override - public boolean shouldBeLoaded(Structure structure, DataRepository dataRepository) { + public boolean shouldBeLoaded(Structure structure, BlenderContext blenderContext) { return true; } } diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintInverseKinematics.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintInverseKinematics.java index bb3f36ff7..69ac7abce 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintInverseKinematics.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintInverseKinematics.java @@ -12,8 +12,8 @@ import com.jme3.math.Quaternion; import com.jme3.math.Transform; import com.jme3.math.Vector3f; import com.jme3.scene.Node; -import com.jme3.scene.plugins.blender.DataRepository; -import com.jme3.scene.plugins.blender.DataRepository.LoadedFeatureDataType; +import com.jme3.scene.plugins.blender.BlenderContext; +import com.jme3.scene.plugins.blender.BlenderContext.LoadedFeatureDataType; import com.jme3.scene.plugins.blender.animations.CalculationBone; import com.jme3.scene.plugins.blender.animations.Ipo; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; @@ -37,22 +37,22 @@ import com.jme3.scene.plugins.blender.objects.ObjectHelper; * the old memory address of the constraint owner * @param influenceIpo * the ipo curve of the influence factor - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception is thrown when the blender file is somehow * corrupted */ public ConstraintInverseKinematics(Structure constraintStructure, - Long boneOMA, Ipo influenceIpo, DataRepository dataRepository) throws BlenderFileException { - super(constraintStructure, boneOMA, influenceIpo, dataRepository); + Long boneOMA, Ipo influenceIpo, BlenderContext blenderContext) throws BlenderFileException { + super(constraintStructure, boneOMA, influenceIpo, blenderContext); } @Override public void affectAnimation(Skeleton skeleton, BoneAnimation boneAnimation) { try { // IK solver is only attached to bones - Bone ownerBone = (Bone) dataRepository.getLoadedFeature(boneOMA, LoadedFeatureDataType.LOADED_FEATURE); + Bone ownerBone = (Bone) blenderContext.getLoadedFeature(boneOMA, LoadedFeatureDataType.LOADED_FEATURE); // get the target point Object targetObject = this.getTarget(LoadedFeatureDataType.LOADED_FEATURE); @@ -63,8 +63,8 @@ import com.jme3.scene.plugins.blender.objects.ObjectHelper; pt = ((Node) targetObject).getWorldTranslation(); } else if (targetObject instanceof Skeleton) { Structure armatureNodeStructure = (Structure) this.getTarget(LoadedFeatureDataType.LOADED_STRUCTURE); - ObjectHelper objectHelper = dataRepository.getHelper(ObjectHelper.class); - Transform transform = objectHelper.getTransformation(armatureNodeStructure, dataRepository); + ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class); + Transform transform = objectHelper.getTransformation(armatureNodeStructure, blenderContext); pt = transform.getTranslation(); } else { throw new IllegalStateException( diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintLocLike.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintLocLike.java index 15a9c4d6d..a956bb7a0 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintLocLike.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintLocLike.java @@ -4,7 +4,7 @@ import com.jme3.animation.BoneAnimation; import com.jme3.animation.BoneTrack; import com.jme3.animation.Skeleton; import com.jme3.math.Vector3f; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.animations.Ipo; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Structure; @@ -33,15 +33,15 @@ import com.jme3.scene.plugins.blender.file.Structure; * the old memory address of the constraint owner * @param influenceIpo * the ipo curve of the influence factor - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception is thrown when the blender file is somehow * corrupted */ public ConstraintLocLike(Structure constraintStructure, Long boneOMA, - Ipo influenceIpo, DataRepository dataRepository) throws BlenderFileException { - super(constraintStructure, boneOMA, influenceIpo, dataRepository); + Ipo influenceIpo, BlenderContext blenderContext) throws BlenderFileException { + super(constraintStructure, boneOMA, influenceIpo, blenderContext); } @Override diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintLocLimit.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintLocLimit.java index 081e1bb51..45a1bd665 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintLocLimit.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintLocLimit.java @@ -4,7 +4,7 @@ import com.jme3.animation.BoneAnimation; import com.jme3.animation.BoneTrack; import com.jme3.animation.Skeleton; import com.jme3.math.Vector3f; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.animations.Ipo; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Structure; @@ -30,15 +30,15 @@ import com.jme3.scene.plugins.blender.file.Structure; * the old memory address of the constraint owner * @param influenceIpo * the ipo curve of the influence factor - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception is thrown when the blender file is somehow * corrupted */ public ConstraintLocLimit(Structure constraintStructure, Long boneOMA, - Ipo influenceIpo, DataRepository dataRepository) throws BlenderFileException { - super(constraintStructure, boneOMA, influenceIpo, dataRepository); + Ipo influenceIpo, BlenderContext blenderContext) throws BlenderFileException { + super(constraintStructure, boneOMA, influenceIpo, blenderContext); } @Override diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintLockTrack.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintLockTrack.java index 89cec67c1..3bc91c2a5 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintLockTrack.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintLockTrack.java @@ -5,7 +5,7 @@ import java.util.logging.Logger; import com.jme3.animation.BoneAnimation; import com.jme3.animation.Skeleton; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.animations.Ipo; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Structure; @@ -26,16 +26,16 @@ import com.jme3.scene.plugins.blender.file.Structure; * the old memory address of the constraint owner * @param influenceIpo * the ipo curve of the influence factor - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception is thrown when the blender file is somehow * corrupted */ public ConstraintLockTrack(Structure constraintStructure, Long boneOMA, - Ipo influenceIpo, DataRepository dataRepository) + Ipo influenceIpo, BlenderContext blenderContext) throws BlenderFileException { - super(constraintStructure, boneOMA, influenceIpo, dataRepository); + super(constraintStructure, boneOMA, influenceIpo, blenderContext); } @Override diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintMinMax.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintMinMax.java index 699d0abf4..6013366cf 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintMinMax.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintMinMax.java @@ -5,7 +5,7 @@ import java.util.logging.Logger; import com.jme3.animation.BoneAnimation; import com.jme3.animation.Skeleton; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.animations.Ipo; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Structure; @@ -26,15 +26,15 @@ import com.jme3.scene.plugins.blender.file.Structure; * the old memory address of the constraint owner * @param influenceIpo * the ipo curve of the influence factor - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception is thrown when the blender file is somehow * corrupted */ public ConstraintMinMax(Structure constraintStructure, Long boneOMA, - Ipo influenceIpo, DataRepository dataRepository) throws BlenderFileException { - super(constraintStructure, boneOMA, influenceIpo, dataRepository); + Ipo influenceIpo, BlenderContext blenderContext) throws BlenderFileException { + super(constraintStructure, boneOMA, influenceIpo, blenderContext); } @Override diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintNull.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintNull.java index cbe584fee..275b0d03d 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintNull.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintNull.java @@ -2,7 +2,7 @@ package com.jme3.scene.plugins.blender.constraints; import com.jme3.animation.BoneAnimation; import com.jme3.animation.Skeleton; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.animations.Ipo; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Structure; @@ -22,16 +22,16 @@ import com.jme3.scene.plugins.blender.file.Structure; * the old memory address of the constraint owner * @param influenceIpo * the ipo curve of the influence factor - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception is thrown when the blender file is somehow * corrupted */ public ConstraintNull(Structure constraintStructure, Long boneOMA, - Ipo influenceIpo, DataRepository dataRepository) + Ipo influenceIpo, BlenderContext blenderContext) throws BlenderFileException { - super(constraintStructure, boneOMA, influenceIpo, dataRepository); + super(constraintStructure, boneOMA, influenceIpo, blenderContext); } @Override diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintPython.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintPython.java index df90eb33b..5d3861867 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintPython.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintPython.java @@ -5,7 +5,7 @@ import java.util.logging.Logger; import com.jme3.animation.BoneAnimation; import com.jme3.animation.Skeleton; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.animations.Ipo; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Structure; @@ -26,15 +26,15 @@ import com.jme3.scene.plugins.blender.file.Structure; * the old memory address of the constraint owner * @param influenceIpo * the ipo curve of the influence factor - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception is thrown when the blender file is somehow * corrupted */ public ConstraintPython(Structure constraintStructure, Long boneOMA, - Ipo influenceIpo, DataRepository dataRepository) throws BlenderFileException { - super(constraintStructure, boneOMA, influenceIpo, dataRepository); + Ipo influenceIpo, BlenderContext blenderContext) throws BlenderFileException { + super(constraintStructure, boneOMA, influenceIpo, blenderContext); } @Override diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintRigidBodyJoint.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintRigidBodyJoint.java index bbb843a99..fdd329c41 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintRigidBodyJoint.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintRigidBodyJoint.java @@ -5,7 +5,7 @@ import java.util.logging.Logger; import com.jme3.animation.BoneAnimation; import com.jme3.animation.Skeleton; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.animations.Ipo; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Structure; @@ -26,15 +26,15 @@ import com.jme3.scene.plugins.blender.file.Structure; * the old memory address of the constraint owner * @param influenceIpo * the ipo curve of the influence factor - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception is thrown when the blender file is somehow * corrupted */ public ConstraintRigidBodyJoint(Structure constraintStructure, - Long boneOMA, Ipo influenceIpo, DataRepository dataRepository) throws BlenderFileException { - super(constraintStructure, boneOMA, influenceIpo, dataRepository); + Long boneOMA, Ipo influenceIpo, BlenderContext blenderContext) throws BlenderFileException { + super(constraintStructure, boneOMA, influenceIpo, blenderContext); } @Override diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintRotLike.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintRotLike.java index b77133123..b91f1fe67 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintRotLike.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintRotLike.java @@ -4,7 +4,7 @@ import com.jme3.animation.BoneAnimation; import com.jme3.animation.BoneTrack; import com.jme3.animation.Skeleton; import com.jme3.math.Quaternion; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.animations.Ipo; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Structure; @@ -31,15 +31,15 @@ import com.jme3.scene.plugins.blender.file.Structure; * the old memory address of the constraint owner * @param influenceIpo * the ipo curve of the influence factor - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception is thrown when the blender file is somehow * corrupted */ public ConstraintRotLike(Structure constraintStructure, Long boneOMA, - Ipo influenceIpo, DataRepository dataRepository) throws BlenderFileException { - super(constraintStructure, boneOMA, influenceIpo, dataRepository); + Ipo influenceIpo, BlenderContext blenderContext) throws BlenderFileException { + super(constraintStructure, boneOMA, influenceIpo, blenderContext); } @Override diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintRotLimit.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintRotLimit.java index 4df401d3e..b1f102a4a 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintRotLimit.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintRotLimit.java @@ -5,7 +5,7 @@ import com.jme3.animation.BoneTrack; import com.jme3.animation.Skeleton; import com.jme3.math.FastMath; import com.jme3.math.Quaternion; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.animations.Ipo; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Structure; @@ -28,15 +28,15 @@ import com.jme3.scene.plugins.blender.file.Structure; * the old memory address of the constraint owner * @param influenceIpo * the ipo curve of the influence factor - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception is thrown when the blender file is somehow * corrupted */ public ConstraintRotLimit(Structure constraintStructure, Long boneOMA, - Ipo influenceIpo, DataRepository dataRepository) throws BlenderFileException { - super(constraintStructure, boneOMA, influenceIpo, dataRepository); + Ipo influenceIpo, BlenderContext blenderContext) throws BlenderFileException { + super(constraintStructure, boneOMA, influenceIpo, blenderContext); } @Override diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintShrinkWrap.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintShrinkWrap.java index 5b6dccdfe..551b32e8d 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintShrinkWrap.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintShrinkWrap.java @@ -15,8 +15,8 @@ import com.jme3.scene.Mesh; import com.jme3.scene.Node; import com.jme3.scene.Spatial; import com.jme3.scene.VertexBuffer.Type; -import com.jme3.scene.plugins.blender.DataRepository; -import com.jme3.scene.plugins.blender.DataRepository.LoadedFeatureDataType; +import com.jme3.scene.plugins.blender.BlenderContext; +import com.jme3.scene.plugins.blender.BlenderContext.LoadedFeatureDataType; import com.jme3.scene.plugins.blender.animations.Ipo; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Structure; @@ -37,15 +37,15 @@ import com.jme3.scene.plugins.blender.file.Structure; * the old memory address of the constraint owner * @param influenceIpo * the ipo curve of the influence factor - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception is thrown when the blender file is somehow * corrupted */ public ConstraintShrinkWrap(Structure constraintStructure, Long boneOMA, - Ipo influenceIpo, DataRepository dataRepository) throws BlenderFileException { - super(constraintStructure, boneOMA, influenceIpo, dataRepository); + Ipo influenceIpo, BlenderContext blenderContext) throws BlenderFileException { + super(constraintStructure, boneOMA, influenceIpo, blenderContext); } @Override diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintSizeLike.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintSizeLike.java index 9d79d5bd5..32d1952e5 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintSizeLike.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintSizeLike.java @@ -4,7 +4,7 @@ import com.jme3.animation.BoneAnimation; import com.jme3.animation.BoneTrack; import com.jme3.animation.Skeleton; import com.jme3.math.Vector3f; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.animations.Ipo; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Structure; @@ -28,15 +28,15 @@ import com.jme3.scene.plugins.blender.file.Structure; * the old memory address of the constraint owner * @param influenceIpo * the ipo curve of the influence factor - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception is thrown when the blender file is somehow * corrupted */ public ConstraintSizeLike(Structure constraintStructure, Long boneOMA, - Ipo influenceIpo, DataRepository dataRepository) throws BlenderFileException { - super(constraintStructure, boneOMA, influenceIpo, dataRepository); + Ipo influenceIpo, BlenderContext blenderContext) throws BlenderFileException { + super(constraintStructure, boneOMA, influenceIpo, blenderContext); } @Override diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintSizeLimit.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintSizeLimit.java index d682f81aa..ed6e9631d 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintSizeLimit.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintSizeLimit.java @@ -4,7 +4,7 @@ import com.jme3.animation.BoneAnimation; import com.jme3.animation.BoneTrack; import com.jme3.animation.Skeleton; import com.jme3.math.Vector3f; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.animations.Ipo; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Structure; @@ -30,15 +30,15 @@ import com.jme3.scene.plugins.blender.file.Structure; * the old memory address of the constraint owner * @param influenceIpo * the ipo curve of the influence factor - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception is thrown when the blender file is somehow * corrupted */ public ConstraintSizeLimit(Structure constraintStructure, Long boneOMA, - Ipo influenceIpo, DataRepository dataRepository) throws BlenderFileException { - super(constraintStructure, boneOMA, influenceIpo, dataRepository); + Ipo influenceIpo, BlenderContext blenderContext) throws BlenderFileException { + super(constraintStructure, boneOMA, influenceIpo, blenderContext); } @Override diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintStretchTo.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintStretchTo.java index 4c5825f3c..7d8d738d2 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintStretchTo.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintStretchTo.java @@ -5,7 +5,7 @@ import java.util.logging.Logger; import com.jme3.animation.BoneAnimation; import com.jme3.animation.Skeleton; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.animations.Ipo; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Structure; @@ -26,16 +26,16 @@ import com.jme3.scene.plugins.blender.file.Structure; * the old memory address of the constraint owner * @param influenceIpo * the ipo curve of the influence factor - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception is thrown when the blender file is somehow * corrupted */ public ConstraintStretchTo(Structure constraintStructure, Long boneOMA, - Ipo influenceIpo, DataRepository dataRepository) + Ipo influenceIpo, BlenderContext blenderContext) throws BlenderFileException { - super(constraintStructure, boneOMA, influenceIpo, dataRepository); + super(constraintStructure, boneOMA, influenceIpo, blenderContext); } @Override diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintTransform.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintTransform.java index 5de071e01..9c8b18f0d 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintTransform.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintTransform.java @@ -5,7 +5,7 @@ import java.util.logging.Logger; import com.jme3.animation.BoneAnimation; import com.jme3.animation.Skeleton; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.animations.Ipo; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Structure; @@ -26,15 +26,15 @@ import com.jme3.scene.plugins.blender.file.Structure; * the old memory address of the constraint owner * @param influenceIpo * the ipo curve of the influence factor - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception is thrown when the blender file is somehow * corrupted */ public ConstraintTransform(Structure constraintStructure, Long boneOMA, - Ipo influenceIpo, DataRepository dataRepository) throws BlenderFileException { - super(constraintStructure, boneOMA, influenceIpo, dataRepository); + Ipo influenceIpo, BlenderContext blenderContext) throws BlenderFileException { + super(constraintStructure, boneOMA, influenceIpo, blenderContext); } @Override 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 56347963d..d6f95efd7 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 @@ -22,7 +22,7 @@ import com.jme3.scene.Geometry; import com.jme3.scene.Mesh; import com.jme3.scene.VertexBuffer.Type; import com.jme3.scene.plugins.blender.AbstractBlenderHelper; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.BlenderInputStream; import com.jme3.scene.plugins.blender.file.DynamicArray; @@ -74,12 +74,12 @@ public class CurvesHelper extends AbstractBlenderHelper { * can have several separate curves. * @param curveStructure * the curve structure - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @return a list of geometries repreenting a single curve object * @throws BlenderFileException */ - public List toCurve(Structure curveStructure, DataRepository dataRepository) throws BlenderFileException { + public List toCurve(Structure curveStructure, BlenderContext blenderContext) throws BlenderFileException { String name = curveStructure.getName(); int flag = ((Number) curveStructure.getFieldValue("flag")).intValue(); boolean is3D = (flag & 0x01) != 0; @@ -93,7 +93,7 @@ public class CurvesHelper extends AbstractBlenderHelper { } //reading nurbs (and sorting them by material) - List nurbStructures = ((Structure) curveStructure.getFieldValue("nurb")).evaluateListBase(dataRepository); + List nurbStructures = ((Structure) curveStructure.getFieldValue("nurb")).evaluateListBase(blenderContext); Map> nurbs = new HashMap>(); for (Structure nurb : nurbStructures) { Number matNumber = (Number) nurb.getFieldValue("mat_nr"); @@ -106,10 +106,10 @@ public class CurvesHelper extends AbstractBlenderHelper { } //getting materials - MaterialHelper materialHelper = dataRepository.getHelper(MaterialHelper.class); - Material[] materials = materialHelper.getMaterials(curveStructure, dataRepository); + MaterialHelper materialHelper = blenderContext.getHelper(MaterialHelper.class); + Material[] materials = materialHelper.getMaterials(curveStructure, blenderContext); if (materials == null) { - materials = new Material[]{dataRepository.getDefaultMaterial().clone()}; + materials = new Material[]{blenderContext.getDefaultMaterial().clone()}; } for (Material material : materials) { material.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off); @@ -119,9 +119,9 @@ public class CurvesHelper extends AbstractBlenderHelper { List bevelObject = null; Pointer pBevelObject = (Pointer) curveStructure.getFieldValue("bevobj"); if (pBevelObject.isNotNull()) { - Pointer pBevelStructure = (Pointer) pBevelObject.fetchData(dataRepository.getInputStream()).get(0).getFieldValue("data"); - Structure bevelStructure = pBevelStructure.fetchData(dataRepository.getInputStream()).get(0); - bevelObject = this.toCurve(bevelStructure, dataRepository); + Pointer pBevelStructure = (Pointer) pBevelObject.fetchData(blenderContext.getInputStream()).get(0).getFieldValue("data"); + Structure bevelStructure = pBevelStructure.fetchData(blenderContext.getInputStream()).get(0); + bevelObject = this.toCurve(bevelStructure, blenderContext); } else { int bevResol = ((Number) curveStructure.getFieldValue("bevresol")).intValue(); float extrude = ((Number) curveStructure.getFieldValue("ext1")).floatValue(); @@ -179,9 +179,9 @@ public class CurvesHelper extends AbstractBlenderHelper { Curve taperObject = null; Pointer pTaperObject = (Pointer) curveStructure.getFieldValue("taperobj"); if (bevelObject != null && pTaperObject.isNotNull()) { - Pointer pTaperStructure = (Pointer) pTaperObject.fetchData(dataRepository.getInputStream()).get(0).getFieldValue("data"); - Structure taperStructure = pTaperStructure.fetchData(dataRepository.getInputStream()).get(0); - taperObject = this.loadTaperObject(taperStructure, dataRepository); + Pointer pTaperStructure = (Pointer) pTaperObject.fetchData(blenderContext.getInputStream()).get(0).getFieldValue("data"); + Structure taperStructure = pTaperStructure.fetchData(blenderContext.getInputStream()).get(0); + taperObject = this.loadTaperObject(taperStructure, blenderContext); } Vector3f loc = this.getLoc(curveStructure); @@ -192,9 +192,9 @@ public class CurvesHelper extends AbstractBlenderHelper { int type = ((Number) nurb.getFieldValue("type")).intValue(); List nurbGeoms = null; if ((type & 0x01) != 0) {//Bezier curve - nurbGeoms = this.loadBezierCurve(loc, nurb, bevelObject, taperObject, dataRepository); + nurbGeoms = this.loadBezierCurve(loc, nurb, bevelObject, taperObject, blenderContext); } else if ((type & 0x04) != 0) {//NURBS - nurbGeoms = this.loadNurb(loc, nurb, bevelObject, taperObject, dataRepository); + nurbGeoms = this.loadNurb(loc, nurb, bevelObject, taperObject, blenderContext); } if (nurbGeoms != null) {//setting the name and assigning materials for (Geometry nurbGeom : nurbGeoms) { @@ -207,7 +207,7 @@ public class CurvesHelper extends AbstractBlenderHelper { } //reading custom properties - Properties properties = this.loadProperties(curveStructure, dataRepository); + Properties properties = this.loadProperties(curveStructure, blenderContext); if(properties != null && properties.getValue() != null) { for(Geometry geom : result) { geom.setUserData("properties", properties); @@ -227,14 +227,14 @@ public class CurvesHelper extends AbstractBlenderHelper { * the bevel object * @param taperObject * the taper object - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @return a list of geometries representing the curves * @throws BlenderFileException * an exception is thrown when there are problems with the blender file */ protected List loadBezierCurve(Vector3f loc, Structure nurb, List bevelObject, Curve taperObject, - DataRepository dataRepository) throws BlenderFileException { + BlenderContext blenderContext) throws BlenderFileException { Pointer pBezierTriple = (Pointer) nurb.getFieldValue("bezt"); List result = new ArrayList(); if (pBezierTriple.isNotNull()) { @@ -243,7 +243,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(dataRepository.getInputStream()), 3); + BezierCurve bezierCurve = new BezierCurve(0, pBezierTriple.fetchData(blenderContext.getInputStream()), 3); List controlPoints = bezierCurve.getControlPoints(); if (cyclic) { //copy the first three points at the end @@ -263,7 +263,7 @@ public class CurvesHelper extends AbstractBlenderHelper { result.add(curveGeometry); //TODO: use front and back flags; surface excluding algorithm for bezier circles should be added } else {//creating curve with bevel and taper shape - result = this.applyBevelAndTaper(curve, bevelObject, taperObject, smooth, dataRepository); + result = this.applyBevelAndTaper(curve, bevelObject, taperObject, smooth, blenderContext); } } return result; @@ -279,22 +279,22 @@ public class CurvesHelper extends AbstractBlenderHelper { * the bevel object to be applied * @param taperObject * the taper object to be applied - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @return a list of geometries that represents the loaded NURBS curve or surface * @throws BlenderFileException * an exception is throw when problems with blender loaded data occurs */ @SuppressWarnings("unchecked") protected List loadNurb(Vector3f loc, Structure nurb, List bevelObject, Curve taperObject, - DataRepository dataRepository) throws BlenderFileException { + BlenderContext blenderContext) throws BlenderFileException { //loading the knots List[] knots = new List[2]; Pointer[] pKnots = new Pointer[]{(Pointer) nurb.getFieldValue("knotsu"), (Pointer) nurb.getFieldValue("knotsv")}; for (int i = 0; i < knots.length; ++i) { if (pKnots[i].isNotNull()) { - FileBlockHeader fileBlockHeader = dataRepository.getFileBlock(pKnots[i].getOldMemoryAddress()); - BlenderInputStream blenderInputStream = dataRepository.getInputStream(); + FileBlockHeader fileBlockHeader = blenderContext.getFileBlock(pKnots[i].getOldMemoryAddress()); + BlenderInputStream blenderInputStream = blenderContext.getInputStream(); blenderInputStream.setPosition(fileBlockHeader.getBlockPosition()); int knotsAmount = fileBlockHeader.getCount() * fileBlockHeader.getSize() / 4; knots[i] = new ArrayList(knotsAmount); @@ -313,7 +313,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(dataRepository.getInputStream()); + List bPoints = ((Pointer) nurb.getFieldValue("bp")).fetchData(blenderContext.getInputStream()); List> controlPoints = new ArrayList>(pntsV); for (int i = 0; i < pntsV; ++i) { List uControlPoints = new ArrayList(pntsU); @@ -344,7 +344,7 @@ public class CurvesHelper extends AbstractBlenderHelper { Spline nurbSpline = new Spline(controlPoints.get(0), knots[0]); Curve nurbCurve = new Curve(nurbSpline, resolu); if (bevelObject != null) { - result = this.applyBevelAndTaper(nurbCurve, bevelObject, taperObject, true, dataRepository);//TODO: smooth + result = this.applyBevelAndTaper(nurbCurve, bevelObject, taperObject, true, blenderContext);//TODO: smooth } else { result = new ArrayList(1); Geometry nurbGeometry = new Geometry("", nurbCurve); @@ -400,14 +400,14 @@ public class CurvesHelper extends AbstractBlenderHelper { * the taper object * @param smooth * the smooth flag - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @return a list of geometries representing the beveled and/or tapered curve */ protected List applyBevelAndTaper(Curve curve, List bevelObject, Curve taperObject, - boolean smooth, DataRepository dataRepository) { + boolean smooth, BlenderContext blenderContext) { float[] curvePoints = BufferUtils.getFloatArray(curve.getFloatBuffer(Type.Position)); - MeshHelper meshHelper = dataRepository.getHelper(MeshHelper.class); + MeshHelper meshHelper = blenderContext.getHelper(MeshHelper.class); float curveLength = curve.getLength(); //TODO: use the smooth var @@ -556,19 +556,19 @@ public class CurvesHelper extends AbstractBlenderHelper { * This method loads the taper object. * @param taperStructure * the taper structure - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @return the taper object * @throws BlenderFileException */ - protected Curve loadTaperObject(Structure taperStructure, DataRepository dataRepository) throws BlenderFileException { + protected Curve loadTaperObject(Structure taperStructure, BlenderContext blenderContext) throws BlenderFileException { //reading nurbs - List nurbStructures = ((Structure) taperStructure.getFieldValue("nurb")).evaluateListBase(dataRepository); + List nurbStructures = ((Structure) taperStructure.getFieldValue("nurb")).evaluateListBase(blenderContext); for (Structure nurb : nurbStructures) { Pointer pBezierTriple = (Pointer) nurb.getFieldValue("bezt"); if (pBezierTriple.isNotNull()) { //creating the curve object - BezierCurve bezierCurve = new BezierCurve(0, pBezierTriple.fetchData(dataRepository.getInputStream()), 3); + BezierCurve bezierCurve = new BezierCurve(0, pBezierTriple.fetchData(blenderContext.getInputStream()), 3); List controlPoints = bezierCurve.getControlPoints(); //removing the first and last handles controlPoints.remove(0); @@ -602,7 +602,7 @@ public class CurvesHelper extends AbstractBlenderHelper { } @Override - public boolean shouldBeLoaded(Structure structure, DataRepository dataRepository) { + public boolean shouldBeLoaded(Structure structure, BlenderContext blenderContext) { return true; } } \ No newline at end of file diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/file/DnaBlockData.java b/engine/src/blender/com/jme3/scene/plugins/blender/file/DnaBlockData.java index ecb224cd7..75e6c848c 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/file/DnaBlockData.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/file/DnaBlockData.java @@ -34,7 +34,7 @@ package com.jme3.scene.plugins.blender.file; import java.util.HashMap; import java.util.Map; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; /** @@ -57,12 +57,12 @@ public class DnaBlockData { * Constructor. Loads the block from the given stream during instance creation. * @param inputStream * the stream we read the block from - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception is throw if the blend file is invalid or somehow corrupted */ - public DnaBlockData(BlenderInputStream inputStream, DataRepository dataRepository) throws BlenderFileException { + public DnaBlockData(BlenderInputStream inputStream, BlenderContext blenderContext) throws BlenderFileException { int identifier; //reading 'SDNA' identifier @@ -130,7 +130,7 @@ public class DnaBlockData { structures = new Structure[amount]; structuresMap = new HashMap(amount); for (int i = 0; i < amount; ++i) { - structures[i] = new Structure(inputStream, names, types, dataRepository); + structures[i] = new Structure(inputStream, names, types, blenderContext); if (structuresMap.containsKey(structures[i].getType())) { throw new BlenderFileException("Blend file seems to be corrupted! The type " + structures[i].getType() + " is defined twice!"); } 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 a744b1520..ca0272014 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 @@ -3,7 +3,7 @@ package com.jme3.scene.plugins.blender.file; import java.util.ArrayList; import java.util.List; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Structure.DataType; @@ -17,8 +17,8 @@ class Field implements Cloneable { private static final int NAME_LENGTH = 24; private static final int TYPE_LENGTH = 16; - /** The data repository. */ - public DataRepository dataRepository; + /** The blender context. */ + public BlenderContext blenderContext; /** The type of the field. */ public String type; /** The name of the field. */ @@ -40,14 +40,14 @@ class Field implements Cloneable { * the name of the field * @param type * the type of the field - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception is thrown if the names contain errors */ - public Field(String name, String type, DataRepository dataRepository) throws BlenderFileException { + public Field(String name, String type, BlenderContext blenderContext) throws BlenderFileException { this.type = type; - this.dataRepository = dataRepository; + this.blenderContext = blenderContext; this.parseField(new StringBuilder(name)); } @@ -60,7 +60,7 @@ class Field implements Cloneable { private Field(Field field) { type = field.type; name = field.name; - dataRepository = field.dataRepository; + blenderContext = field.blenderContext; pointerLevel = field.pointerLevel; if (field.tableSizes != null) { tableSizes = field.tableSizes.clone(); @@ -90,17 +90,17 @@ class Field implements Cloneable { dataToRead *= size; } } - DataType dataType = pointerLevel == 0 ? DataType.getDataType(type, dataRepository) : DataType.POINTER; + DataType dataType = pointerLevel == 0 ? DataType.getDataType(type, blenderContext) : DataType.POINTER; switch (dataType) { case POINTER: if (dataToRead == 1) { - Pointer pointer = new Pointer(pointerLevel, function, dataRepository); + Pointer pointer = new Pointer(pointerLevel, function, blenderContext); pointer.fill(blenderInputStream); value = pointer; } else { Pointer[] data = new Pointer[dataToRead]; for (int i = 0; i < dataToRead; ++i) { - Pointer pointer = new Pointer(pointerLevel, function, dataRepository); + Pointer pointer = new Pointer(pointerLevel, function, blenderContext); pointer.fill(blenderInputStream); data[i] = pointer; } @@ -180,13 +180,13 @@ class Field implements Cloneable { break; case STRUCTURE: if (dataToRead == 1) { - Structure structure = dataRepository.getDnaBlockData().getStructure(type); + Structure structure = blenderContext.getDnaBlockData().getStructure(type); structure.fill(blenderInputStream); value = structure; } else { Structure[] data = new Structure[dataToRead]; for (int i = 0; i < dataToRead; ++i) { - Structure structure = dataRepository.getDnaBlockData().getStructure(type); + Structure structure = blenderContext.getDnaBlockData().getStructure(type); structure.fill(blenderInputStream); data[i] = structure; } diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/file/FileBlockHeader.java b/engine/src/blender/com/jme3/scene/plugins/blender/file/FileBlockHeader.java index 91aa0b793..c2ca6b023 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/file/FileBlockHeader.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/file/FileBlockHeader.java @@ -31,7 +31,7 @@ */ package com.jme3.scene.plugins.blender.file; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; /** @@ -78,12 +78,12 @@ public class FileBlockHeader { * Constructor. Loads the block header from the given stream during instance creation. * @param inputStream * the stream we read the block header from - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception is thrown when the pointer size is neither 4 nor 8 */ - public FileBlockHeader(BlenderInputStream inputStream, DataRepository dataRepository) throws BlenderFileException { + public FileBlockHeader(BlenderInputStream inputStream, BlenderContext blenderContext) throws BlenderFileException { inputStream.alignPosition(4); code = inputStream.readByte() << 24 | inputStream.readByte() << 16 | inputStream.readByte() << 8 | inputStream.readByte(); @@ -93,24 +93,24 @@ public class FileBlockHeader { count = inputStream.readInt(); blockPosition = inputStream.getPosition(); if (FileBlockHeader.BLOCK_DNA1 == code) { - dataRepository.setBlockData(new DnaBlockData(inputStream, dataRepository)); + blenderContext.setBlockData(new DnaBlockData(inputStream, blenderContext)); } else { inputStream.setPosition(blockPosition + size); - dataRepository.addFileBlockHeader(Long.valueOf(oldMemoryAddress), this); + blenderContext.addFileBlockHeader(Long.valueOf(oldMemoryAddress), this); } } /** * This method returns the structure described by the header filled with appropriate data. - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @return structure filled with data * @throws BlenderFileException */ - public Structure getStructure(DataRepository dataRepository) throws BlenderFileException { - dataRepository.getInputStream().setPosition(blockPosition); - Structure structure = dataRepository.getDnaBlockData().getStructure(sdnaIndex); - structure.fill(dataRepository.getInputStream()); + public Structure getStructure(BlenderContext blenderContext) throws BlenderFileException { + blenderContext.getInputStream().setPosition(blockPosition); + Structure structure = blenderContext.getDnaBlockData().getStructure(sdnaIndex); + structure.fill(blenderContext.getInputStream()); return structure; } 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 1e718340d..147a43c01 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 @@ -34,7 +34,7 @@ package com.jme3.scene.plugins.blender.file; import java.util.ArrayList; import java.util.List; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; /** @@ -43,8 +43,8 @@ import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; */ public class Pointer { - /** The data repository. */ - private DataRepository dataRepository; + /** The blender context. */ + private BlenderContext blenderContext; /** The level of the pointer. */ private int pointerLevel; /** The address in file it points to. */ @@ -58,13 +58,13 @@ public class Pointer { * the level of the pointer * @param function * this variable indicates if the field is a function pointer - * @param dataRepository + * @param blenderContext * the repository f data; used in fetching the value that the pointer points */ - public Pointer(int pointerLevel, boolean function, DataRepository dataRepository) { + public Pointer(int pointerLevel, boolean function, BlenderContext blenderContext) { this.pointerLevel = pointerLevel; this.function = function; - this.dataRepository = dataRepository; + this.blenderContext = blenderContext; } /** @@ -92,14 +92,14 @@ public class Pointer { throw new NullPointerException("The pointer points to nothing!"); } List structures = null; - FileBlockHeader dataFileBlock = dataRepository.getFileBlock(oldMemoryAddress); + FileBlockHeader dataFileBlock = blenderContext.getFileBlock(oldMemoryAddress); 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, dataRepository); + Pointer p = new Pointer(pointerLevel - 1, this.function, blenderContext); p.oldMemoryAddress = oldMemoryAddress; if (structures == null) { structures = p.fetchData(inputStream); @@ -112,7 +112,7 @@ public class Pointer { inputStream.setPosition(dataFileBlock.getBlockPosition()); structures = new ArrayList(dataFileBlock.getCount()); for (int i = 0; i < dataFileBlock.getCount(); ++i) { - Structure structure = dataRepository.getDnaBlockData().getStructure(dataFileBlock.getSdnaIndex()); + Structure structure = blenderContext.getDnaBlockData().getStructure(dataFileBlock.getSdnaIndex()); structure.fill(inputStream); structures.add(structure); } 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 ac8ebc815..df7682900 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 @@ -36,7 +36,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; /** @@ -45,8 +45,8 @@ import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; */ public class Structure implements Cloneable { - /** The data repository. */ - private DataRepository dataRepository; + /** 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 +60,18 @@ public class Structure implements Cloneable { * Constructor that copies the data of the structure. * @param structure * the structure to copy. - * @param dataRepository - * the data repository of the structure + * @param blenderContext + * the blender context of the structure * @throws CloneNotSupportedException * this exception should never be thrown */ - private Structure(Structure structure, DataRepository dataRepository) throws CloneNotSupportedException { + private Structure(Structure structure, BlenderContext blenderContext) 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.dataRepository = dataRepository; + this.blenderContext = blenderContext; this.oldMemoryAddress = structure.oldMemoryAddress; } @@ -83,15 +83,15 @@ public class Structure implements Cloneable { * the names from which the name of structure and its fields will be taken * @param types * the names of types for the structure - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception occurs if the amount of fields, defined in the file, is negative */ - public Structure(BlenderInputStream inputStream, String[] names, String[] types, DataRepository dataRepository) throws BlenderFileException { + public Structure(BlenderInputStream inputStream, String[] names, String[] types, BlenderContext blenderContext) throws BlenderFileException { int nameIndex = inputStream.readShort(); type = types[nameIndex]; - this.dataRepository = dataRepository; + this.blenderContext = blenderContext; int fieldsAmount = inputStream.readShort(); if (fieldsAmount < 0) { throw new BlenderFileException("The amount of fields of " + this.type + " structure cannot be negative!"); @@ -101,7 +101,7 @@ public class Structure implements Cloneable { for (int i = 0; i < fieldsAmount; ++i) { int typeIndex = inputStream.readShort(); nameIndex = inputStream.readShort(); - fields[i] = new Field(names[nameIndex], types[typeIndex], dataRepository); + fields[i] = new Field(names[nameIndex], types[typeIndex], blenderContext); } } this.oldMemoryAddress = Long.valueOf(-1L); @@ -165,15 +165,15 @@ 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 dataRepository - * the data repository + * @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(DataRepository dataRepository) throws BlenderFileException { + public List evaluateListBase(BlenderContext blenderContext) throws BlenderFileException { if (!"ListBase".equals(this.type)) { throw new IllegalStateException("This structure is not of type: 'ListBase'"); } @@ -184,7 +184,7 @@ public class Structure implements Cloneable { List result = new LinkedList(); while (currentAddress != lastAddress) { currentAddress = first.getOldMemoryAddress(); - Structure structure = first.fetchData(dataRepository.getInputStream()).get(0); + Structure structure = first.fetchData(blenderContext.getInputStream()).get(0); result.add(structure); first = (Pointer) structure.getFlatFieldValue("next"); } @@ -264,7 +264,7 @@ public class Structure implements Cloneable { @Override public Object clone() throws CloneNotSupportedException { - return new Structure(this, dataRepository); + return new Structure(this, blenderContext); } /** @@ -296,18 +296,18 @@ public class Structure implements Cloneable { * is case sensitive! * @param type * the type name of the data - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @return appropriate enum value to the given type name * @throws BlenderFileException * this exception is thrown if the given type name does not exist in the blend file */ - public static DataType getDataType(String type, DataRepository dataRepository) throws BlenderFileException { + public static DataType getDataType(String type, BlenderContext blenderContext) throws BlenderFileException { DataType result = PRIMARY_TYPES.get(type); if (result != null) { return result; } - if (dataRepository.getDnaBlockData().hasStructure(type)) { + if (blenderContext.getDnaBlockData().hasStructure(type)) { return STRUCTURE; } throw new BlenderFileException("Unknown data type: " + type); diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/lights/LightHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/lights/LightHelper.java index 7066de727..776c029d2 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/lights/LightHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/lights/LightHelper.java @@ -42,8 +42,8 @@ import com.jme3.light.SpotLight; import com.jme3.math.ColorRGBA; import com.jme3.math.FastMath; import com.jme3.scene.plugins.blender.AbstractBlenderHelper; -import com.jme3.scene.plugins.blender.DataRepository; -import com.jme3.scene.plugins.blender.DataRepository.LoadedFeatureDataType; +import com.jme3.scene.plugins.blender.BlenderContext; +import com.jme3.scene.plugins.blender.BlenderContext.LoadedFeatureDataType; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Structure; @@ -65,8 +65,8 @@ public class LightHelper extends AbstractBlenderHelper { super(blenderVersion); } - public Light toLight(Structure structure, DataRepository dataRepository) throws BlenderFileException { - Light result = (Light) dataRepository.getLoadedFeature(structure.getOldMemoryAddress(), LoadedFeatureDataType.LOADED_FEATURE); + public Light toLight(Structure structure, BlenderContext blenderContext) throws BlenderFileException { + Light result = (Light) blenderContext.getLoadedFeature(structure.getOldMemoryAddress(), LoadedFeatureDataType.LOADED_FEATURE); if (result != null) { return result; } @@ -114,7 +114,7 @@ public class LightHelper extends AbstractBlenderHelper { } @Override - public boolean shouldBeLoaded(Structure structure, DataRepository dataRepository) { - return (dataRepository.getBlenderKey().getFeaturesToLoad() & FeaturesToLoad.LIGHTS) != 0; + public boolean shouldBeLoaded(Structure structure, BlenderContext blenderContext) { + return (blenderContext.getBlenderKey().getFeaturesToLoad() & FeaturesToLoad.LIGHTS) != 0; } } diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/materials/MaterialContext.java b/engine/src/blender/com/jme3/scene/plugins/blender/materials/MaterialContext.java index 4302aea52..1fc0bf503 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/materials/MaterialContext.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/materials/MaterialContext.java @@ -5,7 +5,7 @@ import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.DynamicArray; import com.jme3.scene.plugins.blender.file.Pointer; @@ -31,7 +31,7 @@ public final class MaterialContext { /* package */int projectionType; @SuppressWarnings("unchecked") - /* package */MaterialContext(Structure structure, DataRepository dataRepository) throws BlenderFileException { + /* package */MaterialContext(Structure structure, BlenderContext blenderContext) throws BlenderFileException { name = structure.getName(); int mode = ((Number) structure.getFieldValue("mode")).intValue(); @@ -48,7 +48,7 @@ public final class MaterialContext { for (int i = 0; i < mtexsArray.getTotalSize(); ++i) { Pointer p = mtexsArray.get(i); if (p.isNotNull() && (separatedTextures & 1 << i) == 0) { - Structure mtex = p.fetchData(dataRepository.getInputStream()).get(0); + Structure mtex = p.fetchData(blenderContext.getInputStream()).get(0); // the first texture determines the texture coordinates type if (uvCoordinatesType == -1) { @@ -61,7 +61,7 @@ public final class MaterialContext { Pointer pTex = (Pointer) mtex.getFieldValue("tex"); if (pTex.isNotNull()) { - Structure tex = pTex.fetchData(dataRepository.getInputStream()).get(0); + Structure tex = pTex.fetchData(blenderContext.getInputStream()).get(0); int type = ((Number) tex.getFieldValue("type")).intValue(); Type textureType = this.getType(type); if (textureType != null) { 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 5c21bebdf..4f4dcb5c3 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 @@ -49,8 +49,8 @@ import com.jme3.material.RenderState.FaceCullMode; import com.jme3.math.ColorRGBA; import com.jme3.math.FastMath; import com.jme3.scene.plugins.blender.AbstractBlenderHelper; -import com.jme3.scene.plugins.blender.DataRepository; -import com.jme3.scene.plugins.blender.DataRepository.LoadedFeatureDataType; +import com.jme3.scene.plugins.blender.BlenderContext; +import com.jme3.scene.plugins.blender.BlenderContext.LoadedFeatureDataType; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Pointer; import com.jme3.scene.plugins.blender.file.Structure; @@ -182,23 +182,23 @@ public class MaterialHelper extends AbstractBlenderHelper { * This method converts the material structure to jme Material. * @param structure * structure with material data - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @return jme material * @throws BlenderFileException * an exception is throw when problems with blend file occur */ - public Material toMaterial(Structure structure, DataRepository dataRepository) throws BlenderFileException { + public Material toMaterial(Structure structure, BlenderContext blenderContext) throws BlenderFileException { LOGGER.log(Level.INFO, "Loading material."); if (structure == null) { - return dataRepository.getDefaultMaterial(); + return blenderContext.getDefaultMaterial(); } - Material result = (Material) dataRepository.getLoadedFeature(structure.getOldMemoryAddress(), LoadedFeatureDataType.LOADED_FEATURE); + Material result = (Material) blenderContext.getLoadedFeature(structure.getOldMemoryAddress(), LoadedFeatureDataType.LOADED_FEATURE); if (result != null) { return result; } - MaterialContext materialContext = new MaterialContext(structure, dataRepository); + MaterialContext materialContext = new MaterialContext(structure, blenderContext); LOGGER.log(Level.INFO, "Material's name: {0}", materialContext.name); if(materialContext.textures.size() > 0) { @@ -212,8 +212,8 @@ public class MaterialHelper extends AbstractBlenderHelper { // texture Map texturesMap = new HashMap(); Type firstTextureType = null; - if ((dataRepository.getBlenderKey().getFeaturesToLoad() & FeaturesToLoad.TEXTURES) != 0) { - TextureHelper textureHelper = dataRepository.getHelper(TextureHelper.class); + if ((blenderContext.getBlenderKey().getFeaturesToLoad() & FeaturesToLoad.TEXTURES) != 0) { + TextureHelper textureHelper = blenderContext.getHelper(TextureHelper.class); for (int i=0;i materialStructures = ppMaterials.fetchData(dataRepository.getInputStream()); + List materialStructures = ppMaterials.fetchData(blenderContext.getInputStream()); if (materialStructures != null && materialStructures.size() > 0) { - MaterialHelper materialHelper = dataRepository.getHelper(MaterialHelper.class); + MaterialHelper materialHelper = blenderContext.getHelper(MaterialHelper.class); materials = new Material[materialStructures.size()]; int i = 0; for (Structure s : materialStructures) { - Material material = (Material) dataRepository.getLoadedFeature(s.getOldMemoryAddress(), LoadedFeatureDataType.LOADED_FEATURE); + Material material = (Material) blenderContext.getLoadedFeature(s.getOldMemoryAddress(), LoadedFeatureDataType.LOADED_FEATURE); if (material == null) { - material = materialHelper.toMaterial(s, dataRepository); + material = materialHelper.toMaterial(s, blenderContext); } materials[i++] = material; } @@ -751,7 +751,7 @@ public class MaterialHelper extends AbstractBlenderHelper { } @Override - public boolean shouldBeLoaded(Structure structure, DataRepository dataRepository) { - return (dataRepository.getBlenderKey().getFeaturesToLoad() & FeaturesToLoad.MATERIALS) != 0; + public boolean shouldBeLoaded(Structure structure, BlenderContext blenderContext) { + return (blenderContext.getBlenderKey().getFeaturesToLoad() & FeaturesToLoad.MATERIALS) != 0; } } 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 aa6f59d94..56bc1c89a 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 @@ -52,8 +52,8 @@ import com.jme3.scene.VertexBuffer.Format; import com.jme3.scene.VertexBuffer.Type; import com.jme3.scene.VertexBuffer.Usage; import com.jme3.scene.plugins.blender.AbstractBlenderHelper; -import com.jme3.scene.plugins.blender.DataRepository; -import com.jme3.scene.plugins.blender.DataRepository.LoadedFeatureDataType; +import com.jme3.scene.plugins.blender.BlenderContext; +import com.jme3.scene.plugins.blender.BlenderContext.LoadedFeatureDataType; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.DynamicArray; import com.jme3.scene.plugins.blender.file.Pointer; @@ -92,8 +92,8 @@ public class MeshHelper extends AbstractBlenderHelper { * @throws BlenderFileException */ @SuppressWarnings("unchecked") - public List toMesh(Structure structure, DataRepository dataRepository) throws BlenderFileException { - List geometries = (List) dataRepository.getLoadedFeature(structure.getOldMemoryAddress(), + public List toMesh(Structure structure, BlenderContext blenderContext) throws BlenderFileException { + List geometries = (List) blenderContext.getLoadedFeature(structure.getOldMemoryAddress(), LoadedFeatureDataType.LOADED_FEATURE); if (geometries != null) { List copiedGeometries = new ArrayList(geometries.size()); @@ -104,17 +104,17 @@ public class MeshHelper extends AbstractBlenderHelper { } // helpers - TextureHelper textureHelper = dataRepository.getHelper(TextureHelper.class); + TextureHelper textureHelper = blenderContext.getHelper(TextureHelper.class); // reading mesh data String name = structure.getName(); // reading vertices - Vector3f[] vertices = this.getVertices(structure, dataRepository); + Vector3f[] vertices = this.getVertices(structure, blenderContext); int verticesAmount = vertices.length; // vertices Colors - List verticesColors = this.getVerticesColors(structure, dataRepository); + List verticesColors = this.getVerticesColors(structure, blenderContext); // reading faces // the following map sorts faces by material number (because in jme Mesh can have only one material) @@ -122,7 +122,7 @@ public class MeshHelper extends AbstractBlenderHelper { Pointer pMFace = (Pointer) structure.getFieldValue("mface"); List mFaces = null; if (pMFace.isNotNull()){ - mFaces = pMFace.fetchData(dataRepository.getInputStream()); + mFaces = pMFace.fetchData(blenderContext.getInputStream()); if(mFaces==null || mFaces.size()==0) { return new ArrayList(0); } @@ -133,7 +133,7 @@ public class MeshHelper extends AbstractBlenderHelper { List mtFaces = null; if (pMTFace.isNotNull()) { - mtFaces = pMTFace.fetchData(dataRepository.getInputStream()); + mtFaces = pMTFace.fetchData(blenderContext.getInputStream()); int facesAmount = ((Number) structure.getFieldValue("totface")).intValue(); if (mtFaces.size() != facesAmount) { throw new BlenderFileException("The amount of faces uv coordinates is not equal to faces amount!"); @@ -178,8 +178,8 @@ public class MeshHelper extends AbstractBlenderHelper { // attaching image to texture (face can have UV's and image whlie its material may have no texture attached) if (pImage != null && pImage.isNotNull() && !materialNumberToTexture.containsKey(materialNumber)) { - Texture texture = textureHelper.getTextureFromImage(pImage.fetchData(dataRepository.getInputStream()).get(0), - dataRepository); + Texture texture = textureHelper.getTextureFromImage(pImage.fetchData(blenderContext.getInputStream()).get(0), + blenderContext); if (texture != null) { materialNumberToTexture.put(materialNumber, texture); } @@ -243,14 +243,14 @@ public class MeshHelper extends AbstractBlenderHelper { } } } - dataRepository.setVertexData(structure.getOldMemoryAddress(), new VertexData(vertexList, vertexReferenceMap)); + blenderContext.setVertexData(structure.getOldMemoryAddress(), new VertexData(vertexList, vertexReferenceMap)); Vector3f[] normals = normalList.toArray(new Vector3f[normalList.size()]); // reading vertices groups (from the parent) - Structure parent = dataRepository.peekParent(); + Structure parent = blenderContext.peekParent(); Structure defbase = (Structure) parent.getFieldValue("defbase"); - List defs = defbase.evaluateListBase(dataRepository); + List defs = defbase.evaluateListBase(blenderContext); String[] verticesGroups = new String[defs.size()]; int defIndex = 0; for (Structure def : defs) { @@ -258,11 +258,11 @@ public class MeshHelper extends AbstractBlenderHelper { } // reading materials - MaterialHelper materialHelper = dataRepository.getHelper(MaterialHelper.class); + MaterialHelper materialHelper = blenderContext.getHelper(MaterialHelper.class); Material[] materials = null; Material[] nonTexturedMaterials = null; - if ((dataRepository.getBlenderKey().getFeaturesToLoad() & FeaturesToLoad.MATERIALS) != 0) { - materials = materialHelper.getMaterials(structure, dataRepository); + if ((blenderContext.getBlenderKey().getFeaturesToLoad() & FeaturesToLoad.MATERIALS) != 0) { + materials = materialHelper.getMaterials(structure, blenderContext); nonTexturedMaterials = materials == null ? null : new Material[materials.length];// fill it when needed } @@ -292,7 +292,7 @@ public class MeshHelper extends AbstractBlenderHelper { } //reading custom properties - Properties properties = this.loadProperties(structure, dataRepository); + Properties properties = this.loadProperties(structure, blenderContext); // generating meshes FloatBuffer verticesColorsBuffer = this.createFloatBuffer(verticesColors); @@ -355,7 +355,7 @@ public class MeshHelper extends AbstractBlenderHelper { geometry.setQueueBucket(Bucket.Transparent); } } else { - geometry.setMaterial(dataRepository.getDefaultMaterial()); + geometry.setMaterial(blenderContext.getDefaultMaterial()); } if(properties != null && properties.getValue() != null) { geometry.setUserData("properties", properties); @@ -381,7 +381,7 @@ public class MeshHelper extends AbstractBlenderHelper { } for(Entry> entry : materialMap.entrySet()) { - MaterialContext materialContext = dataRepository.getMaterialContext(entry.getKey()); + MaterialContext materialContext = blenderContext.getMaterialContext(entry.getKey()); if(materialContext != null && materialContext.getTexturesCount()>0) { UVCoordinatesGenerator.generateUVCoordinates(materialContext.getUvCoordinatesType(), materialContext.getProjectionType(), materialContext.getTextureDimension(), @@ -390,7 +390,7 @@ public class MeshHelper extends AbstractBlenderHelper { } } - dataRepository.addLoadedFeatures(structure.getOldMemoryAddress(), structure.getName(), structure, geometries); + blenderContext.addLoadedFeatures(structure.getOldMemoryAddress(), structure.getName(), structure, geometries); return geometries; } @@ -443,19 +443,19 @@ public class MeshHelper extends AbstractBlenderHelper { * * @param meshStructure * the structure containing the mesh data - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @return a list of vertices colors, each color belongs to a single vertex * @throws BlenderFileException * this exception is thrown when the blend file structure is somehow invalid or corrupted */ - public List getVerticesColors(Structure meshStructure, DataRepository dataRepository) throws BlenderFileException { + public List getVerticesColors(Structure meshStructure, BlenderContext blenderContext) throws BlenderFileException { Pointer pMCol = (Pointer) meshStructure.getFieldValue("mcol"); List verticesColors = null; List mCol = null; if (pMCol.isNotNull()) { verticesColors = new LinkedList(); - mCol = pMCol.fetchData(dataRepository.getInputStream()); + mCol = pMCol.fetchData(blenderContext.getInputStream()); for (Structure color : mCol) { float r = ((Number) color.getFieldValue("r")).byteValue() / 256.0f; float g = ((Number) color.getFieldValue("g")).byteValue() / 256.0f; @@ -472,14 +472,14 @@ public class MeshHelper extends AbstractBlenderHelper { * * @param meshStructure * the structure containing the mesh data - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @return a list of vertices colors, each color belongs to a single vertex * @throws BlenderFileException * this exception is thrown when the blend file structure is somehow invalid or corrupted */ @SuppressWarnings("unchecked") - public Vector3f[] getVertices(Structure meshStructure, DataRepository dataRepository) throws BlenderFileException { + public Vector3f[] getVertices(Structure meshStructure, BlenderContext blenderContext) throws BlenderFileException { int verticesAmount = ((Number) meshStructure.getFieldValue("totvert")).intValue(); Vector3f[] vertices = new Vector3f[verticesAmount]; if (verticesAmount == 0) { @@ -487,7 +487,7 @@ public class MeshHelper extends AbstractBlenderHelper { } Pointer pMVert = (Pointer) meshStructure.getFieldValue("mvert"); - List mVerts = pMVert.fetchData(dataRepository.getInputStream()); + List mVerts = pMVert.fetchData(blenderContext.getInputStream()); for (int i = 0; i < verticesAmount; ++i) { DynamicArray coordinates = (DynamicArray) mVerts.get(i).getFieldValue("co"); vertices[i] = new Vector3f(coordinates.get(0).floatValue(), coordinates.get(1).floatValue(), coordinates.get(2).floatValue()); @@ -496,7 +496,7 @@ public class MeshHelper extends AbstractBlenderHelper { } @Override - public boolean shouldBeLoaded(Structure structure, DataRepository dataRepository) { + public boolean shouldBeLoaded(Structure structure, BlenderContext blenderContext) { return true; } 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 c26251f4f..89fcff60a 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 @@ -23,8 +23,8 @@ 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.DataRepository; -import com.jme3.scene.plugins.blender.DataRepository.LoadedFeatureDataType; +import com.jme3.scene.plugins.blender.BlenderContext; +import com.jme3.scene.plugins.blender.BlenderContext.LoadedFeatureDataType; import com.jme3.scene.plugins.blender.animations.ArmatureHelper; import com.jme3.scene.plugins.blender.animations.ArmatureHelper.BoneTransformationData; import com.jme3.scene.plugins.blender.constraints.Constraint; @@ -73,28 +73,28 @@ import com.jme3.util.BufferUtils; * the structure of the object * @param modifierStructure * the structure of the modifier - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception is thrown when the blender file is somehow * corrupted */ - public ArmatureModifier(Structure objectStructure, Structure modifierStructure, DataRepository dataRepository) throws BlenderFileException { + public ArmatureModifier(Structure objectStructure, Structure modifierStructure, BlenderContext blenderContext) throws BlenderFileException { Pointer pArmatureObject = (Pointer) modifierStructure.getFieldValue("object"); if (pArmatureObject.isNotNull()) { - ObjectHelper objectHelper = dataRepository.getHelper(ObjectHelper.class); - ArmatureHelper armatureHelper = dataRepository.getHelper(ArmatureHelper.class); + ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class); + ArmatureHelper armatureHelper = blenderContext.getHelper(ArmatureHelper.class); - Structure armatureObject = pArmatureObject.fetchData(dataRepository.getInputStream()).get(0); + Structure armatureObject = pArmatureObject.fetchData(blenderContext.getInputStream()).get(0); this.armatureObjectOMA = armatureObject.getOldMemoryAddress(); //read skeleton // changing bones matrices so that they fit the current object - Structure armatureStructure = ((Pointer)armatureObject.getFieldValue("data")).fetchData(dataRepository.getInputStream()).get(0); + Structure armatureStructure = ((Pointer)armatureObject.getFieldValue("data")).fetchData(blenderContext.getInputStream()).get(0); Structure bonebase = (Structure) armatureStructure.getFieldValue("bonebase"); - List bonesStructures = bonebase.evaluateListBase(dataRepository); + List bonesStructures = bonebase.evaluateListBase(blenderContext); for (Structure boneStructure : bonesStructures) { - BoneTransformationData rootBoneTransformationData = armatureHelper.readBoneAndItsChildren(boneStructure, null, dataRepository); + BoneTransformationData rootBoneTransformationData = armatureHelper.readBoneAndItsChildren(boneStructure, null, blenderContext); armatureHelper.addBoneDataRoot(rootBoneTransformationData); } Matrix4f armatureObjectMatrix = objectHelper.getTransformationMatrix(armatureObject); @@ -103,26 +103,26 @@ import com.jme3.util.BufferUtils; Bone[] bones = armatureHelper.buildBonesStructure(Long.valueOf(0L), additionalRootBoneTransformation); //read mesh indexes - Structure meshStructure = ((Pointer)objectStructure.getFieldValue("data")).fetchData(dataRepository.getInputStream()).get(0); + Structure meshStructure = ((Pointer)objectStructure.getFieldValue("data")).fetchData(blenderContext.getInputStream()).get(0); this.meshOMA = meshStructure.getOldMemoryAddress(); - this.readVerticesWeightsData(objectStructure, meshStructure, dataRepository); + this.readVerticesWeightsData(objectStructure, meshStructure, blenderContext); //read animations String objectName = objectStructure.getName(); - Set animationNames = dataRepository.getBlenderKey().getAnimationNames(objectName); + Set animationNames = blenderContext.getBlenderKey().getAnimationNames(objectName); if (animationNames != null && animationNames.size() > 0) { ArrayList animations = new ArrayList(); - List actionHeaders = dataRepository.getFileBlocks(Integer.valueOf(FileBlockHeader.BLOCK_AC00)); + List actionHeaders = blenderContext.getFileBlocks(Integer.valueOf(FileBlockHeader.BLOCK_AC00)); for (FileBlockHeader header : actionHeaders) { - Structure actionStructure = header.getStructure(dataRepository); + Structure actionStructure = header.getStructure(blenderContext); String actionName = actionStructure.getName(); if (animationNames.contains(actionName)) { - int[] animationFrames = dataRepository.getBlenderKey().getAnimationFrames(objectName, actionName); - int fps = dataRepository.getBlenderKey().getFps(); + int[] animationFrames = blenderContext.getBlenderKey().getAnimationFrames(objectName, actionName); + int fps = blenderContext.getBlenderKey().getFps(); float start = (float) animationFrames[0] / (float) fps; float stop = (float) animationFrames[1] / (float) fps; BoneAnimation boneAnimation = new BoneAnimation(actionName, stop - start); - boneAnimation.setTracks(armatureHelper.getTracks(actionStructure, dataRepository, objectName, actionName)); + boneAnimation.setTracks(armatureHelper.getTracks(actionStructure, blenderContext, objectName, actionName)); animations.add(boneAnimation); } } @@ -133,13 +133,13 @@ import com.jme3.util.BufferUtils; @Override @SuppressWarnings("unchecked") - public Node apply(Node node, DataRepository dataRepository) { + public Node apply(Node node, BlenderContext blenderContext) { if(animData == null) { return node; } // setting weights for bones - List geomList = (List) dataRepository.getLoadedFeature(this.meshOMA, LoadedFeatureDataType.LOADED_FEATURE); + List geomList = (List) blenderContext.getLoadedFeature(this.meshOMA, LoadedFeatureDataType.LOADED_FEATURE); for(Geometry geom : geomList) { Mesh mesh = geom.getMesh(); if (this.verticesWeights != null) { @@ -151,7 +151,7 @@ import com.jme3.util.BufferUtils; ArrayList animList = animData.anims; if (animList != null && animList.size() > 0) { - List constraints = dataRepository.getConstraints(this.armatureObjectOMA); + List constraints = blenderContext.getConstraints(this.armatureObjectOMA); HashMap anims = new HashMap(); for (int i = 0; i < animList.size(); ++i) { BoneAnimation boneAnimation = (BoneAnimation) animList.get(i).clone(); @@ -194,21 +194,21 @@ import com.jme3.util.BufferUtils; * This method reads mesh indexes * @param objectStructure structure of the object that has the armature modifier applied * @param meshStructure the structure of the object's mesh - * @param dataRepository the data repository + * @param blenderContext the blender context * @throws BlenderFileException * this exception is thrown when the blend file structure is somehow invalid or corrupted */ - private void readVerticesWeightsData(Structure objectStructure, Structure meshStructure, DataRepository dataRepository) throws BlenderFileException { - ArmatureHelper armatureHelper = dataRepository.getHelper(ArmatureHelper.class); + private void readVerticesWeightsData(Structure objectStructure, Structure meshStructure, BlenderContext blenderContext) throws BlenderFileException { + ArmatureHelper armatureHelper = blenderContext.getHelper(ArmatureHelper.class); Structure defBase = (Structure) objectStructure.getFieldValue("defbase"); - Map groupToBoneIndexMap = armatureHelper.getGroupToBoneIndexMap(defBase, dataRepository); + Map groupToBoneIndexMap = armatureHelper.getGroupToBoneIndexMap(defBase, blenderContext); int[] bonesGroups = new int[] { 0 }; - VertexData vertexData = dataRepository.getVertexData(meshStructure.getOldMemoryAddress()); + VertexData vertexData = blenderContext.getVertexData(meshStructure.getOldMemoryAddress()); VertexBuffer[] boneWeightsAndIndex = this.getBoneWeightAndIndexBuffer(meshStructure, vertexData.getVertexList().size(), bonesGroups, - vertexData.getVertexReferenceMap(), groupToBoneIndexMap, dataRepository); + vertexData.getVertexReferenceMap(), groupToBoneIndexMap, blenderContext); this.verticesWeights = boneWeightsAndIndex[0]; this.verticesWeightsIndices = boneWeightsAndIndex[1]; this.boneGroups = bonesGroups[0]; @@ -230,20 +230,20 @@ import com.jme3.util.BufferUtils; * vertex may appear several times in the result model * @param groupToBoneIndexMap * this object maps the group index (to which a vertices in blender belong) to bone index of the model - * @param dataRepository - * the data repository + * @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, DataRepository dataRepository) + Map> vertexReferenceMap, Map groupToBoneIndexMap, BlenderContext blenderContext) throws BlenderFileException { Pointer pDvert = (Pointer) meshStructure.getFieldValue("dvert");// dvert = DeformVERTices FloatBuffer weightsFloatData = BufferUtils.createFloatBuffer(vertexListSize * MAXIMUM_WEIGHTS_PER_VERTEX); ByteBuffer indicesData = BufferUtils.createByteBuffer(vertexListSize * MAXIMUM_WEIGHTS_PER_VERTEX); if (pDvert.isNotNull()) {// assigning weights and bone indices - List dverts = pDvert.fetchData(dataRepository.getInputStream());// dverts.size() == verticesAmount (one dvert per + List dverts = pDvert.fetchData(blenderContext.getInputStream());// dverts.size() == verticesAmount (one dvert per // vertex in blender) int vertexIndex = 0; for (Structure dvert : dverts) { @@ -253,7 +253,7 @@ import com.jme3.util.BufferUtils; List vertexIndices = vertexReferenceMap.get(Integer.valueOf(vertexIndex));// we fetch the referenced vertices here if (totweight > 0 && pDW.isNotNull() && groupToBoneIndexMap!=null) {// pDW should never be null here, but I check it just in case :) int weightIndex = 0; - List dw = pDW.fetchData(dataRepository.getInputStream()); + List dw = pDW.fetchData(blenderContext.getInputStream()); for (Structure deformWeight : dw) { Integer boneIndex = groupToBoneIndexMap.get(((Number) deformWeight.getFieldValue("def_nr")).intValue()); if (boneIndex != null) {// null here means that we came accross group that has no bone attached to 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 bbbeb7aac..3b1542287 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 @@ -15,8 +15,8 @@ import com.jme3.scene.Geometry; import com.jme3.scene.Mesh; import com.jme3.scene.Node; import com.jme3.scene.Spatial; -import com.jme3.scene.plugins.blender.DataRepository; -import com.jme3.scene.plugins.blender.DataRepository.LoadedFeatureDataType; +import com.jme3.scene.plugins.blender.BlenderContext; +import com.jme3.scene.plugins.blender.BlenderContext.LoadedFeatureDataType; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.DynamicArray; import com.jme3.scene.plugins.blender.file.FileBlockHeader; @@ -45,14 +45,14 @@ import com.jme3.scene.shape.Curve; * the structure of the object * @param modifierStructure * the structure of the modifier - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception is thrown when the blender file is somehow * corrupted */ @SuppressWarnings("unchecked") - public ArrayModifier(Structure modifier, DataRepository dataRepository) throws BlenderFileException { + public ArrayModifier(Structure modifier, BlenderContext blenderContext) throws BlenderFileException { Number fittype = (Number) modifier.getFieldValue("fit_type"); modifierData.put("fittype", fittype); switch (fittype.intValue()) { @@ -66,9 +66,9 @@ import com.jme3.scene.shape.Curve; Pointer pCurveOb = (Pointer) modifier.getFieldValue("curve_ob"); float length = 0; if (pCurveOb.isNotNull()) { - Structure curveStructure = pCurveOb.fetchData(dataRepository.getInputStream()).get(0); - ObjectHelper objectHelper = dataRepository.getHelper(ObjectHelper.class); - Node curveObject = (Node) objectHelper.toObject(curveStructure, dataRepository); + Structure curveStructure = pCurveOb.fetchData(blenderContext.getInputStream()).get(0); + ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class); + Node curveObject = (Node) objectHelper.toObject(curveStructure, blenderContext); Set referencesToCurveLengths = new HashSet(curveObject.getChildren().size()); for (Spatial spatial : curveObject.getChildren()) { if (spatial instanceof Geometry) { @@ -125,7 +125,7 @@ import com.jme3.scene.shape.Curve; } @Override - public Node apply(Node node, DataRepository dataRepository) { + public Node apply(Node node, BlenderContext blenderContext) { int fittype = ((Number) modifierData.get("fittype")).intValue(); float[] offset = (float[]) modifierData.get("offset"); if (offset == null) {// the node will be repeated several times in the same place @@ -156,11 +156,11 @@ import com.jme3.scene.shape.Curve; float[] objectOffset = new float[]{0.0f, 0.0f, 0.0f}; Pointer pOffsetObject = (Pointer) modifierData.get("offsetob"); if (pOffsetObject != null) { - FileBlockHeader offsetObjectBlock = dataRepository.getFileBlock(pOffsetObject.getOldMemoryAddress()); - ObjectHelper objectHelper = dataRepository.getHelper(ObjectHelper.class); + FileBlockHeader offsetObjectBlock = blenderContext.getFileBlock(pOffsetObject.getOldMemoryAddress()); + ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class); try {// we take the structure in case the object was not yet loaded - Structure offsetStructure = offsetObjectBlock.getStructure(dataRepository); - Vector3f translation = objectHelper.getTransformation(offsetStructure, dataRepository).getTranslation(); + Structure offsetStructure = offsetObjectBlock.getStructure(blenderContext); + Vector3f translation = objectHelper.getTransformation(offsetStructure, blenderContext).getTranslation(); objectOffset[0] = translation.x; objectOffset[1] = translation.y; objectOffset[2] = translation.z; @@ -174,15 +174,15 @@ import com.jme3.scene.shape.Curve; Pointer[] pCaps = new Pointer[]{(Pointer) modifierData.get("startcap"), (Pointer) modifierData.get("endcap")}; for (int i = 0; i < pCaps.length; ++i) { if (pCaps[i] != null) { - caps[i] = (Node) dataRepository.getLoadedFeature(pCaps[i].getOldMemoryAddress(), LoadedFeatureDataType.LOADED_FEATURE); + caps[i] = (Node) blenderContext.getLoadedFeature(pCaps[i].getOldMemoryAddress(), LoadedFeatureDataType.LOADED_FEATURE); if (caps[i] != null) { caps[i] = (Node) caps[i].clone(); } else { - FileBlockHeader capBlock = dataRepository.getFileBlock(pOffsetObject.getOldMemoryAddress()); + FileBlockHeader capBlock = blenderContext.getFileBlock(pOffsetObject.getOldMemoryAddress()); try {// we take the structure in case the object was not yet loaded - Structure capStructure = capBlock.getStructure(dataRepository); - ObjectHelper objectHelper = dataRepository.getHelper(ObjectHelper.class); - caps[i] = (Node) objectHelper.toObject(capStructure, dataRepository); + Structure capStructure = capBlock.getStructure(blenderContext); + ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class); + caps[i] = (Node) objectHelper.toObject(capStructure, blenderContext); if (caps[i] == null) { LOGGER.log(Level.WARNING, "Cap object ''{0}'' couldn''t be loaded!", capStructure.getName()); } 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 f9d9b00e1..b64a95dfe 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 @@ -15,7 +15,7 @@ import com.jme3.scene.Mesh; import com.jme3.scene.Node; import com.jme3.scene.Spatial; import com.jme3.scene.VertexBuffer.Type; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Pointer; import com.jme3.scene.plugins.blender.file.Structure; @@ -42,13 +42,13 @@ import com.jme3.scene.plugins.blender.objects.ObjectHelper; * the structure of the object * @param modifierStructure * the structure of the modifier - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * this exception is thrown when the blender file is somehow * corrupted */ - public MirrorModifier(Structure modifier, DataRepository dataRepository) { + public MirrorModifier(Structure modifier, BlenderContext blenderContext) { modifierData.put("flag", modifier.getFieldValue("flag")); modifierData.put("tolerance", modifier.getFieldValue("tolerance")); Pointer pMirrorOb = (Pointer) modifier.getFieldValue("mirror_ob"); @@ -58,7 +58,7 @@ import com.jme3.scene.plugins.blender.objects.ObjectHelper; } @Override - public Node apply(Node node, DataRepository dataRepository) { + public Node apply(Node node, BlenderContext blenderContext) { int flag = ((Number) modifierData.get("flag")).intValue(); float[] mirrorFactor = new float[]{ (flag & 0x08) != 0 ? -1.0f : 1.0f, @@ -70,9 +70,9 @@ import com.jme3.scene.plugins.blender.objects.ObjectHelper; if (pObject != null) { Structure objectStructure; try { - objectStructure = pObject.fetchData(dataRepository.getInputStream()).get(0); - ObjectHelper objectHelper = dataRepository.getHelper(ObjectHelper.class); - Node object = (Node) objectHelper.toObject(objectStructure, dataRepository); + objectStructure = pObject.fetchData(blenderContext.getInputStream()).get(0); + ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class); + Node object = (Node) objectHelper.toObject(objectStructure, blenderContext); if (object != null) { Vector3f translation = object.getWorldTranslation(); center[0] = translation.x; diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/Modifier.java b/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/Modifier.java index 17ccf8aab..ceac97600 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/Modifier.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/Modifier.java @@ -1,7 +1,7 @@ package com.jme3.scene.plugins.blender.modifiers; import com.jme3.scene.Node; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; /** * This class represents an object's modifier. The modifier object can be varied @@ -24,11 +24,11 @@ public abstract class Modifier { * * @param node * the node that will have modifier applied - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @return the node with applied modifier */ - public abstract Node apply(Node node, DataRepository dataRepository); + public abstract Node apply(Node node, BlenderContext blenderContext); /** * This method returns blender's type of modifier. 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 17c56addf..51af62269 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 @@ -38,7 +38,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import com.jme3.scene.plugins.blender.AbstractBlenderHelper; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Pointer; import com.jme3.scene.plugins.blender.file.Structure; @@ -65,32 +65,32 @@ public class ModifierHelper extends AbstractBlenderHelper { * This method reads the given object's modifiers. * @param objectStructure * the object structure - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @param converter * the converter object (in some cases we need to read an object first before loading the modifier) * @throws BlenderFileException * this exception is thrown when the blender file is somehow corrupted */ - public Collection readModifiers(Structure objectStructure, DataRepository dataRepository) throws BlenderFileException { + public Collection readModifiers(Structure objectStructure, BlenderContext blenderContext) throws BlenderFileException { Collection result = new ArrayList(); Structure modifiersListBase = (Structure) objectStructure.getFieldValue("modifiers"); - List modifiers = modifiersListBase.evaluateListBase(dataRepository); + List modifiers = modifiersListBase.evaluateListBase(blenderContext); for (Structure modifierStructure : modifiers) { Modifier modifier = null; if (Modifier.ARRAY_MODIFIER_DATA.equals(modifierStructure.getType())) { - modifier = new ArrayModifier(modifierStructure, dataRepository); + modifier = new ArrayModifier(modifierStructure, blenderContext); } else if (Modifier.MIRROR_MODIFIER_DATA.equals(modifierStructure.getType())) { - modifier = new MirrorModifier(modifierStructure, dataRepository); + modifier = new MirrorModifier(modifierStructure, blenderContext); } else if (Modifier.ARMATURE_MODIFIER_DATA.equals(modifierStructure.getType())) { - modifier = new ArmatureModifier(objectStructure, modifierStructure, dataRepository); + modifier = new ArmatureModifier(objectStructure, modifierStructure, blenderContext); } else if (Modifier.PARTICLE_MODIFIER_DATA.equals(modifierStructure.getType())) { - modifier = new ParticlesModifier(modifierStructure, dataRepository); + modifier = new ParticlesModifier(modifierStructure, blenderContext); } if(modifier != null) { result.add(modifier); - dataRepository.addModifier(objectStructure.getOldMemoryAddress(), modifier); + blenderContext.addModifier(objectStructure.getOldMemoryAddress(), modifier); } else { LOGGER.log(Level.WARNING, "Unsupported modifier type: {0}", modifierStructure.getType()); } @@ -99,15 +99,15 @@ public class ModifierHelper extends AbstractBlenderHelper { //at the end read object's animation modifier Pointer pIpo = (Pointer) objectStructure.getFieldValue("ipo"); if (pIpo.isNotNull()) { - Modifier modifier = new ObjectAnimationModifier(objectStructure, dataRepository); + Modifier modifier = new ObjectAnimationModifier(objectStructure, blenderContext); result.add(modifier); - dataRepository.addModifier(objectStructure.getOldMemoryAddress(), modifier); + blenderContext.addModifier(objectStructure.getOldMemoryAddress(), modifier); } return result; } @Override - public boolean shouldBeLoaded(Structure structure, DataRepository dataRepository) { + public boolean shouldBeLoaded(Structure structure, BlenderContext blenderContext) { return true; } } diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ObjectAnimationModifier.java b/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ObjectAnimationModifier.java index 38b05c4d4..fe39688e8 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ObjectAnimationModifier.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ObjectAnimationModifier.java @@ -11,7 +11,7 @@ import com.jme3.animation.BoneTrack; import com.jme3.animation.Skeleton; import com.jme3.math.Transform; import com.jme3.scene.Node; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.animations.Ipo; import com.jme3.scene.plugins.blender.animations.IpoHelper; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; @@ -44,24 +44,24 @@ import com.jme3.scene.plugins.ogre.AnimData; * * @param objectStructure * the structure of the object - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @return animation modifier is returned, it should be separately applied * when the object is loaded * @throws BlenderFileException * this exception is thrown when the blender file is somehow * corrupted */ - public ObjectAnimationModifier(Structure objectStructure, DataRepository dataRepository) throws BlenderFileException { + public ObjectAnimationModifier(Structure objectStructure, BlenderContext blenderContext) throws BlenderFileException { Pointer pIpo = (Pointer) objectStructure.getFieldValue("ipo"); if (pIpo.isNotNull()) { // check if there is an action name connected with this ipo String objectAnimationName = null; - List actionBlocks = dataRepository + List actionBlocks = blenderContext .getFileBlocks(Integer.valueOf(FileBlockHeader.BLOCK_AC00)); for (FileBlockHeader actionBlock : actionBlocks) { - Structure action = actionBlock.getStructure(dataRepository); - List actionChannels = ((Structure) action.getFieldValue("chanbase")).evaluateListBase(dataRepository); + Structure action = actionBlock.getStructure(blenderContext); + List actionChannels = ((Structure) action.getFieldValue("chanbase")).evaluateListBase(blenderContext); if (actionChannels.size() == 1) {// object's animtion action has only one channel Pointer pChannelIpo = (Pointer) actionChannels.get(0).getFieldValue("ipo"); if (pChannelIpo.equals(pIpo)) { @@ -76,14 +76,14 @@ import com.jme3.scene.plugins.ogre.AnimData; objectAnimationName = objectName; } - IpoHelper ipoHelper = dataRepository.getHelper(IpoHelper.class); - Structure ipoStructure = pIpo.fetchData(dataRepository.getInputStream()).get(0); - Ipo ipo = ipoHelper.createIpo(ipoStructure, dataRepository); - int[] animationFrames = dataRepository.getBlenderKey().getAnimationFrames(objectName, objectAnimationName); + IpoHelper ipoHelper = blenderContext.getHelper(IpoHelper.class); + Structure ipoStructure = pIpo.fetchData(blenderContext.getInputStream()).get(0); + Ipo ipo = ipoHelper.createIpo(ipoStructure, blenderContext); + int[] animationFrames = blenderContext.getBlenderKey().getAnimationFrames(objectName, objectAnimationName); if (animationFrames == null) {// if the name was created here there are no frames set for the animation animationFrames = new int[] { 1, ipo.getLastFrame() }; } - int fps = dataRepository.getBlenderKey().getFps(); + int fps = blenderContext.getBlenderKey().getFps(); float start = (float) animationFrames[0] / (float) fps; float stop = (float) animationFrames[1] / (float) fps; @@ -97,8 +97,8 @@ import com.jme3.scene.plugins.ogre.AnimData; animations.add(boneAnimation); // preparing the object's bone - ObjectHelper objectHelper = dataRepository.getHelper(ObjectHelper.class); - Transform t = objectHelper.getTransformation(objectStructure, dataRepository); + ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class); + Transform t = objectHelper.getTransformation(objectStructure, blenderContext); Bone bone = new Bone(null); bone.setBindTransforms(t.getTranslation(), t.getRotation(), t.getScale()); @@ -108,7 +108,7 @@ import com.jme3.scene.plugins.ogre.AnimData; } @Override - public Node apply(Node node, DataRepository dataRepository) { + public Node apply(Node node, BlenderContext blenderContext) { LOGGER.warning("Object animation modifier not yet implemented!"); return null; } 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 23054bc1c..4a04b42d9 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 @@ -11,7 +11,7 @@ import com.jme3.scene.Geometry; import com.jme3.scene.Mesh; import com.jme3.scene.Node; import com.jme3.scene.Spatial; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.Pointer; import com.jme3.scene.plugins.blender.file.Structure; @@ -32,25 +32,25 @@ import com.jme3.scene.plugins.blender.particles.ParticlesHelper; * * @param modifier * the structure of the modifier - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * an exception is throw wneh there are problems with the * blender file */ - public ParticlesModifier(Structure modifier, DataRepository dataRepository) + public ParticlesModifier(Structure modifier, BlenderContext blenderContext) throws BlenderFileException { Pointer pParticleSystem = (Pointer) modifier.getFieldValue("psys"); if (pParticleSystem.isNotNull()) { - ParticlesHelper particlesHelper = dataRepository.getHelper(ParticlesHelper.class); - Structure particleSystem = pParticleSystem.fetchData(dataRepository.getInputStream()).get(0); - particleEmitter = particlesHelper.toParticleEmitter(particleSystem, dataRepository); + ParticlesHelper particlesHelper = blenderContext.getHelper(ParticlesHelper.class); + Structure particleSystem = pParticleSystem.fetchData(blenderContext.getInputStream()).get(0); + particleEmitter = particlesHelper.toParticleEmitter(particleSystem, blenderContext); } } @Override - public Node apply(Node node, DataRepository dataRepository) { - MaterialHelper materialHelper = dataRepository.getHelper(MaterialHelper.class); + public Node apply(Node node, BlenderContext blenderContext) { + MaterialHelper materialHelper = blenderContext.getHelper(MaterialHelper.class); ParticleEmitter emitter = particleEmitter.clone(); // veryfying the alpha function for particles' texture @@ -71,7 +71,7 @@ import com.jme3.scene.plugins.blender.particles.ParticlesHelper; if (mesh != null) { meshes.add(mesh); Material material = materialHelper.getParticlesMaterial( - ((Geometry) spatial).getMaterial(), alphaFunction, dataRepository); + ((Geometry) spatial).getMaterial(), alphaFunction, blenderContext); emitter.setMaterial(material);// TODO: divide into several pieces } } 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 6d049c477..7dc764e17 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 @@ -53,8 +53,8 @@ import com.jme3.scene.Node; import com.jme3.scene.Spatial; import com.jme3.scene.Spatial.CullHint; import com.jme3.scene.plugins.blender.AbstractBlenderHelper; -import com.jme3.scene.plugins.blender.DataRepository; -import com.jme3.scene.plugins.blender.DataRepository.LoadedFeatureDataType; +import com.jme3.scene.plugins.blender.BlenderContext; +import com.jme3.scene.plugins.blender.BlenderContext.LoadedFeatureDataType; import com.jme3.scene.plugins.blender.cameras.CameraHelper; import com.jme3.scene.plugins.blender.constraints.ConstraintHelper; import com.jme3.scene.plugins.blender.curves.CurvesHelper; @@ -127,20 +127,20 @@ public class ObjectHelper extends AbstractBlenderHelper { * This method reads the given structure and createn an object that represents the data. * @param objectStructure * the object's structure - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @return blener's object representation * @throws BlenderFileException * an exception is thrown when the given data is inapropriate */ - public Object toObject(Structure objectStructure, DataRepository dataRepository) throws BlenderFileException { - Object loadedResult = dataRepository.getLoadedFeature(objectStructure.getOldMemoryAddress(), LoadedFeatureDataType.LOADED_FEATURE); + public Object toObject(Structure objectStructure, BlenderContext blenderContext) throws BlenderFileException { + Object loadedResult = blenderContext.getLoadedFeature(objectStructure.getOldMemoryAddress(), LoadedFeatureDataType.LOADED_FEATURE); if(loadedResult != null) { return loadedResult; } - dataRepository.pushParent(objectStructure); - ObjectHelper objectHelper = dataRepository.getHelper(ObjectHelper.class); + blenderContext.pushParent(objectStructure); + ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class); //get object data int type = ((Number)objectStructure.getFieldValue("type")).intValue(); @@ -148,21 +148,21 @@ public class ObjectHelper extends AbstractBlenderHelper { LOGGER.log(Level.INFO, "Loading obejct: {0}", name); //loading constraints connected with this object - ConstraintHelper constraintHelper = dataRepository.getHelper(ConstraintHelper.class); - constraintHelper.loadConstraints(objectStructure, dataRepository); + ConstraintHelper constraintHelper = blenderContext.getHelper(ConstraintHelper.class); + constraintHelper.loadConstraints(objectStructure, blenderContext); int restrictflag = ((Number)objectStructure.getFieldValue("restrictflag")).intValue(); boolean visible = (restrictflag & 0x01) != 0; Object result = null; Pointer pParent = (Pointer)objectStructure.getFieldValue("parent"); - Object parent = dataRepository.getLoadedFeature(pParent.getOldMemoryAddress(), LoadedFeatureDataType.LOADED_FEATURE); + Object parent = blenderContext.getLoadedFeature(pParent.getOldMemoryAddress(), LoadedFeatureDataType.LOADED_FEATURE); if(parent == null && pParent.isNotNull()) { - Structure parentStructure = pParent.fetchData(dataRepository.getInputStream()).get(0);//TODO: what if there are more parents ?? - parent = this.toObject(parentStructure, dataRepository); + Structure parentStructure = pParent.fetchData(blenderContext.getInputStream()).get(0);//TODO: what if there are more parents ?? + parent = this.toObject(parentStructure, blenderContext); } - Transform t = objectHelper.getTransformation(objectStructure, dataRepository); + Transform t = objectHelper.getTransformation(objectStructure, blenderContext); try { switch(type) { @@ -178,10 +178,10 @@ public class ObjectHelper extends AbstractBlenderHelper { node.setCullHint(visible ? CullHint.Always : CullHint.Inherit); //reading mesh - MeshHelper meshHelper = dataRepository.getHelper(MeshHelper.class); + MeshHelper meshHelper = blenderContext.getHelper(MeshHelper.class); Pointer pMesh = (Pointer)objectStructure.getFieldValue("data"); - List meshesArray = pMesh.fetchData(dataRepository.getInputStream()); - List geometries = meshHelper.toMesh(meshesArray.get(0), dataRepository); + List meshesArray = pMesh.fetchData(blenderContext.getInputStream()); + List geometries = meshHelper.toMesh(meshesArray.get(0), blenderContext); if (geometries != null){ for(Geometry geometry : geometries) { node.attachChild(geometry); @@ -190,10 +190,10 @@ public class ObjectHelper extends AbstractBlenderHelper { node.setLocalTransform(t); //reading and applying all modifiers - ModifierHelper modifierHelper = dataRepository.getHelper(ModifierHelper.class); - Collection modifiers = modifierHelper.readModifiers(objectStructure, dataRepository); + ModifierHelper modifierHelper = blenderContext.getHelper(ModifierHelper.class); + Collection modifiers = modifierHelper.readModifiers(objectStructure, blenderContext); for(Modifier modifier : modifiers) { - modifier.apply(node, dataRepository); + modifier.apply(node, blenderContext); } //setting the parent @@ -208,9 +208,9 @@ public class ObjectHelper extends AbstractBlenderHelper { LOGGER.log(Level.INFO, "Importing curve/nurb."); Pointer pCurve = (Pointer)objectStructure.getFieldValue("data"); if(pCurve.isNotNull()) { - CurvesHelper curvesHelper = dataRepository.getHelper(CurvesHelper.class); - Structure curveData = pCurve.fetchData(dataRepository.getInputStream()).get(0); - List curves = curvesHelper.toCurve(curveData, dataRepository); + CurvesHelper curvesHelper = blenderContext.getHelper(CurvesHelper.class); + Structure curveData = pCurve.fetchData(blenderContext.getInputStream()).get(0); + List curves = curvesHelper.toCurve(curveData, blenderContext); result = new Node(name); for(Geometry curve : curves) { ((Node)result).attachChild(curve); @@ -222,9 +222,9 @@ public class ObjectHelper extends AbstractBlenderHelper { LOGGER.log(Level.INFO, "Importing lamp."); Pointer pLamp = (Pointer)objectStructure.getFieldValue("data"); if(pLamp.isNotNull()) { - LightHelper lightHelper = dataRepository.getHelper(LightHelper.class); - List lampsArray = pLamp.fetchData(dataRepository.getInputStream()); - Light light = lightHelper.toLight(lampsArray.get(0), dataRepository); + LightHelper lightHelper = blenderContext.getHelper(LightHelper.class); + List lampsArray = pLamp.fetchData(blenderContext.getInputStream()); + Light light = lightHelper.toLight(lampsArray.get(0), blenderContext); if(light!=null) { light.setName(name); } @@ -251,8 +251,8 @@ public class ObjectHelper extends AbstractBlenderHelper { case OBJECT_TYPE_CAMERA: Pointer pCamera = (Pointer)objectStructure.getFieldValue("data"); if(pCamera.isNotNull()) { - CameraHelper cameraHelper = dataRepository.getHelper(CameraHelper.class); - List camerasArray = pCamera.fetchData(dataRepository.getInputStream()); + CameraHelper cameraHelper = blenderContext.getHelper(CameraHelper.class); + List camerasArray = pCamera.fetchData(blenderContext.getInputStream()); Camera camera = cameraHelper.toCamera(camerasArray.get(0)); camera.setLocation(t.getTranslation()); camera.setRotation(t.getRotation()); @@ -266,17 +266,17 @@ public class ObjectHelper extends AbstractBlenderHelper { LOGGER.log(Level.WARNING, "Unknown object type: {0}", type); } } finally { - dataRepository.popParent(); + blenderContext.popParent(); } if(result != null) { //reading custom properties - Properties properties = this.loadProperties(objectStructure, dataRepository); + Properties properties = this.loadProperties(objectStructure, blenderContext); if(result instanceof Spatial && properties != null && properties.getValue() != null) { ((Spatial)result).setUserData("properties", properties); } - dataRepository.addLoadedFeatures(objectStructure.getOldMemoryAddress(), name, objectStructure, result); + blenderContext.addLoadedFeatures(objectStructure.getOldMemoryAddress(), name, objectStructure, result); } return result; } @@ -288,7 +288,7 @@ public class ObjectHelper extends AbstractBlenderHelper { * @return objects transformation relative to its parent */ @SuppressWarnings("unchecked") - public Transform getTransformation(Structure objectStructure, DataRepository dataRepository) { + public Transform getTransformation(Structure objectStructure, BlenderContext blenderContext) { //these are transformations in global space DynamicArray loc = (DynamicArray)objectStructure.getFieldValue("loc"); DynamicArray size = (DynamicArray)objectStructure.getFieldValue("size"); @@ -299,7 +299,7 @@ public class ObjectHelper extends AbstractBlenderHelper { Structure parent = null; if(pParent.isNotNull()) { try { - parent = pParent.fetchData(dataRepository.getInputStream()).get(0); + parent = pParent.fetchData(blenderContext.getInputStream()).get(0); } catch (BlenderFileException e) { LOGGER.log(Level.WARNING, "Cannot fetch parent for object! Reason: {0}", e.getLocalizedMessage()); } @@ -324,7 +324,7 @@ public class ObjectHelper extends AbstractBlenderHelper { size.get(2).floatValue() * scaleZ); //the root object is transformed if the Y axis is UP - if(fixUpAxis && (pParent.isNull() || (parent!=null && !this.shouldBeLoaded(parent, dataRepository)))) { + if(fixUpAxis && (pParent.isNull() || (parent!=null && !this.shouldBeLoaded(parent, blenderContext)))) { float y = translation.y; translation.y = translation.z; translation.z = -y; @@ -373,9 +373,9 @@ public class ObjectHelper extends AbstractBlenderHelper { } @Override - public boolean shouldBeLoaded(Structure structure, DataRepository dataRepository) { + public boolean shouldBeLoaded(Structure structure, BlenderContext blenderContext) { int lay = ((Number) structure.getFieldValue("lay")).intValue(); - return ((lay & dataRepository.getBlenderKey().getLayersToLoad()) != 0 - && (dataRepository.getBlenderKey().getFeaturesToLoad() & FeaturesToLoad.OBJECTS) != 0); + return ((lay & blenderContext.getBlenderKey().getLayersToLoad()) != 0 + && (blenderContext.getBlenderKey().getFeaturesToLoad() & FeaturesToLoad.OBJECTS) != 0); } } 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 229313c12..b2deef147 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 @@ -11,7 +11,7 @@ import com.jme3.export.JmeExporter; import com.jme3.export.JmeImporter; import com.jme3.export.OutputCapsule; import com.jme3.export.Savable; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.BlenderInputStream; import com.jme3.scene.plugins.blender.file.FileBlockHeader; @@ -57,12 +57,12 @@ public class Properties implements Cloneable, Savable { * This method loads the property from the belnder file. * @param idPropertyStructure * the ID structure constining the property - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @throws BlenderFileException * an exception is thrown when the belnder file is somehow invalid */ - public void load(Structure idPropertyStructure, DataRepository dataRepository) throws BlenderFileException { + public void load(Structure idPropertyStructure, BlenderContext blenderContext) throws BlenderFileException { name = idPropertyStructure.getFieldValue("name").toString(); if (name == null || name.length() == 0) { name = DEFAULT_NAME; @@ -76,8 +76,8 @@ public class Properties implements Cloneable, Savable { switch (type) { case IDP_STRING: { Pointer pointer = (Pointer) data.getFieldValue("pointer"); - BlenderInputStream bis = dataRepository.getInputStream(); - FileBlockHeader dataFileBlock = dataRepository.getFileBlock(pointer.getOldMemoryAddress()); + BlenderInputStream bis = blenderContext.getInputStream(); + FileBlockHeader dataFileBlock = blenderContext.getFileBlock(pointer.getOldMemoryAddress()); bis.setPosition(dataFileBlock.getBlockPosition()); value = bis.readString(); break; @@ -92,8 +92,8 @@ public class Properties implements Cloneable, Savable { break; case IDP_ARRAY: { Pointer pointer = (Pointer) data.getFieldValue("pointer"); - BlenderInputStream bis = dataRepository.getInputStream(); - FileBlockHeader dataFileBlock = dataRepository.getFileBlock(pointer.getOldMemoryAddress()); + BlenderInputStream bis = blenderContext.getInputStream(); + FileBlockHeader dataFileBlock = blenderContext.getFileBlock(pointer.getOldMemoryAddress()); bis.setPosition(dataFileBlock.getBlockPosition()); int elementAmount = dataFileBlock.getSize(); switch (subType) { @@ -127,11 +127,11 @@ public class Properties implements Cloneable, Savable { } case IDP_GROUP: Structure group = (Structure) data.getFieldValue("group"); - List dataList = group.evaluateListBase(dataRepository); + List dataList = group.evaluateListBase(blenderContext); List subProperties = new ArrayList(len); for (Structure d : dataList) { Properties properties = new Properties(); - properties.load(d, dataRepository); + properties.load(d, blenderContext); subProperties.add(properties); } value = subProperties; @@ -144,11 +144,11 @@ public class Properties implements Cloneable, Savable { break; case IDP_IDPARRAY: { Pointer pointer = (Pointer) data.getFieldValue("pointer"); - List arrays = pointer.fetchData(dataRepository.getInputStream()); + List arrays = pointer.fetchData(blenderContext.getInputStream()); List result = new ArrayList(arrays.size()); Properties temp = new Properties(); for (Structure array : arrays) { - temp.load(array, dataRepository); + temp.load(array, blenderContext); result.add(temp.value); } this.value = result; 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 dd3a9eb48..8d3e1f91f 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 @@ -12,7 +12,7 @@ import com.jme3.effect.shapes.EmitterMeshFaceShape; import com.jme3.effect.shapes.EmitterMeshVertexShape; import com.jme3.math.ColorRGBA; import com.jme3.scene.plugins.blender.AbstractBlenderHelper; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.DynamicArray; import com.jme3.scene.plugins.blender.file.Pointer; @@ -93,11 +93,11 @@ public class ParticlesHelper extends AbstractBlenderHelper { } @SuppressWarnings("unchecked") - public ParticleEmitter toParticleEmitter(Structure particleSystem, DataRepository dataRepository) throws BlenderFileException { + public ParticleEmitter toParticleEmitter(Structure particleSystem, BlenderContext blenderContext) throws BlenderFileException { ParticleEmitter result = null; Pointer pParticleSettings = (Pointer) particleSystem.getFieldValue("part"); if(pParticleSettings.isNotNull()) { - Structure particleSettings = pParticleSettings.fetchData(dataRepository.getInputStream()).get(0); + Structure particleSettings = pParticleSettings.fetchData(blenderContext.getInputStream()).get(0); int totPart = ((Number) particleSettings.getFieldValue("totpart")).intValue(); @@ -159,7 +159,7 @@ public class ParticlesHelper extends AbstractBlenderHelper { result.setEndSize(size); //reading lifetime - int fps = dataRepository.getBlenderKey().getFps(); + int fps = blenderContext.getBlenderKey().getFps(); float lifetime = ((Number)particleSettings.getFieldValue("lifetime")).floatValue() / fps; float randlife = ((Number)particleSettings.getFieldValue("randlife")).floatValue() / fps; result.setLowLife(lifetime * (1.0f - randlife)); @@ -189,7 +189,7 @@ public class ParticlesHelper extends AbstractBlenderHelper { } @Override - public boolean shouldBeLoaded(Structure structure, DataRepository dataRepository) { + public boolean shouldBeLoaded(Structure structure, BlenderContext blenderContext) { return true; } } diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/textures/NoiseGenerator.java b/engine/src/blender/com/jme3/scene/plugins/blender/textures/NoiseGenerator.java index 3b0b5f2bc..a3d8800ff 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/textures/NoiseGenerator.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/textures/NoiseGenerator.java @@ -41,14 +41,14 @@ import java.util.logging.Logger; import com.jme3.math.FastMath; import com.jme3.scene.plugins.blender.AbstractBlenderHelper; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.file.Structure; import com.jme3.scene.plugins.blender.textures.TextureGeneratorMusgrave.MusgraveData; /** * This generator is responsible for creating various noises used to create * generated textures loaded from blender. - * It derives from AbstractBlenderHelper but is not stored in data repository. + * It derives from AbstractBlenderHelper but is not stored in blender context. * It is only used by TextureHelper. * @author Marcin Roguski (Kaelthas) */ @@ -844,7 +844,7 @@ import com.jme3.scene.plugins.blender.textures.TextureGeneratorMusgrave.Musgrave } @Override - public boolean shouldBeLoaded(Structure structure, DataRepository dataRepository) { + public boolean shouldBeLoaded(Structure structure, BlenderContext blenderContext) { return true; } diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGenerator.java b/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGenerator.java index ac23b375b..5176ed4cd 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGenerator.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGenerator.java @@ -37,7 +37,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import com.jme3.math.FastMath; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.DynamicArray; import com.jme3.scene.plugins.blender.file.Pointer; @@ -67,29 +67,29 @@ import com.jme3.texture.Texture; * the height of the result texture * @param depth * the depth of the texture - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @return newly generated texture */ - protected abstract Texture generate(Structure tex, int width, int height, int depth, DataRepository dataRepository); + protected abstract Texture generate(Structure tex, int width, int height, int depth, BlenderContext blenderContext); /** * This method reads the colorband data from the given texture structure. * * @param tex * the texture structure - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @return read colorband or null if not present */ - private ColorBand readColorband(Structure tex, DataRepository dataRepository) { + private ColorBand readColorband(Structure tex, BlenderContext blenderContext) { ColorBand result = null; int flag = ((Number) tex.getFieldValue("flag")).intValue(); if ((flag & NoiseGenerator.TEX_COLORBAND) != 0) { Pointer pColorband = (Pointer) tex.getFieldValue("coba"); Structure colorbandStructure; try { - colorbandStructure = pColorband.fetchData(dataRepository.getInputStream()).get(0); + colorbandStructure = pColorband.fetchData(blenderContext.getInputStream()).get(0); result = new ColorBand(colorbandStructure); } catch (BlenderFileException e) { LOGGER.log(Level.WARNING, "Cannot fetch the colorband structure. The reason: {0}", e.getLocalizedMessage()); @@ -98,8 +98,8 @@ import com.jme3.texture.Texture; return result; } - protected float[][] computeColorband(Structure tex, DataRepository dataRepository) { - ColorBand colorBand = this.readColorband(tex, dataRepository); + protected float[][] computeColorband(Structure tex, BlenderContext blenderContext) { + ColorBand colorBand = this.readColorband(tex, blenderContext); float[][] result = null; if(colorBand!=null) { result = new float[1001][4];//1001 - amount of possible cursor positions; 4 = [r, g, b, a] diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorBlend.java b/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorBlend.java index bb2bb83f1..3528f3be9 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorBlend.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorBlend.java @@ -35,7 +35,7 @@ import java.nio.ByteBuffer; import java.util.ArrayList; import com.jme3.math.FastMath; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.file.Structure; import com.jme3.texture.Image; import com.jme3.texture.Image.Format; @@ -115,13 +115,13 @@ public final class TextureGeneratorBlend extends TextureGenerator { } @Override - protected Texture generate(Structure tex, int width, int height, int depth, DataRepository dataRepository) { + protected Texture generate(Structure tex, int width, int height, int depth, BlenderContext blenderContext) { int flag = ((Number) tex.getFieldValue("flag")).intValue(); int stype = ((Number) tex.getFieldValue("stype")).intValue(); TextureResult texres = new TextureResult(); int halfW = width >> 1, halfH = height >> 1, halfD = depth >> 1, index = 0; float wDelta = 1.0f / halfW, hDelta = 1.0f / halfH, dDelta = 1.0f / halfD, x, y; - float[][] colorBand = this.computeColorband(tex, dataRepository); + float[][] colorBand = this.computeColorband(tex, blenderContext); BrightnessAndContrastData bacd = new BrightnessAndContrastData(tex); Format format = colorBand != null ? Format.RGB8 : Format.Luminance8; int bytesPerPixel = colorBand != null ? 3 : 1; diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorClouds.java b/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorClouds.java index ffb6abdf9..fdd3cf78f 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorClouds.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorClouds.java @@ -35,7 +35,7 @@ import java.nio.ByteBuffer; import java.util.ArrayList; import com.jme3.math.FastMath; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.file.Structure; import com.jme3.texture.Image; import com.jme3.texture.Image.Format; @@ -66,7 +66,7 @@ public class TextureGeneratorClouds extends TextureGenerator { } @Override - protected Texture generate(Structure tex, int width, int height, int depth, DataRepository dataRepository) { + protected Texture generate(Structure tex, int width, int height, int depth, BlenderContext blenderContext) { float[] texvec = new float[] { 0, 0, 0 }; TextureResult texres = new TextureResult(); @@ -79,7 +79,7 @@ public class TextureGeneratorClouds extends TextureGenerator { int sType = ((Number) tex.getFieldValue("stype")).intValue(); int halfW = width >> 1, halfH = height >> 1, halfD = depth >> 1, index = 0; float wDelta = 1.0f / halfW, hDelta = 1.0f / halfH, dDelta = 1.0f / halfD; - float[][] colorBand = this.computeColorband(tex, dataRepository); + float[][] colorBand = this.computeColorband(tex, blenderContext); Format format = sType == TEX_COLOR || colorBand != null ? Format.RGB8 : Format.Luminance8; int bytesPerPixel = sType == TEX_COLOR || colorBand != null ? 3 : 1; BrightnessAndContrastData bacd = new BrightnessAndContrastData(tex); diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorDistnoise.java b/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorDistnoise.java index a1ffab9a8..4f7d07b0d 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorDistnoise.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorDistnoise.java @@ -34,7 +34,7 @@ package com.jme3.scene.plugins.blender.textures; import java.nio.ByteBuffer; import java.util.ArrayList; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.file.Structure; import com.jme3.scene.plugins.blender.textures.NoiseGenerator.NoiseFunction; import com.jme3.texture.Image; @@ -59,7 +59,7 @@ public class TextureGeneratorDistnoise extends TextureGenerator { } @Override - protected Texture generate(Structure tex, int width, int height, int depth, DataRepository dataRepository) { + protected Texture generate(Structure tex, int width, int height, int depth, BlenderContext blenderContext) { float noisesize = ((Number) tex.getFieldValue("noisesize")).floatValue(); float distAmount = ((Number) tex.getFieldValue("dist_amount")).floatValue(); int noisebasis = ((Number) tex.getFieldValue("noisebasis")).intValue(); @@ -69,7 +69,7 @@ public class TextureGeneratorDistnoise extends TextureGenerator { float[] texvec = new float[] { 0, 0, 0 }; int halfW = width >> 1, halfH = height >> 1, halfD = depth >> 1, index = 0; float wDelta = 1.0f / halfW, hDelta = 1.0f / halfH, dDelta = 1.0f / halfD; - float[][] colorBand = this.computeColorband(tex, dataRepository); + float[][] colorBand = this.computeColorband(tex, blenderContext); Format format = colorBand != null ? Format.RGB8 : Format.Luminance8; int bytesPerPixel = colorBand != null ? 3 : 1; BrightnessAndContrastData bacd = new BrightnessAndContrastData(tex); diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorMagic.java b/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorMagic.java index 9b2002f25..a6d051a47 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorMagic.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorMagic.java @@ -34,7 +34,7 @@ package com.jme3.scene.plugins.blender.textures; import java.nio.ByteBuffer; import java.util.ArrayList; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.file.Structure; import com.jme3.texture.Image; import com.jme3.texture.Image.Format; @@ -121,7 +121,7 @@ public class TextureGeneratorMagic extends TextureGenerator { } @Override - protected Texture generate(Structure tex, int width, int height, int depth, DataRepository dataRepository) { + protected Texture generate(Structure tex, int width, int height, int depth, BlenderContext blenderContext) { float xyz[] = new float[3], turb; int noisedepth = ((Number) tex.getFieldValue("noisedepth")).intValue(); float turbul = ((Number) tex.getFieldValue("turbul")).floatValue() / 5.0f; @@ -129,7 +129,7 @@ public class TextureGeneratorMagic extends TextureGenerator { TextureResult texres = new TextureResult(); int halfW = width >> 1, halfH = height >> 1, halfD = depth >> 1, index = 0; float wDelta = 1.0f / halfW, hDelta = 1.0f / halfH, dDelta = 1.0f / halfD; - float[][] colorBand = this.computeColorband(tex, dataRepository); + float[][] colorBand = this.computeColorband(tex, blenderContext); BrightnessAndContrastData bacd = new BrightnessAndContrastData(tex); byte[] data = new byte[width * height * depth * 3]; diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorMarble.java b/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorMarble.java index af8877160..47148564f 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorMarble.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorMarble.java @@ -34,7 +34,7 @@ package com.jme3.scene.plugins.blender.textures; import java.nio.ByteBuffer; import java.util.ArrayList; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.file.Structure; import com.jme3.texture.Image; import com.jme3.texture.Image.Format; @@ -62,12 +62,12 @@ public class TextureGeneratorMarble extends TextureGeneratorWood { } @Override - protected Texture generate(Structure tex, int width, int height, int depth, DataRepository dataRepository) { + protected Texture generate(Structure tex, int width, int height, int depth, BlenderContext blenderContext) { float[] texvec = new float[] { 0, 0, 0 }; TextureResult texres = new TextureResult(); int halfW = width >> 1, halfH = height >> 1, halfD = depth >> 1, index = 0; float wDelta = 1.0f / halfW, hDelta = 1.0f / halfH, dDelta = 1.0f / halfD; - float[][] colorBand = this.computeColorband(tex, dataRepository); + float[][] colorBand = this.computeColorband(tex, blenderContext); Format format = colorBand != null ? Format.RGB8 : Format.Luminance8; int bytesPerPixel = colorBand != null ? 3 : 1; BrightnessAndContrastData bacd = new BrightnessAndContrastData(tex); diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorMusgrave.java b/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorMusgrave.java index 8877ef4f6..94479aeee 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorMusgrave.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorMusgrave.java @@ -34,7 +34,7 @@ package com.jme3.scene.plugins.blender.textures; import java.nio.ByteBuffer; import java.util.ArrayList; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.file.Structure; import com.jme3.scene.plugins.blender.textures.NoiseGenerator.MusgraveFunction; import com.jme3.texture.Image; @@ -59,14 +59,14 @@ public class TextureGeneratorMusgrave extends TextureGenerator { } @Override - protected Texture generate(Structure tex, int width, int height, int depth, DataRepository dataRepository) { + protected Texture generate(Structure tex, int width, int height, int depth, BlenderContext blenderContext) { int stype = ((Number) tex.getFieldValue("stype")).intValue(); float noisesize = ((Number) tex.getFieldValue("noisesize")).floatValue(); TextureResult texres = new TextureResult(); float[] texvec = new float[] { 0, 0, 0 }; int halfW = width >> 1, halfH = height >> 1, halfD = depth >> 1, index = 0; float wDelta = 1.0f / halfW, hDelta = 1.0f / halfH, dDelta = 1.0f / halfD; - float[][] colorBand = this.computeColorband(tex, dataRepository); + float[][] colorBand = this.computeColorband(tex, blenderContext); Format format = colorBand != null ? Format.RGB8 : Format.Luminance8; int bytesPerPixel = colorBand != null ? 3 : 1; MusgraveData musgraveData = new MusgraveData(tex); diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorNoise.java b/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorNoise.java index 9213906ee..cadba7c8e 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorNoise.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorNoise.java @@ -35,7 +35,7 @@ import java.nio.ByteBuffer; import java.util.ArrayList; import com.jme3.math.FastMath; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.file.Structure; import com.jme3.texture.Image; import com.jme3.texture.Image.Format; @@ -59,12 +59,12 @@ public class TextureGeneratorNoise extends TextureGenerator { } @Override - protected Texture generate(Structure tex, int width, int height, int depth, DataRepository dataRepository) { + protected Texture generate(Structure tex, int width, int height, int depth, BlenderContext blenderContext) { int val, random, loop; int noisedepth = ((Number) tex.getFieldValue("noisedepth")).intValue(); TextureResult texres = new TextureResult(); int halfW = width >> 1, halfH = height >> 1, halfD = depth >> 1, index = 0; - float[][] colorBand = this.computeColorband(tex, dataRepository); + float[][] colorBand = this.computeColorband(tex, blenderContext); Format format = colorBand != null ? Format.RGB8 : Format.Luminance8; int bytesPerPixel = colorBand != null ? 3 : 1; BrightnessAndContrastData bacd = new BrightnessAndContrastData(tex); diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorStucci.java b/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorStucci.java index 4da0d0286..3fd4e54e8 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorStucci.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorStucci.java @@ -34,7 +34,7 @@ package com.jme3.scene.plugins.blender.textures; import java.nio.ByteBuffer; import java.util.ArrayList; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.file.Structure; import com.jme3.texture.Image; import com.jme3.texture.Image.Format; @@ -59,7 +59,7 @@ public class TextureGeneratorStucci extends TextureGenerator { } @Override - protected Texture generate(Structure tex, int width, int height, int depth, DataRepository dataRepository) { + protected Texture generate(Structure tex, int width, int height, int depth, BlenderContext blenderContext) { float noisesize = ((Number) tex.getFieldValue("noisesize")).floatValue(); int noisebasis = ((Number) tex.getFieldValue("noisebasis")).intValue(); int noisetype = ((Number) tex.getFieldValue("noisetype")).intValue(); @@ -75,7 +75,7 @@ public class TextureGeneratorStucci extends TextureGenerator { TextureResult texres = new TextureResult(); int halfW = width >> 1, halfH = height >> 1, halfD = depth >> 1, index = 0; float wDelta = 1.0f / halfW, hDelta = 1.0f / halfH, dDelta = 1.0f / halfD, noiseValue, ofs;; - float[][] colorBand = this.computeColorband(tex, dataRepository); + float[][] colorBand = this.computeColorband(tex, blenderContext); Format format = colorBand != null ? Format.RGB8 : Format.Luminance8; int bytesPerPixel = colorBand != null ? 3 : 1; diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorVoronoi.java b/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorVoronoi.java index 0448b29a3..fe1b40dd9 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorVoronoi.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorVoronoi.java @@ -35,7 +35,7 @@ import java.nio.ByteBuffer; import java.util.ArrayList; import com.jme3.math.FastMath; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.file.Structure; import com.jme3.scene.plugins.blender.textures.NoiseGenerator.NoiseMath; import com.jme3.texture.Image; @@ -60,7 +60,7 @@ public class TextureGeneratorVoronoi extends TextureGenerator { } @Override - protected Texture generate(Structure tex, int width, int height, int depth, DataRepository dataRepository) { + protected Texture generate(Structure tex, int width, int height, int depth, BlenderContext blenderContext) { float voronoiWeight1 = ((Number) tex.getFieldValue("vn_w1")).floatValue(); float voronoiWeight2 = ((Number) tex.getFieldValue("vn_w2")).floatValue(); float voronoiWeight3 = ((Number) tex.getFieldValue("vn_w3")).floatValue(); @@ -76,7 +76,7 @@ public class TextureGeneratorVoronoi extends TextureGenerator { int halfW = width >> 1, halfH = height >> 1, halfD = depth >> 1, index = 0; float wDelta = 1.0f / halfW, hDelta = 1.0f / halfH, dDelta = 1.0f / halfD; - float[][] colorBand = this.computeColorband(tex, dataRepository); + float[][] colorBand = this.computeColorband(tex, blenderContext); Format format = voronoiColorType != 0 || colorBand != null ? Format.RGB8 : Format.Luminance8; int bytesPerPixel = voronoiColorType != 0 || colorBand != null ? 3 : 1; BrightnessAndContrastData bacd = new BrightnessAndContrastData(tex); diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorWood.java b/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorWood.java index f9bd7f9d9..c7ed8946f 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorWood.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/textures/TextureGeneratorWood.java @@ -34,7 +34,7 @@ import java.nio.ByteBuffer; import java.util.ArrayList; import com.jme3.math.FastMath; -import com.jme3.scene.plugins.blender.DataRepository; +import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.file.Structure; import com.jme3.texture.Image; import com.jme3.texture.Image.Format; @@ -71,7 +71,7 @@ public class TextureGeneratorWood extends TextureGenerator { } @Override - protected Texture generate(Structure tex, int width, int height, int depth, DataRepository dataRepository) { + protected Texture generate(Structure tex, int width, int height, int depth, BlenderContext blenderContext) { float[] texvec = new float[] { 0, 0, 0 }; TextureResult texres = new TextureResult(); int halfW = width >> 1; @@ -79,7 +79,7 @@ public class TextureGeneratorWood extends TextureGenerator { int halfD = depth >> 1; float wDelta = 1.0f / halfW, hDelta = 1.0f / halfH, dDelta = 1.0f / halfD; - float[][] colorBand = this.computeColorband(tex, dataRepository); + float[][] colorBand = this.computeColorband(tex, blenderContext); Format format = colorBand != null ? Format.RGB8 : Format.Luminance8; int bytesPerPixel = colorBand != null ? 3 : 1; WoodIntensityData woodIntensityData = new WoodIntensityData(tex); 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 42b137b1b..bb1d47912 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 @@ -53,8 +53,8 @@ import com.jme3.asset.TextureKey; import com.jme3.math.FastMath; import com.jme3.math.Vector3f; import com.jme3.scene.plugins.blender.AbstractBlenderHelper; -import com.jme3.scene.plugins.blender.DataRepository; -import com.jme3.scene.plugins.blender.DataRepository.LoadedFeatureDataType; +import com.jme3.scene.plugins.blender.BlenderContext; +import com.jme3.scene.plugins.blender.BlenderContext.LoadedFeatureDataType; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.file.FileBlockHeader; import com.jme3.scene.plugins.blender.file.Pointer; @@ -160,28 +160,28 @@ public class TextureHelper extends AbstractBlenderHelper { * * @param tex * texture structure filled with data - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @return the texture that can be used by JME engine * @throws BlenderFileException * this exception is thrown when the blend file structure is somehow invalid or corrupted */ - public Texture getTexture(Structure tex, DataRepository dataRepository) throws BlenderFileException { - Texture result = (Texture) dataRepository.getLoadedFeature(tex.getOldMemoryAddress(), LoadedFeatureDataType.LOADED_FEATURE); + public Texture getTexture(Structure tex, BlenderContext blenderContext) throws BlenderFileException { + Texture result = (Texture) blenderContext.getLoadedFeature(tex.getOldMemoryAddress(), LoadedFeatureDataType.LOADED_FEATURE); if (result != null) { return result; } int type = ((Number) tex.getFieldValue("type")).intValue(); - int width = dataRepository.getBlenderKey().getGeneratedTextureWidth(); - int height = dataRepository.getBlenderKey().getGeneratedTextureHeight(); - int depth = dataRepository.getBlenderKey().getGeneratedTextureDepth(); + int width = blenderContext.getBlenderKey().getGeneratedTextureWidth(); + int height = blenderContext.getBlenderKey().getGeneratedTextureHeight(); + int depth = blenderContext.getBlenderKey().getGeneratedTextureDepth(); switch (type) { 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(dataRepository.getInputStream()).get(0); - result = this.getTextureFromImage(image, dataRepository); + Structure image = pImage.fetchData(blenderContext.getInputStream()).get(0); + result = this.getTextureFromImage(image, blenderContext); } break; case TEX_CLOUDS: @@ -195,7 +195,7 @@ public class TextureHelper extends AbstractBlenderHelper { case TEX_VORONOI: case TEX_DISTNOISE: TextureGenerator textureGenerator = textureGenerators.get(Integer.valueOf(type)); - result = textureGenerator.generate(tex, width, height, depth, dataRepository); + result = textureGenerator.generate(tex, width, height, depth, blenderContext); break; case TEX_NONE:// No texture, do nothing break; @@ -236,11 +236,11 @@ public class TextureHelper extends AbstractBlenderHelper { * the factor that the color affects the texture (value form 0.0 to 1.0) * @param blendType * the blending type - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @return new texture that was created after the blending */ - public Texture blendTexture(float[] materialColor, Texture texture, float[] color, float affectFactor, int blendType, boolean neg, DataRepository dataRepository) { + public Texture blendTexture(float[] materialColor, Texture texture, float[] color, float affectFactor, int blendType, boolean neg, BlenderContext blenderContext) { float[] materialColorClone = materialColor.clone();//this array may change, so we copy it Format format = texture.getImage().getFormat(); ByteBuffer data = texture.getImage().getData(0); @@ -257,7 +257,7 @@ public class TextureHelper extends AbstractBlenderHelper { int dataIndex = 0; while (data.hasRemaining()) { float tin = this.setupMaterialColor(data, format, neg, materialColorClone); - this.blendPixel(resultPixel, materialColorClone, color, tin, affectFactor, blendType, dataRepository); + this.blendPixel(resultPixel, materialColorClone, color, tin, affectFactor, blendType, blenderContext); newData.put(dataIndex++, (byte) (resultPixel[0] * 255.0f)); newData.put(dataIndex++, (byte) (resultPixel[1] * 255.0f)); newData.put(dataIndex++, (byte) (resultPixel[2] * 255.0f)); @@ -396,10 +396,10 @@ public class TextureHelper extends AbstractBlenderHelper { * texture affection factor (variable 'facg' in blender source code) * @param blendtype * the blend type - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context */ - protected void blendPixel(float[] result, float[] materialColor, float[] color, float textureIntensity, float textureFactor, int blendtype, DataRepository dataRepository) { + protected void blendPixel(float[] result, float[] materialColor, float[] color, float textureIntensity, float textureFactor, int blendtype, BlenderContext blenderContext) { float oneMinusFactor, col; textureIntensity *= textureFactor; @@ -492,7 +492,7 @@ public class TextureHelper extends AbstractBlenderHelper { case MTEX_BLEND_VAL: case MTEX_BLEND_COLOR: System.arraycopy(materialColor, 0, result, 0, 3); - this.rampBlend(blendtype, result, textureIntensity, color, dataRepository); + this.rampBlend(blendtype, result, textureIntensity, color, blenderContext); break; default: throw new IllegalStateException("Unknown blend type: " + blendtype); @@ -510,12 +510,12 @@ public class TextureHelper extends AbstractBlenderHelper { * color affection factor * @param col * the texture color - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context */ - protected void rampBlend(int type, float[] rgb, float fac, float[] col, DataRepository dataRepository) { + protected void rampBlend(int type, float[] rgb, float fac, float[] col, BlenderContext blenderContext) { float oneMinusFactor = 1.0f - fac; - MaterialHelper materialHelper = dataRepository.getHelper(MaterialHelper.class); + MaterialHelper materialHelper = blenderContext.getHelper(MaterialHelper.class); if (rgb.length >= 3) { switch (type) { @@ -660,30 +660,30 @@ public class TextureHelper extends AbstractBlenderHelper { * * @param image * image structure filled with data - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @return the texture that can be used by JME engine * @throws BlenderFileException * this exception is thrown when the blend file structure is somehow invalid or corrupted */ - public Texture getTextureFromImage(Structure image, DataRepository dataRepository) throws BlenderFileException { - Texture result = (Texture) dataRepository.getLoadedFeature(image.getOldMemoryAddress(), LoadedFeatureDataType.LOADED_FEATURE); + public Texture getTextureFromImage(Structure image, BlenderContext blenderContext) throws BlenderFileException { + Texture result = (Texture) blenderContext.getLoadedFeature(image.getOldMemoryAddress(), LoadedFeatureDataType.LOADED_FEATURE); if (result == null) { String texturePath = image.getFieldValue("name").toString(); Pointer pPackedFile = (Pointer) image.getFieldValue("packedfile"); if (pPackedFile.isNull()) { LOGGER.info("Reading texture from file!"); - result = this.loadTextureFromFile(texturePath, dataRepository); + result = this.loadTextureFromFile(texturePath, blenderContext); } else { LOGGER.info("Packed texture. Reading directly from the blend file!"); - Structure packedFile = pPackedFile.fetchData(dataRepository.getInputStream()).get(0); + Structure packedFile = pPackedFile.fetchData(blenderContext.getInputStream()).get(0); Pointer pData = (Pointer) packedFile.getFieldValue("data"); - FileBlockHeader dataFileBlock = dataRepository.getFileBlock(pData.getOldMemoryAddress()); - dataRepository.getInputStream().setPosition(dataFileBlock.getBlockPosition()); + FileBlockHeader dataFileBlock = blenderContext.getFileBlock(pData.getOldMemoryAddress()); + blenderContext.getInputStream().setPosition(dataFileBlock.getBlockPosition()); ImageLoader imageLoader = new ImageLoader(); // Should the texture be flipped? It works for sinbad .. - Image im = imageLoader.loadImage(dataRepository.getInputStream(), dataFileBlock.getBlockPosition(), true); + Image im = imageLoader.loadImage(blenderContext.getInputStream(), dataFileBlock.getBlockPosition(), true); if (im != null) { result = new Texture2D(im); } @@ -691,7 +691,7 @@ public class TextureHelper extends AbstractBlenderHelper { if (result != null) { result.setName(texturePath); result.setWrap(Texture.WrapMode.Repeat); - dataRepository.addLoadedFeatures(image.getOldMemoryAddress(), image.getName(), image, result); + blenderContext.addLoadedFeatures(image.getOldMemoryAddress(), image.getName(), image, result); } } return result; @@ -702,12 +702,12 @@ public class TextureHelper extends AbstractBlenderHelper { * * @param name * the path to the image - * @param dataRepository - * the data repository + * @param blenderContext + * the blender context * @return the loaded image or null if the image cannot be found */ - protected Texture loadTextureFromFile(String name, DataRepository dataRepository) { - AssetManager assetManager = dataRepository.getAssetManager(); + protected Texture loadTextureFromFile(String name, BlenderContext blenderContext) { + AssetManager assetManager = blenderContext.getAssetManager(); name = name.replaceAll("\\\\", "\\/"); Texture result = null; @@ -715,7 +715,7 @@ public class TextureHelper extends AbstractBlenderHelper { if (name.startsWith("//")) { String relativePath = name.substring(2); //augument the path with blender key path - BlenderKey blenderKey = dataRepository.getBlenderKey(); + BlenderKey blenderKey = blenderContext.getBlenderKey(); int idx = blenderKey.getName().lastIndexOf('/'); String blenderAssetFolder = blenderKey.getName().substring(0, idx != -1 ? idx : 0); assetNames.add(blenderAssetFolder+'/'+relativePath); @@ -747,7 +747,7 @@ public class TextureHelper extends AbstractBlenderHelper { } @Override - public boolean shouldBeLoaded(Structure structure, DataRepository dataRepository) { - return (dataRepository.getBlenderKey().getFeaturesToLoad() & FeaturesToLoad.TEXTURES) != 0; + public boolean shouldBeLoaded(Structure structure, BlenderContext blenderContext) { + return (blenderContext.getBlenderKey().getFeaturesToLoad() & FeaturesToLoad.TEXTURES) != 0; } } \ No newline at end of file