Tons more utils!

This commit is contained in:
Caspian Rychlik-Prince 2004-04-21 18:11:00 +00:00
parent 2f77cb9604
commit c08c972bce
17 changed files with 2198 additions and 5 deletions

View file

@ -36,6 +36,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.lwjgl.util.Color;
import org.lwjgl.util.model.*;
import org.lwjgl.util.model.BoneFrame;
import org.lwjgl.util.model.BonedModel;
@ -92,6 +93,7 @@ public class Loader {
material,
loadTriangles(),
loadSkin(),
loadColor(),
loadBoneAnimations(),
loadBonedVertices()
);
@ -101,6 +103,7 @@ public class Loader {
material,
loadTriangles(),
loadSkin(),
loadColor(),
loadMeshAnimations()
);
} else {
@ -149,6 +152,28 @@ public class Loader {
return skins;
}
/**
* Load the colour
* @return Color[]
* @throws Exception
*/
private Color[] loadColor() throws Exception {
List colorElements = XMLUtil.getChildren(src.getDocumentElement(), "color");
if (colorElements.size() == 0) {
return null;
}
if (colorElements.size() != numVertices) {
throw new Exception("Color count incorrect, got "+colorElements.size()+", expected "+numVertices);
}
Color[] colors = new Color[colorElements.size()];
int colorCount = 0;
for (Iterator i = colorElements.iterator(); i.hasNext(); ) {
Element colorElement = (Element) i.next();
colors[colorCount++] = loadColor(colorElement);
}
return colors;
}
/**
* Load all the Triangles
* @return Triangle[]
@ -317,6 +342,21 @@ public class Loader {
);
}
/**
* Load a colour from XML
* @param element
* @return a Color
* @throws Exception
*/
private Color loadColor(Element element) throws Exception {
return new Color(
XMLUtil.getInt(element, "r"),
XMLUtil.getInt(element, "g"),
XMLUtil.getInt(element, "b"),
XMLUtil.getInt(element, "a", 255)
);
}
/**
* Load a boned Animation from XML
* @param element