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());
}
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());
}
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);
}
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);
}
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();
}
}
}
Aggregations