Search in sources :

Example 11 with AssetInfo

use of com.jme3.asset.AssetInfo in project jmonkeyengine by jMonkeyEngine.

the class J3MLoaderTest method fixedPipelineTechnique_shouldBeIgnored.

@Test
public void fixedPipelineTechnique_shouldBeIgnored() throws IOException {
    when(assetInfo.openStream()).thenReturn(J3MLoader.class.getResourceAsStream("/no-shader-specified.j3md"));
    MaterialDef def = (MaterialDef) j3MLoader.load(assetInfo);
    assertEquals(null, def.getTechniqueDefs("A"));
    assertEquals(1, def.getTechniqueDefs("B").size());
}
Also used : MaterialDef(com.jme3.material.MaterialDef) Test(org.junit.Test)

Example 12 with AssetInfo

use of com.jme3.asset.AssetInfo in project jmonkeyengine by jMonkeyEngine.

the class J3MLoaderTest method noDefaultTechnique_shouldBeSupported.

@Test
public void noDefaultTechnique_shouldBeSupported() throws IOException {
    when(assetInfo.openStream()).thenReturn(J3MLoader.class.getResourceAsStream("/no-default-technique.j3md"));
    MaterialDef def = (MaterialDef) j3MLoader.load(assetInfo);
    assertEquals(1, def.getTechniqueDefs("Test").size());
}
Also used : MaterialDef(com.jme3.material.MaterialDef) Test(org.junit.Test)

Example 13 with AssetInfo

use of com.jme3.asset.AssetInfo in project jmonkeyengine by jMonkeyEngine.

the class J3MLoaderTest method oldStyleTextureParameters_shouldBeSupported.

@Test
public void oldStyleTextureParameters_shouldBeSupported() throws Exception {
    when(assetInfo.openStream()).thenReturn(J3MLoader.class.getResourceAsStream("/texture-parameters-oldstyle.j3m"));
    final Texture textureOldStyle = Mockito.mock(Texture.class);
    final Texture textureOldStyleUsingQuotes = Mockito.mock(Texture.class);
    final TextureKey textureKeyUsingQuotes = setupMockForTexture("OldStyleUsingQuotes", "old style using quotes/texture.png", true, textureOldStyleUsingQuotes);
    final TextureKey textureKeyOldStyle = setupMockForTexture("OldStyle", "old style/texture.png", true, textureOldStyle);
    j3MLoader.load(assetInfo);
    verify(assetManager).loadTexture(textureKeyUsingQuotes);
    verify(assetManager).loadTexture(textureKeyOldStyle);
    verify(textureOldStyle).setWrap(Texture.WrapMode.Repeat);
    verify(textureOldStyleUsingQuotes).setWrap(Texture.WrapMode.Repeat);
}
Also used : TextureKey(com.jme3.asset.TextureKey) MatParamTexture(com.jme3.material.MatParamTexture) Texture(com.jme3.texture.Texture) Test(org.junit.Test)

Example 14 with AssetInfo

use of com.jme3.asset.AssetInfo in project jmonkeyengine by jMonkeyEngine.

the class J3MLoaderTest method newStyleTextureParameters_shouldBeSupported.

@Test
public void newStyleTextureParameters_shouldBeSupported() throws Exception {
    when(assetInfo.openStream()).thenReturn(J3MLoader.class.getResourceAsStream("/texture-parameters-newstyle.j3m"));
    final Texture textureNoParameters = Mockito.mock(Texture.class);
    final Texture textureFlip = Mockito.mock(Texture.class);
    final Texture textureRepeat = Mockito.mock(Texture.class);
    final Texture textureRepeatAxis = Mockito.mock(Texture.class);
    final Texture textureMin = Mockito.mock(Texture.class);
    final Texture textureMag = Mockito.mock(Texture.class);
    final Texture textureCombined = Mockito.mock(Texture.class);
    final Texture textureLooksLikeOldStyle = Mockito.mock(Texture.class);
    final TextureKey textureKeyNoParameters = setupMockForTexture("Empty", "empty.png", false, textureNoParameters);
    final TextureKey textureKeyFlip = setupMockForTexture("Flip", "flip.png", true, textureFlip);
    setupMockForTexture("Repeat", "repeat.png", false, textureRepeat);
    setupMockForTexture("RepeatAxis", "repeat-axis.png", false, textureRepeatAxis);
    setupMockForTexture("Min", "min.png", false, textureMin);
    setupMockForTexture("Mag", "mag.png", false, textureMag);
    setupMockForTexture("Combined", "combined.png", true, textureCombined);
    setupMockForTexture("LooksLikeOldStyle", "oldstyle.png", true, textureLooksLikeOldStyle);
    j3MLoader.load(assetInfo);
    verify(assetManager).loadTexture(textureKeyNoParameters);
    verify(assetManager).loadTexture(textureKeyFlip);
    verify(textureRepeat).setWrap(Texture.WrapMode.Repeat);
    verify(textureRepeatAxis).setWrap(Texture.WrapAxis.T, Texture.WrapMode.Repeat);
    verify(textureMin).setMinFilter(Texture.MinFilter.Trilinear);
    verify(textureMag).setMagFilter(Texture.MagFilter.Bilinear);
    verify(textureCombined).setMagFilter(Texture.MagFilter.Nearest);
    verify(textureCombined).setMinFilter(Texture.MinFilter.BilinearNoMipMaps);
    verify(textureCombined).setWrap(Texture.WrapMode.Repeat);
}
Also used : TextureKey(com.jme3.asset.TextureKey) MatParamTexture(com.jme3.material.MatParamTexture) Texture(com.jme3.texture.Texture) Test(org.junit.Test)

Example 15 with AssetInfo

use of com.jme3.asset.AssetInfo in project jmonkeyengine by jMonkeyEngine.

the class HDRLoader method load.

public Object load(AssetInfo info) throws IOException {
    if (!(info.getKey() instanceof TextureKey))
        throw new IllegalArgumentException("Texture assets must be loaded using a TextureKey");
    boolean flip = ((TextureKey) info.getKey()).isFlipY();
    InputStream in = null;
    try {
        in = info.openStream();
        Image img = load(in, flip);
        return img;
    } finally {
        if (in != null) {
            in.close();
        }
    }
}
Also used : TextureKey(com.jme3.asset.TextureKey) InputStream(java.io.InputStream) Image(com.jme3.texture.Image)

Aggregations

InputStream (java.io.InputStream)17 TextureKey (com.jme3.asset.TextureKey)12 IOException (java.io.IOException)9 Image (com.jme3.texture.Image)7 AssetInfo (com.jme3.asset.AssetInfo)6 Texture (com.jme3.texture.Texture)6 AssetLoadException (com.jme3.asset.AssetLoadException)5 Test (org.junit.Test)5 AssetKey (com.jme3.asset.AssetKey)4 AssetNotFoundException (com.jme3.asset.AssetNotFoundException)4 ModelKey (com.jme3.asset.ModelKey)4 InputStreamReader (java.io.InputStreamReader)4 BlenderKey (com.jme3.asset.BlenderKey)3 AudioStream (com.jme3.audio.AudioStream)3 MaterialDef (com.jme3.material.MaterialDef)3 DataInputStream (java.io.DataInputStream)3 AssetFileDescriptor (android.content.res.AssetFileDescriptor)2 AssetManager (com.jme3.asset.AssetManager)2 AndroidAssetInfo (com.jme3.asset.plugins.AndroidLocator.AndroidAssetInfo)2 AudioBuffer (com.jme3.audio.AudioBuffer)2