Disabling loading all assets by default. Now unlinked assets or those being on inactive layers will not be loaded if they are not requested to.
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8042 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
b3a37f93b7
commit
daa86cfec7
@ -88,6 +88,8 @@ public class BlenderKey extends ModelKey {
|
||||
* This variable is a bitwise flag of FeatureToLoad interface values; By default everything is being loaded.
|
||||
*/
|
||||
protected int featuresToLoad = FeaturesToLoad.ALL;
|
||||
/** This variable determines if assets that are not linked to the objects should be loaded. */
|
||||
protected boolean loadUnlinkedAssets;
|
||||
/** The root path for all the assets. */
|
||||
protected String assetRootPath;
|
||||
/** This variable indicate if Y axis is UP axis. If not then Z is up. By default set to true. */
|
||||
@ -113,8 +115,7 @@ public class BlenderKey extends ModelKey {
|
||||
/**
|
||||
* Constructor used by serialization mechanisms.
|
||||
*/
|
||||
public BlenderKey() {
|
||||
}
|
||||
public BlenderKey() {}
|
||||
|
||||
/**
|
||||
* Constructor. Creates a key for the given file name.
|
||||
@ -155,7 +156,7 @@ public class BlenderKey extends ModelKey {
|
||||
objectAnimations = new HashMap<String, int[]>();
|
||||
animations.put(objectName, objectAnimations);
|
||||
}
|
||||
objectAnimations.put(name, new int[]{start, stop});
|
||||
objectAnimations.put(name, new int[] { start, stop });
|
||||
}
|
||||
|
||||
/**
|
||||
@ -273,7 +274,8 @@ public class BlenderKey extends ModelKey {
|
||||
|
||||
/**
|
||||
* This method sets layers to be loaded.
|
||||
* @param layersToLoad layers to be loaded
|
||||
* @param layersToLoad
|
||||
* layers to be loaded
|
||||
*/
|
||||
public void setLayersToLoad(int layersToLoad) {
|
||||
this.layersToLoad = layersToLoad;
|
||||
@ -331,6 +333,29 @@ public class BlenderKey extends ModelKey {
|
||||
return featuresToLoad;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method determines if unlinked assets should be loaded.
|
||||
* If not then only objects on selected layers will be loaded and their assets if required.
|
||||
* If yes then all assets will be loaded even if they are on inactive layers or are not linked
|
||||
* to anything.
|
||||
* @return <b>true</b> if unlinked assets should be loaded and <b>false</b> otherwise
|
||||
*/
|
||||
public boolean isLoadUnlinkedAssets() {
|
||||
return loadUnlinkedAssets;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets if unlinked assets should be loaded.
|
||||
* If not then only objects on selected layers will be loaded and their assets if required.
|
||||
* If yes then all assets will be loaded even if they are on inactive layers or are not linked
|
||||
* to anything.
|
||||
* @param loadUnlinkedAssets
|
||||
* <b>true</b> if unlinked assets should be loaded and <b>false</b> otherwise
|
||||
*/
|
||||
public void setLoadUnlinkedAssets(boolean loadUnlinkedAssets) {
|
||||
this.loadUnlinkedAssets = loadUnlinkedAssets;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates an object where loading results will be stores. Only those features will be allowed to store
|
||||
* that were specified by features-to-load flag.
|
||||
@ -399,7 +424,7 @@ public class BlenderKey extends ModelKey {
|
||||
public void write(JmeExporter e) throws IOException {
|
||||
super.write(e);
|
||||
OutputCapsule oc = e.getCapsule(this);
|
||||
//saving animations
|
||||
// saving animations
|
||||
oc.write(animations == null ? 0 : animations.size(), "anim-size", 0);
|
||||
if (animations != null) {
|
||||
int objectCounter = 0;
|
||||
@ -414,9 +439,13 @@ public class BlenderKey extends ModelKey {
|
||||
++objectCounter;
|
||||
}
|
||||
}
|
||||
//saving the rest of the data
|
||||
// saving the rest of the data
|
||||
oc.write(fps, "fps", DEFAULT_FPS);
|
||||
oc.write(generatedTextureWidth, "generated-texture-width", 20);
|
||||
oc.write(generatedTextureHeight, "generated-texture-height", 20);
|
||||
oc.write(generatedTextureDepth, "generated-texture-depth", 20);
|
||||
oc.write(featuresToLoad, "features-to-load", FeaturesToLoad.ALL);
|
||||
oc.write(loadUnlinkedAssets, "load-unlinked-assets", false);
|
||||
oc.write(assetRootPath, "asset-root-path", null);
|
||||
oc.write(fixUpAxis, "fix-up-axis", true);
|
||||
oc.write(usedWorld, "used-world", null);
|
||||
@ -429,7 +458,7 @@ public class BlenderKey extends ModelKey {
|
||||
public void read(JmeImporter e) throws IOException {
|
||||
super.read(e);
|
||||
InputCapsule ic = e.getCapsule(this);
|
||||
//reading animations
|
||||
// reading animations
|
||||
int animSize = ic.readInt("anim-size", 0);
|
||||
if (animSize > 0) {
|
||||
if (animations == null) {
|
||||
@ -450,9 +479,13 @@ public class BlenderKey extends ModelKey {
|
||||
}
|
||||
}
|
||||
|
||||
//reading the rest of the data
|
||||
// reading the rest of the data
|
||||
fps = ic.readInt("fps", DEFAULT_FPS);
|
||||
generatedTextureWidth = ic.readInt("generated-texture-width", 20);
|
||||
generatedTextureHeight = ic.readInt("generated-texture-height", 20);
|
||||
generatedTextureDepth = ic.readInt("generated-texture-depth", 20);
|
||||
featuresToLoad = ic.readInt("features-to-load", FeaturesToLoad.ALL);
|
||||
loadUnlinkedAssets = ic.readBoolean("load-unlinked-assets", false);
|
||||
assetRootPath = ic.readString("asset-root-path", null);
|
||||
fixUpAxis = ic.readBoolean("fix-up-axis", true);
|
||||
usedWorld = ic.readString("used-world", null);
|
||||
@ -472,9 +505,11 @@ public class BlenderKey extends ModelKey {
|
||||
result = prime * result + featuresToLoad;
|
||||
result = prime * result + (fixUpAxis ? 1231 : 1237);
|
||||
result = prime * result + fps;
|
||||
result = prime * result + generatedTextureDepth;
|
||||
result = prime * result + generatedTextureHeight;
|
||||
result = prime * result + generatedTextureWidth;
|
||||
result = prime * result + layersToLoad;
|
||||
result = prime * result + (loadUnlinkedAssets ? 1231 : 1237);
|
||||
result = prime * result + (usedWorld == null ? 0 : usedWorld.hashCode());
|
||||
return result;
|
||||
}
|
||||
@ -524,6 +559,9 @@ public class BlenderKey extends ModelKey {
|
||||
if (fps != other.fps) {
|
||||
return false;
|
||||
}
|
||||
if (generatedTextureDepth != other.generatedTextureDepth) {
|
||||
return false;
|
||||
}
|
||||
if (generatedTextureHeight != other.generatedTextureHeight) {
|
||||
return false;
|
||||
}
|
||||
@ -533,6 +571,9 @@ public class BlenderKey extends ModelKey {
|
||||
if (layersToLoad != other.layersToLoad) {
|
||||
return false;
|
||||
}
|
||||
if (loadUnlinkedAssets != other.loadUnlinkedAssets) {
|
||||
return false;
|
||||
}
|
||||
if (usedWorld == null) {
|
||||
if (other.usedWorld != null) {
|
||||
return false;
|
||||
@ -751,12 +792,10 @@ public class BlenderKey extends ModelKey {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateModelBound() {
|
||||
}
|
||||
public void updateModelBound() {}
|
||||
|
||||
@Override
|
||||
public void setModelBound(BoundingVolume modelBound) {
|
||||
}
|
||||
public void setModelBound(BoundingVolume modelBound) {}
|
||||
|
||||
@Override
|
||||
public int getVertexCount() {
|
||||
@ -774,12 +813,10 @@ public class BlenderKey extends ModelKey {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void depthFirstTraversal(SceneGraphVisitor visitor) {
|
||||
}
|
||||
public void depthFirstTraversal(SceneGraphVisitor visitor) {}
|
||||
|
||||
@Override
|
||||
protected void breadthFirstTraversal(SceneGraphVisitor visitor, Queue<Spatial> queue) {
|
||||
}
|
||||
protected void breadthFirstTraversal(SceneGraphVisitor visitor, Queue<Spatial> queue) {}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -153,7 +153,7 @@ public class BlenderLoader implements AssetLoader {
|
||||
}
|
||||
break;
|
||||
case FileBlockHeader.BLOCK_MA00://Material
|
||||
if ((blenderKey.getFeaturesToLoad() & FeaturesToLoad.MATERIALS) != 0) {
|
||||
if (blenderKey.isLoadUnlinkedAssets() && (blenderKey.getFeaturesToLoad() & FeaturesToLoad.MATERIALS) != 0) {
|
||||
loadingResults.addMaterial(converter.toMaterial(block.getStructure(dataRepository)));
|
||||
}
|
||||
break;
|
||||
@ -163,7 +163,7 @@ public class BlenderLoader implements AssetLoader {
|
||||
}
|
||||
break;
|
||||
case FileBlockHeader.BLOCK_WO00://World
|
||||
if (worldData == null) {//onlu one world data is used
|
||||
if (blenderKey.isLoadUnlinkedAssets() && worldData == null) {//onlu one world data is used
|
||||
Structure worldStructure = block.getStructure(dataRepository);
|
||||
String worldName = worldStructure.getName();
|
||||
if (blenderKey.getUsedWorld() == null || blenderKey.getUsedWorld().equals(worldName)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user