📄 meshshapes.h
字号:
#ifndef _MESH_SHAPE_
#define _MESH_SHAPE_
#include <string>
#include <iostream>
#include <fstream>
using namespace std;
#include "BaseShapes.h"
#include "affine.h"
//################## class VertexID ################
//used to define a Mesh
class VertexID { public: size_t vertIndex, normIndex; };
//################# class FACE ##############
//used to define a Mesh
class Face
{
public:
size_t nVerts;
VertexID * vert; // array of vertex IDs (index of point and normal)
Face() { nVerts = 0; vert = NULL;}
~Face() {delete[] vert; nVerts = 0;}
};
//@$@$@$@$@$@$@$@$@$@ Mesh class @$@$@$@$@$@$@$@$@$
class Mesh : public Shape
{
private:
size_t numVerts, numNorms, numFaces;
Point3 *pt; // array of points
Vector3 *norm; // array of normals
Face *face; // array of faces
int lastVertUsed, lastNormUsed, lastFaceUsed;
void outputOBJ(string filename);
public:
string meshFileName; // holds file name for this Mesh
Mesh();
Mesh(string fname);
~Mesh();
void freeMesh();
bool hit(Ray &r, Intersection &inter);
void makeExtentPoints(PointCluster& clust);
void readMesh(string fname);
void writeMesh(char* fname);
void drawOpenGL();
void print();
int isEmpty();
void makeEmpty();
void interpolate(VertexID* v, Point3 P, Vector3 &N);
GLvoid gluMakeIdentityf(GLfloat m[], int dimension);
int gluInvertMatrixf(GLfloat src[], GLfloat inverse[], int dimension);
};
//@$@$@$@$@$@$@$@$@$@ Tetrahedron class @$@$@$@$@$@$@$@$@$
class Tetrahedron : public Mesh
{
public:
Tetrahedron();
void print();
};
//@$@$@$@$@$@$@$@$@$@ Octahedron class @$@$@$@$@$@$@$@$@$
class Octahedron : public Mesh
{
public:
Octahedron();
void print();
};
//@$@$@$@$@$@$@$@$@$@ Dodecahedron class @$@$@$@$@$@$@$@$@$
class Dodecahedron : public Mesh
{
public:
Dodecahedron();
void print();
};
//@$@$@$@$@$@$@$@$@$@ Icosahedron class @$@$@$@$@$@$@$@$@$
class Icosahedron : public Mesh
{
public:
Icosahedron();
void print();
};
//@$@$@$@$@$@$@$@$@$@ BuckyBall class @$@$@$@$@$@$@$@$@$
class BuckyBall : public Mesh
{
public:
BuckyBall();
void print();
};
//@$@$@$@$@$@$@$@$@$@ Diamond class @$@$@$@$@$@$@$@$@$
class Diamond : public Mesh
{
public:
Diamond();
void print();
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -