#include "Models.h" #include "Serialize.h" //Functions void Model::UpdateVertexArray(){ int i; for(i=0;iboundingboxmax.x)boundingboxmax.x=vertex[i].x; if(vertex[i].y>boundingboxmax.y)boundingboxmax.y=vertex[i].y; if(vertex[i].z>boundingboxmax.z)boundingboxmax.z=vertex[i].z; } average=average/howmany; boundingspherecenter=average; boundingsphereradius=0; for(int i=0;iboundingsphereradius)boundingsphereradius=findDistancefast(average,vertex[i]); } boundingsphereradius=sqrt(boundingsphereradius); } bool Model::load(Str255 Name) { short tfile; Files file; tfile=file.OpenFile(Name); SetFPos(tfile,fsFromStart,0); // read model settings ReadShort(tfile,1,&vertexNum); ReadShort(tfile,1,&TriangleNum); // read the model data ReadXYZ(tfile,vertexNum,vertex); ReadTexturedTriangle(tfile,TriangleNum,Triangles); FSClose(tfile); UpdateVertexArray(); XYZ average; int howmany; average=0; howmany=0; for(int i=0;iboundingsphereradius)boundingsphereradius=findDistancefast(average,vertex[i]); } boundingsphereradius=sqrt(boundingsphereradius); return 1; } void Model::Scale(float xscale,float yscale,float zscale) { int i; for(i=0; ix,p1->y,p1->z, p2->x,p2->y,p2->z, boundingspherecenter.x,boundingspherecenter.y,boundingspherecenter.z, boundingsphereradius)) for (j=0;jx)*(point.x-p1->x)+(point.y-p1->y)*(point.y-p1->y)+(point.z-p1->z)*(point.z-p1->z); if((distance