1package com.jme3.util; 2 3import com.jme3.asset.AssetManager; 4import com.jme3.audio.AudioBuffer; 5import com.jme3.audio.AudioData; 6import com.jme3.material.Material; 7import com.jme3.math.ColorRGBA; 8import com.jme3.scene.Geometry; 9import com.jme3.scene.Spatial; 10import com.jme3.scene.shape.Box; 11import com.jme3.texture.Image; 12import com.jme3.texture.Image.Format; 13import java.nio.ByteBuffer; 14 15public class PlaceholderAssets { 16 17 /** 18 * Checkerboard of white and red squares 19 */ 20 private static final byte[] imageData = { 21 (byte)0xFF, (byte)0xFF, (byte)0xFF, 22 (byte)0xFF, (byte)0x00, (byte)0x00, 23 (byte)0xFF, (byte)0xFF, (byte)0xFF, 24 (byte)0xFF, (byte)0x00, (byte)0x00, 25 26 (byte)0xFF, (byte)0x00, (byte)0x00, 27 (byte)0xFF, (byte)0xFF, (byte)0xFF, 28 (byte)0xFF, (byte)0x00, (byte)0x00, 29 (byte)0xFF, (byte)0xFF, (byte)0xFF, 30 31 (byte)0xFF, (byte)0xFF, (byte)0xFF, 32 (byte)0xFF, (byte)0x00, (byte)0x00, 33 (byte)0xFF, (byte)0xFF, (byte)0xFF, 34 (byte)0xFF, (byte)0x00, (byte)0x00, 35 36 (byte)0xFF, (byte)0x00, (byte)0x00, 37 (byte)0xFF, (byte)0xFF, (byte)0xFF, 38 (byte)0xFF, (byte)0x00, (byte)0x00, 39 (byte)0xFF, (byte)0xFF, (byte)0xFF, 40 }; 41 42 public static Image getPlaceholderImage(){ 43 ByteBuffer tempData = BufferUtils.createByteBuffer(3 * 4 * 4); 44 tempData.put(imageData).flip(); 45 return new Image(Format.RGB8, 4, 4, tempData); 46 } 47 48 public static Material getPlaceholderMaterial(AssetManager assetManager){ 49 Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); 50 mat.setColor("Color", ColorRGBA.Red); 51 return mat; 52 } 53 54 public static Spatial getPlaceholderModel(AssetManager assetManager){ 55 // What should be the size? Nobody knows 56 // the user's expected scale... 57 Box box = new Box(1, 1, 1); 58 Geometry geom = new Geometry("placeholder", box); 59 geom.setMaterial(getPlaceholderMaterial(assetManager)); 60 return geom; 61 } 62 63 public static AudioData getPlaceholderAudio(){ 64 AudioBuffer audioBuf = new AudioBuffer(); 65 audioBuf.setupFormat(1, 8, 44100); 66 ByteBuffer bb = BufferUtils.createByteBuffer(1); 67 bb.put((byte)0).flip(); 68 audioBuf.updateData(bb); 69 return audioBuf; 70 } 71 72} 73