diff --git a/jme3-core/src/main/java/com/jme3/texture/Texture.java b/jme3-core/src/main/java/com/jme3/texture/Texture.java index 45cda623f..b41d2ac10 100644 --- a/jme3-core/src/main/java/com/jme3/texture/Texture.java +++ b/jme3-core/src/main/java/com/jme3/texture/Texture.java @@ -620,7 +620,7 @@ public abstract class Texture implements CloneableSmartAsset, Savable, Cloneable image = loadedTex.getImage(); } catch (AssetNotFoundException ex){ Logger.getLogger(Texture.class.getName()).log(Level.SEVERE, "Cannot locate texture {0}", key); - image = PlaceholderAssets.getPlaceholderImage(); + image = PlaceholderAssets.getPlaceholderImage(e.getAssetManager()); } }else{ // no key is set on the texture. Attempt to load an embedded image diff --git a/jme3-core/src/main/java/com/jme3/util/PlaceholderAssets.java b/jme3-core/src/main/java/com/jme3/util/PlaceholderAssets.java index c485b00ba..4fa0ca157 100644 --- a/jme3-core/src/main/java/com/jme3/util/PlaceholderAssets.java +++ b/jme3-core/src/main/java/com/jme3/util/PlaceholderAssets.java @@ -35,12 +35,12 @@ import com.jme3.asset.AssetManager; import com.jme3.audio.AudioBuffer; import com.jme3.audio.AudioData; import com.jme3.material.Material; -import com.jme3.math.ColorRGBA; import com.jme3.scene.Geometry; import com.jme3.scene.Spatial; import com.jme3.scene.shape.Box; import com.jme3.texture.Image; import com.jme3.texture.Image.Format; +import com.jme3.texture.Texture; import com.jme3.texture.image.ColorSpace; import java.nio.ByteBuffer; @@ -71,15 +71,22 @@ public class PlaceholderAssets { (byte)0xFF, (byte)0xFF, (byte)0xFF, }; + @Deprecated public static Image getPlaceholderImage(){ ByteBuffer tempData = BufferUtils.createByteBuffer(3 * 4 * 4); tempData.put(imageData).flip(); return new Image(Format.RGB8, 4, 4, tempData, null, ColorSpace.Linear); } + public static Image getPlaceholderImage(AssetManager assetManager){ + return assetManager.loadTexture("Common/Textures/MissingTexture.png").getImage(); + } + public static Material getPlaceholderMaterial(AssetManager assetManager){ Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); - mat.setColor("Color", ColorRGBA.Red); + Texture tex = assetManager.loadTexture("Common/Textures/MissingMaterial.png"); + tex.setWrap(Texture.WrapMode.Repeat); + mat.setTexture("ColorMap", tex); return mat; } @@ -88,7 +95,11 @@ public class PlaceholderAssets { // the user's expected scale... Box box = new Box(1, 1, 1); Geometry geom = new Geometry("placeholder", box); - geom.setMaterial(getPlaceholderMaterial(assetManager)); + Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); + Texture tex = assetManager.loadTexture("Common/Textures/MissingModel.png"); + tex.setWrap(Texture.WrapMode.Repeat); + mat.setTexture("ColorMap", tex); + geom.setMaterial(mat); return geom; } diff --git a/jme3-core/src/main/resources/Common/Textures/MissingMaterial.png b/jme3-core/src/main/resources/Common/Textures/MissingMaterial.png new file mode 100644 index 000000000..799b70c18 Binary files /dev/null and b/jme3-core/src/main/resources/Common/Textures/MissingMaterial.png differ diff --git a/jme3-core/src/main/resources/Common/Textures/MissingModel.png b/jme3-core/src/main/resources/Common/Textures/MissingModel.png new file mode 100644 index 000000000..d59a78ce7 Binary files /dev/null and b/jme3-core/src/main/resources/Common/Textures/MissingModel.png differ diff --git a/jme3-core/src/main/resources/Common/Textures/MissingTexture.png b/jme3-core/src/main/resources/Common/Textures/MissingTexture.png new file mode 100644 index 000000000..3b46d2894 Binary files /dev/null and b/jme3-core/src/main/resources/Common/Textures/MissingTexture.png differ diff --git a/jme3-core/src/plugins/java/com/jme3/material/plugins/J3MLoader.java b/jme3-core/src/plugins/java/com/jme3/material/plugins/J3MLoader.java index dc8592abe..23310f12f 100644 --- a/jme3-core/src/plugins/java/com/jme3/material/plugins/J3MLoader.java +++ b/jme3-core/src/plugins/java/com/jme3/material/plugins/J3MLoader.java @@ -165,7 +165,7 @@ public class J3MLoader implements AssetLoader { tex.setWrap(WrapMode.Repeat); } }else{ - tex = new Texture2D(PlaceholderAssets.getPlaceholderImage()); + tex = new Texture2D(PlaceholderAssets.getPlaceholderImage(assetManager)); if (repeat){ tex.setWrap(WrapMode.Repeat); } diff --git a/jme3-core/src/plugins/java/com/jme3/scene/plugins/MTLLoader.java b/jme3-core/src/plugins/java/com/jme3/scene/plugins/MTLLoader.java index 8ee833346..f09eae150 100644 --- a/jme3-core/src/plugins/java/com/jme3/scene/plugins/MTLLoader.java +++ b/jme3-core/src/plugins/java/com/jme3/scene/plugins/MTLLoader.java @@ -182,7 +182,7 @@ public class MTLLoader implements AssetLoader { texture.setWrap(WrapMode.Repeat); } catch (AssetNotFoundException ex){ logger.log(Level.WARNING, "Cannot locate {0} for material {1}", new Object[]{texKey, key}); - texture = new Texture2D(PlaceholderAssets.getPlaceholderImage()); + texture = new Texture2D(PlaceholderAssets.getPlaceholderImage(assetManager)); texture.setWrap(WrapMode.Repeat); texture.setKey(key); }