Giter Club home page Giter Club logo

games102's Introduction

Hi there 👋

Stats Top Langs

games102's People

Contributors

ubpa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

games102's Issues

使用无境框架完成作业九(曲面简化 QEM 方法)问题

Hello 助教好,很抱歉在课程结束这么久之后的打扰。
我在使用无境引擎完成作业九时,需要支持三角面的局部删除和添加操作。
我出错的关键函数是 contract,它需要支持删除顶点 pc.i, pc.j ,插入顶点 pc.k 并将 pc.i, pc.j 的所有相邻三角面移植到 pc.k 上。
我使用的是 heMeshRemovePolygon, AddPolygon 来完成这一边收缩操作,其中插入三角面仿照的是 heMesh->Init 的写法。
在 release 模式下,执行不会报错,但是得到的结果不是三角形网络。可能是我 API 的使用错误?
在 debug 模式下,会提示调用 heMesh->AddPolygon 时会产生非流形网络。虽然在上述代码操作中有可能出现这种问题,但是插入三角面结束后却并不会。
image
下面是代码。希望助教可以帮忙解答一下,感激不尽!

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);
}

作业资产无法下载

http://home.ustc.edu.cn/~ustczt/GAMES102/assets_v2.zip

上述下载链接已失效,无法完成cmake配置

image

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.