Java Code Examples for org.lwjgl.assimp.AIMesh#create()
The following examples show how to use
org.lwjgl.assimp.AIMesh#create() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StaticMeshesLoader.java From lwjglbook with Apache License 2.0 | 6 votes |
public static Mesh[] load(String resourcePath, String texturesDir, int flags) throws Exception { AIScene aiScene = aiImportFile(resourcePath, flags); if (aiScene == null) { throw new Exception("Error loading model [resourcePath: " + resourcePath + ", texturesDir:" + texturesDir + "]"); } int numMaterials = aiScene.mNumMaterials(); PointerBuffer aiMaterials = aiScene.mMaterials(); List<Material> materials = new ArrayList<>(); for (int i = 0; i < numMaterials; i++) { AIMaterial aiMaterial = AIMaterial.create(aiMaterials.get(i)); processMaterial(aiMaterial, materials, texturesDir); } int numMeshes = aiScene.mNumMeshes(); PointerBuffer aiMeshes = aiScene.mMeshes(); Mesh[] meshes = new Mesh[numMeshes]; for (int i = 0; i < numMeshes; i++) { AIMesh aiMesh = AIMesh.create(aiMeshes.get(i)); Mesh mesh = processMesh(aiMesh, materials); meshes[i] = mesh; } return meshes; }
Example 2
Source File: StaticMeshesLoader.java From lwjglbook with Apache License 2.0 | 6 votes |
public static Mesh[] load(String resourcePath, String texturesDir, int flags) throws Exception { AIScene aiScene = aiImportFile(resourcePath, flags); if (aiScene == null) { throw new Exception("Error loading model"); } int numMaterials = aiScene.mNumMaterials(); PointerBuffer aiMaterials = aiScene.mMaterials(); List<Material> materials = new ArrayList<>(); for (int i = 0; i < numMaterials; i++) { AIMaterial aiMaterial = AIMaterial.create(aiMaterials.get(i)); processMaterial(aiMaterial, materials, texturesDir); } int numMeshes = aiScene.mNumMeshes(); PointerBuffer aiMeshes = aiScene.mMeshes(); Mesh[] meshes = new Mesh[numMeshes]; for (int i = 0; i < numMeshes; i++) { AIMesh aiMesh = AIMesh.create(aiMeshes.get(i)); Mesh mesh = processMesh(aiMesh, materials); meshes[i] = mesh; } return meshes; }
Example 3
Source File: StaticMeshesLoader.java From lwjglbook with Apache License 2.0 | 6 votes |
public static Mesh[] load(String resourcePath, String texturesDir, int flags) throws Exception { AIScene aiScene = aiImportFile(resourcePath, flags); if (aiScene == null) { throw new Exception("Error loading model"); } int numMaterials = aiScene.mNumMaterials(); PointerBuffer aiMaterials = aiScene.mMaterials(); List<Material> materials = new ArrayList<>(); for (int i = 0; i < numMaterials; i++) { AIMaterial aiMaterial = AIMaterial.create(aiMaterials.get(i)); processMaterial(aiMaterial, materials, texturesDir); } int numMeshes = aiScene.mNumMeshes(); PointerBuffer aiMeshes = aiScene.mMeshes(); Mesh[] meshes = new Mesh[numMeshes]; for (int i = 0; i < numMeshes; i++) { AIMesh aiMesh = AIMesh.create(aiMeshes.get(i)); Mesh mesh = processMesh(aiMesh, materials); meshes[i] = mesh; } return meshes; }
Example 4
Source File: AnimMeshesLoader.java From lwjglbook with Apache License 2.0 | 5 votes |
public static AnimGameItem loadAnimGameItem(String resourcePath, String texturesDir, int flags) throws Exception { AIScene aiScene = aiImportFile(resourcePath, flags); if (aiScene == null) { throw new Exception("Error loading model"); } int numMaterials = aiScene.mNumMaterials(); PointerBuffer aiMaterials = aiScene.mMaterials(); List<Material> materials = new ArrayList<>(); for (int i = 0; i < numMaterials; i++) { AIMaterial aiMaterial = AIMaterial.create(aiMaterials.get(i)); processMaterial(aiMaterial, materials, texturesDir); } List<Bone> boneList = new ArrayList<>(); int numMeshes = aiScene.mNumMeshes(); PointerBuffer aiMeshes = aiScene.mMeshes(); Mesh[] meshes = new Mesh[numMeshes]; for (int i = 0; i < numMeshes; i++) { AIMesh aiMesh = AIMesh.create(aiMeshes.get(i)); Mesh mesh = processMesh(aiMesh, materials, boneList); meshes[i] = mesh; } AINode aiRootNode = aiScene.mRootNode(); Matrix4f rootTransfromation = AnimMeshesLoader.toMatrix(aiRootNode.mTransformation()); Node rootNode = processNodesHierarchy(aiRootNode, null); Map<String, Animation> animations = processAnimations(aiScene, boneList, rootNode, rootTransfromation); AnimGameItem item = new AnimGameItem(meshes, animations); return item; }
Example 5
Source File: AnimMeshesLoader.java From lwjglbook with Apache License 2.0 | 5 votes |
public static AnimGameItem loadAnimGameItem(String resourcePath, String texturesDir, int flags) throws Exception { AIScene aiScene = aiImportFile(resourcePath, flags); if (aiScene == null) { throw new Exception("Error loading model"); } int numMaterials = aiScene.mNumMaterials(); PointerBuffer aiMaterials = aiScene.mMaterials(); List<Material> materials = new ArrayList<>(); for (int i = 0; i < numMaterials; i++) { AIMaterial aiMaterial = AIMaterial.create(aiMaterials.get(i)); processMaterial(aiMaterial, materials, texturesDir); } List<Bone> boneList = new ArrayList<>(); int numMeshes = aiScene.mNumMeshes(); PointerBuffer aiMeshes = aiScene.mMeshes(); Mesh[] meshes = new Mesh[numMeshes]; for (int i = 0; i < numMeshes; i++) { AIMesh aiMesh = AIMesh.create(aiMeshes.get(i)); Mesh mesh = processMesh(aiMesh, materials, boneList); meshes[i] = mesh; } AINode aiRootNode = aiScene.mRootNode(); Matrix4f rootTransfromation = AnimMeshesLoader.toMatrix(aiRootNode.mTransformation()); Node rootNode = processNodesHierarchy(aiRootNode, null); Map<String, Animation> animations = processAnimations(aiScene, boneList, rootNode, rootTransfromation); AnimGameItem item = new AnimGameItem(meshes, animations); return item; }
Example 6
Source File: VkAssimpModelLoader.java From oreon-engine with GNU General Public License v3.0 | 5 votes |
public static List<Model> loadModel(String path, String file) { List<Model> models = new ArrayList<>(); // List<Material<VkImage>> materials = new ArrayList<>(); path = VkAssimpModelLoader.class.getClassLoader().getResource(path).getPath(); // For Linux need to keep '/' or else the Assimp.aiImportFile(...) call below returns null! if (System.getProperty("os.name").contains("Windows")) { // TODO Language/region agnostic value for 'Windows' ? if (path.startsWith("/")) path = path.substring(1); } AIScene aiScene = Assimp.aiImportFile(path + "/" + file, 0); // if (aiScene.mMaterials() != null){ // for (int i=0; i<aiScene.mNumMaterials(); i++){ // AIMaterial aiMaterial = AIMaterial.create(aiScene.mMaterials().get(i)); // Material<GLTexture> material = processMaterial(aiMaterial, path); // materials.add(material); // } // } for (int i=0; i<aiScene.mNumMeshes(); i++){ AIMesh aiMesh = AIMesh.create(aiScene.mMeshes().get(i)); Mesh mesh = processMesh(aiMesh); Model model = new Model(); model.setMesh(mesh); // int materialIndex = aiMesh.mMaterialIndex(); // model.setMaterial(materials.get(materialIndex)); models.add(model); } return models; }
Example 7
Source File: AssimpAPI.java From WraithEngine with Apache License 2.0 | 4 votes |
@Override public IAssimpMesh getMesh(int index) { return new AssimpMesh(AIMesh.create(scene.mMeshes() .get(index))); }
Example 8
Source File: AssimpAPI.java From WraithEngine with Apache License 2.0 | 4 votes |
@Override public IAssimpMesh getMesh(int index) { return new AssimpMesh(AIMesh.create(scene.mMeshes() .get(index))); }