Java Code Examples for com.jme3.texture.Texture.WrapMode

The following examples show how to use com.jme3.texture.Texture.WrapMode. These examples are extracted from open source projects. 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
/** Initialize the materials used in this scene. */
public void initMaterials() {
  wall_mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
  TextureKey key = new TextureKey("Textures/Terrain/BrickWall/BrickWall.jpg");
  key.setGenerateMips(true);
  Texture tex = assetManager.loadTexture(key);
  wall_mat.setTexture("ColorMap", tex);

  stone_mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
  TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG");
  key2.setGenerateMips(true);
  Texture tex2 = assetManager.loadTexture(key2);
  stone_mat.setTexture("ColorMap", tex2);

  floor_mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
  TextureKey key3 = new TextureKey("Textures/Terrain/Pond/Pond.jpg");
  key3.setGenerateMips(true);
  Texture tex3 = assetManager.loadTexture(key3);
  tex3.setWrap(WrapMode.Repeat);
  floor_mat.setTexture("ColorMap", tex3);
}
 
Example 2
public void setupFloor() {
    Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    mat.getTextureParam("DiffuseMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.getTextureParam("NormalMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.setBoolean("UseMaterialColors", true);
    mat.setColor("Diffuse", ColorRGBA.White.clone());
    mat.setColor("Ambient", ColorRGBA.White.clone());
   // mat.setColor("Specular", ColorRGBA.White.clone());
    // mat.getTextureParam("ParallaxMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.setFloat("Shininess", 0);
    //  mat.setBoolean("VertexLighting", true);


    Box floor = new Box(50, 1f, 50);
    TangentBinormalGenerator.generate(floor);
    floor.scaleTextureCoordinates(new Vector2f(5, 5));
    Geometry floorGeom = new Geometry("Floor", floor);
    floorGeom.setMaterial(mat);
    floorGeom.setShadowMode(ShadowMode.Receive);
    rootNode.attachChild(floorGeom);
}
 
Example 3
public void setupFloor(){
    Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    mat.getTextureParam("DiffuseMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.getTextureParam("NormalMap").getTextureValue().setWrap(WrapMode.Repeat);
   // mat.getTextureParam("ParallaxMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.setFloat("Shininess",3);
  //  mat.setBoolean("VertexLighting", true);
    
    
    Box floor = new Box(50, 1f, 50);
    TangentBinormalGenerator.generate(floor);
    floor.scaleTextureCoordinates(new Vector2f(5, 5));
    Geometry floorGeom = new Geometry("Floor", floor);
    floorGeom.setMaterial(mat);
    floorGeom.setShadowMode(ShadowMode.Receive);
    rootNode.attachChild(floorGeom);
}
 
Example 4
public void initMaterial() {
    mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey key = new TextureKey("Textures/Terrain/BrickWall/BrickWall.jpg");
    key.setGenerateMips(true);
    Texture tex = assetManager.loadTexture(key);
    mat.setTexture("ColorMap", tex);

    mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG");
    key2.setGenerateMips(true);
    Texture tex2 = assetManager.loadTexture(key2);
    mat2.setTexture("ColorMap", tex2);

    mat3 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey key3 = new TextureKey("Textures/Terrain/Pond/Pond.jpg");
    key3.setGenerateMips(true);
    Texture tex3 = assetManager.loadTexture(key3);
    tex3.setWrap(WrapMode.Repeat);
    mat3.setTexture("ColorMap", tex3);
}
 
Example 5
public void initMaterial() {
    mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey key = new TextureKey("Textures/Terrain/BrickWall/BrickWall.jpg");
    key.setGenerateMips(true);
    Texture tex = assetManager.loadTexture(key);
    mat.setTexture("ColorMap", tex);

    mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG");
    key2.setGenerateMips(true);
    Texture tex2 = assetManager.loadTexture(key2);
    mat2.setTexture("ColorMap", tex2);

    mat3 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey key3 = new TextureKey("Textures/Terrain/Pond/Pond.jpg");
    key3.setGenerateMips(true);
    Texture tex3 = assetManager.loadTexture(key3);
    tex3.setWrap(WrapMode.Repeat);
    mat3.setTexture("ColorMap", tex3);
}
 
Example 6
public void initMaterial() {
    mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey key = new TextureKey("Textures/Terrain/BrickWall/BrickWall.jpg");
    key.setGenerateMips(true);
    Texture tex = assetManager.loadTexture(key);
    mat.setTexture("ColorMap", tex);

    mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG");
    key2.setGenerateMips(true);
    Texture tex2 = assetManager.loadTexture(key2);
    mat2.setTexture("ColorMap", tex2);

    mat3 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey key3 = new TextureKey("Textures/Terrain/Pond/Pond.jpg");
    key3.setGenerateMips(true);
    Texture tex3 = assetManager.loadTexture(key3);
    tex3.setWrap(WrapMode.Repeat);
    mat3.setTexture("ColorMap", tex3);
}
 
Example 7
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 8
/** Initialize the materials used in this scene. */
public void initMaterials() {
  wall_mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
  TextureKey key = new TextureKey("Textures/Terrain/BrickWall/BrickWall.jpg");
  key.setGenerateMips(true);
  Texture tex = assetManager.loadTexture(key);
  wall_mat.setTexture("ColorMap", tex);

  stone_mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
  TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG");
  key2.setGenerateMips(true);
  Texture tex2 = assetManager.loadTexture(key2);
  stone_mat.setTexture("ColorMap", tex2);

  floor_mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
  TextureKey key3 = new TextureKey("Textures/Terrain/Pond/Pond.jpg");
  key3.setGenerateMips(true);
  Texture tex3 = assetManager.loadTexture(key3);
  tex3.setWrap(WrapMode.Repeat);
  floor_mat.setTexture("ColorMap", tex3);
}
 
Example 9
public void setupFloor(){
    Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    mat.getTextureParam("DiffuseMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.getTextureParam("NormalMap").getTextureValue().setWrap(WrapMode.Repeat);
   // mat.getTextureParam("ParallaxMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.setFloat("Shininess",3);
  //  mat.setBoolean("VertexLighting", true);
    
    
    Box floor = new Box(Vector3f.ZERO, 50, 1f, 50);
    TangentBinormalGenerator.generate(floor);
    floor.scaleTextureCoordinates(new Vector2f(5, 5));
    Geometry floorGeom = new Geometry("Floor", floor);
    floorGeom.setMaterial(mat);
    floorGeom.setShadowMode(ShadowMode.Receive);
    rootNode.attachChild(floorGeom);
}
 
Example 10
public void initMaterial() {
    mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey key = new TextureKey("Textures/Terrain/BrickWall/BrickWall.jpg");
    key.setGenerateMips(true);
    Texture tex = assetManager.loadTexture(key);
    mat.setTexture("ColorMap", tex);

    mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG");
    key2.setGenerateMips(true);
    Texture tex2 = assetManager.loadTexture(key2);
    mat2.setTexture("ColorMap", tex2);

    mat3 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey key3 = new TextureKey("Textures/Terrain/Pond/Pond.jpg");
    key3.setGenerateMips(true);
    Texture tex3 = assetManager.loadTexture(key3);
    tex3.setWrap(WrapMode.Repeat);
    mat3.setTexture("ColorMap", tex3);
}
 
Example 11
public void initMaterial() {
    mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey key = new TextureKey("Textures/Terrain/BrickWall/BrickWall.jpg");
    key.setGenerateMips(true);
    Texture tex = assetManager.loadTexture(key);
    mat.setTexture("ColorMap", tex);

    mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG");
    key2.setGenerateMips(true);
    Texture tex2 = assetManager.loadTexture(key2);
    mat2.setTexture("ColorMap", tex2);

    mat3 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey key3 = new TextureKey("Textures/Terrain/Pond/Pond.jpg");
    key3.setGenerateMips(true);
    Texture tex3 = assetManager.loadTexture(key3);
    tex3.setWrap(WrapMode.Repeat);
    mat3.setTexture("ColorMap", tex3);
}
 
Example 12
public void setupFloor() {
    mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall2.j3m");
    mat.getTextureParam("DiffuseMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.getTextureParam("NormalMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.setFloat("Shininess", 0);

    Node floorGeom = (Node) assetManager.loadAsset("Models/WaterTest/WaterTest.mesh.xml");
    Geometry g = ((Geometry) floorGeom.getChild(0));
    g.getMesh().scaleTextureCoordinates(new Vector2f(10, 10));
    TangentBinormalGenerator.generate(floorGeom);
    floorGeom.setLocalTranslation(0, 22, 0);
    floorGeom.setLocalScale(100);

    floorGeom.setMaterial(mat);        
    rootNode.attachChild(floorGeom);
}
 
Example 13
public void initMaterial() {
    mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey key = new TextureKey("Textures/Terrain/BrickWall/BrickWall.jpg");
    key.setGenerateMips(true);
    Texture tex = assetManager.loadTexture(key);
    mat.setTexture("ColorMap", tex);

    mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG");
    key2.setGenerateMips(true);
    Texture tex2 = assetManager.loadTexture(key2);
    mat2.setTexture("ColorMap", tex2);

    mat3 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey key3 = new TextureKey("Textures/Terrain/Pond/Pond.jpg");
    key3.setGenerateMips(true);
    Texture tex3 = assetManager.loadTexture(key3);
    tex3.setWrap(WrapMode.Repeat);
    mat3.setTexture("ColorMap", tex3);
}
 
Example 14
public void initMaterial() {
    mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey key = new TextureKey("Textures/Terrain/BrickWall/BrickWall.jpg");
    key.setGenerateMips(true);
    Texture tex = assetManager.loadTexture(key);
    mat.setTexture("ColorMap", tex);

    mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG");
    key2.setGenerateMips(true);
    Texture tex2 = assetManager.loadTexture(key2);
    mat2.setTexture("ColorMap", tex2);

    mat3 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey key3 = new TextureKey("Textures/Terrain/Pond/Pond.jpg");
    key3.setGenerateMips(true);
    Texture tex3 = assetManager.loadTexture(key3);
    tex3.setWrap(WrapMode.Repeat);
    mat3.setTexture("ColorMap", tex3);
}
 
Example 15
private void doSetDiffuseTexture(int layer, String texturePath) {
    if (texturePath == null || texturePath.equals(""))
        texturePath = DEFAULT_TERRAIN_TEXTURE;

    Texture tex = SceneApplication.getApplication().getAssetManager().loadTexture(texturePath);
    tex.setWrap(WrapMode.Repeat);
    Terrain terrain = (Terrain) getTerrain(null);
    
    if (layer == 0)
        terrain.getMaterial().setTexture("DiffuseMap", tex);
    else
        terrain.getMaterial().setTexture("DiffuseMap_"+layer, tex);

    doSetTextureScale(layer, DEFAULT_TEXTURE_SCALE);
    
    setNeedsSave(true);
}
 
Example 16
private void doSetNormalMap(int layer, String texturePath) {
    Terrain terrain = (Terrain) getTerrain(null);
    if (terrain == null)
        return;

    if (texturePath == null) {
        // remove the texture if it is null
        if (layer == 0)
            terrain.getMaterial().clearParam("NormalMap");
        else
            terrain.getMaterial().clearParam("NormalMap_"+layer);
    } else {
        Texture tex = SceneApplication.getApplication().getAssetManager().loadTexture(texturePath);
        tex.setWrap(WrapMode.Repeat);

        if (layer == 0)
            terrain.getMaterial().setTexture("NormalMap", tex);
        else
            terrain.getMaterial().setTexture("NormalMap_"+layer, tex);
    }
    enableTextureButtons();
    setNeedsSave(true);
}
 
Example 17
private void doSetNormalMap(int layer, Texture tex) {
    Terrain terrain = (Terrain) getTerrain(null);
    if (terrain == null)
        return;
    if (tex == null) {
        // remove the texture if it is null
        if (layer == 0)
            terrain.getMaterial().clearParam("NormalMap");
        else
            terrain.getMaterial().clearParam("NormalMap_"+layer);
        return;
    }

    tex.setWrap(WrapMode.Repeat);
    
    if (layer == 0)
        terrain.getMaterial().setTexture("NormalMap", tex);
    else
        terrain.getMaterial().setTexture("NormalMap_"+layer, tex);

    setNeedsSave(true);
}
 
Example 18
protected Geometry makeFloor() {
  Box box = new Box(220, .2f, 220);
  box.scaleTextureCoordinates(new Vector2f(10, 10));
  Geometry floor = new Geometry("the Floor", box);
  floor.setLocalTranslation(200, -9, 200);
  Material matGroundL = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
  Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
  grass.setWrap(WrapMode.Repeat);
  matGroundL.setTexture("DiffuseMap", grass);
  floor.setMaterial(matGroundL);
  floor.setShadowMode(ShadowMode.CastAndReceive);
  return floor;
}
 
Example 19
protected static String formatWrapMode(Texture texVal, Texture.WrapAxis axis) {
    WrapMode mode;
    try {
        mode = texVal.getWrap(axis);
    } catch (IllegalArgumentException e) {
        //this axis doesn't exist on the texture
        return "";
    }
    if (mode != WrapMode.EdgeClamp) {
        return "Wrap" + mode.name() + "_" + axis.name() + " ";
    }
    return "";
}
 
Example 20
private void readTextureUnitStatement(Statement statement){
    String[] split = statement.getLine().split(" ", 2);
    String keyword = split[0];
    if (keyword.equals("texture")){
        if (split.length < 2) {
            logger.log(Level.WARNING, "Invalid texture directive, no image specified at [{0}]", 
                                        statement.getLineNumber());
            return;
        }
        readTextureImage(split[1]);
    }else if (keyword.equals("tex_address_mode")){
        String mode = split[1];
        if (mode.equals("wrap")){
            textures[texUnit].setWrap(WrapMode.Repeat);
        }else if (mode.equals("clamp")){
            textures[texUnit].setWrap(WrapMode.EdgeClamp);
        }else if (mode.equals("mirror")){
            textures[texUnit].setWrap(WrapMode.MirroredRepeat);
        }else if (mode.equals("border")){
            textures[texUnit].setWrap(WrapMode.BorderClamp);
        }
    }else if (keyword.equals("filtering")){
        // ignored.. only anisotropy is considered
    }else if (keyword.equals("tex_coord_set")){
        int texCoord = Integer.parseInt(split[1]);
        if (texCoord == 1){
            separateTexCoord = true;
        }
    }else if (keyword.equals("max_anisotropy")){
        int amount = Integer.parseInt(split[1]);
        textures[texUnit].setAnisotropicFilter(amount);
    }else{
        logger.log(Level.WARNING, "Unsupported texture_unit directive: {0}", keyword);
    }
}
 
Example 21
/**
 * 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 22
/**
 * 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 23
/**
 * 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 24
private String getWrapMode(Texture texVal, Texture.WrapAxis axis) {
    WrapMode mode = WrapMode.EdgeClamp;
    try{
        mode = texVal.getWrap(axis);
    }catch (IllegalArgumentException e){
        //this axis doesn't exist on the texture
        return "";
    }
    if(mode != WrapMode.EdgeClamp){
        return"Wrap"+ mode.name() + "_" + axis.name() + " ";
    }
    return "";
}
 
Example 25
Source Project: OpenRTS   Source File: MaterialManager.java    License: MIT License 5 votes vote down vote up
public static Material getLightingTexture(String texturePath) {
	// We first check if the requested texture exist in the material map
	if (texturesMap.containsKey(texturePath)) {
		return texturesMap.get(texturePath);
	}

	// At this point, we know that the texture doesn't exist.
	// We must create a new material, add it to the map and return it.
	Material res = new Material(am, "Common/MatDefs/Light/Lighting.j3md");
	Texture t = am.loadTexture(texturePath);
	t.setWrap(WrapMode.Repeat);
	t.setAnisotropicFilter(8);
	res.setTexture("DiffuseMap", t);

	res.setFloat("Shininess", 10f); // [0,128]

	// test for envmap
	// TextureCubeMap envmap = new TextureCubeMap(assetManager.loadTexture("Textures/cubemap_reflec.dds").getImage());
	// res.setTexture("EnvMap", envmap);
	// res.setVector3("FresnelParams", new Vector3f(0.05f, 0.18f, 0.11f));
	// res.setVector3("FresnelParams", new Vector3f(0.05f, 0.05f, 0.05f));

	// normal map loading
	// String normalPath = texturePath.replaceAll(".jpg", "norm.jpg");;
	// try {
	// Texture normalMap = assetManager.loadTexture(normalPath);
	// normalMap.setWrap(WrapMode.Repeat);
	// normalMap.setAnisotropicFilter(8);
	// res.setTexture("NormalMap", normalMap);
	// }catch (Exception e) {
	// LogUtil.logger.info("No normal map found for "+texturePath);
	// }

	texturesMap.put(texturePath, res);

	return res;
}
 
Example 26
public void setupFloor() {
    Material mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall.j3m");
    mat.getTextureParam("DiffuseMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.getTextureParam("NormalMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.getTextureParam("ParallaxMap").getTextureValue().setWrap(WrapMode.Repeat);
    Box floor = new Box(Vector3f.ZERO, 50, 1f, 50);
    TangentBinormalGenerator.generate(floor);
    floor.scaleTextureCoordinates(new Vector2f(5, 5));
    Geometry floorGeom = new Geometry("Floor", floor);
    floorGeom.setMaterial(mat);
    floorGeom.setShadowMode(ShadowMode.Receive);
    rootNode.attachChild(floorGeom);
}
 
Example 27
public void setupFloor(){
    Material mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall.j3m");
    mat.getTextureParam("DiffuseMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.getTextureParam("NormalMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.getTextureParam("ParallaxMap").getTextureValue().setWrap(WrapMode.Repeat);
    
    Box floor = new Box(Vector3f.ZERO, 50, 1f, 50);
    TangentBinormalGenerator.generate(floor);
    floor.scaleTextureCoordinates(new Vector2f(5, 5));
    Geometry floorGeom = new Geometry("Floor", floor);
    floorGeom.setMaterial(mat);
    floorGeom.setShadowMode(ShadowMode.Receive);
    rootNode.attachChild(floorGeom);
}
 
Example 28
private void readTextureUnitStatement(Statement statement){
    String[] split = statement.getLine().split(" ", 2);
    String keyword = split[0];
    if (keyword.equals("texture")){
        readTextureImage(split[1]);
    }else if (keyword.equals("tex_address_mode")){
        String mode = split[1];
        if (mode.equals("wrap")){
            textures[texUnit].setWrap(WrapMode.Repeat);
        }else if (mode.equals("clamp")){
            textures[texUnit].setWrap(WrapMode.Clamp);
        }else if (mode.equals("mirror")){
            textures[texUnit].setWrap(WrapMode.MirroredRepeat);
        }else if (mode.equals("border")){
            textures[texUnit].setWrap(WrapMode.BorderClamp);
        }
    }else if (keyword.equals("filtering")){
        // ignored.. only anisotropy is considered
    }else if (keyword.equals("tex_coord_set")){
        int texCoord = Integer.parseInt(split[1]);
        if (texCoord == 1){
            separateTexCoord = true;
        }
    }else if (keyword.equals("max_anisotropy")){
        int amount = Integer.parseInt(split[1]);
        textures[texUnit].setAnisotropicFilter(amount);
    }else{
        logger.log(Level.WARNING, "Unsupported texture_unit directive: {0}", keyword);
    }
}
 
Example 29
Source Project: MikuMikuStudio   Source File: MTLLoader.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected Texture loadTexture(String path){
    String[] split = path.trim().split("\\p{javaWhitespace}+");
    
    // will crash if path is an empty string
    path = split[split.length-1];
    
    String name = new File(path).getName();
    TextureKey key = new TextureKey(folderName + name);
    key.setGenerateMips(true);
    Texture texture = assetManager.loadTexture(key);
    if (texture != null){
        texture.setWrap(WrapMode.Repeat);
    }
    return texture;
}
 
Example 30
Source Project: MikuMikuStudio   Source File: WaterFilter.java    License: 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);
    }
}