diff options
Diffstat (limited to 'src/Models.cpp')
-rw-r--r-- | src/Models.cpp | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/Models.cpp b/src/Models.cpp index b4fbb82..60330c2 100644 --- a/src/Models.cpp +++ b/src/Models.cpp @@ -15,7 +15,7 @@ void Model::UpdateVertexArray(){ vArray[i*27+6]=Triangles[i].r; vArray[i*27+7]=Triangles[i].g; vArray[i*27+8]=Triangles[i].b; - + vArray[i*27+9]=vertex[Triangles[i].vertex[1]].x; vArray[i*27+10]=vertex[Triangles[i].vertex[1]].y; vArray[i*27+11]=vertex[Triangles[i].vertex[1]].z; @@ -25,7 +25,7 @@ void Model::UpdateVertexArray(){ vArray[i*27+15]=Triangles[i].r; vArray[i*27+16]=Triangles[i].g; vArray[i*27+17]=Triangles[i].b; - + vArray[i*27+18]=vertex[Triangles[i].vertex[2]].x; vArray[i*27+19]=vertex[Triangles[i].vertex[2]].y; vArray[i*27+20]=vertex[Triangles[i].vertex[2]].z; @@ -36,7 +36,7 @@ void Model::UpdateVertexArray(){ vArray[i*27+25]=Triangles[i].g; vArray[i*27+26]=Triangles[i].b; } - + XYZ average; int howmany; average=0; @@ -67,24 +67,24 @@ bool Model::load(Str255 Name) short tfile; long err; Files file; - + tfile=file.OpenFile(Name); SetFPos(tfile,fsFromStart,0); // read model settings - + err=ReadShort(tfile,1,&vertexNum); err=ReadShort(tfile,1,&TriangleNum); - + // read the model data - + err=ReadXYZ(tfile,vertexNum,vertex); err=ReadTexturedTriangle(tfile,TriangleNum,Triangles); FSClose(tfile); - + UpdateVertexArray(); - + XYZ average; int howmany; average=0; @@ -100,7 +100,7 @@ bool Model::load(Str255 Name) if(findDistancefast(average,vertex[i])>boundingsphereradius)boundingsphereradius=findDistancefast(average,vertex[i]); } boundingsphereradius=sqrt(boundingsphereradius); - + return 1; } @@ -157,7 +157,6 @@ void Model::Rotate(float xang,float yang,float zang) UpdateVertexArray(); } - void Model::CalculateNormals() { int i; @@ -191,7 +190,6 @@ void Model::draw() } } - void Model::draw(float r, float g, float b) { if(!nocolors)glColor4f(r,g,b,1); @@ -234,7 +232,6 @@ void Model::draw(float r, float g, float b, float x, float y, float z) glDrawArrays(GL_TRIANGLES, 0, TriangleNum*3); } - int Model::LineCheck(XYZ p1,XYZ p2, XYZ *p) { int j; @@ -278,7 +275,7 @@ int Model::LineCheck2(XYZ p1,XYZ p2, XYZ *p, XYZ move, float rotate) distance=(point.x-p1.x)*(point.x-p1.x)+(point.y-p1.y)*(point.y-p1.y)+(point.z-p1.z)*(point.z-p1.z); if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;} } - + if(rotate)*p=DoRotation(*p,0,rotate,0); *p=*p+move; return firstintersecting; @@ -306,7 +303,7 @@ int Model::LineCheck2(XYZ *p1,XYZ *p2, XYZ *p, XYZ *move, float *rotate) distance=(point.x-p1->x)*(point.x-p1->x)+(point.y-p1->y)*(point.y-p1->y)+(point.z-p1->z)*(point.z-p1->z); if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;} } - + if(*rotate)*p=DoRotation(*p,0,*rotate,0); *p=*p+*move; return firstintersecting; |