meshshapes.h

来自「file code.zip are used to implement ray 」· C头文件 代码 · 共 122 行

H
122
字号
#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 + =
减小字号Ctrl + -
显示快捷键?