PDA

View Full Version : Scanf opengl



aje1234l
11-16-2015, 08:51 AM
Hello, I have this code which reads indices from txt .


fscanf(file, "%d", &(o->planes[i].p[0]));
fscanf(file, "%d", &(o->planes[i].textures[0]));
fscanf(file, "%d", &(o->planes[i].normals[0]));

It reads them like the example: 1 2 3
I want to modify the code to read them like 1/2/3.

Can anyone help me plz

GClements
11-16-2015, 09:07 AM
I want to modify the code to read them like 1/2/3.



fscanf(file, "%d/%d/%d", &(o->planes[i].p[0]), &(o->planes[i].textures[0]), &(o->planes[i].normals[0]));

But if you're reading OBJ format, you should ideally allow for the fact that the normal and/or texture indices can be omitted, i.e. each vertex can be any of "v", "v/t", "v//n" or "v/t/n". That's not something which can be done directly with fscanf().

aje1234l
11-16-2015, 09:14 AM
Thanks a lot man, u really saved me......