OpenGL 3D Game Tutorial 10: Loading 3D Models
Why Stack Overflow recommends it
Stack Overflow users link it when someone needs to write an OBJ/Wavefront model loader, in Java or ported to C++ or Android.
Recommended by 4 people across 4 different months, 2015 to 2020.
What it is
Episode 10 of ThinMatrix's LWJGL OpenGL 3D Java game series. It walks through writing an OBJ file parser that loads Blender-made models (a stall) into the game, with notes on common pitfalls like normals array size, texture dimensions and flipped V coordinates.
What people said
Recommends Joehot200 · 2015-03 · Stack Overflow · on “Loading Wavefront Object with Lwjgl”
You know what - Just watch this tutorial: [this video] - It should contain everything you need. Feel free to ask about anything that confuses you. Though I am fine with just giving you the code if you want.
Recommends Zoltán · 2016-03 · Stack Overflow · on “Creating a simple obj reader in c++ that reads vertices, vertice normals, and faces for both”
I suggest this tutorial: [this video] This is java, but with a minimal extra effort you'll be able to write it in c++
Recommends Григорий Дикий · 2016-11 · Stack Overflow · on “Issue with texture mapping UV in blender”
I have problem with texture mapping. I have created OBJ loader using this tutorial: [this video] And when i loading the model provided in this tutorial all works great, but when i create my simple cub model, I have problems with mapping. In blender this model looks like this: normal mapping in blender [LINK] model in my program [LINK] When i Export the model I am using options: Write normals Trangulate Faces Include UVs Can anyone explain what is wrong with my model? Model that looks normal in my program: dropbox.com/sh/7l598pr7b4zx63j/AAB_PzQl3zU2WS5hhlKgMb1Wa?dl=0 OBJ loader Code: RawModel * OBJLoader::LoadObjModel(const std::string & fileName, Loader * loader) { std::ifstream file("./resources
Recommends alexrnov · 2020-07 · Stack Overflow · on “i want to make obj parsing in android”
The obj-parser on Java described here (ThinMatrix) [this video] works well for me. Source codes are here [LINK] and here [LINK] . When you apply this parser, you can get the data of object like: InputStream input = context.getAssets().open("objects/suzanne.obj"); OBJFileLoader loader = new OBJFileLoader(); ModelData model = loader.loadOBJ(input); float[] vertices = model.getVertices(); int[] indices = model.getIndices(); float[] normals = model.getNormals(); float[] textureCoordinates = model.getTextureCoordinates(); And get buffer objects of data, like: FloatBuffer bufferVertices = ByteBuffer.allocateDirect(vertices.length * 4) .order(ByteOrder.nativeOrder()).asFloatBuffer(); bufferVertices.put(