Blender Loader

* Correct calculation of spot light's inner and outer cone angles
 * Loaded lights are now attached to the model's root node instead of being foolishly discarded


git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8209 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
sha..rd 13 years ago
parent ca0e7a83af
commit 120a3d1e4f
  1. 2
      engine/src/android/com/jme3/app/android/AndroidApplication.java
  2. 23
      engine/src/blender/com/jme3/scene/plugins/blender/BlenderModelLoader.java
  3. 10
      engine/src/blender/com/jme3/scene/plugins/blender/lights/LightHelper.java
  4. 1
      engine/src/core/com/jme3/texture/FrameBuffer.java

@ -222,7 +222,7 @@ public abstract class AndroidApplication extends Application implements DialogIn
// render states
stateManager.render(renderManager);
renderManager.render(tpf, true);
renderManager.render(tpf, context.isRenderable());
render(renderManager);
stateManager.postRender();
}

@ -38,6 +38,7 @@ import java.util.logging.Logger;
import com.jme3.asset.AssetInfo;
import com.jme3.asset.BlenderKey.LoadingResults;
import com.jme3.light.Light;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.plugins.blender.exceptions.BlenderFileException;
@ -54,35 +55,31 @@ public class BlenderModelLoader extends BlenderLoader {
@Override
public Spatial load(AssetInfo assetInfo) throws IOException {
try {
this.setup(assetInfo);
setup(assetInfo);
Node modelRoot = new Node(blenderKey.getName());
LoadingResults loadingResults = blenderKey.prepareLoadingResults();
for (FileBlockHeader block : blocks) {
if (block.getCode() == FileBlockHeader.BLOCK_OB00) {
Object object = converter.toObject(block.getStructure(dataRepository));
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) {
loadingResults.addObject((Node) object);
modelRoot.attachChild( (Node) object );
}
}else if (object instanceof Light){
modelRoot.addLight( (Light) object );
}
}
}
try {
inputStream.close();
} catch(IOException e) {
LOGGER.warning(e.getLocalizedMessage());
}
List<Node> objects = loadingResults.getObjects();
if (objects.size() > 0) {
Node modelNode = new Node(blenderKey.getName());
for(Node object : objects) {
modelNode.attachChild(object);
}
return modelNode;
} else if (objects.size() == 1) {
return objects.get(0);
}
return modelRoot;
} catch (BlenderFileException e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
}

@ -90,13 +90,9 @@ public class LightHelper extends AbstractBlenderHelper {
//inner angle
float spotblend = ((Number) structure.getFieldValue("spotblend")).floatValue();
if(spotblend > 1.0f) {//floating point errors fix
spotblend = 1.0f;
}
if(spotblend < 0.0f) {//floating point errors fix
spotblend = 0.0f;
}
float innerAngle = 2.0f * (float)Math.atan((1.0f-spotblend)*Math.tan(spotblend/2.0f));
spotblend = FastMath.clamp(spotblend, 0, 1);
//float innerAngle = 2.0f * (float)Math.atan((1.0f-spotblend)*Math.tan(spotblend/2.0f));
float innerAngle = outerAngle * (1 - spotblend);
((SpotLight)result).setSpotInnerAngle(innerAngle);
break;
case 3://Hemi

@ -437,6 +437,7 @@ public class FrameBuffer extends GLObject {
@Override
public void resetObject() {
this.id = -1;
for (int i = 0; i < colorBufs.size(); i++) {
colorBufs.get(i).resetObject();
}

Loading…
Cancel
Save