Search in sources :

Example 66 with Texture

use of com.jme3.texture.Texture 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 67 with Texture

use of com.jme3.texture.Texture 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 68 with Texture

use of com.jme3.texture.Texture 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)

Example 69 with Texture

use of com.jme3.texture.Texture in project jmonkeyengine by jMonkeyEngine.

the class JmeBatchRenderBackend method createAtlasTextureInternal.

// internal implementations
private Texture2D createAtlasTextureInternal(final int width, final int height) throws Exception {
    ByteBuffer initialData = BufferUtils.createByteBuffer(width * height * 4);
    for (int i = 0; i < width * height * 4; i++) {
        initialData.put((byte) 0x00);
    }
    initialData.rewind();
    Texture2D texture = new Texture2D(new com.jme3.texture.Image(Format.RGBA8, width, height, initialData, ColorSpace.sRGB));
    texture.setMinFilter(MinFilter.NearestNoMipMaps);
    texture.setMagFilter(MagFilter.Nearest);
    return texture;
}
Also used : Texture2D(com.jme3.texture.Texture2D) ByteBuffer(java.nio.ByteBuffer)

Example 70 with Texture

use of com.jme3.texture.Texture in project jmonkeyengine by jMonkeyEngine.

the class JmeBatchRenderBackend method loadImage.

@Override
public Image loadImage(final String filename) {
    TextureKey key = new TextureKey(filename, false);
    key.setAnisotropy(0);
    key.setGenerateMips(false);
    Texture2D texture = (Texture2D) display.getAssetManager().loadTexture(key);
    return new ImageImpl(texture.getImage());
}
Also used : TextureKey(com.jme3.asset.TextureKey) Texture2D(com.jme3.texture.Texture2D)

Aggregations

Material (com.jme3.material.Material)97 Texture (com.jme3.texture.Texture)94 Vector3f (com.jme3.math.Vector3f)66 Geometry (com.jme3.scene.Geometry)40 Image (com.jme3.texture.Image)39 TextureKey (com.jme3.asset.TextureKey)31 ArrayList (java.util.ArrayList)27 Texture2D (com.jme3.texture.Texture2D)25 ColorRGBA (com.jme3.math.ColorRGBA)23 Box (com.jme3.scene.shape.Box)19 Spatial (com.jme3.scene.Spatial)18 TerrainQuad (com.jme3.terrain.geomipmap.TerrainQuad)18 ParticleEmitter (com.jme3.effect.ParticleEmitter)17 DirectionalLight (com.jme3.light.DirectionalLight)17 Vector2f (com.jme3.math.Vector2f)17 TerrainLodControl (com.jme3.terrain.geomipmap.TerrainLodControl)16 ByteBuffer (java.nio.ByteBuffer)16 AbstractHeightMap (com.jme3.terrain.heightmap.AbstractHeightMap)15 ImageBasedHeightMap (com.jme3.terrain.heightmap.ImageBasedHeightMap)15 Camera (com.jme3.renderer.Camera)14