@Override public void init() throws Exception { renderer.init(); float[] positions = new float[]{ -0.5f, 0.5f, 0.0f, -0.5f, -0.5f, 0.0f, 0.5f, -0.5f, 0.0f, 0.5f, 0.5f, 0.0f,}; int[] indices = new int[]{ 0, 1, 3, 3, 1, 2,}; mesh = new Mesh(positions, indices); }
@Override public void init() throws Exception { renderer.init(); float[] positions = new float[]{ -0.5f, 0.5f, 0.0f, -0.5f, -0.5f, 0.0f, 0.5f, -0.5f, 0.0f, 0.5f, 0.5f, 0.0f, }; float[] colours = new float[]{ 0.5f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.5f, 0.5f, }; int[] indices = new int[]{ 0, 1, 3, 3, 1, 2, }; mesh = new Mesh(positions, colours, indices); }
@Override public void init(Window window) throws Exception { renderer.init(window); float[] positions = new float[]{ -0.5f, 0.5f, -1.05f, -0.5f, -0.5f, -1.05f, 0.5f, -0.5f, -1.05f, 0.5f, 0.5f, -1.05f, }; float[] colours = new float[]{ 0.5f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.5f, 0.5f, }; int[] indices = new int[]{ 0, 1, 3, 3, 1, 2, }; mesh = new Mesh(positions, colours, indices); }
private static Mesh reorderLists(List<Vector3f> posList, List<Vector2f> textCoordList, List<Vector3f> normList, List<Face> facesList) { List<Integer> indices = new ArrayList(); // Create position array in the order it has been declared float[] posArr = new float[posList.size() * 3]; int i = 0; for (Vector3f pos : posList) { posArr[i * 3] = pos.x; posArr[i * 3 + 1] = pos.y; posArr[i * 3 + 2] = pos.z; i++; } float[] textCoordArr = new float[posList.size() * 2]; float[] normArr = new float[posList.size() * 3]; for (Face face : facesList) { IdxGroup[] faceVertexIndices = face.getFaceVertexIndices(); for (IdxGroup indValue : faceVertexIndices) { processFaceVertex(indValue, textCoordList, normList, indices, textCoordArr, normArr); } } int[] indicesArr = new int[indices.size()]; indicesArr = indices.stream().mapToInt((Integer v) -> v).toArray(); Mesh mesh = new Mesh(posArr, textCoordArr, normArr, indicesArr); return mesh; }
private static Mesh reorderLists(List<Vector3f> posList, List<Vector2f> textCoordList, List<Vector3f> normList, List<Face> facesList) { List<Integer> indices = new ArrayList(); // Create position array in the order it has been declared float[] posArr = new float[posList.size() * 3]; int i = 0; for (Vector3f pos : posList) { posArr[i * 3] = pos.x; posArr[i * 3 + 1] = pos.y; posArr[i * 3 + 2] = pos.z; i++; } float[] textCoordArr = new float[posList.size() * 2]; float[] normArr = new float[posList.size() * 3]; for (Face face : facesList) { IdxGroup[] faceVertexIndices = face.getFaceVertexIndices(); for (IdxGroup indValue : faceVertexIndices) { processFaceVertex(indValue, textCoordList, normList, indices, textCoordArr, normArr); } } int[] indicesArr = new int[indices.size()]; indicesArr = indices.stream().mapToInt((Integer v) -> v).toArray(); Mesh mesh = new Mesh(posArr, textCoordArr, normArr, indicesArr); return mesh; }
private static Mesh reorderLists(List<Vector3f> posList, List<Vector2f> textCoordList, List<Vector3f> normList, List<Face> facesList) { List<Integer> indices = new ArrayList(); // Create position array in the order it has been declared float[] posArr = new float[posList.size() * 3]; int i = 0; for (Vector3f pos : posList) { posArr[i * 3] = pos.x; posArr[i * 3 + 1] = pos.y; posArr[i * 3 + 2] = pos.z; i++; } float[] textCoordArr = new float[posList.size() * 2]; float[] normArr = new float[posList.size() * 3]; for (Face face : facesList) { IdxGroup[] faceVertexIndices = face.getFaceVertexIndices(); for (IdxGroup indValue : faceVertexIndices) { processFaceVertex(indValue, textCoordList, normList, indices, textCoordArr, normArr); } } int[] indicesArr = new int[indices.size()]; indicesArr = indices.stream().mapToInt((Integer v) -> v).toArray(); Mesh mesh = new Mesh(posArr, textCoordArr, normArr, indicesArr); return mesh; }
private static Mesh reorderLists(List<Vector3f> posList, List<Vector2f> textCoordList, List<Vector3f> normList, List<Face> facesList) { List<Integer> indices = new ArrayList(); // Create position array in the order it has been declared float[] posArr = new float[posList.size() * 3]; int i = 0; for (Vector3f pos : posList) { posArr[i * 3] = pos.x; posArr[i * 3 + 1] = pos.y; posArr[i * 3 + 2] = pos.z; i++; } float[] textCoordArr = new float[posList.size() * 2]; float[] normArr = new float[posList.size() * 3]; for (Face face : facesList) { IdxGroup[] faceVertexIndices = face.getFaceVertexIndices(); for (IdxGroup indValue : faceVertexIndices) { processFaceVertex(indValue, textCoordList, normList, indices, textCoordArr, normArr); } } int[] indicesArr = new int[indices.size()]; indicesArr = indices.stream().mapToInt((Integer v) -> v).toArray(); Mesh mesh = new Mesh(posArr, textCoordArr, normArr, indicesArr); return mesh; }
private static Mesh reorderLists(List<Vector3f> posList, List<Vector2f> textCoordList, List<Vector3f> normList, List<Face> facesList) { List<Integer> indices = new ArrayList(); // Create position array in the order it has been declared float[] posArr = new float[posList.size() * 3]; int i = 0; for (Vector3f pos : posList) { posArr[i * 3] = pos.x; posArr[i * 3 + 1] = pos.y; posArr[i * 3 + 2] = pos.z; i++; } float[] textCoordArr = new float[posList.size() * 2]; float[] normArr = new float[posList.size() * 3]; for (Face face : facesList) { IdxGroup[] faceVertexIndices = face.getFaceVertexIndices(); for (IdxGroup indValue : faceVertexIndices) { processFaceVertex(indValue, textCoordList, normList, indices, textCoordArr, normArr); } } int[] indicesArr = new int[indices.size()]; indicesArr = indices.stream().mapToInt((Integer v) -> v).toArray(); Mesh mesh = new Mesh(posArr, textCoordArr, normArr, indicesArr); return mesh; }
private static Mesh reorderLists(List<Vector3f> posList, List<Vector2f> textCoordList, List<Vector3f> normList, List<Face> facesList) { List<Integer> indices = new ArrayList(); // Create position array in the order it has been declared float[] posArr = new float[posList.size() * 3]; int i = 0; for (Vector3f pos : posList) { posArr[i * 3] = pos.x; posArr[i * 3 + 1] = pos.y; posArr[i * 3 + 2] = pos.z; i++; } float[] textCoordArr = new float[posList.size() * 2]; float[] normArr = new float[posList.size() * 3]; for (Face face : facesList) { IdxGroup[] faceVertexIndices = face.getFaceVertexIndices(); for (IdxGroup indValue : faceVertexIndices) { processFaceVertex(indValue, textCoordList, normList, indices, textCoordArr, normArr); } } int[] indicesArr = new int[indices.size()]; indicesArr = indices.stream().mapToInt((Integer v) -> v).toArray(); Mesh mesh = new Mesh(posArr, textCoordArr, normArr, indicesArr); return mesh; }
private static Mesh reorderLists(List<Vector3f> posList, List<Vector2f> textCoordList, List<Vector3f> normList, List<Face> facesList) { List<Integer> indices = new ArrayList(); // Create position array in the order it has been declared float[] posArr = new float[posList.size() * 3]; int i = 0; for (Vector3f pos : posList) { posArr[i * 3] = pos.x; posArr[i * 3 + 1] = pos.y; posArr[i * 3 + 2] = pos.z; i++; } float[] textCoordArr = new float[posList.size() * 2]; float[] normArr = new float[posList.size() * 3]; for (Face face : facesList) { IdxGroup[] faceVertexIndices = face.getFaceVertexIndices(); for (IdxGroup indValue : faceVertexIndices) { processFaceVertex(indValue, textCoordList, normList, indices, textCoordArr, normArr); } } int[] indicesArr = Utils.listIntToArray(indices); Mesh mesh = new Mesh(posArr, textCoordArr, normArr, indicesArr); return mesh; }
private static Mesh reorderLists(List<Vector3f> posList, List<Vector2f> textCoordList, List<Vector3f> normList, List<Face> facesList) { List<Integer> indices = new ArrayList(); // Create position array in the order it has been declared float[] posArr = new float[posList.size() * 3]; int i = 0; for (Vector3f pos : posList) { posArr[i * 3] = pos.x; posArr[i * 3 + 1] = pos.y; posArr[i * 3 + 2] = pos.z; i++; } float[] textCoordArr = new float[posList.size() * 2]; float[] normArr = new float[posList.size() * 3]; for (Face face : facesList) { IdxGroup[] faceVertexIndices = face.getFaceVertexIndices(); for (IdxGroup indValue : faceVertexIndices) { processFaceVertex(indValue, textCoordList, normList, indices, textCoordArr, normArr); } } int[] indicesArr = Utils.listIntToArray(indices); Mesh mesh = new Mesh(posArr, textCoordArr, normArr, indicesArr); return mesh; }
private static Mesh reorderLists(List<Vector3f> posList, List<Vector2f> textCoordList, List<Vector3f> normList, List<Face> facesList) { List<Integer> indices = new ArrayList(); // Create position array in the order it has been declared float[] posArr = new float[posList.size() * 3]; int i = 0; for (Vector3f pos : posList) { posArr[i * 3] = pos.x; posArr[i * 3 + 1] = pos.y; posArr[i * 3 + 2] = pos.z; i++; } float[] textCoordArr = new float[posList.size() * 2]; float[] normArr = new float[posList.size() * 3]; for (Face face : facesList) { IdxGroup[] faceVertexIndices = face.getFaceVertexIndices(); for (IdxGroup indValue : faceVertexIndices) { processFaceVertex(indValue, textCoordList, normList, indices, textCoordArr, normArr); } } int[] indicesArr = Utils.listIntToArray(indices); Mesh mesh = new Mesh(posArr, textCoordArr, normArr, indicesArr); return mesh; }
private static Mesh reorderLists(List<Vector3f> posList, List<Vector2f> textCoordList, List<Vector3f> normList, List<Face> facesList) { List<Integer> indices = new ArrayList(); // Create position array in the order it has been declared float[] posArr = new float[posList.size() * 3]; int i = 0; for (Vector3f pos : posList) { posArr[i * 3] = pos.x; posArr[i * 3 + 1] = pos.y; posArr[i * 3 + 2] = pos.z; i++; } float[] textCoordArr = new float[posList.size() * 2]; float[] normArr = new float[posList.size() * 3]; for (Face face : facesList) { IdxGroup[] faceVertexIndices = face.getFaceVertexIndices(); for (IdxGroup indValue : faceVertexIndices) { processFaceVertex(indValue, textCoordList, normList, indices, textCoordArr, normArr); } } int[] indicesArr = Utils.listIntToArray(indices); Mesh mesh = new Mesh(posArr, textCoordArr, normArr, indicesArr); return mesh; }
private static Mesh reorderLists(List<Vector3f> posList, List<Vector2f> textCoordList, List<Vector3f> normList, List<Face> facesList) { List<Integer> indices = new ArrayList(); // Create position array in the order it has been declared float[] posArr = new float[posList.size() * 3]; int i = 0; for (Vector3f pos : posList) { posArr[i * 3] = pos.x; posArr[i * 3 + 1] = pos.y; posArr[i * 3 + 2] = pos.z; i++; } float[] textCoordArr = new float[posList.size() * 2]; float[] normArr = new float[posList.size() * 3]; for (Face face : facesList) { IdxGroup[] faceVertexIndices = face.getFaceVertexIndices(); for (IdxGroup indValue : faceVertexIndices) { processFaceVertex(indValue, textCoordList, normList, indices, textCoordArr, normArr); } } int[] indicesArr = Utils.listIntToArray(indices); Mesh mesh = new Mesh(posArr, textCoordArr, normArr, indicesArr); return mesh; }
@Override public void init(Window window) throws Exception { renderer.init(window); // Create the Mesh float[] positions = new float[]{ -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 0.5f, 0.5f, }; float[] colours = new float[]{ 0.5f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.5f, 0.5f, }; int[] indices = new int[]{ 0, 1, 3, 3, 1, 2, }; Mesh mesh = new Mesh(positions, colours, indices); GameItem gameItem = new GameItem(mesh); gameItem.setPosition(0, 0, -2); gameItems = new GameItem[] { gameItem }; }
private static Mesh processMesh(AIMesh aiMesh, List<Material> materials) { List<Float> vertices = new ArrayList<>(); List<Float> textures = new ArrayList<>(); List<Float> normals = new ArrayList<>(); List<Integer> indices = new ArrayList(); processVertices(aiMesh, vertices); processNormals(aiMesh, normals); processTextCoords(aiMesh, textures); processIndices(aiMesh, indices); Mesh mesh = new Mesh(Utils.listToArray(vertices), Utils.listToArray(textures), Utils.listToArray(normals), Utils.listIntToArray(indices)); Material material; int materialIdx = aiMesh.mMaterialIndex(); if (materialIdx >= 0 && materialIdx < materials.size()) { material = materials.get(materialIdx); } else { material = new Material(); } mesh.setMaterial(material); return mesh; }
private static Mesh processMesh(AIMesh aiMesh, List<Material> materials) { List<Float> vertices = new ArrayList<>(); List<Float> textures = new ArrayList<>(); List<Float> normals = new ArrayList<>(); List<Integer> indices = new ArrayList(); processVertices(aiMesh, vertices); processNormals(aiMesh, normals); processTextCoords(aiMesh, textures); processIndices(aiMesh, indices); Mesh mesh = new Mesh(Utils.listToArray(vertices), Utils.listToArray(textures), Utils.listToArray(normals), Utils.listIntToArray(indices)); Material material; int materialIdx = aiMesh.mMaterialIndex(); if (materialIdx >= 0 && materialIdx < materials.size()) { material = materials.get(materialIdx); } else { material = new Material(); } mesh.setMaterial(material); return mesh; }
private static Mesh processMesh(AIMesh aiMesh, List<Material> materials) { List<Float> vertices = new ArrayList<>(); List<Float> textures = new ArrayList<>(); List<Float> normals = new ArrayList<>(); List<Integer> indices = new ArrayList(); processVertices(aiMesh, vertices); processNormals(aiMesh, normals); processTextCoords(aiMesh, textures); processIndices(aiMesh, indices); Mesh mesh = new Mesh(Utils.listToArray(vertices), Utils.listToArray(textures), Utils.listToArray(normals), Utils.listIntToArray(indices) ); Material material; int materialIdx = aiMesh.mMaterialIndex(); if (materialIdx >= 0 && materialIdx < materials.size()) { material = materials.get(materialIdx); } else { material = new Material(); } mesh.setMaterial(material); return mesh; }
private static Mesh processMesh(AIMesh aiMesh, List<Material> materials, List<Bone> boneList) { List<Float> vertices = new ArrayList<>(); List<Float> textures = new ArrayList<>(); List<Float> normals = new ArrayList<>(); List<Integer> indices = new ArrayList<>(); List<Integer> boneIds = new ArrayList<>(); List<Float> weights = new ArrayList<>(); processVertices(aiMesh, vertices); processNormals(aiMesh, normals); processTextCoords(aiMesh, textures); processIndices(aiMesh, indices); processBones(aiMesh, boneList, boneIds, weights); Mesh mesh = new Mesh(Utils.listToArray(vertices), Utils.listToArray(textures), Utils.listToArray(normals), Utils.listIntToArray(indices), Utils.listIntToArray(boneIds), Utils.listToArray(weights)); Material material; int materialIdx = aiMesh.mMaterialIndex(); if (materialIdx >= 0 && materialIdx < materials.size()) { material = materials.get(materialIdx); } else { material = new Material(); } mesh.setMaterial(material); return mesh; }
private static Mesh processMesh(AIMesh aiMesh, List<Material> materials, List<Bone> boneList) { List<Float> vertices = new ArrayList<>(); List<Float> textures = new ArrayList<>(); List<Float> normals = new ArrayList<>(); List<Integer> indices = new ArrayList<>(); List<Integer> boneIds = new ArrayList<>(); List<Float> weights = new ArrayList<>(); processVertices(aiMesh, vertices); processNormals(aiMesh, normals); processTextCoords(aiMesh, textures); processIndices(aiMesh, indices); processBones(aiMesh, boneList, boneIds, weights); Mesh mesh = new Mesh(Utils.listToArray(vertices), Utils.listToArray(textures), Utils.listToArray(normals), Utils.listIntToArray(indices), Utils.listIntToArray(boneIds), Utils.listToArray(weights)); Material material; int materialIdx = aiMesh.mMaterialIndex(); if (materialIdx >= 0 && materialIdx < materials.size()) { material = materials.get(materialIdx); } else { material = new Material(); } mesh.setMaterial(material); return mesh; }