Java Code Examples for com.jme3.texture.Texture2D#setWrap()

The following examples show how to use com.jme3.texture.Texture2D#setWrap() . 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: GltfLoader.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public Texture2D readTexture(JsonObject texture, boolean flip) throws IOException {
    if (texture == null) {
        return null;
    }
    Integer textureIndex = getAsInteger(texture, "index");
    assertNotNull(textureIndex, "Texture has no index");
    assertNotNull(textures, "There are no textures, yet one is referenced by a material");

    JsonObject textureData = textures.get(textureIndex).getAsJsonObject();
    Integer sourceIndex = getAsInteger(textureData, "source");
    Integer samplerIndex = getAsInteger(textureData, "sampler");

    Texture2D texture2d = readImage(sourceIndex, flip);

    if (samplerIndex != null) {
        texture2d = readSampler(samplerIndex, texture2d);
    } else {
        texture2d.setWrap(Texture.WrapMode.Repeat);
    }

    texture2d = customContentManager.readExtensionAndExtras("texture", texture, texture2d);

    return texture2d;
}
 
Example 2
Source File: GltfLoader.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public Texture2D readSampler(int samplerIndex, Texture2D texture) throws IOException {
    if (samplers == null) {
        throw new AssetLoadException("No samplers defined");
    }
    JsonObject sampler = samplers.get(samplerIndex).getAsJsonObject();
    Texture.MagFilter magFilter = getMagFilter(getAsInteger(sampler, "magFilter"));
    Texture.MinFilter minFilter = getMinFilter(getAsInteger(sampler, "minFilter"));
    Texture.WrapMode wrapS = getWrapMode(getAsInteger(sampler, "wrapS"));
    Texture.WrapMode wrapT = getWrapMode(getAsInteger(sampler, "wrapT"));

    if (magFilter != null) {
        texture.setMagFilter(magFilter);
    }
    if (minFilter != null) {
        texture.setMinFilter(minFilter);
    }
    texture.setWrap(Texture.WrapAxis.S, wrapS);
    texture.setWrap(Texture.WrapAxis.T, wrapT);

    texture = customContentManager.readExtensionAndExtras("texture.sampler", sampler, texture);

    return texture;
}
 
Example 3
Source File: FbxTexture.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public FbxTexture(SceneLoader scene, FbxElement element) {
	super(scene, element);
	for(FbxElement e : element.children) {
		switch(e.id) {
		case "Type":
			bindType = (String) e.properties.get(0);
			break;
		case "FileName":
			filename = (String) e.properties.get(0);
			break;
		}
	}
	texture = new Texture2D();
	texture.setName(name);
	texture.setWrap(WrapMode.Repeat); // Default FBX wrapping. TODO: Investigate where this is stored (probably, in material)
}
 
Example 4
Source File: TextureAtlas.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Creates a new atlas texture for the given map name.
 * @param mapName
 * @return the atlas texture
 */
public Texture getAtlasTexture(String mapName) {
    if (images == null) {
        return null;
    }
    byte[] image = images.get(mapName);
    if (image != null) {
        //TODO check if color space shouldn't be sRGB
        Texture2D tex = new Texture2D(new Image(format, atlasWidth, atlasHeight, BufferUtils.createByteBuffer(image), null, ColorSpace.Linear));
        tex.setMagFilter(Texture.MagFilter.Bilinear);
        tex.setMinFilter(Texture.MinFilter.BilinearNearestMipMap);
        tex.setWrap(Texture.WrapMode.EdgeClamp);
        return tex;
    }
    return null;
}
 
Example 5
Source File: WaterFilter.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Sets the foam texture.
 *
 * @param foamTexture the foam texture.
 */
public void setFoamTexture(Texture2D foamTexture) {
    this.foamTexture = foamTexture;
    foamTexture.setWrap(WrapMode.Repeat);
    if (material != null) {
        material.setTexture("FoamMap", foamTexture);
    }
}
 
Example 6
Source File: WaterFilter.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Sets the height texture
 *
 * @param heightTexture
 */
public void setHeightTexture(Texture2D heightTexture) {
    this.heightTexture = heightTexture;
    heightTexture.setWrap(WrapMode.Repeat);
    if (material != null) {
        material.setTexture("HeightMap", heightTexture);
    }
}
 
Example 7
Source File: WaterFilter.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Sets the normal texture.
 *
 * @param normalTexture the normal texture.
 */
public void setNormalTexture(Texture2D normalTexture) {
    this.normalTexture = normalTexture;
    normalTexture.setWrap(WrapMode.Repeat);
    if (material != null) {
        material.setTexture("NormalMap", normalTexture);
    }
}
 
Example 8
Source File: WaterFilter.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Sets the foam texture
 * @param foamTexture
 */
public void setFoamTexture(Texture2D foamTexture) {
    this.foamTexture = foamTexture;
    foamTexture.setWrap(WrapMode.Repeat);
    if (material != null) {
        material.setTexture("FoamMap", foamTexture);
    }
}
 
Example 9
Source File: WaterFilter.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Sets the height texture
 * @param heightTexture
 */
public void setHeightTexture(Texture2D heightTexture) {
    this.heightTexture = heightTexture;
    heightTexture.setWrap(WrapMode.Repeat);
    if (material != null) {
        material.setTexture("HeightMap", heightTexture);
    }
}
 
Example 10
Source File: WaterFilter.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Sets the normal Texture
 * @param normalTexture
 */
public void setNormalTexture(Texture2D normalTexture) {
    this.normalTexture = normalTexture;
    normalTexture.setWrap(WrapMode.Repeat);
    if (material != null) {
        material.setTexture("NormalMap", normalTexture);
    }
}
 
Example 11
Source File: SimpleWaterProcessor.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
protected void loadTextures(AssetManager manager) {
    normalTexture = (Texture2D) manager.loadTexture("Common/MatDefs/Water/Textures/water_normalmap.png");
    dudvTexture = (Texture2D) manager.loadTexture("Common/MatDefs/Water/Textures/dudv_map.jpg");
    normalTexture.setWrap(WrapMode.Repeat);
    dudvTexture.setWrap(WrapMode.Repeat);
}