i am trying to figure out how to read an xfile into vectors and structures. What i am trying to do is take an xfile, and extract the vertices of the polygons in the xfile. I am using this for bounding box purposes, but my character will actually be inside the xfile, which is why i need the vertices. Every xfile gives the number of vertices, number of polygons, number of normals, but when i try to read the file normally, i get errors. The project that this will be used by requires Direct X9, and i seem to lose functionality of the string class when direct x is implemented. I can find tutorials on how to read the xfile heirarchy for animation purposes and bounding boxes on the outside, but nothing for inside. I really need any help that can be offered. Xfile is attached below as a pdf
Code:
#include <d3d9.h>
#include <d3dx9.h>
#include <ifstream>
#include <string>
#include <vector>
using namespace std;
struct point()
{int x;//x coordinate of each vertice
int y;//y coordinate of each vertice
int z;//z coordinate of each vertice
};
stuct polygon()
{vector<point> vertices;//polygon can have 4 or 5 vertices, hence the vector
};
struct room()
{string name;//will be derived from the xfile
vector<polygons> sides;//most of the rooms have about 180 polygons to them
};
void main()
{ifstream xfile("Alpa aon 1.x")//i have tried both the .x file and .txt file with no success
string readline;
if(!xfile.isopen())
{cerr<<"File will not open";
}
else
{while(!xfile.eof()){
getline(xfile,readline);//i was using this for testing purposes, but for some reason, my executable get stuck in an endless loop or
cout<<readline<<endl;//this line outputs hexadecimal characters instead of the line it read
}
}
}
if anyone has any ideas about what i need to change or an easier way to do this please let me know. i appreciate all the help i can get