diff --git a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj
index db4a2a9..334afac 100644
--- a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj
+++ b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj
@@ -58,6 +58,16 @@
+
+
+ stdcpp17
+
+
+
+
+ stdcpp17
+
+
true
@@ -97,6 +107,7 @@
+
@@ -137,6 +148,7 @@
+
diff --git a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters
index 9cb0c67..5c42780 100644
--- a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters
+++ b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters
@@ -79,6 +79,9 @@
Source Files
+
+ Source Files
+
@@ -172,5 +175,8 @@
Header Files
+
+ Header Files
+
\ No newline at end of file
diff --git a/ArchitectureColoredPainting/BvhTree.h b/ArchitectureColoredPainting/BvhTree.h
index 0dad260..63a62c9 100644
--- a/ArchitectureColoredPainting/BvhTree.h
+++ b/ArchitectureColoredPainting/BvhTree.h
@@ -10,7 +10,7 @@
#include
#include
-using std::tr1::shared_ptr;
+using std::shared_ptr;
struct BvhTreeData {
QVector4D bound;
@@ -59,7 +59,7 @@ struct BvhNode {
~BvhNode() {}
};
-typedef std::tr1::shared_ptr BvhPtr;
+typedef std::shared_ptr BvhPtr;
class BvhTree
{
diff --git a/ArchitectureColoredPainting/CubicBezier.cpp b/ArchitectureColoredPainting/CubicBezier.cpp
index 83c41ab..515527c 100644
--- a/ArchitectureColoredPainting/CubicBezier.cpp
+++ b/ArchitectureColoredPainting/CubicBezier.cpp
@@ -8,11 +8,11 @@ float CubicBezier::getLineValueByT(float t, bool isY) {
return pt * pt * pt * p[0] + 3 * t * pt * pt * p[1] + 3 * t * t * pt * p[2] + t * t * t * p[3];
}
-point CubicBezier::getPointByT(point a, point b, float t) {
+Point CubicBezier::getPointByT(Point a, Point b, float t) {
return { a.x * (1 - t) + b.x * t, a.y * (1 - t) + b.y * t };
}
-point CubicBezier::calculateControlPoint(point a, point b) {
+Point CubicBezier::calculateControlPoint(Point a, Point b) {
return {
a.x + 2 * (b.x - a.x) / 3,
a.y + 2 * (b.y - a.y) / 3
@@ -47,7 +47,7 @@ void CubicBezier::findPointsOfDivison(vector &p, vector& res) {
void CubicBezier::transformToCubic() {
if (siz == 4) return;
- point p[3] = {
+ Point p[3] = {
getPointByIndex(0),
getPointByIndex(1),
getPointByIndex(2)
@@ -61,10 +61,10 @@ void CubicBezier::transformToCubic() {
void CubicBezier::splitBezierCubic(float t, vector& res) {
LinePtr Lf(new CubicBezier());
float pt = 1 - t;
- point pointE = { getLineValueByT(t, false), getLineValueByT(t, true) };
- point pointF = getPointByT(getPointByIndex(0), getPointByIndex(1), t);
- point pointG = getPointByT(getPointByIndex(1), getPointByIndex(2), t);
- point pointH = getPointByT(getPointByIndex(2), getPointByIndex(3), t);
+ Point pointE = { getLineValueByT(t, false), getLineValueByT(t, true) };
+ Point pointF = getPointByT(getPointByIndex(0), getPointByIndex(1), t);
+ Point pointG = getPointByT(getPointByIndex(1), getPointByIndex(2), t);
+ Point pointH = getPointByT(getPointByIndex(2), getPointByIndex(3), t);
Lf->push_back(getPointByIndex(0));
Lf->push_back(pointF);
Lf->push_back(getPointByT(pointF, pointG, t));
diff --git a/ArchitectureColoredPainting/CubicBezier.h b/ArchitectureColoredPainting/CubicBezier.h
index 835485f..4b6c02d 100644
--- a/ArchitectureColoredPainting/CubicBezier.h
+++ b/ArchitectureColoredPainting/CubicBezier.h
@@ -6,8 +6,8 @@ class CubicBezier : public Line
{
using Line::Line;
private:
- static point getPointByT(point a, point b, float t);
- static point calculateControlPoint(point a, point b);
+ static Point getPointByT(Point a, Point b, float t);
+ static Point calculateControlPoint(Point a, Point b);
static void findPointsOfDivison(vector &p, vector& res);
void splitBezierCubic(float t, vector& res);
public:
diff --git a/ArchitectureColoredPainting/Line.cpp b/ArchitectureColoredPainting/Line.cpp
index 427b158..473becb 100644
--- a/ArchitectureColoredPainting/Line.cpp
+++ b/ArchitectureColoredPainting/Line.cpp
@@ -1,8 +1,8 @@
#include "Line.h"
-Line::Line(vector Vp) {
+Line::Line(vector Vp) {
siz = Vp.size();
- for (point now : Vp) {
+ for (Point now : Vp) {
vX.push_back(now.x);
vY.push_back(now.y);
}
@@ -12,23 +12,23 @@ int Line::size() {
return siz;
}
-vector Line::toPointVector() const {
- vector vL;
+vector Line::toPointVector() const {
+ vector vL;
for (int i = 0; i < siz; i++) {
vL.push_back({vX[i], vY[i]});
}
return vL;
}
-point Line::operator[](int index) const {
+Point Line::operator[](int index) const {
return { vX[index], vY[index] };
}
-point Line::getPointByIndex(int index) const {
+Point Line::getPointByIndex(int index) const {
return operator[](index);
}
-void Line::setPointByIndex(int index, point now) {
+void Line::setPointByIndex(int index, Point now) {
vX[index] = now.x;
vY[index] = now.y;
}
@@ -38,7 +38,7 @@ void Line::clear() {
vY.clear();
}
-void Line::push_back(point now) {
+void Line::push_back(Point now) {
siz++;
vX.push_back(now.x);
vY.push_back(now.y);
@@ -52,11 +52,11 @@ bool Line::isLineContained(QVector4D bound) {
else return false;
}
-point Line::getBegin() {
+Point Line::getBegin() {
return { *vX.begin(), *vY.begin() };
}
-point Line::getEnd() {
+Point Line::getEnd() {
return { *vX.rbegin(), *vY.rbegin() };
}
diff --git a/ArchitectureColoredPainting/Line.h b/ArchitectureColoredPainting/Line.h
index 61e20e3..d20e66c 100644
--- a/ArchitectureColoredPainting/Line.h
+++ b/ArchitectureColoredPainting/Line.h
@@ -12,20 +12,20 @@ using std::pair;
using std::min;
using std::max;
using std::sort;
-using std::tr1::shared_ptr;
-using std::tr1::make_shared;
+using std::shared_ptr;
+using std::make_shared;
using std::swap;
const float eps = 1e-6;
-struct point {
+struct Point {
float x, y;
- point operator - (const point a) { return { x - a.x, y - a.y }; }
- float operator * (const point a) { return x * a.y - y * a.x; }
- bool operator== (const point& a) const {
+ Point operator - (const Point a) { return { x - a.x, y - a.y }; }
+ float operator * (const Point a) { return x * a.y - y * a.x; }
+ bool operator== (const Point& a) const {
return fabs(x - a.x) <= eps && fabs(y - a.y) <= eps;
}
- bool operator< (const point& a) const {
+ bool operator< (const Point& a) const {
return fabs(x - a.x) <= eps ? y < a.y : x < a.x;
}
void show() {
@@ -41,22 +41,22 @@ protected:
public:
typedef shared_ptr LinePtr;
Line() :siz(0) {}
- Line(vector Vp);
+ Line(vector Vp);
int size();
void clear();
- point getBegin();
- point getEnd();
+ Point getBegin();
+ Point getEnd();
int direction(bool isY);
virtual float getLineValueByT(float t, bool isY) = 0;
virtual void monotonization(vector & res) = 0;
virtual int judgeBoundIntersection(float xy, float l, float r, bool isY) = 0;
virtual bool judgeIntersection(QVector4D bound);
bool isLineContained(QVector4D bound);
- point operator[](int index) const;
- point getPointByIndex(int index) const;
- vector toPointVector() const;
- void setPointByIndex(int index, point now);
- void push_back(point now);
+ Point operator[](int index) const;
+ Point getPointByIndex(int index) const;
+ vector toPointVector() const;
+ void setPointByIndex(int index, Point now);
+ void push_back(Point now);
virtual ~Line() {}
};
diff --git a/ArchitectureColoredPainting/Model.cpp b/ArchitectureColoredPainting/Model.cpp
index 7cea585..a037bbc 100644
--- a/ArchitectureColoredPainting/Model.cpp
+++ b/ArchitectureColoredPainting/Model.cpp
@@ -8,6 +8,7 @@
#include
#include "BvhTree.h"
#include "ShortCutTree.h"
+#include "SvgParser.h"
Model::Model(QString path, QOpenGLContext* context, QOpenGLShaderProgram* shaderProgram)
: context(context)
@@ -186,11 +187,20 @@ Drawable* Model::processMesh(aiMesh* mesh, const aiScene* scene, aiMatrix4x4 mod
initBound.push_back(QVector4D(-0.8, 0.7, -0.7, 0.8));
initBound.push_back(QVector4D(0.7, -0.8, 0.8, -0.7));
initBound.push_back(QVector4D(0.7, 0.7, 0.8, 0.8));*/
- //bvhTree.buildBvhTree(initBound.data(), initBound.size());
-
- //vector> lineSet = { {point{-1,-1}, point{1,-1}},{point{1,-1}, point{1,1}}, {point{1,1}, point{-1,1}},{point{-1,1}, point{-1,-1}} };
- vector> lineSet = { {point{-1,-1}, point{1,-1}},{point{1,-1}, point{1,1}}, {point{1,1}, point{-1,1}},{point{-1,1}, point{-1,-1}} };
- ShortCutTree shortCutTree;
+ //bvhTree.buildBvhTree(initBound.data(), initBound.size());
+
+
+ vector> lineSet = SvgParser::parse("M100,100C-.5,100,0,100.5,0,0L40,.07C40,59.5,39.5,60,100,60Z", 100,100);
+ for (vector line : lineSet)
+ {
+ for (Point p : line)
+ p.show();
+ std::cout << std::endl;
+ }
+
+ //vector> lineSet = { {Point{-1,-1}, Point{1,-1}},{Point{1,-1}, Point{1,1}}, {Point{1,1}, Point{-1,1}},{Point{-1,1}, Point{-1,-1}} };
+ //vector> lineSet = { {Point{-1,-1}, Point{1,-1}},{Point{1,-1}, Point{1,1}}, {Point{1,1}, Point{-1,1}},{Point{-1,1}, Point{-1,-1}} };
+ ShortCutTree shortCutTree(5);
shortCutTree.buildShortCutTree(lineSet);
vector pointVector;
vector lineVector;
@@ -296,7 +306,7 @@ Drawable* Model::processMesh(aiMesh* mesh, const aiScene* scene, aiMatrix4x4 mod
3, 0,2,3,
//element1
//lines
- 0,1,1,2
+ 0,1,1,2
};
std::vector elementData0 = {
diff --git a/ArchitectureColoredPainting/ShortCutTree.cpp b/ArchitectureColoredPainting/ShortCutTree.cpp
index 755d8ad..838c3f5 100644
--- a/ArchitectureColoredPainting/ShortCutTree.cpp
+++ b/ArchitectureColoredPainting/ShortCutTree.cpp
@@ -8,7 +8,7 @@ void ShortCutTree::init() {
numLine = numPoint = 0;
}
-int ShortCutTree::getPointIndex(point nowPoint) {
+int ShortCutTree::getPointIndex(Point nowPoint) {
auto iter = pointMap.find(nowPoint);
if (iter != pointMap.end()) {
return iter->second;
@@ -44,7 +44,7 @@ void ShortCutTree::monotonization(vector& inL, vector& out
}
void ShortCutTree::generateShortCutsegmentement(ShortCutNode& nowTreeNode) {
- point p = {0, 0};
+ Point p = {0, 0};
vector v;
for (int & lineIndex : nowTreeNode.lineSet) {
int type = allLine[lineIndex]->judgeBoundIntersection(nowTreeNode.bound.z(), nowTreeNode.bound.y(), nowTreeNode.bound.w(), false), be, en;
@@ -112,7 +112,7 @@ void ShortCutTree::simplifyLineVector() {
numLine = allLine.size();
for (auto& nowLine : allLine) {
PointVector pointVector = nowLine->toPointVector();
- for (point& p : pointVector) {
+ for (Point& p : pointVector) {
int pointIndex = getPointIndex(p);
lineIndexs.push_back(pointIndex);
if (pointVector.size() == 2)
@@ -216,7 +216,10 @@ void ShortCutTree::buildShortCutTree(vector& lineSet) {
}
vector ShortCutTree::getPointLineAndBvhTree(vector& resPoints, vector& resLines) {
- vector > tmpPoints; tmpPoints.clear();
+ vector > tmpPoints; tmpPoints.clear();
+ for (auto& now : restOfTreeNodes) {
+ std::cout << now.windingIncrement << ' ';
+ }
for (auto& mapIter : pointMap) {
tmpPoints.push_back({ mapIter.second , mapIter.first});
}
diff --git a/ArchitectureColoredPainting/ShortCutTree.h b/ArchitectureColoredPainting/ShortCutTree.h
index 6ee81c9..87129e2 100644
--- a/ArchitectureColoredPainting/ShortCutTree.h
+++ b/ArchitectureColoredPainting/ShortCutTree.h
@@ -9,7 +9,7 @@ using std::map;
using std::for_each;
struct ShortCutNode {
- typedef vector vectorPoint;
+ typedef vector vectorPoint;
int windingIncrement;
bool divided;
/* type 代表进入广度优先搜索队列的节点种类:
@@ -27,16 +27,16 @@ struct ShortCutNode {
};
class ShortCutTree
{
- typedef vector PointVector;
+ typedef vector PointVector;
typedef vector PointIndexVector;
private:
vector restOfTreeNodes;
vector allLine;
int RequiredLineMin, numPoint, numLine;
- map pointMap;
+ map pointMap;
vector lineIndexs;
- int getPointIndex(point nowPoint);
+ int getPointIndex(Point nowPoint);
void generateShortCutsegmentement(ShortCutNode& nowTreeNode);
bool handleShortCutNode(ShortCutNode& fa, ShortCutNode& nowTreeNode, float yValue, vector& v, int& sumIncrement);
void spliteToShortCutTree();
@@ -48,7 +48,7 @@ public:
//lineMin最小线数目,即划分终止条件
ShortCutTree(int lineMin = 3)
:RequiredLineMin(lineMin), numPoint(0), numLine(0) {}
- // 传入一个vector > 作为所有输入的线
+ // 传入一个vector > 作为所有输入的线
void buildShortCutTree(vector& lineSet);
// 获得点集合和线集合 返回输入BvhTree的数据集合
vector getPointLineAndBvhTree(vector &pointSet, vector &lineSet);
diff --git a/ArchitectureColoredPainting/StraightLine.cpp b/ArchitectureColoredPainting/StraightLine.cpp
index 7de7438..ec35127 100644
--- a/ArchitectureColoredPainting/StraightLine.cpp
+++ b/ArchitectureColoredPainting/StraightLine.cpp
@@ -14,7 +14,7 @@ float StraightLine::getLineValueByT(float t, bool isY) {
}
float StraightLine::findTByValue(float value, bool isY) {
- point be = getPointByIndex(0), en = getPointByIndex(1);
+ Point be = getPointByIndex(0), en = getPointByIndex(1);
if (!isY) {
if(fabs(be.x - en.x) <= eps) return 0;
return (value - be.x) / (en.x - be.x);
@@ -26,7 +26,7 @@ float StraightLine::findTByValue(float value, bool isY) {
}
int StraightLine::judgeBoundIntersection(float xy, float l, float r, bool isY) {
- point be = getBegin(), en = getEnd();
+ Point be = getBegin(), en = getEnd();
if (isY) {
swap(be.x, be.y);
swap(en.x, en.y);
diff --git a/ArchitectureColoredPainting/SvgParser.cpp b/ArchitectureColoredPainting/SvgParser.cpp
new file mode 100644
index 0000000..399eb97
--- /dev/null
+++ b/ArchitectureColoredPainting/SvgParser.cpp
@@ -0,0 +1,44 @@
+#include "SvgParser.h"
+#include
+
+vector> SvgParser::parse(const std::string path, float width, float height)
+{
+ std::string tmp;
+ vector point;
+ vector line;
+ vector> lines;
+ for (char c : path.substr(1))
+ {
+ if ((c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+')
+ {
+ tmp += c;
+ }
+
+ else
+ {
+ if (tmp != "")
+ {
+ point.push_back(std::stof(tmp));
+ tmp = "";
+ if (point.size() == 2)
+ {
+ line.push_back(Point{ std::clamp(point[0] / width * 2 - 1, -1.f, 1.f) , std::clamp(1 - point[1] / height * 2 , -1.f, 1.f)});
+ point.clear();
+ }
+ }
+ if (c != ',' && c != ' ')
+ {
+ lines.push_back(line);
+ line.erase(line.begin(), line.end() - 1);
+ if (c == 'Z')
+ {
+ line.push_back(lines[0][0]);
+ lines.push_back(line);
+ break;
+ }
+ }
+ }
+ }
+ lines.erase(lines.begin());
+ return lines;
+}
diff --git a/ArchitectureColoredPainting/SvgParser.h b/ArchitectureColoredPainting/SvgParser.h
new file mode 100644
index 0000000..f507be7
--- /dev/null
+++ b/ArchitectureColoredPainting/SvgParser.h
@@ -0,0 +1,10 @@
+#pragma once
+
+#include
+#include "Line.h"
+class SvgParser
+{
+public:
+ static vector> parse(const std::string path, float width, float height);
+};
+
diff --git a/README.md b/README.md
index a92cd3f..7080096 100644
--- a/README.md
+++ b/README.md
@@ -1,17 +1,20 @@
# ArchitectureColoredPainting
-vs2022椤圭洰 qt5.15.2 msvc 2019 64-bit
+鍙ゅ缓绛戝僵缁樿绠楁満杈呭姪璁捐绯荤粺
-閲囩敤pbr鏉愯川锛岀幇鍦ㄦ湁涓涓殢鏃堕棿鍙樺寲鐨勬柟鍚戝厜骞舵坊鍔犱簡闃村奖
+## 渚濊禆
-鎶婁竴鍧楀竷鏇挎崲鎴愪簡锛堝緟瀹屾垚鐨勶級褰╃粯绠$嚎锛岃PaintingMesh绫讳互鍙妏ainting鐫鑹插櫒
+- Qt 5.15.2 (MSVC 2019 64-bit)
+- Assimp (x64-windows)
-TODO锛
+## 鏋勫缓
-- [x] 鏀圭敤寤惰繜娓叉煋
+浣跨敤 Visual Studio 2022 鎵撳紑椤圭洰缂栬瘧杩愯銆
-- [x] 鎸囧畾涓鍧楁潗璐ㄤ娇鐢ㄧ嫭绔嬬绾胯繘琛岀汗鐞嗛噰鏍
+## 杩涘害
-- [ ] 褰╃粯鐨勮〃绀恒佽鍙栥侀噰鏍...
+閲囩敤 PBR (閲戝睘搴-绮楃硻搴) 鏉愯川妯″瀷锛屽満鏅腑瀛樺湪涓涓柟鍚戝厜锛屽彲鎷栧姩婊戝姩鏉¤皟鏁村厜婧愭柟鍚戣瀵熸潗璐ㄦ晥鏋溿
-- [x] PCF Shadow Map
\ No newline at end of file
+宸插疄鐜癇VH鍔犻熺粨鏋勭殑寤虹珛
+
+鍩烘湰瀹炵幇鍗曞浘鍏冪殑鎷嗗垎锛屽嵆鍒掑垎缃戞牸骞剁敓鎴愬揩鎹锋鍜岀紶缁曞閲忥紝灏氭湭楠岃瘉姝g‘鎬
\ No newline at end of file