|
|
|
@ -40,7 +40,6 @@ import java.util.logging.Level; |
|
|
|
|
import java.util.logging.Logger; |
|
|
|
|
|
|
|
|
|
import com.jme3.asset.BlenderKey.FeaturesToLoad; |
|
|
|
|
import com.jme3.asset.TextureKey; |
|
|
|
|
import com.jme3.material.MatParam; |
|
|
|
|
import com.jme3.material.Material; |
|
|
|
|
import com.jme3.material.Material.MatParamTexture; |
|
|
|
@ -259,12 +258,9 @@ public class MaterialHelper extends AbstractBlenderHelper { |
|
|
|
|
result.setBoolean("UseMaterialColors", Boolean.FALSE); |
|
|
|
|
// blending the texture with material color and texture's defined color
|
|
|
|
|
int blendType = ((Number) textureLink.getFieldValue("blendtype")).intValue(); |
|
|
|
|
float[] color = new float[] { ((Number) textureLink.getFieldValue("r")).floatValue(), |
|
|
|
|
((Number) textureLink.getFieldValue("g")).floatValue(), |
|
|
|
|
((Number) textureLink.getFieldValue("b")).floatValue() }; |
|
|
|
|
float[] color = new float[] { ((Number) textureLink.getFieldValue("r")).floatValue(), ((Number) textureLink.getFieldValue("g")).floatValue(), ((Number) textureLink.getFieldValue("b")).floatValue() }; |
|
|
|
|
float colfac = ((Number) textureLink.getFieldValue("colfac")).floatValue(); |
|
|
|
|
texture = textureHelper.blendTexture(diffuseColor.getColorArray(), texture, color, colfac, blendType, |
|
|
|
|
negateTexture, dataRepository); |
|
|
|
|
texture = textureHelper.blendTexture(diffuseColor.getColorArray(), texture, color, colfac, blendType, negateTexture, dataRepository); |
|
|
|
|
texture.setWrap(WrapMode.Repeat); |
|
|
|
|
if (shadeless) { |
|
|
|
|
result.setTexture(TEXTURE_TYPE_COLOR, texture); |
|
|
|
@ -315,8 +311,7 @@ public class MaterialHelper extends AbstractBlenderHelper { |
|
|
|
|
* @return material without textures of a specified type |
|
|
|
|
*/ |
|
|
|
|
public Material getNonTexturedMaterial(Material material, int imageType) { |
|
|
|
|
String[] textureParamNames = new String[] { TEXTURE_TYPE_DIFFUSE, TEXTURE_TYPE_NORMAL, TEXTURE_TYPE_GLOW, TEXTURE_TYPE_SPECULAR, |
|
|
|
|
TEXTURE_TYPE_ALPHA }; |
|
|
|
|
String[] textureParamNames = new String[] { TEXTURE_TYPE_DIFFUSE, TEXTURE_TYPE_NORMAL, TEXTURE_TYPE_GLOW, TEXTURE_TYPE_SPECULAR, TEXTURE_TYPE_ALPHA }; |
|
|
|
|
Map<String, Texture> textures = new HashMap<String, Texture>(textureParamNames.length); |
|
|
|
|
for (String textureParamName : textureParamNames) { |
|
|
|
|
MatParamTexture matParamTexture = material.getTextureParam(textureParamName); |
|
|
|
@ -336,8 +331,7 @@ public class MaterialHelper extends AbstractBlenderHelper { |
|
|
|
|
material.clearParam(textureParamName.getKey()); |
|
|
|
|
} |
|
|
|
|
} catch (NumberFormatException e) { |
|
|
|
|
LOGGER.log(Level.WARNING, "The name of the texture does not contain the texture type value! {0} will not be removed!", |
|
|
|
|
name); |
|
|
|
|
LOGGER.log(Level.WARNING, "The name of the texture does not contain the texture type value! {0} will not be removed!", name); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Material result = material.clone(); |
|
|
|
@ -353,8 +347,10 @@ public class MaterialHelper extends AbstractBlenderHelper { |
|
|
|
|
* This method converts the given material into particles-usable material. |
|
|
|
|
* The texture and glow color are being copied. |
|
|
|
|
* The method assumes it receives the Lighting type of material. |
|
|
|
|
* @param material the source material |
|
|
|
|
* @param dataRepository the data repository |
|
|
|
|
* @param material |
|
|
|
|
* the source material |
|
|
|
|
* @param dataRepository |
|
|
|
|
* the data repository |
|
|
|
|
* @return material converted into particles-usable material |
|
|
|
|
*/ |
|
|
|
|
public Material getParticlesMaterial(Material material, Integer alphaMaskIndex, DataRepository dataRepository) { |
|
|
|
@ -399,15 +395,6 @@ public class MaterialHelper extends AbstractBlenderHelper { |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected byte calculateAlpha(float x, float y) { |
|
|
|
|
return (byte)255; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected Texture loadParticleAlphaMapTexture(DataRepository dataRepository) { |
|
|
|
|
TextureKey textureKey = new TextureKey(this.getClass().getPackage().getName().replace('.', '/') + "/particle_alpha_map.png"); |
|
|
|
|
return dataRepository.getAssetManager().loadTexture(textureKey); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* This method indicates if the material has a texture of a specified type. |
|
|
|
|
* |
|
|
|
@ -565,8 +552,7 @@ public class MaterialHelper extends AbstractBlenderHelper { |
|
|
|
|
materials = new Material[materialStructures.size()]; |
|
|
|
|
int i = 0; |
|
|
|
|
for (Structure s : materialStructures) { |
|
|
|
|
Material material = (Material) dataRepository.getLoadedFeature(s.getOldMemoryAddress(), |
|
|
|
|
LoadedFeatureDataType.LOADED_FEATURE); |
|
|
|
|
Material material = (Material) dataRepository.getLoadedFeature(s.getOldMemoryAddress(), LoadedFeatureDataType.LOADED_FEATURE); |
|
|
|
|
if (material == null) { |
|
|
|
|
material = materialHelper.toMaterial(s, dataRepository); |
|
|
|
|
} |
|
|
|
@ -688,8 +674,28 @@ public class MaterialHelper extends AbstractBlenderHelper { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* An interface used in calculating alpha mask during particles' texture calculations. |
|
|
|
|
* @author Marcin Roguski (Kaelthas) |
|
|
|
|
*/ |
|
|
|
|
protected static interface IAlphaMask { |
|
|
|
|
/** |
|
|
|
|
* This method sets the size of the texture's image. |
|
|
|
|
* @param width |
|
|
|
|
* the width of the image |
|
|
|
|
* @param height |
|
|
|
|
* the height of the image |
|
|
|
|
*/ |
|
|
|
|
void setImageSize(int width, int height); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* This method returns the alpha value for the specified texture position. |
|
|
|
|
* @param x |
|
|
|
|
* the X coordinate of the texture position |
|
|
|
|
* @param y |
|
|
|
|
* the Y coordinate of the texture position |
|
|
|
|
* @return the alpha value for the specified texture position |
|
|
|
|
*/ |
|
|
|
|
byte getAlpha(float x, float y); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|