diff options
Diffstat (limited to 'ardor3d-extras')
-rw-r--r-- | ardor3d-extras/src/main/java/com/ardor3d/extension/model/off/OffImporter.java | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/ardor3d-extras/src/main/java/com/ardor3d/extension/model/off/OffImporter.java b/ardor3d-extras/src/main/java/com/ardor3d/extension/model/off/OffImporter.java index ca2fcb3..77a8484 100644 --- a/ardor3d-extras/src/main/java/com/ardor3d/extension/model/off/OffImporter.java +++ b/ardor3d-extras/src/main/java/com/ardor3d/extension/model/off/OffImporter.java @@ -19,6 +19,7 @@ import java.io.StreamTokenizer; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; @@ -84,10 +85,20 @@ public class OffImporter { private ResourceLocator _modelLocator; /** + * optional indexed color map + */ + private final Map<Integer, ColorRGBA> _colorMap; + + /** * Constructor. */ public OffImporter() { + this(null); + } + + public OffImporter(final Map<Integer, ColorRGBA> colorMap) { super(); + _colorMap = colorMap; } /** @@ -359,7 +370,19 @@ public class OffImporter { // nothing to do break; case 1: - // TODO store the color index somewhere + final int colorIndex = valueList.get(nextIndex).intValue(); + if (_colorMap == null) { + OffImporter.LOGGER.log(Level.WARNING, + "Color index found but no color map passed to the importer"); + } else { + final ColorRGBA indexedRgba = _colorMap.get(Integer.valueOf(colorIndex)); + if (indexedRgba == null) { + OffImporter.LOGGER.log(Level.WARNING, + "No color found at the index " + colorIndex + " in the color map"); + } else { + store.getDataStore().getColors().add(indexedRgba); + } + } break; case 3: final ColorRGBA rgb = new ColorRGBA(valueList.get(nextIndex).floatValue(), @@ -439,7 +462,19 @@ public class OffImporter { // no declared color break; case 1: - // TODO store the color index somewhere + final int colorIndex = valueList.get(vertexIndexCount + 1).intValue(); + if (_colorMap == null) { + OffImporter.LOGGER.log(Level.WARNING, + "Color index found but no color map passed to the importer"); + } else { + final ColorRGBA indexedRgba = _colorMap.get(Integer.valueOf(colorIndex)); + if (indexedRgba == null) { + OffImporter.LOGGER.log(Level.WARNING, + "No color found at the index " + colorIndex + " in the color map"); + } else { + faceInfo.setColor(indexedRgba); + } + } break; case 3: final ColorRGBA rgb = new ColorRGBA( |