1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
#include "graphics.h"
#include <iostream>
#include <cmath>
void CPrimitive::LoadObject(char *file, CPrimitive *obj = new CPrimitive)
{
FILE*fp = fopen(file,"r");
fscanf(fp,"%d",&TempNum);
obj->NumTri = TempNum;
for(i=0;i<obj->NumTri;i++)
{
fscanf(fp,"%f %f %f", &A[i].x,&A[i].y,&A[i].z);
fscanf(fp,"%f %f %f", &B[i].x,&B[i].y,&B[i].z);
fscanf(fp,"%f %f %f", &C[i].x,&C[i].y,&C[i].z);
}
fclose(fp);
}
void CPrimitive::Draw(CPrimitive *obj=new CPrimitive)
{
int j=0;
glPushMatrix();
glBegin(GL_POINTS);
for(int j=0;j<obj->NumTri;j++)
{
glVertex3fv(&A[j].x);
glVertex3fv(&B[j].x);
glVertex3fv(&C[j].x);
}
glEnd();
glPopMatrix();
}
|