PDA

View Full Version : Please help ! read .ase file



McZ
02-28-2001, 01:32 AM
I need help to read .ase files!
this is the way I do to read a line and save it for later use:

void LoadAse(char *filename)
{
char buff[200];
ifstream fin:

fin.open(filename);

do {
fin.getline(buff, sizeof(buff));

if(strcmp("*MESH_VERTEX", buff) == 0)
sscanf(buff, "*MESH_VERTEX %f %f %f", &object.x, &object.y, &object.z);

}while(fin.eof() =! 1)

this line : sscanf(buff, "*MESH_VERTEX %f %f %f", &object.x, &object.y, &object.z); doesnīt work because the *MESH_VERTEX isnīt at the start of the line how to fix this ?

AndersO
02-28-2001, 03:01 AM
Hardly related to opengl..

Anyway, try put %s in the format string and a dummy variable to catch the MESH_VERTEX.

[This message has been edited by AndersO (edited 02-28-2001).]

McZ
03-01-2001, 01:31 AM
thanks for that http://www.opengl.org/discussion_boards/ubb/smile.gif I got a step on the way but I canīt read the Faces now http://www.opengl.org/discussion_boards/ubb/frown.gif I donīt know whats wrong. I have found a source for reading the ase files. they use fscanf instead of sscanf as I do I have tried to make it almost the same as they have except that I use sscanf and read from a buffer instead of fscanf.

[This message has been edited by McZ (edited 03-01-2001).]

s_fonden
03-02-2001, 09:03 AM
yes, use fscanf("%s", &data) where data is an array of 255 characters. then simply do a if(!strcmp(data, "data you are looking for")) to see if you're about to read vertices, normals or faces.

btw, it bothers me when someone feels high and mighty enough to complain about non-opengl subjects in this forum, there's nothing wrong with asking a question that we all know can be answered by the people who read these forums.

gl with the ASE loading! if you have any more questions, email me at s_fonden@mail.plymouth.edu.

Deiussum
03-02-2001, 12:29 PM
Originally posted by s_fonden:
yes, use fscanf("%s", &data) where data is an array of 255 characters. then simply do a if(!strcmp(data, "data you are looking for")) to see if you're about to read vertices, normals or faces.


Actually it should be fscanf("%s", data) if data is a char[255]. Passing it as &data would pass a pointer to the array pointer and the most likely result will be CRASH!! http://www.opengl.org/discussion_boards/ubb/smile.gif

McZ
03-02-2001, 01:13 PM
thanks for your help http://www.opengl.org/discussion_boards/ubb/smile.gif but I think I have to learn little more about file reading and stuff http://www.opengl.org/discussion_boards/ubb/smile.gif my C++ book has only a little chapter http://www.opengl.org/discussion_boards/ubb/frown.gif but I got my .ASE reader to work http://www.opengl.org/discussion_boards/ubb/smile.gif but now I canīt rotate the object http://www.opengl.org/discussion_boards/ubb/frown.gif and Iīm using the same rotating stuff as I did before and it worked OK then http://www.opengl.org/discussion_boards/ubb/frown.gif