How to convert .obj file to openGL? - opengl

I am finding difficulty in converting .obj file into openGL. I have found my model and here i have attach the main.cpp file for your reference. I am unsure of how to run the files.
Which file should I run when I called all these files in openGL.
Initially when I open OpenGL in Visual studio I called main.cpp file and run the file. But it shows many errors. The error says that cant find PDB file. What is that?

I'm just throwing in my answer to clear up the misconception leading to a question like that one:
How to convert .obj file (human head) to openGL?
The answer is: You don't.
OpenGL is a drawing API called from a program. It there for a program to make calls to draw points, lines and triangles. OpenGL is not a file format.
.OBJ is actually not very well defined name for a file format (there are literally hundreds of file formats that end .OBJ). But I take it you mean Wavefront OBJ. Anyway, files contain data. And while a program is data as well, a Wavefront OBJ file is not a program and can not be executed. Hence it makes no sense to even try to formulate a OBJ to OpenGL conversion.
What you need to do is writing a program, that reads the data from the Wavefront OBJ file, and uses that data to make the right calls to OpenGL. The other answers you already got link to such tutorials.

You will need to parse the .obj file then (depending on OpenGL version) load the parsed data into array/element_array buffers then use glDraw[Elements/Arrays] to work with in glsl or draw all the vertices using fixed functions.
But I think the real answer here lies in more study and not jumping in the deep water when you can hardly doggy paddle. You should do more basic exercises and get an understanding of the API.
Oh, and a .pdb file is for debugging in visual studio; I think it stands for program database.

Here is good tiny parser for obj
https://github.com/syoyo/tinyobjloader
You need:
1. parse data
2. create buffer object with data
3. draw buffer object

Yet another OBJ-loading tutorial http://www.opengl-tutorial.org/beginners-tutorials/tutorial-7-model-loading/

Related

libtdms: How to access the metadata of the .tdms file in order to process it?

For reading .tdms file with c++ I downloaded libtdms from sourceforge.net. I use Visual Studio 22 on Windows so I also installed MinGW for executing the Makefile.
The library does what it should, reading the .tdms file, but I dont know how to access the data in order to process and visualize it. Do I have to look inside the variables of libtdms?
Is there an easier way of outputting some kind of table with all the informations without getting deep into the code. (not that easy as mechanical engineer)
How do I include the full library dictionary with its makefiles into a possible programm?
So far i only included single .h files when programming
My goal is to get measurements from the .tdms file (values, coordinates,...) an then use them for plotting datapoints 2D and 3D.
this kind of output would be helpful for processing the data further

How to open an FBX file from my UE4 project's interface

I've created an interface for my UE4 project that has an import button. What I want it to do is to access FBX files in the user's desktop and opens the one the user selects.
I've written a c++ code that searches for FBX files in the desktop and returns their names, if found.
I'm kind of confused/stuck at this moment, and don't know exactly how to continue. My question is:
Shall I open the FBX file using c++ or blueprints?
It would be much appreciated if you could elaborate more on the approach you suggest.
Thank you
What I want it to do is to access FBX files in the user's desktop and opens the one the user selects.
"Opening something" does not actually tell us what you want to do.
Open the file with The default application for the file type?
Load the mesh somewhere into RAM?
Spawn objects in UE4 with the mesh?
Who knows what opening means. Opening the file in maya will be quite different from opening it with a hex editor.
Specify what your programm should do.
Shall I open the FBX file using c++ or blueprints?
Appart from what you can add to what I said above this questions answer will be purely subjective if BP is actually capable of doing what you want. IF you are doing good in c++ I suggest to stick with it for file operations.
Here Epics documentation on asset references, this should fit for people finding this thread and probably for you.
https://docs.unrealengine.com/latest/INT/Programming/Assets/ReferencingAssets/index.html
Just use UStaticMesh instead of the filetype used in the examples.
Here a UE4 wiki example implementation of what you could mean:
https://wiki.unrealengine.com/Dynamic_Load_Object
Shall I open the FBX file using c++ or blueprints? It would be much appreciated if you could elaborate more on the approach you suggest.
Yes, you can use the thirdparty libray to import the FBX, such as assimp
https://github.com/assimp/assimp
In the mean time, instead of use static mesh, you could use precedure mesh instead.

OBJ Loader for OpenGL + Glut

