diff options
Diffstat (limited to 'engine/src/core/com/jme3/util/PlaceholderAssets.java')
-rw-r--r-- | engine/src/core/com/jme3/util/PlaceholderAssets.java | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/engine/src/core/com/jme3/util/PlaceholderAssets.java b/engine/src/core/com/jme3/util/PlaceholderAssets.java new file mode 100644 index 0000000..c36abc9 --- /dev/null +++ b/engine/src/core/com/jme3/util/PlaceholderAssets.java @@ -0,0 +1,72 @@ +package com.jme3.util; + +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 java.nio.ByteBuffer; + +public class PlaceholderAssets { + + /** + * Checkerboard of white and red squares + */ + private static final byte[] imageData = { + (byte)0xFF, (byte)0xFF, (byte)0xFF, + (byte)0xFF, (byte)0x00, (byte)0x00, + (byte)0xFF, (byte)0xFF, (byte)0xFF, + (byte)0xFF, (byte)0x00, (byte)0x00, + + (byte)0xFF, (byte)0x00, (byte)0x00, + (byte)0xFF, (byte)0xFF, (byte)0xFF, + (byte)0xFF, (byte)0x00, (byte)0x00, + (byte)0xFF, (byte)0xFF, (byte)0xFF, + + (byte)0xFF, (byte)0xFF, (byte)0xFF, + (byte)0xFF, (byte)0x00, (byte)0x00, + (byte)0xFF, (byte)0xFF, (byte)0xFF, + (byte)0xFF, (byte)0x00, (byte)0x00, + + (byte)0xFF, (byte)0x00, (byte)0x00, + (byte)0xFF, (byte)0xFF, (byte)0xFF, + (byte)0xFF, (byte)0x00, (byte)0x00, + (byte)0xFF, (byte)0xFF, (byte)0xFF, + }; + + public static Image getPlaceholderImage(){ + ByteBuffer tempData = BufferUtils.createByteBuffer(3 * 4 * 4); + tempData.put(imageData).flip(); + return new Image(Format.RGB8, 4, 4, tempData); + } + + public static Material getPlaceholderMaterial(AssetManager assetManager){ + Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); + mat.setColor("Color", ColorRGBA.Red); + return mat; + } + + public static Spatial getPlaceholderModel(AssetManager assetManager){ + // What should be the size? Nobody knows + // the user's expected scale... + Box box = new Box(1, 1, 1); + Geometry geom = new Geometry("placeholder", box); + geom.setMaterial(getPlaceholderMaterial(assetManager)); + return geom; + } + + public static AudioData getPlaceholderAudio(){ + AudioBuffer audioBuf = new AudioBuffer(); + audioBuf.setupFormat(1, 8, 44100); + ByteBuffer bb = BufferUtils.createByteBuffer(1); + bb.put((byte)0).flip(); + audioBuf.updateData(bb); + return audioBuf; + } + +} |