#include #include #include #include #include using namespace std; struct Triangle{ int data[3]; }; struct Vertex{ float x, y, z; }; //strips the prefix from the faces and UV coords //and returns the index int strip(string b){ int num=0; int x; int colon; int size=b.size(); colon=b.find(":"); //find the : colon++; for(int i=colon;i vertices; vector tris; // vector public: void Load(char* filename); void Draw(); void setPos(float x, float y, float z){}; void setRot(float x, float y, float z){}; void setScale(float x, float y, float z){}; }; void ASC::Load(char* filename){ ifstream fin(filename); char b[256]; string buffer; Vertex t; Triangle tri; fin>>buffer>>buffer>>buffer; //pass the named object line fin>>buffer>>buffer; //reads past "tri-mesh" and "vertices" fin>>(int)numVerts; //number of vertices fin>>buffer; //reads past "buffer" fin>>(int)numFaces; //number of faces fin>>buffer>>buffer; //pass the vertex list line //reads in vertices for(int i=0;i>buffer>>buffer>>buffer; //pass "vertex", "0:" and "X:" fin>>(float)t.x; fin>>buffer; fin>>(float)t.y; fin>>buffer; fin>>(float)t.z; vertices.push_back(t); } fin>>buffer>>buffer; //passes "Face list:" //reads in the vertex indices for(int i=0;i>buffer>>buffer; fin>>buffer; //get A:- tri.data[0]=strip(buffer); fin>>buffer; //get B:- tri.data[1]=strip(buffer); fin>>buffer; //get C:- tri.data[2]=strip(buffer); tris.push_back(tri); fin>>buffer; //get AB:- //tri.data[0]=strip(buffer); fin>>buffer; //get BC:- //tri.data[1]=strip(buffer); fin>>buffer; //get CA:- //tri.data[2]=strip(buffer); //tris.push_back(tri); memset(b,256,' '); fin.getline(b,256); //reads material line } fin.close(); } void ASC::Draw(){ glPushMatrix(); glColor3f(1.0,0.0,0.0); glBegin(GL_TRIANGLES); for(int i=0; i