com.jme3.asset.plugins.ClasspathLocator Java Examples

The following examples show how to use com.jme3.asset.plugins.ClasspathLocator. 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: CollideIgnoreTransformTest.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void testPhantomTriangles() {
    JmeSystem.setSystemDelegate(new MockJmeSystemDelegate());
    assetManager = new DesktopAssetManager();
    assetManager.registerLocator(null, ClasspathLocator.class);
    assetManager.registerLoader(J3MLoader.class, "j3m", "j3md");
    rootNode = new Node();

    createRedSquare();

    rootNode.updateLogicalState(0.01f);
    rootNode.updateGeometricState();
    /**
     * ray in the -Z direction, starting from (0.5, 0.6, 10)
     */
    Ray ray1 = new Ray(/* origin */new Vector3f(0.5f, 0.6f, 10f),
            /* direction */ new Vector3f(0f, 0f, -1f));
    castRay(ray1, 1);
    /**
     * ray in the -Z direction, starting from (0.5, 3, 10)
     */
    Ray ray0 = new Ray(/* origin */new Vector3f(0.5f, 3f, 10f),
            /* direction */ new Vector3f(0f, 0f, -1f));
    castRay(ray0, 0);
}
 
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: PhantomTrianglesTest.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testPhantomTriangles() {
    assetManager = new DesktopAssetManager();
    assetManager.registerLocator(null, ClasspathLocator.class);
    assetManager.registerLoader(J3MLoader.class, "j3m", "j3md");
    rootNode = new Node();

    createRedSquare();
    createWhiteLines();
    rootNode.updateLogicalState(0.01f);
    rootNode.updateGeometricState();
    castRay();
}
 
Example #5
Source File: LoadShaderSourceTest.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testLoadShaderSource() {
    JmeSystem.setSystemDelegate(new MockJmeSystemDelegate());
    AssetManager assetManager = new DesktopAssetManager();
    assetManager.registerLocator(null, ClasspathLocator.class);
    assetManager.registerLoader(GLSLLoader.class, "frag");
    assetManager.registerLoader(GLSLLoader.class, "glsllib");
    assetManager.registerLoader(GLSLLoader.class, "glsl");
    String showNormals = (String) assetManager.loadAsset("Common/MatDefs/Misc/ShowNormals.frag");
    System.out.println(showNormals);
}
 
Example #6
Source File: AndroidAssetManager.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * AndroidAssetManager constructor
 * If URL == null then a default list of locators and loaders for android is set
 * @param configFile
 */
public AndroidAssetManager(URL configFile) {

    System.setProperty("org.xml.sax.driver", "org.xmlpull.v1.sax2.Driver");


    // Set Default Android config        	       
    this.registerLocator("", AndroidLocator.class);
    this.registerLocator("", ClasspathLocator.class);
    this.registerLoader(AndroidImageLoader.class, "jpg", "bmp", "gif", "png", "jpeg");
    this.registerLoader(AndroidAudioLoader.class, "ogg", "mp3");
    this.registerLoader(com.jme3.material.plugins.J3MLoader.class, "j3m");
    this.registerLoader(com.jme3.material.plugins.J3MLoader.class, "j3md");
    this.registerLoader(com.jme3.font.plugins.BitmapFontLoader.class, "fnt");
    this.registerLoader(com.jme3.texture.plugins.DDSLoader.class, "dds");
    this.registerLoader(com.jme3.texture.plugins.PFMLoader.class, "pfm");
    this.registerLoader(com.jme3.texture.plugins.HDRLoader.class, "hdr");
    this.registerLoader(com.jme3.texture.plugins.AndroidTGALoader.class, "tga");
    this.registerLoader(com.jme3.export.binary.BinaryImporter.class, "j3o");
    this.registerLoader(com.jme3.scene.plugins.OBJLoader.class, "obj");
    this.registerLoader(com.jme3.scene.plugins.MTLLoader.class, "mtl");
    this.registerLoader(com.jme3.scene.plugins.ogre.MeshLoader.class, "meshxml", "mesh.xml");
    this.registerLoader(com.jme3.scene.plugins.ogre.SkeletonLoader.class, "skeletonxml", "skeleton.xml");
    this.registerLoader(com.jme3.scene.plugins.ogre.MaterialLoader.class, "material");
    this.registerLoader(com.jme3.scene.plugins.ogre.SceneLoader.class, "scene");
    this.registerLoader(com.jme3.shader.plugins.GLSLLoader.class, "vert", "frag", "glsl", "glsllib");

    this.registerLoader(PMDLoaderGLSLSkinning2.class, "pmd");
    this.registerLoader(VMDLoader.class, "vmd");
    this.registerLoader(AndroidImageLoader.class, "sph", "spa");

    logger.info("AndroidAssetManager created.");
}
 
Example #7
Source File: TestAbsoluteLocators.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void main(String[] args){
    AssetManager am = new DesktopAssetManager();

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

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

    // 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 #8
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 #9
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 #10
Source File: TestManyLocators.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static void main(String[] args){
    AssetManager am = new DesktopAssetManager();

    am.registerLocator("http://www.jmonkeyengine.com/wp-content/uploads/2010/09/",
                       UrlLocator.class);

    am.registerLocator("town.zip", ZipLocator.class);
    am.registerLocator("http://jmonkeyengine.googlecode.com/files/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("planet-2.jpg"));

    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");
    else
        System.out.println("Found zip image: " + b.toString());

    if (c == null)
        System.out.println("Failed to load from wildhouse.zip on googlecode.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());
}