Texture key for generated textures added.
Normalmap is only calculated when generated texture is an input. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7927 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
48e4522da5
commit
cc403160be
37
engine/src/blender/com/jme3/asset/GeneratedTextureKey.java
Normal file
37
engine/src/blender/com/jme3/asset/GeneratedTextureKey.java
Normal file
@ -0,0 +1,37 @@
|
||||
package com.jme3.asset;
|
||||
|
||||
|
||||
/**
|
||||
* This key is mostly used to distinguish between textures that are loaded from
|
||||
* the given assets and those being generated automatically. Every generated
|
||||
* texture will have this kind of key attached.
|
||||
*
|
||||
* @author Marcin Roguski (Kaelthas)
|
||||
*/
|
||||
public class GeneratedTextureKey extends TextureKey {
|
||||
/**
|
||||
* Constructor. Stores the name. Extension and folder name are empty
|
||||
* strings.
|
||||
*
|
||||
* @param name
|
||||
* the name of the texture
|
||||
*/
|
||||
public GeneratedTextureKey(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExtension() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFolder() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Generated texture [" + name + "]";
|
||||
}
|
||||
}
|
@ -40,6 +40,7 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.jme3.asset.BlenderKey.FeaturesToLoad;
|
||||
import com.jme3.asset.GeneratedTextureKey;
|
||||
import com.jme3.material.MatParam;
|
||||
import com.jme3.material.MatParamTexture;
|
||||
import com.jme3.material.Material;
|
||||
@ -274,7 +275,12 @@ public class MaterialHelper extends AbstractBlenderHelper {
|
||||
}
|
||||
}
|
||||
if ((mapto & 0x02) != 0) {// Nor
|
||||
Texture normalMapTexture = textureHelper.convertToNormalMapTexture(texture, ((Number)textureLink.getFieldValue("norfac")).floatValue());
|
||||
Texture normalMapTexture;
|
||||
if(texture.getKey() instanceof GeneratedTextureKey) {
|
||||
normalMapTexture = textureHelper.convertToNormalMapTexture(texture, ((Number)textureLink.getFieldValue("norfac")).floatValue());
|
||||
} else {
|
||||
normalMapTexture = texture;
|
||||
}
|
||||
result.setTexture(TEXTURE_TYPE_NORMAL, normalMapTexture);
|
||||
if (vertexColor) {
|
||||
result.setBoolean(shadeless ? "VertexColor" : "UseVertexColor", false);
|
||||
|
@ -47,8 +47,9 @@ import java.util.logging.Logger;
|
||||
import jme3tools.converters.ImageToAwt;
|
||||
|
||||
import com.jme3.asset.AssetNotFoundException;
|
||||
import com.jme3.asset.TextureKey;
|
||||
import com.jme3.asset.BlenderKey.FeaturesToLoad;
|
||||
import com.jme3.asset.GeneratedTextureKey;
|
||||
import com.jme3.asset.TextureKey;
|
||||
import com.jme3.math.FastMath;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.plugins.blender.data.FileBlockHeader;
|
||||
@ -230,6 +231,9 @@ public class TextureHelper extends AbstractBlenderHelper {
|
||||
if (result != null) {
|
||||
result.setName(tex.getName());
|
||||
result.setWrap(WrapMode.Repeat);
|
||||
if(type != TEX_IMAGE) {//only generated textures should have this key
|
||||
result.setKey(new GeneratedTextureKey(tex.getName()));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user