Feature: user can now decide if the mipmaps will be generated or not; by default 'mipmap' blender flag is used to decide if mips for specified textures shall be generated or not
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10201 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
519e968999
commit
fea4c37e06
@ -104,6 +104,8 @@ public class BlenderKey extends ModelKey {
|
|||||||
protected int maxTextureSize = -1;
|
protected int maxTextureSize = -1;
|
||||||
/** Allows to toggle generated textures loading. Disabled by default because it very often takes too much memory and needs to be used wisely. */
|
/** Allows to toggle generated textures loading. Disabled by default because it very often takes too much memory and needs to be used wisely. */
|
||||||
protected boolean loadGeneratedTextures;
|
protected boolean loadGeneratedTextures;
|
||||||
|
/** Tells if the mipmaps will be generated by jme or not. By default generation is dependant on the blender settings. */
|
||||||
|
protected MipmapGenerationMethod mipmapGenerationMethod = MipmapGenerationMethod.GENERATE_WHEN_NEEDED;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor used by serialization mechanisms.
|
* Constructor used by serialization mechanisms.
|
||||||
@ -334,6 +336,21 @@ public class BlenderKey extends ModelKey {
|
|||||||
return generatedTexturePPU;
|
return generatedTexturePPU;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mipmaps generation method
|
||||||
|
*/
|
||||||
|
public MipmapGenerationMethod getMipmapGenerationMethod() {
|
||||||
|
return mipmapGenerationMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mipmapGenerationMethod
|
||||||
|
* mipmaps generation method
|
||||||
|
*/
|
||||||
|
public void setMipmapGenerationMethod(MipmapGenerationMethod mipmapGenerationMethod) {
|
||||||
|
this.mipmapGenerationMethod = mipmapGenerationMethod;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This mehtod sets the name of the WORLD data block taht should be used during file loading. By default the name is
|
* This mehtod sets the name of the WORLD data block taht should be used during file loading. By default the name is
|
||||||
* not set. If no name is set or the given name does not occur in the file - the first WORLD data block will be used
|
* not set. If no name is set or the given name does not occur in the file - the first WORLD data block will be used
|
||||||
@ -384,6 +401,7 @@ public class BlenderKey extends ModelKey {
|
|||||||
oc.write(defaultMaterial, "default-material", null);
|
oc.write(defaultMaterial, "default-material", null);
|
||||||
oc.write(faceCullMode, "face-cull-mode", FaceCullMode.Off);
|
oc.write(faceCullMode, "face-cull-mode", FaceCullMode.Off);
|
||||||
oc.write(layersToLoad, "layers-to-load", -1);
|
oc.write(layersToLoad, "layers-to-load", -1);
|
||||||
|
oc.write(mipmapGenerationMethod , "mipmap-generation-method", MipmapGenerationMethod.GENERATE_WHEN_NEEDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -400,6 +418,7 @@ public class BlenderKey extends ModelKey {
|
|||||||
defaultMaterial = (Material) ic.readSavable("default-material", null);
|
defaultMaterial = (Material) ic.readSavable("default-material", null);
|
||||||
faceCullMode = ic.readEnum("face-cull-mode", FaceCullMode.class, FaceCullMode.Off);
|
faceCullMode = ic.readEnum("face-cull-mode", FaceCullMode.class, FaceCullMode.Off);
|
||||||
layersToLoad = ic.readInt("layers-to=load", -1);
|
layersToLoad = ic.readInt("layers-to=load", -1);
|
||||||
|
mipmapGenerationMethod = ic.readEnum("mipmap-generation-method", MipmapGenerationMethod.class, MipmapGenerationMethod.GENERATE_WHEN_NEEDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -476,7 +495,18 @@ public class BlenderKey extends ModelKey {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This enum tells the importer if the mipmaps for textures will be generated by jme.
|
||||||
|
* <li> NEVER_GENERATE and ALWAYS_GENERATE are quite understandable
|
||||||
|
* <li> GENERATE_WHEN_NEEDED is an option that checks if the texture had 'Generate mipmaps' option set
|
||||||
|
* in blender, mipmaps are generated only when the option is set
|
||||||
|
* @author Marcin Roguski (Kaelthas)
|
||||||
|
*/
|
||||||
|
public static enum MipmapGenerationMethod {
|
||||||
|
NEVER_GENERATE,
|
||||||
|
ALWAYS_GENERATE,
|
||||||
|
GENERATE_WHEN_NEEDED;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface describes the features of the scene that are to be loaded.
|
* This interface describes the features of the scene that are to be loaded.
|
||||||
|
@ -162,11 +162,7 @@ public class TextureHelper extends AbstractBlenderHelper {
|
|||||||
case TEX_NONE:// No texture, do nothing
|
case TEX_NONE:// No texture, do nothing
|
||||||
break;
|
break;
|
||||||
case TEX_POINTDENSITY:
|
case TEX_POINTDENSITY:
|
||||||
LOGGER.warning("Point density texture loading currently not supported!");
|
|
||||||
break;
|
|
||||||
case TEX_VOXELDATA:
|
case TEX_VOXELDATA:
|
||||||
LOGGER.warning("Voxel data texture loading currently not supported!");
|
|
||||||
break;
|
|
||||||
case TEX_PLUGIN:
|
case TEX_PLUGIN:
|
||||||
case TEX_ENVMAP:
|
case TEX_ENVMAP:
|
||||||
LOGGER.log(Level.WARNING, "Unsupported texture type: {0} for texture: {1}", new Object[] { type, tex.getName() });
|
LOGGER.log(Level.WARNING, "Unsupported texture type: {0} for texture: {1}", new Object[] { type, tex.getName() });
|
||||||
@ -177,8 +173,25 @@ public class TextureHelper extends AbstractBlenderHelper {
|
|||||||
if (result != null) {
|
if (result != null) {
|
||||||
result.setName(tex.getName());
|
result.setName(tex.getName());
|
||||||
result.setWrap(WrapMode.Repeat);
|
result.setWrap(WrapMode.Repeat);
|
||||||
// NOTE: Enable mipmaps FOR ALL TEXTURES EVER
|
|
||||||
|
//decide if the mipmaps will be generated
|
||||||
|
switch(blenderContext.getBlenderKey().getMipmapGenerationMethod()) {
|
||||||
|
case ALWAYS_GENERATE:
|
||||||
result.setMinFilter(MinFilter.Trilinear);
|
result.setMinFilter(MinFilter.Trilinear);
|
||||||
|
break;
|
||||||
|
case NEVER_GENERATE:
|
||||||
|
break;
|
||||||
|
case GENERATE_WHEN_NEEDED:
|
||||||
|
int imaflag = ((Number) tex.getFieldValue("imaflag")).intValue();
|
||||||
|
if((imaflag & 0x04) != 0) {
|
||||||
|
result.setMinFilter(MinFilter.Trilinear);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalStateException("Unknown mipmap generation method: " +
|
||||||
|
blenderContext.getBlenderKey().getMipmapGenerationMethod());
|
||||||
|
}
|
||||||
|
|
||||||
if (type != TEX_IMAGE) {// only generated textures should have this key
|
if (type != TEX_IMAGE) {// only generated textures should have this key
|
||||||
result.setKey(new GeneratedTextureKey(tex.getName()));
|
result.setKey(new GeneratedTextureKey(tex.getName()));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user