Java Code Examples for com.jme3.system.JmeSystem#newAssetManager()

The following examples show how to use com.jme3.system.JmeSystem#newAssetManager() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseAWTTest.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private AssetManager createAssetManager() {
    /* Desktop.cfg supports the following additional file formats at the time of writing:
        LOADER com.jme3.texture.plugins.AWTLoader : jpg, bmp, gif, png, jpeg
        LOADER com.jme3.audio.plugins.OGGLoader : ogg
     */
    return JmeSystem.newAssetManager(BaseTest.class.getResource("/com/jme3/asset/Desktop.cfg"));
}
 
Example 2
Source File: TestAbsoluteLocators.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void main(String[] args){
    AssetManager am = JmeSystem.newAssetManager();

    am.registerLoader(AWTLoader.class, "jpg");
    am.registerLoader(WAVLoader.class, "wav");

    // register absolute locator
    am.registerLocator("/",  ClasspathLocator.class);

    // find a sound
    AudioData audio = am.loadAudio("Sound/Effects/Gun.wav");

    // find a texture
    Texture tex = am.loadTexture("Textures/Terrain/Pond/Pond.jpg");

    if (audio == null)
        throw new RuntimeException("Cannot find audio!");
    else
        System.out.println("Audio loaded from Sounds/Effects/Gun.wav");

    if (tex == null)
        throw new RuntimeException("Cannot find texture!");
    else
        System.out.println("Texture loaded from Textures/Terrain/Pond/Pond.jpg");

    System.out.println("Success!");
}
 
Example 3
Source File: ShaderCheck.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void initAssetManager(){
    assetManager = JmeSystem.newAssetManager();
    assetManager.registerLocator(".", FileLocator.class);
    assetManager.registerLocator("/", ClasspathLocator.class);
    assetManager.registerLoader(J3MLoader.class, "j3m");
    assetManager.registerLoader(J3MLoader.class, "j3md");
    assetManager.registerLoader(GLSLLoader.class, "vert", "frag","geom","tsctrl","tseval","glsllib","glsl");
}
 
Example 4
Source File: AndroidApplication.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void initialize() 
{
    // Create a default Android assetmanager before Application can create one in super.initialize();
    assetManager = JmeSystem.newAssetManager(null);        
    super.initialize();

    guiNode.setQueueBucket(Bucket.Gui);
    guiNode.setCullHint(CullHint.Never);
    loadFPSText();
    viewPort.attachScene(rootNode);
    guiViewPort.attachScene(guiNode);
    
    inputManager.addMapping("TouchEscape", new TouchTrigger(TouchInput.KEYCODE_BACK));
    inputManager.addListener(this, new String[]{"TouchEscape"}); 

    // call user code
    init();
    
    // Start thread for async load
    Thread t = new Thread(new Runnable()
    {
        @Override
        public void run ()
        {
            try
            {
                // call user code
                asyncload();
            }
            catch (Exception e)
            {
                handleError("AsyncLoad failed", e);
            }
            loadingFinished.set(true);
        }
    });
    t.setDaemon(true);
    t.start();
}
 
