1

I have two .obj files (bunny_low.obj) , (bunny_high.obj), and I need help for loading these two obj files

Also where I have to keep it, I mean it should be on header files or source files?

This is the code

#include <iostream>
#ifdef WIN32
#include <windows.h>
#endif

#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <math.h>

#ifdef __APPLE__
#include <GLUT/glut.h>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#else
#include <GL/glut.h>
#include <GL/glu.h>
#include <GL/gl.h>
#endif

using namespace std;

#include "callbackFunctions.h"

int main(int argc,  char * argv[]) {

glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH|GLUT_RGB|GLUT_SINGLE);
glutInitWindowSize(640, 480);
glutInitWindowPosition(200, 100);
glutCreateWindow("Bunny");


glClearColor(0, 0, 0, 0);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-0.4, 0.4, -0.4 * .48 / .64, 0.4 * .48 / .64, 2, 10); 
gluLookAt( 0, 0, 5, 0, 0.2, 0, 0, 1, 0);


glutDisplayFunc(onDisplay);
glutMouseFunc(onMouse);
glutMotionFunc(onMouseMotion);
glutKeyboardFunc(onKeyboard);


glutMainLoop();


return 0;
}

Thanks

Spektre
  • 49,595
  • 11
  • 110
  • 380
  • you are missing important info like what file format the obj files are, from names I got the impression that they are meshes But what kind we can only guess (do they have just geometry, or skeleton structure, or animations). OpenGL does not have anything to store 3D Mesh files in general instead it is capable of storing geometry as **VBO/VAO**s or **Display lists**. In any case you need to load/save decode/encode 3D mesh files on your own or use some lib for it. Then create/use program that will render the mesh with OpenGL. Also OS and compiler is important as you need to acces OS file-system – Spektre Oct 26 '15 at 08:22
  • your current code is absolutely non-relevant to your question (at least from mine point of view). I retagged your question. See some related questions [info on some 3D mesh ASCII fileformats](http://stackoverflow.com/a/23951304/2521214) and most definetly look at [3DS parser](http://stackoverflow.com/a/31693895/2521214) – Spektre Oct 26 '15 at 08:28
  • And finally look at [complete simple GL+GLSL+VBO/VAO example](http://stackoverflow.com/a/31913542/2521214) how to use VBO to store 3D mesh – Spektre Oct 26 '15 at 08:39
  • @Spektre I said the format file which is .obj – faho0ody wbas Oct 26 '15 at 13:20
  • obj is just file extension and can stand for anything (from linker object file to 3D mesh) ... try to find signature in it or at least mention program that created/exported it .... Also link to an example would be a good idea to share. For example is this it? [Wavefront obj](https://en.wikipedia.org/wiki/Wavefront_.obj_file) – Spektre Oct 26 '15 at 14:51
  • It's just 3D object, how can I know the type of this file ? @Spektre – faho0ody wbas Oct 26 '15 at 15:58
  • Most fileformats have some kind of signature or magic number at the start of file (if you view the file as text or hex). Also most of them use structure called Header at the start so you took few entries from it and check if the content is consistent with fileformat description ... – Spektre Oct 26 '15 at 16:09
  • export ASCII files usually skip this ... if you open the file in text mode does it look like this: http://stackoverflow.com/a/193633/2521214 ? – Spektre Oct 26 '15 at 16:16
  • so did you determine if you got Wavefront or not? any chance you got these: http://graphics.im.ntu.edu.tw/~robin/courses/cg03/model/ download some and compare to your model in text editor/viewer if they are similar. You should post a link to sample of your object file or at least copy its content (some chunk from the start) as code to your Question so we can see what you have – Spektre Oct 28 '15 at 11:15

0 Answers0