public static Mesh[] load(String resourcePath, String texturesDir) throws Exception { return load(resourcePath, texturesDir, aiProcess_GenSmoothNormals | aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_FixInfacingNormals); }
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; }
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; }
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; }
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; }
public static Mesh[] load(String resourcePath, String texturesDir) throws Exception { return load(resourcePath, texturesDir, aiProcess_GenSmoothNormals | aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_FixInfacingNormals); }
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; }
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; }
public static Mesh[] load(String resourcePath, String texturesDir) throws Exception { return load(resourcePath, texturesDir, aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_FixInfacingNormals); }
public SkyBox(String objModel, Vector4f colour) throws Exception { super(); Mesh skyBoxMesh = StaticMeshesLoader.load(objModel, "", 0)[0]; Material material = new Material(colour, 0); skyBoxMesh.setMaterial(material); setMesh(skyBoxMesh); setPosition(0, 0, 0); } }
public SkyBox(String objModel, Vector4f colour) throws Exception { super(); Mesh skyBoxMesh = StaticMeshesLoader.load(objModel, "", 0)[0]; Material material = new Material(colour, 0); skyBoxMesh.setMaterial(material); setMesh(skyBoxMesh); setPosition(0, 0, 0); } }
public SkyBox(String objModel, Vector4f colour) throws Exception { super(); Mesh skyBoxMesh = StaticMeshesLoader.load(objModel, "", 0)[0]; Material material = new Material(colour, 0); skyBoxMesh.setMaterial(material); setMesh(skyBoxMesh); setPosition(0, 0, 0); } }
public SkyBox(String objModel, String textureFile) throws Exception { super(); Mesh skyBoxMesh = StaticMeshesLoader.load(objModel, "")[0]; Texture skyBoxtexture = new Texture(textureFile); skyBoxMesh.setMaterial(new Material(skyBoxtexture, 0.0f)); setMesh(skyBoxMesh); setPosition(0, 0, 0); }
public SkyBox(String objModel, String textureFile) throws Exception { super(); Mesh skyBoxMesh = StaticMeshesLoader.load(objModel, "")[0]; Texture skyBoxtexture = new Texture(textureFile); skyBoxMesh.setMaterial(new Material(skyBoxtexture, 0.0f)); setMesh(skyBoxMesh); setPosition(0, 0, 0); }
public SkyBox(String objModel, String textureFile) throws Exception { super(); Mesh skyBoxMesh = StaticMeshesLoader.load(objModel, "")[0]; Texture skyBoxtexture = new Texture(textureFile); skyBoxMesh.setMaterial(new Material(skyBoxtexture, 0.0f)); setMesh(skyBoxMesh); setPosition(0, 0, 0); }
private void setupTestShader() throws Exception { testShaderProgram = new ShaderProgram(); testShaderProgram.createVertexShader(Utils.loadResource("/shaders/test_vertex.vs")); testShaderProgram.createFragmentShader(Utils.loadResource("/shaders/test_fragment.fs")); testShaderProgram.link(); for (int i = 0; i < ShadowRenderer.NUM_CASCADES; i++) { testShaderProgram.createUniform("texture_sampler[" + i + "]"); } quadMesh = StaticMeshesLoader.load("/models/quad.obj", "")[0]; }
private void setupTestShader() throws Exception { testShaderProgram = new ShaderProgram(); testShaderProgram.createVertexShader(Utils.loadResource("/shaders/test_vertex.vs")); testShaderProgram.createFragmentShader(Utils.loadResource("/shaders/test_fragment.fs")); testShaderProgram.link(); for (int i = 0; i < ShadowRenderer.NUM_CASCADES; i++) { testShaderProgram.createUniform("texture_sampler[" + i + "]"); } quadMesh = StaticMeshesLoader.load("/models/quad.obj", "")[0]; }
private void setupTestShader() throws Exception { testShaderProgram = new ShaderProgram(); testShaderProgram.createVertexShader(Utils.loadResource("/shaders/test_vertex.vs")); testShaderProgram.createFragmentShader(Utils.loadResource("/shaders/test_fragment.fs")); testShaderProgram.link(); for (int i = 0; i < ShadowRenderer.NUM_CASCADES; i++) { testShaderProgram.createUniform("texture_sampler[" + i + "]"); } quadMesh = StaticMeshesLoader.load("/models/quad.obj", "")[0]; }
public void init(Window window) throws Exception { shadowRenderer.init(window); gBuffer = new GBuffer(window); sceneBuffer = new SceneBuffer(window); setupSkyBoxShader(); setupParticlesShader(); setupGeometryShader(); setupDirLightShader(); setupPointLightShader(); setupFogShader(); bufferPassModelMatrix = new Matrix4f(); bufferPassMesh = StaticMeshesLoader.load("src/main/resources/models/buffer_pass_mess.obj", "src/main/resources/models")[0]; }
@Override public void init(Window window) throws Exception { renderer.init(window); scene = new Scene(); Mesh[] houseMesh = StaticMeshesLoader.load("src/main/resources/models/house/house.obj", "src/main/resources/models/house"); GameItem house = new GameItem(houseMesh); Mesh[] terrainMesh = StaticMeshesLoader.load("src/main/resources/models/terrain/terrain.obj", "src/main/resources/models/terrain"); GameItem terrain = new GameItem(terrainMesh); terrain.setScale(100.0f); scene.setGameItems(new GameItem[]{house, terrain}); // Shadows scene.setRenderShadows(true); // Fog Vector3f fogColour = new Vector3f(0.5f, 0.5f, 0.5f); scene.setFog(new Fog(true, fogColour, 0.02f)); // Setup SkyBox float skyBoxScale = 100.0f; SkyBox skyBox = new SkyBox("src/main/resources/models/skybox.obj", new Vector4f(0.65f, 0.65f, 0.65f, 1.0f)); skyBox.setScale(skyBoxScale); scene.setSkyBox(skyBox); // Setup Lights setupLights(); camera.getPosition().x = -17.0f; camera.getPosition().y = 17.0f; camera.getPosition().z = -30.0f; camera.getRotation().x = 20.0f; camera.getRotation().y = 140.f; }