|
|
|
@ -16,16 +16,18 @@ SoftBody::SoftBody(Mesh* mesh, float edgeCompliance, float triangleCompliance, f |
|
|
|
|
in.pointlist = new REAL[mesh->vertices.size() * 3]; |
|
|
|
|
in.numberoffacets = static_cast<int>(mesh->faces.size()); |
|
|
|
|
in.facetlist = new tetgenio::facet[mesh->faces.size()]; |
|
|
|
|
in.numberofpointattributes = 3; |
|
|
|
|
in.pointattributelist = new REAL[mesh->vertices.size() * 3]; |
|
|
|
|
in.numberofpointattributes = 5; // color, uv
|
|
|
|
|
in.pointattributelist = new REAL[mesh->vertices.size() * 5]; |
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < mesh->vertices.size(); i++){ |
|
|
|
|
in.pointlist[i * 3 + 0] = mesh->vertices[i].position.x; |
|
|
|
|
in.pointlist[i * 3 + 1] = mesh->vertices[i].position.y; |
|
|
|
|
in.pointlist[i * 3 + 2] = mesh->vertices[i].position.z; |
|
|
|
|
in.pointattributelist[i * 3 + 0] = (mesh->vertices[i].position.x + 1) / 2; |
|
|
|
|
in.pointattributelist[i * 3 + 1] = (mesh->vertices[i].position.y + 1) / 2; |
|
|
|
|
in.pointattributelist[i * 3 + 2] = (mesh->vertices[i].position.z + 1) / 2; |
|
|
|
|
in.pointattributelist[i * 5 + 0] = mesh->vertices[i].color.r; |
|
|
|
|
in.pointattributelist[i * 5 + 1] = mesh->vertices[i].color.g; |
|
|
|
|
in.pointattributelist[i * 5 + 2] = mesh->vertices[i].color.b; |
|
|
|
|
in.pointattributelist[i * 5 + 3] = mesh->vertices[i].uv.s; |
|
|
|
|
in.pointattributelist[i * 5 + 4] = mesh->vertices[i].uv.t; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < mesh->faces.size(); i++){ |
|
|
|
@ -53,10 +55,12 @@ SoftBody::SoftBody(Mesh* mesh, float edgeCompliance, float triangleCompliance, f |
|
|
|
|
float x = static_cast<float>(out.pointlist[i * 3 + 0]); |
|
|
|
|
float y = static_cast<float>(out.pointlist[i * 3 + 1]); |
|
|
|
|
float z = static_cast<float>(out.pointlist[i * 3 + 2]); |
|
|
|
|
float r = static_cast<float>(out.pointattributelist[i * 3 + 0]); |
|
|
|
|
float g = static_cast<float>(out.pointattributelist[i * 3 + 1]); |
|
|
|
|
float b = static_cast<float>(out.pointattributelist[i * 3 + 2]); |
|
|
|
|
vertices.emplace_back(Vertex({x, y, z}, {r, g, b})); |
|
|
|
|
float r = static_cast<float>(out.pointattributelist[i * 5 + 0]); |
|
|
|
|
float g = static_cast<float>(out.pointattributelist[i * 5 + 1]); |
|
|
|
|
float b = static_cast<float>(out.pointattributelist[i * 5 + 2]); |
|
|
|
|
float s = static_cast<float>(out.pointattributelist[i * 5 + 3]); |
|
|
|
|
float t = static_cast<float>(out.pointattributelist[i * 5 + 4]); |
|
|
|
|
vertices.emplace_back(Vertex({x, y, z}, {r, g, b}, {s, t})); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
faces.reserve(out.numberoftrifaces); |
|
|
|
|