Fix for blender loader classes (latest changes to light and camera loading were taken into account).

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9711 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
Kae..pl 12 years ago
parent 2a11aae3a4
commit 4fa00b6d9a
  1. 13
      engine/src/blender/com/jme3/scene/plugins/blender/AbstractBlenderLoader.java
  2. 26
      engine/src/blender/com/jme3/scene/plugins/blender/BlenderModelLoader.java

@ -39,7 +39,6 @@ import com.jme3.asset.AssetLoader;
import com.jme3.asset.BlenderKey.FeaturesToLoad;
import com.jme3.asset.BlenderKey.WorldData;
import com.jme3.light.AmbientLight;
import com.jme3.light.Light;
import com.jme3.math.ColorRGBA;
import com.jme3.scene.CameraNode;
import com.jme3.scene.Geometry;
@ -81,10 +80,14 @@ import com.jme3.scene.plugins.blender.objects.ObjectHelper;
if(pObject.isNotNull()) {
Structure objectStructure = pObject.fetchData(blenderContext.getInputStream()).get(0);
Object object = this.toObject(objectStructure);
if(object instanceof Spatial && ((Spatial) object).getParent()==null) {
result.attachChild((Spatial) object);
} else if(object instanceof Light) {
result.addLight((Light)object);
if(object instanceof LightNode && (blenderContext.getBlenderKey().getFeaturesToLoad() & FeaturesToLoad.LIGHTS) != 0) {
result.addLight(((LightNode)object).getLight());
result.attachChild((LightNode) object);
} else if (object instanceof Node && (blenderContext.getBlenderKey().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() });
if (((Node) object).getParent() == null) {
result.attachChild((Spatial) object);
}
}
}
}

@ -31,16 +31,18 @@
*/
package com.jme3.scene.plugins.blender;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.jme3.asset.AssetInfo;
import com.jme3.asset.BlenderKey;
import com.jme3.light.Light;
import com.jme3.asset.BlenderKey.FeaturesToLoad;
import com.jme3.scene.LightNode;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.plugins.blender.exceptions.BlenderFileException;
import com.jme3.scene.plugins.blender.file.FileBlockHeader;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* This is the main loading class. Have in notice that asset manager needs to have loaders for resources like textures.
@ -61,14 +63,16 @@ public class BlenderModelLoader extends BlenderLoader {
for (FileBlockHeader block : blocks) {
if (block.getCode() == FileBlockHeader.BLOCK_OB00) {
Object object = this.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) {
modelRoot.attachChild( (Node) object );
if(object instanceof LightNode && (blenderKey.getFeaturesToLoad() & FeaturesToLoad.LIGHTS) != 0) {
modelRoot.addLight(((LightNode)object).getLight());
modelRoot.attachChild((LightNode)object);
} else if (object instanceof Node && (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() });
if (((Node) object).getParent() == null) {
modelRoot.attachChild((Node)object);
}
}else if (object instanceof Light){
modelRoot.addLight( (Light) object );
}
}
}
}
blenderContext.dispose();

Loading…
Cancel
Save