这里是 GAMES 102 的课程作业网站。
- 课程主页:GAMES 102
- 授课老师:刘利刚
- 助教
- 庄涛 ([email protected])
- 刘中远 ([email protected])
- 史雨宸 ([email protected])
1. 课程作业 ->
- 函数拟合
- 神经网络曲线拟合
- 参数曲线拟合
- 三次样条函数
- 曲线细分
- 极小曲面局部方法
- 极小曲面全局方法、曲面参数化
- 实现平面点集 CVT 的 Lloyd 算法
- 网格简化的 QEM 方法
- 曲面重建
GAMES 102
这里是 GAMES 102 的课程作业网站。
Hello 助教好,很抱歉在课程结束这么久之后的打扰。
我在使用无境引擎完成作业九时,需要支持三角面的局部删除和添加操作。
我出错的关键函数是 contract
,它需要支持删除顶点 pc.i, pc.j
,插入顶点 pc.k
并将 pc.i, pc.j
的所有相邻三角面移植到 pc.k
上。
我使用的是 heMesh
的 RemovePolygon, AddPolygon
来完成这一边收缩操作,其中插入三角面仿照的是 heMesh->Init
的写法。
在 release 模式下,执行不会报错,但是得到的结果不是三角形网络。可能是我 API 的使用错误?
在 debug 模式下,会提示调用 heMesh->AddPolygon
时会产生非流形网络。虽然在上述代码操作中有可能出现这种问题,但是插入三角面结束后却并不会。
下面是代码。希望助教可以帮忙解答一下,感激不尽!
void QuadricSimplification::contract(const PairContraction& pc) {
heMesh->AddVertex();
auto* v1 = heMesh->Vertices().at(pc.i);
auto* v2 = heMesh->Vertices().at(pc.j);
auto* v_bar = heMesh->Vertices().at(pc.k);
v_bar->position = positions[pc.k];
/*std::set<Vertex*> s;
for (auto* v : v1->AdjVertices()) s.insert(v);
for (auto* v : v2->AdjVertices()) s.insert(v);*/
auto V1s = v1->AdjVertices();
auto V2s = v2->AdjVertices();
for (size_t i = 0; i < V1s.size(); i++) {
spdlog::info("{}", heMesh->Index(V1s[i]));
}
spdlog::info("-------");
for (size_t i = 0; i < V2s.size(); i++) {
spdlog::info("{}", heMesh->Index(V2s[i]));
}
// merge neighbors, maybe repeat 2 times
std::vector<Vertex*> Vs;
for (auto* v : v1->AdjVertices()) {
if (v == v2) {
auto v2_vec = v2->AdjVertices();
for (size_t i = 0; i < v2_vec.size();i ++) {
if (v2_vec[i] == v1) {
for (size_t j = 1; j < v2_vec.size(); j++) {
int id = (i + j) % v2_vec.size();
Vs.push_back(v2_vec[id]);
}
break;
}
}
}
else {
Vs.push_back(v);
}
}
// record boundary info before removing
bool is_boundary = v1->IsOnBoundary() || v2->IsOnBoundary();
std::vector<bool> mark;
for (size_t i = 0; i < Vs.size(); i++) {
spdlog::info("after merge {}", heMesh->Index(Vs[i]));
mark.push_back(Vs[i]->IsOnBoundary());
}
for (auto* m : v1->AdjPolygons()) {
if (m == nullptr) continue;
auto* A = m->AdjVertices()[0];
auto* B = m->AdjVertices()[1];
auto* C = m->AdjVertices()[2];
spdlog::info("v1 adj {} {} {}", heMesh->Index(A), heMesh->Index(B), heMesh->Index(C));
heMesh->RemovePolygon(m);
}
for (auto* m : v2->AdjPolygons()) {
if (m == nullptr) continue;
auto* A = m->AdjVertices()[0];
auto* B = m->AdjVertices()[1];
auto* C = m->AdjVertices()[2];
spdlog::info("v2 adj {} {} {}", heMesh->Index(A), heMesh->Index(B), heMesh->Index(C));
heMesh->RemovePolygon(m);
}
// add triangle
for (size_t i = 0; i < Vs.size(); i++) {
int id = (0 + i) % Vs.size();
int nx = (0 + i + 1) % Vs.size();
Vertex* A = Vs[id];
Vertex* B = Vs[nx];
if (A == B) continue;
if (is_boundary && mark[id] && mark[nx]) continue;
spdlog::info("add triangle {} {} {}", heMesh->Index(B), heMesh->Index(A), heMesh->Index(v_bar));
std::vector<Vertex*> polygon = { B, A, v_bar };
std::vector<HalfEdge*> heLoop;
for (size_t j = 0; j < polygon.size(); j++) {
size_t next = (j + 1) % polygon.size();
auto* u = polygon[j];
auto* v = polygon[next];
auto* he = u->HalfEdgeTo(v);
if (!he)
he = heMesh->AddEdge(u, v)->HalfEdge();
heLoop.push_back(he);
}
auto* p = heMesh->AddPolygon(heLoop);
assert(p != nullptr);
}
spdlog::info("contract ({}, {}) -> {}", pc.i, pc.j, pc.k);
}
好像是linux的库win10没有,不知道咋修复。。。。
查到的方法都是vs里添加,但cmake build成功前没法这么做啊。。。
在vs2022 下编译时所以 static-assert 都会报错
https://learn.microsoft.com/zh-cn/cpp/build/reference/zc-static-assert?view=msvc-170
http://home.ustc.edu.cn/~ustczt/GAMES102/assets_v2.zip
上述下载链接已失效,无法完成cmake配置
cmake报错日志:
-- Download File: C:/Users/hyt/workspace/projects/GAMES102/homeworks/project/build/GAMES102_Project/assets_v2.zip
CMake Error at build/_deps/ucmake-src/cmake/UbpaDownload.cmake:26 (file):
file DOWNLOAD HASH mismatch
for file: [C:/Users/hyt/workspace/projects/GAMES102/homeworks/project/build/GAMES102_Project/assets_v2.zip]
expected hash: [88004765e50821a1c77958294a11ebf5ae28d5f2d5bf523b2b47c06fb7bddbdd]
actual hash: [e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855]
status: [22;"HTTP response code said error"]
Call Stack (most recent call first):
build/_deps/ucmake-src/cmake/UbpaDownload.cmake:35 (Ubpa_DownloadFile)
CMakeLists.txt:16 (Ubpa_DownloadZip)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.