Example 5
Source File: TestMaterialCompare.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public static void main(String[] args) {
    AssetManager assetManager = JmeSystem.newAssetManager(
            TestMaterialCompare.class.getResource("/com/jme3/asset/Desktop.cfg"));
    
    // Cloned materials
    Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat1.setName("mat1");
    mat1.setColor("Color", ColorRGBA.Blue);

    Material mat2 = mat1.clone();
    mat2.setName("mat2");
    testEquality(mat1, mat2, true);

    // Cloned material with different render states
    Material mat3 = mat1.clone();
    mat3.setName("mat3");
    mat3.getAdditionalRenderState().setBlendMode(BlendMode.ModulateX2);
    testEquality(mat1, mat3, false);

    // Two separately loaded materials
    Material mat4 = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
    mat4.setName("mat4");
    Material mat5 = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
    mat5.setName("mat5");
    testEquality(mat4, mat5, true);
    
    // Comparing same textures
    TextureKey originalKey = (TextureKey) mat4.getTextureParam("DiffuseMap").getTextureValue().getKey();
    TextureKey tex1key = new TextureKey("Models/Sign Post/Sign Post.jpg", false);
    tex1key.setGenerateMips(true);
    
    // Texture keys from the original and the loaded texture
    // must be identical, otherwise the resultant textures not identical
    // and thus materials are not identical!
    if (!originalKey.equals(tex1key)){
        System.out.println("TEXTURE KEYS ARE NOT EQUAL");
    }
    
    Texture tex1 = assetManager.loadTexture(tex1key);
    mat4.setTexture("DiffuseMap", tex1);
    testEquality(mat4, mat5, true);
    
    // Change some stuff on the texture and compare, materials no longer equal
    tex1.setWrap(Texture.WrapMode.MirroredRepeat);
    testEquality(mat4, mat5, false);
    
    // Comparing different textures
    Texture tex2 = assetManager.loadTexture("Interface/Logo/Monkey.jpg");
    mat4.setTexture("DiffuseMap", tex2);
    testEquality(mat4, mat5, false);

    // Two materials created the same way
    Material mat6 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat6.setName("mat6");
    mat6.setColor("Color", ColorRGBA.Blue);
    testEquality(mat1, mat6, true);

    // Changing a material param
    mat6.setColor("Color", ColorRGBA.Green);
    testEquality(mat1, mat6, false);
}
 
Example 6
Source File: TestManyLocators.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public static void main(String[] args){
    AssetManager am = JmeSystem.newAssetManager();

    am.registerLocator("http://wiki.jmonkeyengine.org/jme3/beginner",
                       UrlLocator.class);

    am.registerLocator("town.zip", ZipLocator.class);
    am.registerLocator(
                "https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/jmonkeyengine/wildhouse.zip", 
                HttpZipLocator.class);       
    
    am.registerLocator("/", ClasspathLocator.class);
    
    

    // Try loading from Core-Data source package
    AssetInfo a = am.locateAsset(new AssetKey<Object>("Interface/Fonts/Default.fnt"));

    // Try loading from town scene zip file
    AssetInfo b = am.locateAsset(new ModelKey("casaamarela.jpg"));

    // Try loading from wildhouse online scene zip file
    AssetInfo c = am.locateAsset(new ModelKey("glasstile2.png"));

    // Try loading directly from HTTP
    AssetInfo d = am.locateAsset(new TextureKey("beginner-physics.png"));

    if (a == null)
        System.out.println("Failed to load from classpath");
    else
        System.out.println("Found classpath font: " + a.toString());

    if (b == null)
        System.out.println("Failed to load from town.zip file");
    else
        System.out.println("Found zip image: " + b.toString());

    if (c == null)
        System.out.println("Failed to load from wildhouse.zip on googleapis.com");
    else
        System.out.println("Found online zip image: " + c.toString());

    if (d == null)
        System.out.println("Failed to load from HTTP");
    else
        System.out.println("Found HTTP showcase image: " + d.toString());
}
 
Example 7
Source File: TestCustomLoader.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public static void main(String[] args){
    AssetManager assetManager = JmeSystem.newAssetManager();
    assetManager.registerLocator("/", ClasspathLocator.class);
    assetManager.registerLoader(TextLoader.class, "fnt");
    System.out.println(assetManager.loadAsset("Interface/Fonts/Console.fnt"));
}
 
Example 8
Source File: GltfLoaderTest.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Before
public void init() {
    assetManager = JmeSystem.newAssetManager(
            TestMaterialWrite.class.getResource("/com/jme3/asset/Desktop.cfg"));

}
 
Example 9
Source File: TestMaterialWrite.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
@Before
public void init() {
    assetManager = JmeSystem.newAssetManager(
            TestMaterialWrite.class.getResource("/com/jme3/asset/Desktop.cfg"));


}
 
Example 10
Source File: TestMaterialDefWrite.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
@Before
public void init() {
    assetManager = JmeSystem.newAssetManager(
            TestMaterialDefWrite.class.getResource("/com/jme3/asset/Desktop.cfg"));


}