jMonkeyEngine/jmonkeyengine — pull request #161 by shamanDevel (2014-08-01 08:25:40+00:00)
Title: Extended dds support in the JME-SDK

The engine can load dds textures, but the SDK cannot display, open and edit them.
However, I think that the dds texture format is one of the most important formats for textures, because it can be directly loaded into the GPU memory.
Therefore, I've added support for these textures in the sdk.

These code changes come in four steps:
1. Relax restrictions in the dds loader in the core engine
2. Add libraries to load and store dds textures for the SDK
3. Extend the module Texture-Editor
4. Add a dialog that can convert textures

1. Relax restrictions in the dds loader
The dds loader tests if the flag "DDSCAPS_TEXTURE" is set. However, there exists many vaild textures without these flags (valid because they can be loaded by the official dds loader). Especially the libraries in the next step create textures without that flag.

diff --git a/jme3-core/src/plugins/java/com/jme3/texture/plugins/DDSLoader.java b/jme3-core/src/plugins/java/com/jme3/texture/plugins/DDSLoader.java
index 8ea46a7..8aa6749 100644
--- a/jme3-core/src/plugins/java/com/jme3/texture/plugins/DDSLoader.java
+++ b/jme3-core/src/plugins/java/com/jme3/texture/plugins/DDSLoader.java
@@ -203,9 +203,10 @@ public class DDSLoader implements AssetLoader {
texture3D = false;

if (!directx10) {
- if (!is(caps1, DDSCAPS_TEXTURE)) {
- throw new IOException("File is not a texture");
- }
+	//ignore it, there exists many valid textures that have not this flag set
+// if (!is(caps1, DDSCAPS_TEXTURE)) {
+// throw new IOException("File is not a texture");
+// }

if (depth <= 0) {
depth = 1;

2. Add libraries to load and store dds textures for the SDK
I use the library https://code.google.com/p/java-dds/ for reading
and https://github.com/Dahie/DDS-Utils for writing.
These libraries are a bit old and buggy, but the best I could find.

3. Extend the module Texture-Editor
In this main step, the texture editor is extended, so that dds textures are recognized as textures and can be read and written.

4. Add a dialog that can convert textures
The last step is an addon that allows to convert textures to a different format and also allows to compress the dds textures.
The SDK already support the texture compression tool, but it requires the tool from NVIDIA to be installed. This dialog has limited functionallity,
but it does not need additional executables. It is also directly integrated into the node structure.

This dialog looks like:
![dds-converter](https://cloud.githubusercontent.com/assets/1770337/3776475/0f371334-1955-11e4-9d29-dc38ff393289.jpg)