c++ - openGL .obj not load properly -


i'm trying draw .obj file c++ , opengl aid of https://github.com/chrislundquist/opengl-model-loaders . can read .obj file missing

i didn't understand how affect normals drawing , lighting objects think problem normals

model(){         vertices = std::vector<vec3f>();         triangles = std::vector<unsigned>();         normals = std::vector<vec3f>();         uvs = std::vector<vec3f>();         vaoid[0] = 0;         vboid[0] = 0;     } 

example image

load(char* filename) {      // read      // .obj file     //  here...      objfile.close();     triangles.resize(triangles.size());     normals.resize(normals.size());     uvs.resize(uvs.size());       glgenvertexarrays(1, &vaoid[0]);      glbindvertexarray(vaoid[0]);      glgenbuffers(1, vboid);       glbindbuffer(gl_array_buffer, vboid[0]);     glbufferdata(gl_array_buffer, vertices.size() * sizeof(vertices[0]), &vertices[0], gl_static_draw);     glvertexattribpointer((gluint)0, 3, gl_float, gl_false, 0, 0); // set our vertex attributes pointer       glgenbuffers(1,&indexbufferid);     glbindbuffer(gl_element_array_buffer,indexbufferid);     glbufferdata(gl_element_array_buffer, triangles.size() * sizeof(triangles[0]), &triangles[0], gl_static_draw);     glenablevertexattribarray(0);      glbindvertexarray(0);      return true; }  draw(){     glbindvertexarray(vaoid[0]);      gldrawelements(gl_triangles,triangles.size(),gl_unsigned_int,0);     glbindvertexarray(0);  } 

thanks, yes problem lighting.after lighting configuration

glenable(gl_lighting); glenable(gl_light1); glfloat ambientcolor[] = {0.3, 0.3, 0.3, 0}; gllightmodelfv(gl_light_model_ambient, ambientcolor);  glfloat lightcolor0[] = {1, 1, 1, 1.0f}; glfloat lightpos0[] = {1,1,1,0}; gllightfv(gl_light1, gl_diffuse, lightcolor0); gllightfv(gl_light1, gl_position, lightpos0); 

now drawing looks this; example image

at time, colored .obj file in blender colors not seen here


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -