diff --git a/jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/MaterialLoader.java b/jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/MaterialLoader.java index cd2ecb8fa..c40437bbc 100644 --- a/jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/MaterialLoader.java +++ b/jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/MaterialLoader.java @@ -69,6 +69,7 @@ public class MaterialLoader implements AssetLoader { private boolean twoSide = false; private boolean noLight = false; private boolean separateTexCoord = false; + private boolean receiveShadow = false; private int texUnit = 0; private ColorRGBA readColor(String content){ @@ -314,7 +315,8 @@ public class MaterialLoader implements AssetLoader { readTechnique(statement); }else if (statement.getLine().startsWith("receive_shadows")){ String isOn = statement.getLine().split("\\s")[1]; - if (isOn != null && isOn.equals("true")){ + if (isOn != null && isOn.equals("on")){ + receiveShadow = true; } } } @@ -334,6 +336,11 @@ public class MaterialLoader implements AssetLoader { mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"); } mat.setName(matName); + + if(receiveShadow){ + mat.setReceivesShadows(true); + } + if (blend){ RenderState rs = mat.getAdditionalRenderState(); mat.setFloat("AlphaDiscardThreshold", 0.01f); @@ -433,13 +440,14 @@ public class MaterialLoader implements AssetLoader { twoSide = false; matName = null; texName = null; + receiveShadow = false; return mat; } private MaterialList load(AssetManager assetManager, AssetKey key, InputStream in) throws IOException{ folderName = key.getFolder(); this.assetManager = assetManager; - + MaterialList list = null; List statements = BlockLanguageParser.parse(in); @@ -471,8 +479,8 @@ public class MaterialLoader implements AssetLoader { list.put(mat.getName(), mat); } } - - return list; + + return list; } public Object load(AssetInfo info) throws IOException { diff --git a/jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/MeshLoader.java b/jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/MeshLoader.java index 42780f411..baa30a0d1 100644 --- a/jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/MeshLoader.java +++ b/jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/MeshLoader.java @@ -38,6 +38,7 @@ import com.jme3.asset.*; import com.jme3.material.Material; import com.jme3.material.MaterialList; import com.jme3.math.ColorRGBA; +import com.jme3.renderer.queue.RenderQueue; import com.jme3.renderer.queue.RenderQueue.Bucket; import com.jme3.scene.*; import com.jme3.scene.VertexBuffer.Format; @@ -241,6 +242,10 @@ public class MeshLoader extends DefaultHandler implements AssetLoader { geom.setQueueBucket(Bucket.Transparent); } + if(mat.isReceivesShadows()){ + geom.setShadowMode(RenderQueue.ShadowMode.Receive); + } + geom.setMaterial(mat); }