public static MD5Model parse(String meshModelFile) throws Exception { List<String> lines = Utils.readAllLines(meshModelFile); MD5Model result = new MD5Model(); result.setHeader(header); } else if (inBlock && line.endsWith("}")) { List<String> blockBody = lines.subList(blockStart + 1, i); parseBlock(result, blockId, blockBody); inBlock = false;
@Override public String toString() { StringBuilder str = new StringBuilder("MD5MeshModel: " + System.lineSeparator()); str.append(getHeader()).append(System.lineSeparator()); str.append(getJointInfo()).append(System.lineSeparator()); for (MD5Mesh mesh : meshes) { str.append(mesh).append(System.lineSeparator()); } return str.toString(); }
private static void parseBlock(MD5Model model, String blockId, List<String> blockBody) throws Exception { switch (blockId) { case "joints": MD5JointInfo jointInfo = MD5JointInfo.parse(blockBody); model.setJointInfo(jointInfo); break; case "mesh": MD5Mesh md5Mesh = MD5Mesh.parse(blockBody); model.getMeshes().add(md5Mesh); break; default: break; } }
private static List<Matrix4f> calcInJointMatrices(MD5Model md5Model) { List<Matrix4f> result = new ArrayList<>(); List<MD5JointInfo.MD5JointData> joints = md5Model.getJointInfo().getJoints(); for (MD5JointInfo.MD5JointData joint : joints) { // Calculate translation matrix using joint position // Calculates rotation matrix using joint orientation // Gets transformation matrix bu multiplying translation matrix by rotation matrix // Instead of multiplying we can apply rotation which is optimized internally Matrix4f mat = new Matrix4f() .translate(joint.getPosition()) .rotate(joint.getOrientation()) .invert(); result.add(mat); } return result; }
public static GameItem process(MD5Model md5Model, Vector4f defaultColour) throws Exception { List<MD5Mesh> md5MeshList = md5Model.getMeshes(); List<Mesh> list = new ArrayList<>(); for (MD5Mesh md5Mesh : md5Model.getMeshes()) { Mesh mesh = generateMesh(md5Model, md5Mesh, defaultColour); handleTexture(mesh, md5Mesh, defaultColour); list.add(mesh); } Mesh[] meshes = new Mesh[list.size()]; meshes = list.toArray(meshes); GameItem gameItem = new GameItem(meshes); return gameItem; }
private static List<Matrix4f> calcInJointMatrices(MD5Model md5Model) { List<Matrix4f> result = new ArrayList<>(); List<MD5JointInfo.MD5JointData> joints = md5Model.getJointInfo().getJoints(); for (MD5JointInfo.MD5JointData joint : joints) { // Calculate translation matrix using joint position // Calculates rotation matrix using joint orientation // Gets transformation matrix bu multiplying translation matrix by rotation matrix // Instead of multiplying we can apply rotation which is optimized internally Matrix4f mat = new Matrix4f() .translate(joint.getPosition()) .rotate(joint.getOrientation()) .invert(); result.add(mat); } return result; }
/** * Constructs and AnimGameItem instace based on a MD5 Model an MD5 Animation * * @param md5Model The MD5 Model * @param animModel The MD5 Animation * @param defaultColour Default colour to use if there are no textures * @return * @throws Exception */ public static AnimGameItem process(MD5Model md5Model, MD5AnimModel animModel, Vector4f defaultColour) throws Exception { List<Matrix4f> invJointMatrices = calcInJointMatrices(md5Model); List<AnimatedFrame> animatedFrames = processAnimationFrames(md5Model, animModel, invJointMatrices); List<Mesh> list = new ArrayList<>(); for (MD5Mesh md5Mesh : md5Model.getMeshes()) { Mesh mesh = generateMesh(md5Model, md5Mesh); handleTexture(mesh, md5Mesh, defaultColour); list.add(mesh); } Mesh[] meshes = new Mesh[list.size()]; meshes = list.toArray(meshes); AnimGameItem result = new AnimGameItem(meshes, animatedFrames, invJointMatrices); return result; }
public static MD5Model parse(String meshModelFile) throws Exception { List<String> lines = Utils.readAllLines(meshModelFile); MD5Model result = new MD5Model(); result.setHeader(header); } else if (inBlock && line.endsWith("}")) { List<String> blockBody = lines.subList(blockStart + 1, i); parseBlock(result, blockId, blockBody); inBlock = false;
@Override public String toString() { StringBuilder str = new StringBuilder("MD5MeshModel: " + System.lineSeparator()); str.append(getHeader()).append(System.lineSeparator()); str.append(getJointInfo()).append(System.lineSeparator()); for (MD5Mesh mesh : meshes) { str.append(mesh).append(System.lineSeparator()); } return str.toString(); }
private static void parseBlock(MD5Model model, String blockId, List<String> blockBody) throws Exception { switch (blockId) { case "joints": MD5JointInfo jointInfo = MD5JointInfo.parse(blockBody); model.setJointInfo(jointInfo); break; case "mesh": MD5Mesh md5Mesh = MD5Mesh.parse(blockBody); model.getMeshes().add(md5Mesh); break; default: break; } }
private static List<Matrix4f> calcInJointMatrices(MD5Model md5Model) { List<Matrix4f> result = new ArrayList<>(); List<MD5JointInfo.MD5JointData> joints = md5Model.getJointInfo().getJoints(); for (MD5JointInfo.MD5JointData joint : joints) { // Calculate translation matrix using joint position // Calculates rotation matrix using joint orientation // Gets transformation matrix bu multiplying translation matrix by rotation matrix // Instead of multiplying we can apply rotation which is optimized internally Matrix4f mat = new Matrix4f() .translate(joint.getPosition()) .rotate(joint.getOrientation()) .invert(); result.add(mat); } return result; }
/** * Constructs and AnimGameItem instace based on a MD5 Model an MD5 Animation * * @param md5Model The MD5 Model * @param animModel The MD5 Animation * @param defaultColour Default colour to use if there are no textures * @return * @throws Exception */ public static AnimGameItem process(MD5Model md5Model, MD5AnimModel animModel, Vector4f defaultColour) throws Exception { List<Matrix4f> invJointMatrices = calcInJointMatrices(md5Model); List<AnimatedFrame> animatedFrames = processAnimationFrames(md5Model, animModel, invJointMatrices); List<Mesh> list = new ArrayList<>(); for (MD5Mesh md5Mesh : md5Model.getMeshes()) { Mesh mesh = generateMesh(md5Model, md5Mesh); handleTexture(mesh, md5Mesh, defaultColour); list.add(mesh); } Mesh[] meshes = new Mesh[list.size()]; meshes = list.toArray(meshes); AnimGameItem result = new AnimGameItem(meshes, animatedFrames, invJointMatrices); return result; }
public static MD5Model parse(String meshModelFile) throws Exception { List<String> lines = Utils.readAllLines(meshModelFile); MD5Model result = new MD5Model(); result.setHeader(header); } else if (inBlock && line.endsWith("}")) { List<String> blockBody = lines.subList(blockStart + 1, i); parseBlock(result, blockId, blockBody); inBlock = false;
@Override public String toString() { StringBuilder str = new StringBuilder("MD5MeshModel: " + System.lineSeparator()); str.append(getHeader()).append(System.lineSeparator()); str.append(getJointInfo()).append(System.lineSeparator()); for (MD5Mesh mesh : meshes) { str.append(mesh).append(System.lineSeparator()); } return str.toString(); }
private static void parseBlock(MD5Model model, String blockId, List<String> blockBody) throws Exception { switch (blockId) { case "joints": MD5JointInfo jointInfo = MD5JointInfo.parse(blockBody); model.setJointInfo(jointInfo); break; case "mesh": MD5Mesh md5Mesh = MD5Mesh.parse(blockBody); model.getMeshes().add(md5Mesh); break; default: break; } }
private static List<Matrix4f> calcInJointMatrices(MD5Model md5Model) { List<Matrix4f> result = new ArrayList<>(); List<MD5JointInfo.MD5JointData> joints = md5Model.getJointInfo().getJoints(); for (MD5JointInfo.MD5JointData joint : joints) { // Calculate translation matrix using joint position // Calculates rotation matrix using joint orientation // Gets transformation matrix bu multiplying translation matrix by rotation matrix // Instead of multiplying we can apply rotation which is optimized internally Matrix4f mat = new Matrix4f() .translate(joint.getPosition()) .rotate(joint.getOrientation()) .invert(); result.add(mat); } return result; }
/** * Constructs and AnimGameItem instace based on a MD5 Model an MD5 Animation * * @param md5Model The MD5 Model * @param animModel The MD5 Animation * @param defaultColour Default colour to use if there are no textures * @return * @throws Exception */ public static AnimGameItem process(MD5Model md5Model, MD5AnimModel animModel, Vector4f defaultColour) throws Exception { List<Matrix4f> invJointMatrices = calcInJointMatrices(md5Model); List<AnimatedFrame> animatedFrames = processAnimationFrames(md5Model, animModel, invJointMatrices); List<Mesh> list = new ArrayList<>(); for (MD5Mesh md5Mesh : md5Model.getMeshes()) { Mesh mesh = generateMesh(md5Model, md5Mesh); handleTexture(mesh, md5Mesh, defaultColour); list.add(mesh); } Mesh[] meshes = new Mesh[list.size()]; meshes = list.toArray(meshes); AnimGameItem result = new AnimGameItem(meshes, animatedFrames, invJointMatrices); return result; }
public static MD5Model parse(String meshModelFile) throws Exception { List<String> lines = Utils.readAllLines(meshModelFile); MD5Model result = new MD5Model(); result.setHeader(header); } else if (inBlock && line.endsWith("}")) { List<String> blockBody = lines.subList(blockStart + 1, i); parseBlock(result, blockId, blockBody); inBlock = false;
@Override public String toString() { StringBuilder str = new StringBuilder("MD5MeshModel: " + System.lineSeparator()); str.append(getHeader()).append(System.lineSeparator()); str.append(getJointInfo()).append(System.lineSeparator()); for (MD5Mesh mesh : meshes) { str.append(mesh).append(System.lineSeparator()); } return str.toString(); }
private static void parseBlock(MD5Model model, String blockId, List<String> blockBody) throws Exception { switch (blockId) { case "joints": MD5JointInfo jointInfo = MD5JointInfo.parse(blockBody); model.setJointInfo(jointInfo); break; case "mesh": MD5Mesh md5Mesh = MD5Mesh.parse(blockBody); model.getMeshes().add(md5Mesh); break; default: break; } }