This repository has been archived by the owner on Apr 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCatModel.hpp
123 lines (105 loc) · 2.92 KB
/
CatModel.hpp
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
#pragma once
#include "BaseModel.hpp"
#include "debug_utils.h"
#include "modelerdraw.h"
#include "texturedraw.hpp"
class CatHead : public BaseModel {
public:
CatHead() {}
void draw() {
glTranslated(-1.3 / 2, -1.3 / 2, -0.8 / 2);
drawTextureQuad(1.3, 1.3, 0.8, 1);
float y = 1.3;
drawTriangle(0, y, 0, 0.5, y, 0, 0.25, 0.25 + y, 0);
drawTriangle(1.3, y, 0, 1.3 - 0.5, y, 0, 1.3 - 0.25, 0.25 + y, 0);
}
};
class CatLeg : public BaseModel {
public:
float radius = 0.25;
float rotate = 0;
CatLeg() {}
void draw() {
glRotated(rotate, 0.0, 0.0, 0);
glRotated(-90, 1.0, 0.0, 0.0);
drawTextureCylinder(1, radius, radius, VAL(INDIVIDUAL));
}
};
class TailPart : public BaseModel {
public:
float radius = 0.2;
float rotate = 0;
float length = 0.8;
TailPart(float r = 0, TailPart *another_tail = nullptr) {
rotate = r;
child = another_tail;
pre_draw_transformation = [&](BaseModel *self) {
glRotated(rotate, 1.0, 0.0, 0);
};
post_draw_transformation = [&](BaseModel *self) {
glTranslated(0, 0, length);
};
}
void draw() { drawTextureCylinder(length, radius, radius, VAL(INDIVIDUAL)); }
};
class CatTail : public BaseModel {
public:
CatTail(float r1, float r2, float r3) {
child = new TailPart(r1, new TailPart(r2, new TailPart(r3)));
}
};
class CatBody : public BaseModel {
public:
CatLeg *front_left;
CatLeg *front_right;
CatLeg *back_left;
CatLeg *back_right;
CatHead *h;
CatTail *t;
CatBody(float x, float y, float z) { // (x, y, z) position
pre_draw_transformation = [&](BaseModel *self) {
glTranslated(x, y, z);
glScaled(2, 1, 4);
};
post_draw_transformation = [&](BaseModel *self) {
glScaled(1 / 2.0, 1, 1 / 4.0);
};
front_left = new CatLeg;
front_right = new CatLeg;
back_left = new CatLeg;
back_right = new CatLeg;
front_left->pre_draw_transformation = [&](BaseModel *self) {
glTranslated(0.2, -1, 0.2);
};
front_right->pre_draw_transformation = [&](BaseModel *self) {
glTranslated(1.8, -1, 0.2);
};
back_left->pre_draw_transformation = [&](BaseModel *self) {
glTranslated(1.8, -1, 3.8);
};
back_right->pre_draw_transformation = [&](BaseModel *self) {
glTranslated(0.2, -1, 3.8);
};
h = new CatHead;
h->pre_draw_transformation = [&](BaseModel *self) {
// glTranslated(0.35, 1.2, -0.1);
};
t = new CatTail{10, 10, 10};
t->pre_draw_transformation = [&](BaseModel *self) {
glTranslated(1, 0.5, 4);
};
children.push_back(front_left);
children.push_back(front_right);
children.push_back(back_left);
children.push_back(back_right);
children.push_back(h);
children.push_back(t);
}
void draw() { drawTextureQuad(1, 1.3, 1, 1); }
void render() { BaseModel::render(); }
};
class Cat : public BaseModel {
public:
CatBody *b;
Cat(float x, float y, float z) { child = b = new CatBody(x, y, z); }
};