• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.jme3.util;
2 
3 import com.jme3.asset.AssetManager;
4 import com.jme3.audio.AudioBuffer;
5 import com.jme3.audio.AudioData;
6 import com.jme3.material.Material;
7 import com.jme3.math.ColorRGBA;
8 import com.jme3.scene.Geometry;
9 import com.jme3.scene.Spatial;
10 import com.jme3.scene.shape.Box;
11 import com.jme3.texture.Image;
12 import com.jme3.texture.Image.Format;
13 import java.nio.ByteBuffer;
14 
15 public 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 
getPlaceholderImage()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 
getPlaceholderMaterial(AssetManager assetManager)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 
getPlaceholderModel(AssetManager assetManager)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 
getPlaceholderAudio()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