Created
July 8, 2018 01:23
-
-
Save jqly/7cc24f5c04a8c9ae66cee70e8f4fc0a8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void LoadRes( | |
World *world, | |
std::string characterdir | |
) { | |
// Hair,Body. | |
constexpr std::size_t hairmesh_idx = 0, bodymesh_idx = 1; | |
world->meshes = std::make_unique<std::vector<MeshDesc>>(2); | |
ReadIndHairFile(characterdir + "/hair.ind", &world->meshes->at(hairmesh_idx), 10); | |
ReadObjFile(characterdir + "/body.obj", &world->meshes->at(bodymesh_idx), characterdir + "/bodytex.png"); | |
for (const auto &mesh : *world->meshes.get()) { | |
switch (mesh.type) { | |
case MeshType::Fiber: | |
printf("FIBER fcount: %llu, vcount: %llu\n", mesh.pcnts.size(), mesh.ps.size()); | |
break; | |
case MeshType::TexTri: | |
printf("TEXTRI vcount: %llu\n", mesh.ps.size()); | |
break; | |
case MeshType::Tri: | |
printf("TRI vcount: %llu\n", mesh.ps.size()); | |
break; | |
} | |
} | |
{ | |
Bounds wbox{}; | |
for (auto &mesh : *world->meshes.get()) { | |
auto box = Bounds{ mesh.ps }; | |
box.Extend(box); | |
} | |
for (auto &mesh : *world->meshes.get()) { | |
for (auto &p : mesh.ps) | |
p -= wbox.Center(); | |
} | |
} | |
Bounds wbox{}; | |
for (auto &mesh : *world->meshes.get()) { | |
auto box = Bounds{ mesh.ps }; | |
mesh.box = box; | |
wbox.Extend(box); | |
} | |
GloomyVAO(world->meshes.get()); | |
world->view = std::make_unique<IndScreenView>(); | |
world->view->Init(kWindowWidth, kWindowHeight, glm::radians(60.f), wbox); | |
world->light = std::make_unique<DirLightDesc>(glm::vec3{ 1.f,0.f,0.f }, glm::vec3{ .8f }); | |
world->mona = std::make_unique<Mona>(); | |
world->mona->Init(world->view.get(), world->light.get(), kWindowWidth, kWindowHeight); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment