-
Notifications
You must be signed in to change notification settings - Fork 0
/
mesh.h
63 lines (48 loc) · 1.39 KB
/
mesh.h
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef MESH_H
#define MESH_H
#include <vector>
#include <fstream>
#include <iostream>
#include "matrix.h"
#include "entity.h"
#include "util.h"
class Face {
public:
int v1, v2, v3; //Vertices
//char r, g, b;
Face();
Face(int a, int b, int c);
std::string to_string();
};
class Mesh: public Entity {
public:
std::vector<Vect4> verts;
std::vector<Face> faces;
//If true, the world this is part of will delete it when it garbage-collects
int markedForDeath = FALSE;
//If true, the world this is part of will delete it when it's marked for death
int deleteOnRemove = TRUE;
Mesh();
Mesh(const Mesh& other);
Mesh(int deleteonremove);
~Mesh();
void clear(); //makes it blank again (verts/faces)
//Returns the index of the new vertex
int addVert(Vect4 v);
void addFace(Face f);
void loadFromObjFile(std::string filename);
void applyTransform(Mat4 m); //Doesn't modify the verts, only transVerts
void genPrimEdge(Vect4 a, Vect4 b);
//Adds edges for a circle
//in xy plane
void genPrimCircle(Vect4 c, double r);
//Start, start control, end control, end
void genPrimBezier(Vect4 a, Vect4 b, Vect4 c, Vect4 d);
void genPrimHermite(Vect4 p0, Vect4 p1, Vect4 r0, Vect4 r1);
void genPrimBox(double lx, double ly, double lz);
void genPrimSphere(double r);
void genPrimTorus(double R, double r);
private:
char *myStrtok(char *s, char delim);
};
#endif