5

I am trying to load 3D models. How do I to read the data in the model file?

For an example, this is the data:

VERTICES
80 21 32
32 34 17
14 93 56
33 54 87
MODEL_SCALE 5

I know the data in 3D models is not like this, but how will I read the 'vertex data' and the 'model scale amount'?

1
  • The best piece of advice is to get OpenCTM, that does mesh loading, etc. for you! Commented Aug 15, 2011 at 15:29

1 Answer 1

8

OpenGL doesn't do this for you. You should write your own parser, store the readed datas into your defined data structures and use OpenGL primitives to render them.

Here's a nice tutorial.

Sign up to request clarification or add additional context in comments.

10 Comments

Yes but how will I read the data? What I want to do is read the data of the file and draw vertices on them.
It looks like milkshape is a binary format, which I'm not sure is applicable for OP as it looks like he's showing an example of a text format.
Hmm... seems quite helpful. But there is a way reading words with string.h and other stuff like that, right? I'll try to use that too. Anyway, thanks!
@CppOgl: FILE *filp = fopen(filename, "r"); fread(...), etc. Or in C++ using ifstream. This not an OpenGL question then, but a generic "how do I read a file" question.
@user786653 : yes you are right. But like datenwolf pointed out, this is not an opengl question. The linked tutorial illustrate some basic operation and datastrutctures that one usually use while loading a model to be rendered with openGL primitives.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.