Hi all, I' quite new in C programming and so here is my problem. Though i've been searching a lot(...) through the posts here I haven't found answer to my question.
I am writing a graphics program (using OpenGL) that must read vertexes from a file and do some stuff like computing the normals for them and after that it should be able to demonstrate the result.
My basic problem is that the text files with the coordinates are written in a way I cannot manage to retrieve. e.g.
triangle { <32.3494, -53.9491, -15.0150>, <30.6827, -53.9491, -16.6817>, <30.6827, -53.9491, -15.0150> }
smooth_triangle { <32.3494, -47.0260, -18.3483>, <1.000, 0.000, 0.000>, <32.3494, -40.1029, -20.0150>, <1.000, 0.000, 0.000>, <32.3494, -47.0260, -20.0150>, <1.000, 0.000, 0.000> }
For the lines with "smooth_triangle" I have to retrieve only the coordinates, while for the ones with "triangle" I have to retrieve and compute the normals (witch I don't think would be a problem).
To become more specific (1)I don't know how to distinguish the charachters from the floating point numbers. Should I read the lines as strings and then convert part as floats, should I skip charachters and read only the numbers...
(2)How should I store the data in arrays so tha I could be able to use the with functions like glVertex3f that gl libraries use to create triangles? You can see I'm bit of confused. Is there something anyone knows that could help...a bit?
Thanks in advance, and I hope I was specific enough. My C compiler is Microsoft Visual C++ 6.0.
I am writing a graphics program (using OpenGL) that must read vertexes from a file and do some stuff like computing the normals for them and after that it should be able to demonstrate the result.
My basic problem is that the text files with the coordinates are written in a way I cannot manage to retrieve. e.g.
triangle { <32.3494, -53.9491, -15.0150>, <30.6827, -53.9491, -16.6817>, <30.6827, -53.9491, -15.0150> }
smooth_triangle { <32.3494, -47.0260, -18.3483>, <1.000, 0.000, 0.000>, <32.3494, -40.1029, -20.0150>, <1.000, 0.000, 0.000>, <32.3494, -47.0260, -20.0150>, <1.000, 0.000, 0.000> }
For the lines with "smooth_triangle" I have to retrieve only the coordinates, while for the ones with "triangle" I have to retrieve and compute the normals (witch I don't think would be a problem).
To become more specific (1)I don't know how to distinguish the charachters from the floating point numbers. Should I read the lines as strings and then convert part as floats, should I skip charachters and read only the numbers...
(2)How should I store the data in arrays so tha I could be able to use the with functions like glVertex3f that gl libraries use to create triangles? You can see I'm bit of confused. Is there something anyone knows that could help...a bit?
Thanks in advance, and I hope I was specific enough. My C compiler is Microsoft Visual C++ 6.0.