src/linetypes/triangle.cpp

Sun, 24 Oct 2021 11:33:32 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Sun, 24 Oct 2021 11:33:32 +0300
changeset 147
37f936073cac
parent 141
185eb297dc1e
child 158
5bd755eaa5a8
permissions
-rw-r--r--

update

15
9e18ec63eec3 split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents: 14
diff changeset
1 #include "triangle.h"
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
2
35
98906a94732f renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents: 33
diff changeset
3 QString ldraw::Triangle::textRepresentation() const
6
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
4 {
8
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
5 return utility::format("%1 %2 %3",
33
4c41bfe2ec6e replaced matrix and vertex classes with glm
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
6 utility::vertexToStringParens(points[0]),
4c41bfe2ec6e replaced matrix and vertex classes with glm
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
7 utility::vertexToStringParens(points[1]),
4c41bfe2ec6e replaced matrix and vertex classes with glm
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
8 utility::vertexToStringParens(points[2]));
6
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
9 }
21
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
10
35
98906a94732f renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents: 33
diff changeset
11 void ldraw::Triangle::getPolygons(
21
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
12 std::vector<gl::Polygon>& polygons,
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
13 GetPolygonsContext* context) const
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
14 {
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
15 Q_UNUSED(context)
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
16 polygons.push_back(gl::triangle(
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
17 this->points[0],
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
18 this->points[1],
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
19 this->points[2],
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
20 this->colorIndex,
87
93ec4d630346 added PolygonObject and refactored away a lot of boilerplate
Teemu Piippo <teemu@hecknology.net>
parents: 86
diff changeset
21 this->id));
21
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
22 }
26
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
23
35
98906a94732f renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents: 33
diff changeset
24 void ldraw::Triangle::invert()
26
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
25 {
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
26 // 0 1 2
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
27 // -> 1 0 2
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
28 std::swap(this->points[0], this->points[1]);
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
29 }
132
488d0ba6070b Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents: 87
diff changeset
30
488d0ba6070b Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents: 87
diff changeset
31 ldraw::Object::Type ldraw::Triangle::typeIdentifier() const
488d0ba6070b Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents: 87
diff changeset
32 {
488d0ba6070b Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents: 87
diff changeset
33 return Type::Triangle;
488d0ba6070b Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents: 87
diff changeset
34 }
141
185eb297dc1e Saving works now
Teemu Piippo <teemu@hecknology.net>
parents: 132
diff changeset
35
185eb297dc1e Saving works now
Teemu Piippo <teemu@hecknology.net>
parents: 132
diff changeset
36 QString ldraw::Triangle::toLDrawCode() const
185eb297dc1e Saving works now
Teemu Piippo <teemu@hecknology.net>
parents: 132
diff changeset
37 {
185eb297dc1e Saving works now
Teemu Piippo <teemu@hecknology.net>
parents: 132
diff changeset
38 return utility::format(
185eb297dc1e Saving works now
Teemu Piippo <teemu@hecknology.net>
parents: 132
diff changeset
39 "3 %1 %2 %3 %4",
185eb297dc1e Saving works now
Teemu Piippo <teemu@hecknology.net>
parents: 132
diff changeset
40 this->colorIndex.index,
185eb297dc1e Saving works now
Teemu Piippo <teemu@hecknology.net>
parents: 132
diff changeset
41 utility::vertexToString(this->points[0]),
185eb297dc1e Saving works now
Teemu Piippo <teemu@hecknology.net>
parents: 132
diff changeset
42 utility::vertexToString(this->points[1]),
185eb297dc1e Saving works now
Teemu Piippo <teemu@hecknology.net>
parents: 132
diff changeset
43 utility::vertexToString(this->points[2]));
185eb297dc1e Saving works now
Teemu Piippo <teemu@hecknology.net>
parents: 132
diff changeset
44 }

mercurial