loading geometry from a text file
I want to load my geometry from a .rtg ascii file exported from MAYA.
Does anyone know of a reliable (ie flexible) method of doing this? I tried doing it with fgets and sscanf but the whitespaces in the exported file seem a bit random and sscanf throws a spac at this. The data''s basically in the form:
OBJECT_START objectname v8 t14 n4 p12 //number of verts, uvs etc...
VERTEX
0.0 1.0 0.0
...
...
TEXCOORD
0.0 1.0
...
...
NORMAL
0.0 1.0 0.0
...
...
POLYGON
v 0 1 2 t 0 1 2 n 0
...
...
I was probably gonna skip loading the normals and just calculate them on the fly (not that that matters)
Any ideas anyone?
OnDeZ
I wouldn''t have thought that the whitespace is random - there will be a method to the madness
Built-in functions like sscanf are general functions and not necessarily appropriate for every task. I would suggest writing your own function for importing data from .rtg files. It''ll involve some lovely pointer arithmetic but it''s all good practice.
Built-in functions like sscanf are general functions and not necessarily appropriate for every task. I would suggest writing your own function for importing data from .rtg files. It''ll involve some lovely pointer arithmetic but it''s all good practice.
Try ifstream. The >> operator ignores whitespace, and you can also ignore it with ifstream::ignore or stop reading at whitespace with ifstream::getline.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement