Ogre importer ignores receive_shadows issue #647
This commit is contained in:
parent
8f1ee0ec9a
commit
b2717e19ef
@ -69,6 +69,7 @@ public class MaterialLoader implements AssetLoader {
|
|||||||
private boolean twoSide = false;
|
private boolean twoSide = false;
|
||||||
private boolean noLight = false;
|
private boolean noLight = false;
|
||||||
private boolean separateTexCoord = false;
|
private boolean separateTexCoord = false;
|
||||||
|
private boolean receiveShadow = false;
|
||||||
private int texUnit = 0;
|
private int texUnit = 0;
|
||||||
|
|
||||||
private ColorRGBA readColor(String content){
|
private ColorRGBA readColor(String content){
|
||||||
@ -314,7 +315,8 @@ public class MaterialLoader implements AssetLoader {
|
|||||||
readTechnique(statement);
|
readTechnique(statement);
|
||||||
}else if (statement.getLine().startsWith("receive_shadows")){
|
}else if (statement.getLine().startsWith("receive_shadows")){
|
||||||
String isOn = statement.getLine().split("\\s")[1];
|
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 = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
|
||||||
}
|
}
|
||||||
mat.setName(matName);
|
mat.setName(matName);
|
||||||
|
|
||||||
|
if(receiveShadow){
|
||||||
|
mat.setReceivesShadows(true);
|
||||||
|
}
|
||||||
|
|
||||||
if (blend){
|
if (blend){
|
||||||
RenderState rs = mat.getAdditionalRenderState();
|
RenderState rs = mat.getAdditionalRenderState();
|
||||||
mat.setFloat("AlphaDiscardThreshold", 0.01f);
|
mat.setFloat("AlphaDiscardThreshold", 0.01f);
|
||||||
@ -433,13 +440,14 @@ public class MaterialLoader implements AssetLoader {
|
|||||||
twoSide = false;
|
twoSide = false;
|
||||||
matName = null;
|
matName = null;
|
||||||
texName = null;
|
texName = null;
|
||||||
|
receiveShadow = false;
|
||||||
return mat;
|
return mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MaterialList load(AssetManager assetManager, AssetKey key, InputStream in) throws IOException{
|
private MaterialList load(AssetManager assetManager, AssetKey key, InputStream in) throws IOException{
|
||||||
folderName = key.getFolder();
|
folderName = key.getFolder();
|
||||||
this.assetManager = assetManager;
|
this.assetManager = assetManager;
|
||||||
|
|
||||||
MaterialList list = null;
|
MaterialList list = null;
|
||||||
List<Statement> statements = BlockLanguageParser.parse(in);
|
List<Statement> statements = BlockLanguageParser.parse(in);
|
||||||
|
|
||||||
@ -471,8 +479,8 @@ public class MaterialLoader implements AssetLoader {
|
|||||||
list.put(mat.getName(), mat);
|
list.put(mat.getName(), mat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object load(AssetInfo info) throws IOException {
|
public Object load(AssetInfo info) throws IOException {
|
||||||
|
@ -38,6 +38,7 @@ import com.jme3.asset.*;
|
|||||||
import com.jme3.material.Material;
|
import com.jme3.material.Material;
|
||||||
import com.jme3.material.MaterialList;
|
import com.jme3.material.MaterialList;
|
||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.ColorRGBA;
|
||||||
|
import com.jme3.renderer.queue.RenderQueue;
|
||||||
import com.jme3.renderer.queue.RenderQueue.Bucket;
|
import com.jme3.renderer.queue.RenderQueue.Bucket;
|
||||||
import com.jme3.scene.*;
|
import com.jme3.scene.*;
|
||||||
import com.jme3.scene.VertexBuffer.Format;
|
import com.jme3.scene.VertexBuffer.Format;
|
||||||
@ -241,6 +242,10 @@ public class MeshLoader extends DefaultHandler implements AssetLoader {
|
|||||||
geom.setQueueBucket(Bucket.Transparent);
|
geom.setQueueBucket(Bucket.Transparent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(mat.isReceivesShadows()){
|
||||||
|
geom.setShadowMode(RenderQueue.ShadowMode.Receive);
|
||||||
|
}
|
||||||
|
|
||||||
geom.setMaterial(mat);
|
geom.setMaterial(mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user