3D models

Hi everybody, Im new on this matter I have succesfully loaded 2D drawings and maked some logic Even though my experience on C++ is not so advanced but I have been trying.

The problem is that Im kind of working on a Game engine, It could load 2D textures and have a nice structure (though)

The only thing Im not able to achieve is to render a 3D model made on blender.

I have read tutroials but most of them are not very Newbie friendly or they explain how to load M2D wich I cant because blender couldnt import that format…

People have suggested to make my own Format, But how? I mean how do I export files to that format from blender.

I need some guidance on this.

You need to read up on .OBJ format for easy import/export from Blender.
There are tutorials and sample code to help loading models in this format. Beware that the format is quite extensive and not all features are required to get basic model rendering to work.

You need to first understand OpenGL concepts regarding vertex arrays. This is what you’ll need to use to convert the imported OBJ file into and get OpenGL to draw it.

do you know how to render triangles with texture coordinates?
if you know its simple to load .OBJ file.
create 3 arrays of vec3.
1)vertex position.
3)texture coords.
you need to open the file for read.
for every line you need to check the first letter and insert the information to the arrays.

read here for understand the OBJ file:


I’m trying to do roughly the same thing, except I am experimenting with a hand made cube instead of a full size model. You’ll need to parse the data out of the model file first, then temporarily store the data into vertex arrays, then bind the vertex data and send the vertex and index data to the GPU in the form of an interleaved VBO. You should be able to render the individual models with a call to glDrawElements. If you want to see my code I can send it to you.

Data structure I’m using…

struct vertexType
	GLfloat xPos,yPos,zPos;
	GLfloat xNormal,yNormal,zNormal;
	GLfloat uTCoord,vTCoord;
struct primitiveType
	GLuint vertexBufferID;
	GLuint vertexIndexID;
	GLuint textureID;
	std::string textureFileStr;
	GLFrame primitiveFrame;

std::vector<vertexType> vertexArray;
std::vector<GLushort> vertexIndex;
std::vector<GLfloat> fNormals;
primitiveType cube0;
primitiveType cube1;

I hope some of that will help…

You have to be a little careful when parsing the .OBJ file as I hinted at earlier. The problem is the OBJ is not just a format it’s a framework and there can be many variations of allowed formats.
You need to be able to support 3 or 4 verticies, with or without normals and with or without texture coordinates as a minimum.
Colour and material selections are extra fluff you can support according to your needs.

Thanks I will be practicing this soon, first some C++ advance