Original Post
I'm having a problem. When I try to load in a .raw file to use with my octree, it's only loading part of the stuff. Here is what I'm doing to read in the file.
My Octree stuff is working just fine, it subdivides right and all(at least the debug lines are working). It appears sometimes as if it is subdividing where the model is missing and sometimes it looks like it works right. I don't know what I'm doing wrong. Been messing with it since this morning. Edit: Just figured out that it starts messing up the lower I make the MaxTriCount. It still subdivides but doesn't draw the stuff. When I make the MaxTriCount sufficiently high, it does draw everything. When I set the MaxTriCount too high, it doesn't draw everything, whether or not I have the debug lines. Weird.
[edited by - xg0blin on January 26, 2003 11:09:02 PM]
[edited by - xg0blin on January 26, 2003 11:10:54 PM]
//here are some globals I need
int NumberOfVerts = 0;
Vector *Verts = NULL;
// here are the two functions I'm trying to use.
// one to get the number of vertices in the file, and
// the other to read them into the Verts array
void GetNumVertices(char *FileName)
{
ifstream fin;
fin.open(FileName);
Vector temp;
while(1)
{
fin >> temp.x >> temp.y >> temp.z;
if(fin.eof())
break;
NumberOfVerts++;
}
Verts = new Vector[NumberOfVerts];
fin.close();
}
void ReadData(char *FileName)
{
ifstream fin;
fin.open(FileName);
for(int i = 0; i < NumberOfVerts; i++)
fin >> Verts[i].x >> Verts[i].y >> Verts[i].z;
fin.close();
}
// and here is the function where I'm doing all of this
void LoadVertices(char *FileName)
{
GetNumVertices(FileName);
ReadData(FileName);
}
void Init(void)
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glColor3f(0.0f, 1.0f, 0.0f);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_COLOR_MATERIAL);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, 4/3, 1, 1024);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
Cam.SetCamera(0, 30, 120, 0, 0, 0, 0, 1, 0);
LoadVertices("stuff.raw");
Oct.GetSceneDimension(Verts, NumberOfVerts);
Oct.InitNode(Verts, Oct.GetCenter(), Oct.GetWidth(), NumberOfVerts);
}