View Full Version : 3D models
07-14-2011, 11:30 PM
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.
07-15-2011, 01:54 AM
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.
07-15-2011, 02:04 AM
do you know how to render triangles with texture coordinates?
if you know its simple to load .OBJ file.
create 3 arrays of vec3.
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:
07-15-2011, 07:03 AM
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...
I hope some of that will help...
07-15-2011, 08:53 AM
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.
07-15-2011, 09:41 AM
Thanks I will be practicing this soon, first some C++ advance
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.