ok here are the changes that ive made
const int MAX_VERTEX = 100;struct float3{ float x, y, z; float d; void mag();};void float3::mag(){ d=sqrt((x*x)+(y*y)+(z*z));}struct _node{ float3 center; float width; //calculated by width/pow(2, <recursion level>) int numVertex; vector<float3> vertices; _node *node[8];};struct _cube{ float3 center; //center of root cube float width; //width of root cube int numVertex; vector<float3> vertices; _node *node[8]; _cube(); void Load(vector<float> array); void Draw();};_cube::_cube(){ numVertex = 0;}void Sort(_node temp){ int nodeLevel; if(temp.numVertex > MAX_VERTEX) { for(int x=0; x<temp.numVertex; x++) { nodeLevel = 8; if(temp.vertices[x].x < temp.center.x) if(temp.vertices[x].y < temp.center.y) if(temp.vertices[x].z < temp.center.z) { nodeLevel = 0; } else { nodeLevel = 1; } else if(temp.vertices[x].z < temp.center.z) { nodeLevel = 2; } else { nodeLevel = 3; } else if(temp.vertices[x].y < temp.center.y) if(temp.vertices[x].z < temp.center.z) { nodeLevel = 4; } else { nodeLevel = 5; } else if(temp.vertices[x].z < temp.center.z) { nodeLevel = 6; } else { nodeLevel = 7; } temp.node[nodeLevel]->numVertex++; temp.node[nodeLevel]->vertices.resize(temp.node[nodeLevel]->numVertex); temp.node[nodeLevel]->vertices[temp.node[nodeLevel]->numVertex-1].x = temp.vertices[x].x; temp.node[nodeLevel]->vertices[temp.node[nodeLevel]->numVertex-1].y = temp.vertices[x].y; temp.node[nodeLevel]->vertices[temp.node[nodeLevel]->numVertex-1].z = temp.vertices[x].z; } for(x=0; x<8; x++) { if(temp.node[x]->numVertex > MAX_VERTEX) { Sort(temp.node[x]); } } }}void _cube::Load(vector<float> array){ float3 upperlim; float3 lowerlim; float xlen, ylen, zlen; numVertex = array.size()/3; vertices.resize(numVertex); for(int x=0; x<numVertex; x++) { vertices[x].x = array[3*x]; vertices[x].y = array[3*x+1]; vertices[x].z = array[3*x+2]; } for(x=0; x<numVertex; x++) vertices[x].mag(); for(x=0; x<numVertex; x++) { if(lowerlim.x > vertices[x].x) lowerlim.x = vertices[x].x; if(lowerlim.y > vertices[x].y) lowerlim.y = vertices[x].y; if(lowerlim.z > vertices[x].z) lowerlim.z = vertices[x].z; if(upperlim.x < vertices[x].x) upperlim.x = vertices[x].x; if(upperlim.y < vertices[x].y) upperlim.y = vertices[x].y; if(upperlim.z < vertices[x].z) upperlim.z = vertices[x].z; } xlen = upperlim.x - lowerlim.x; ylen = upperlim.y - lowerlim.y; zlen = upperlim.z - lowerlim.z; if(xlen>ylen) if(xlen>zlen) width=xlen; else width=zlen; else if(ylen>zlen) width=ylen; else width=zlen; center.x = (upperlim.x + lowerlim.x) / 2; center.y = (upperlim.y + lowerlim.y) / 2; center.z = (upperlim.z + lowerlim.z) / 2;}void _cube::Draw(){ float w = width/2; glDisable(GL_LIGHTING); glDisable(GL_TEXTURE_2D); glPointSize(15); glColor3f(1, 0, 0); glBegin(GL_POINTS); glVertex3f(center.x, center.y, center.z); glEnd(); glColor4f(1, 1, 0, 1); glLineWidth(1); glBegin(GL_LINE_LOOP); glVertex3f(center.x-w, center.y-w, center.z-w); glVertex3f(center.x+w, center.y-w, center.z-w); glVertex3f(center.x+w, center.y+w, center.z-w); glVertex3f(center.x-w, center.y+w, center.z-w); glEnd(); glBegin(GL_LINE_LOOP); glVertex3f(center.x-w, center.y-w, center.z+w); glVertex3f(center.x+w, center.y-w, center.z+w); glVertex3f(center.x+w, center.y+w, center.z+w); glVertex3f(center.x-w, center.y+w, center.z+w); glEnd(); glBegin(GL_LINES); glVertex3f(center.x-w, center.y-w, center.z-w); glVertex3f(center.x-w, center.y-w, center.z+w); glVertex3f(center.x+w, center.y-w, center.z-w); glVertex3f(center.x+w, center.y-w, center.z+w); glVertex3f(center.x-w, center.y+w, center.z-w); glVertex3f(center.x-w, center.y+w, center.z+w); glVertex3f(center.x+w, center.y+w, center.z-w); glVertex3f(center.x+w, center.y+w, center.z+w); glEnd(); glEnable(GL_LIGHTING); glEnable(GL_TEXTURE_2D);}
i changed a few things in here like moving variables around and out of the structs.