I'm working on a game for open GL, and I want to simply be able to load OBJ files, with their textures into my game. I want the loader to contain all the necessary code to map the textures to the object.
(Note I have scoured google, and not one example I've seen has been simple enough to bolt onto my currently existing code, I'm talking 2 headers, and 2 cpps maximum)
Could anybody provide me with one?
you could get started by this simple loader which loads objects in a wavefront .obj file into a OpenGL scene. This code restricts to just scanning the vertex information out of OBJ. You could enhance it further may be after getting the basic idea.
http://netization.blogspot.in/2014/10/loading-obj-files-in-opengl.html
https://github.com/nanosmooth/opengl_objloader
You can find mine at: https://github.com/NewbiZ/sandbox/tree/master/mar_tp1
It's a pretty simple one, but clean.
you will only need the Model class, which will load an OBJ file by filename: https://github.com/NewbiZ/sandbox/blob/master/mar_tp1/inc/mar_tp1/model.h
You may need to remove some things to make it fit on your project. Namely the dependency to ResourceManager which loads the textures and return their id, but that should not be much work.
Hope it helps.

Load obj mtl Direct3D 11

Quick question, how do i load a .obj modle into directx 11 (d3d11.h) and also the .mtl file for materials. Thanks in advance.
You can write your own parser, obj is a pretty simple text format (format description)
Otherwise some loaders already exists, like Assimp .It only deals with decoding, you will still need to create vertex/index buffers from decoded data.
DirectX no longer comes with any libraries to load object files, such as *.obj, *.x and so on after version 9. You need to either download a library to open these files, or do it yourself since OBJ files are reasonably simple to parse.
See here for an example of this using OpenGL: http://en.wikibooks.org/wiki/OpenGL_Programming/Modern_OpenGL_Tutorial_Load_OBJ - the concepts should be reasonably easy to transition across.

Getting basic 3D models into an OpenGL app

Ok... I'm doing simple OpenGL ES programming and when I say simple, the most complicated things I do aren't much more than glorified beveled cubes and L-shapes. (Think very Tetris but in 3D.) However, getting all that vertex data into an app is either a) hand-coded (UGH!) or b) 3rd-party game engine (double-UGH!!!) or you use some 3rd-party filetype importer. (Partial Ugh!)
With one exception.
I've been using a program on the Mac called Cheetah3D which is a pretty good modeler (not great, but solid... good) and the one thing it has that I haven't seen elsewhere is the ability to export your models directly to c-ready header files. It exports all the arrays for you and even gives you the code to render them (albeit in a commented out block as a reference.)
While this is great for 90% of what we do, there are some things the modeler can't, like allowing me to specify the same vertex for two different faces but using a different normal for each one... or even to mix flat and curved normals (or rather how they render) in the same model.
Note those features are easily described in an .obj file since your normals and vertices are in different arrays that you can easily specify together with faces but they don't come out in the header file that way.
SO... obj files (or any other file type that will work for that matter...) best way to get it into your code?
Thoughts?
OBJ file format.
Anyone doing 3D work, should at sometime write a obj model loader.
Its a very simple file format.
v
t
n
f
Where:
v is the vertices.
t is the texture coordinates.
n is the normal.
f is the face.
An example obj file segment:
v 1.0 0.1 0.1
t 1.0 0.0
n 1.0 1.0
f 1/1/1 1/1/1 1/1/1
All it takes is storing four collections of the above, and when it comes to rendering the face of a vertex, use the index and perform simple look ups. Simple file I/O is very easy to do in any language, so all in all, using an obj file is quite easy.
Naturally, the downside to obj files is they can get quite big. Personally, I've never found this an issue, and often take the obj file format as a starting point and remove some of the duplication to create a custom file format specially for my application.
OBJ files were used quite a bit historically and it isn't that difficult to roll your own importer or at least an importer that works for simple models you care about. Just handle verts, colors & normals to start and you'll be fine for the simple models you are describing. Sure it will barf if you try to read in arbitrary OBJ files--but just don't do that. ;^)
You certainly don't want to recompile each time you modify your model, if I'm reading your cheetah3d comment right. That will get tedious very fast.
For sure, you don't want to embed anything inti your code, loading OBJ is a good option but different modelers can have their own implementations of OBJ, as there is no official standard for the format. It's simple but I've seen many situations where application X can't load an OBJ from app Y. So if you ever plan on authoring assets from different packages take a peek at their outputted OBJ files to make sure they follow the same conventions.
The best OBJ file documentation I've found is here http://www.martinreddy.net/gfx/3d/OBJ.spec
I've found it's a good starting point but if your app becomes more complex and you start delving into more complex material definitions on your objects then you might want to look into something more standardized like Collada - an XML based format ( https://collada.org ) that covers a lot more but would also be more complex to load into your app.
Also, another good option for generating OBJ files is Blender, a freely available and pretty solid modelling tool ( http://www.blender.org ).
I have written a reader/renderer for AC3D files that works fine on the iPhone (OpenGL ES)
Feel free to have a look at it here.
There is also an obj loader by Jeff Lamarche at google code.