Ogre importer ignores receive_shadows issue #647

v3.2
ThoCed 7 years ago committed by Nehon
parent 8f1ee0ec9a
commit b2717e19ef
  1. 10
      jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/MaterialLoader.java
  2. 5
      jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/MeshLoader.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,6 +440,7 @@ public class MaterialLoader implements AssetLoader {
twoSide = false;
matName = null;
texName = null;
receiveShadow = false;
return mat;
}

@ -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);
}

Loading…
Cancel
Save