-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFiber.h
More file actions
151 lines (118 loc) · 2.75 KB
/
Fiber.h
File metadata and controls
151 lines (118 loc) · 2.75 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#pragma once
#include <vector>
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include "Shader.h"
// TODO: separate rendering from this class
enum RENDER_TYPE {
CORE,
FIBER,
COMPLETE
};
enum FIBER_TYPE {
COTTON1,
COTTON2,
POLYESTER1,
RAYON1,
RAYON2,
RAYON3,
RAYON4,
SILK1,
SILK2
};
using Point3f = glm::vec3;
using Normal3f = glm::vec3;
struct ControlPoint
{
Point3f pos;
Normal3f norm;
int inx;
float distanceFromStart = -1;
};
struct Strand
{
std::vector<ControlPoint> points;
};
class Fiber {
public:
Fiber(FIBER_TYPE type, RENDER_TYPE rType);
~Fiber();
void initShaders();
void initFrameBuffer();
void initializeGL();
void setWindow(GLFWwindow* window);
void setFiberParameters(RENDER_TYPE);
void setRenderType(RENDER_TYPE);
void readFiberParameters(FIBER_TYPE);
void addPoint(ControlPoint, bool);
void loadPoints(bool);
void addStrands(const std::vector<Strand>& strands);
void render();
const Shader& getActiveShader() const;
const std::vector<Shader*> getActiveShaders();
RENDER_TYPE getRenderType() const;
FIBER_TYPE getFiberType() const;
float getFiberAlpha() const;
float getYarnRadius() const;
void createGUIWindow();
unsigned int SCR_WIDTH;
unsigned int SCR_HEIGHT;
unsigned int CORE_HEIGHT;
private:
GLFWwindow* window;
std::vector<float> corepoints_;
std::vector<float> fiberpoints_;
std::vector<GLuint> coreebo_;
std::vector<GLuint> fiberebo_;
GLuint corevao_id_;
GLuint fibervao_id_;
GLuint corevbo_id_;
GLuint fibervbo_id_;
GLuint coreebo_id_;
GLuint fiberebo_id_;
GLuint normalMap;
GLuint heightMap;
GLuint alphaChannel;
GLuint _frameBuffer;
GLuint frameBuffer;
GLuint depthrenderbuffer;
GLuint heightTexture;
GLuint normalTexture;
GLuint alphaTexture;
Shader coreShader_;
Shader fiberShader_;
Shader pointsShader_;
RENDER_TYPE renderType;
FIBER_TYPE fiberType;
bool renderCore = false;
// Fiber parameters
int ply_num;
int fiber_num;
glm::vec3 bounding_min;
glm::vec3 bounding_max;
float z_step_size;
int z_step_num;
int fly_step_size;
int yarn_clock_wise;
int fiber_clock_wise;
float yarn_alpha;
float alpha;
float yarn_radius;
float ellipse_long;
float ellipse_short;
int epsilon;
float beta;
float r_max;
int use_migration;
float s_i;
float rho_min;
float rho_max;
int use_flyaways;
float flyaway_hair_density;
glm::vec2 flyaway_hair_ze;
glm::vec2 flyaway_hair_r0;
glm::vec2 flyaway_hair_re;
glm::vec2 flyaway_hair_pe;
float flyaway_loop_density;
glm::vec2 flyaway_loop_r1;
};