wavefront

Why is my OBJ parser rendering meshes like this?

北战南征 提交于 2019-11-27 05:13:35
I've taken it upon myself to add OBJ parser/importer support to a 3D rendering engine I've been working on. I've followed the specification found HERE nearly 'to a tee', with the current exception of limiting all support to groups, faces, vertices, normals and texture coordinates (so no material library or free-form poly support, as of yet). My goal was to simply parse line by line -- generating an object-oriented, hierarchical tree-like scene graph as I went along -- and allow the developer to automatically bind the data to a shader program with very few manual calls in order to start

Converting quadriladerals in an OBJ file into triangles?

巧了我就是萌 提交于 2019-11-26 20:02:06
问题 At first, it seemed obvious... Make 2 triangles per face wherever 4 indices were found, right? Meaning, the following: v 1.000000 1.000000 0.000000 v -1.000000 1.000000 -0.000000 v 1.000000 -1.000000 0.000000 v -1.000000 -1.000000 -0.000000 f -4 -3 -2 -1 ... would, in turn, need to be converted into something like: v 1.000000 1.000000 0.000000 v -1.000000 1.000000 -0.000000 v 1.000000 -1.000000 0.000000 v -1.000000 -1.000000 -0.000000 f -4 -3 -2 f -2 -3 -1 This particular example, of course,

object loader in opengl

假装没事ソ 提交于 2019-11-26 19:07:46
I have create a program in C++ that contains also opengl and I want to create also an obj loader in order to load an obj file I have ! I have already created two functions which are : void ReadFile(model *md) { // Open the file for reading OBJINFO.TXT ifstream obj_file("tree.obj"); if (obj_file.fail()) exit(1); // Get the number of vertices obj_file >> md->vertices; // Get the number of faces obj_file >> md->faces; // Get the vertex coordinates for (int i = 0; i < md->vertices; i++) { obj_file >> md->obj_points[i].x; obj_file >> md->obj_points[i].y; obj_file >> md->obj_points[i].z; } // Get

parsing into several vector members

那年仲夏 提交于 2019-11-26 18:24:52
问题 I want to recursively parse a string and store the results in one struct. I've written a parser that can handle one iteration. The input is formatted as follows: v 1.5 2.0 2.5 v 3.0 3.5 4.0 f 1 2 3 f 4 5 6 v 4.5 5.0 5.5 v 6.0 6.5 7.0 f 7 8 9 f 10 11 12 The problem is that it only parses the first 4 lines, it stops at the third encountered 'v'. The complete code is given below. How do I modify this code so it also parses the rest of the input into the same struct? I've tried modifying the

Why is my OBJ parser rendering meshes like this?

◇◆丶佛笑我妖孽 提交于 2019-11-26 17:33:40
问题 I've taken it upon myself to add OBJ parser/importer support to a 3D rendering engine I've been working on. I've followed the specification found HERE nearly 'to a tee', with the current exception of limiting all support to groups, faces, vertices, normals and texture coordinates (so no material library or free-form poly support, as of yet). My goal was to simply parse line by line -- generating an object-oriented, hierarchical tree-like scene graph as I went along -- and allow the developer

object loader in opengl

感情迁移 提交于 2019-11-26 06:48:09
问题 I have create a program in C++ that contains also opengl and I want to create also an obj loader in order to load an obj file I have ! I have already created two functions which are : void ReadFile(model *md) { // Open the file for reading OBJINFO.TXT ifstream obj_file(\"tree.obj\"); if (obj_file.fail()) exit(1); // Get the number of vertices obj_file >> md->vertices; // Get the number of faces obj_file >> md->faces; // Get the vertex coordinates for (int i = 0; i < md->vertices; i++) { obj

OpenGL - vertex normals in OBJ

五迷三道 提交于 2019-11-25 21:55:55
问题 I want to know how can I use the vertex normals for lightning effect? Currently what I have is I can send both vertex and texture coords to the shader and use them but with normals, I don\'t know how to use them in the shader program. Below is what I have so far. // vertex shader layout(location = 0) in vec4 vert; layout(location = 1) in vec4 color; layout(location = 2) in vec2 texcoord; uniform mat4 m_model; uniform mat4 m_view; uniform mat4 m_proj; void main() { gl_Position = m_proj * m