Original Post
Hi guys, I'm having some trouble creating a 3d file loader for symbian. Basically I want to be able to read in the text and float data from a .obj file into my symbian program as vertex, normal amd face arrays. I have done this in C++ before, but I am struggling with Symbian's ReadStreams and >> operator. This is the code I am trying to port to Symbian: EDIT: hmm it seems everytime a >> appears in my code it comes out as & g t; & g t; I hope it is still readable... Do you you think this is a good way to read in a 3d file? Will it be hard to get it into the required arrays for glDrawElements? Any help / advice would be greatly appreciated! Thanks, Miranda
bool geometry::buildFromFile(string filename) {
vertexN *vert;
face *fac;
vertex *normal;
string _type = "";
string tempStr = "";
int normalPtr=0;
bool endLine = false;
const int lineSize = 50;
ifstream meshFile(filename.c_str());
if (!meshFile) {
cout << "geometry file failed" << filename << endl;
return false;
} else {
//while still data in file
while(meshFile) {
meshFile >> _type;
//load verticies
if (_type == "v") {
vert = new vertexN;
meshFile >> vert->x >> vert->y >> vert->z;
this->vertList.push_back(vert);
this->numVertices++;
} else if (_type == "vn") {
normal = new vertex;
meshFile >> normal->x >> normal->y >> normal->z;
normalList.push_back(normal);
} else if (_type == "f") {
fac = new face;
for(int i=0;i<3;i++){
meshFile >> tempStr;
// read in vertex & normal
fac->verts=(int)atof(tempStr.substr(0,tempStr.find("/",0)).c_str())-1;
normalPtr = (int)atof(tempStr.substr(tempStr.rfind("/",tempStr.length()-1)+1).c_str())-1;
// assign face normal
fac->normal=normalPtr;
}
fac->numEdges = 3;
this->numFaces++;
this->faceList.push_back(fac);
}
}
addMaterials(filename);
}
return true;
}