-
Notifications
You must be signed in to change notification settings - Fork 11
/
example.cpp
40 lines (32 loc) · 1.64 KB
/
example.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <glm/vec3.hpp>
#include <cor/CoRCalculator.h>
#include <cor/CoRMesh.h>
int main(int argc, char** argv) {
using namespace CoR;
std::vector<glm::vec3> vertices; // get some vertices here
std::vector<unsigned int> faces; // Triangle data: Three consecutive indices describe a triangle.
std::vector<std::vector<unsigned int>> boneIndices; // bone indices for each vertex
std::vector<std::vector<float>> boneWeights; // weights for each vertex
unsigned int numberOfBones;
// Choose computation values
float subdivEpsilon = 0.1f;
float sigma = 0.1f;
float omega = 0.1f;
float bfsEpsilon = 0.000001f;
unsigned int numberOfThreadsToUse = 8;
bool performSubdivision = true;
// Choose one
CoRCalculator c(sigma, omega, performSubdivision, numberOfThreadsToUse);
//BFSCoRCalculator cs(sigma, omega, performSubdivision, numberOfThreadsToUse, bfsEpsilon);
// Create Mesh of CoRCalculation API with conversion methods
std::vector<WeightsPerBone> weightsPerBone = c.convertWeights(numberOfBones, boneIndices, boneWeights);
CoRMesh mesh = c.createCoRMesh(vertices, faces, weightsPerBone, subdivEpsilon);
// Start asynchronously computation. In the callback we just write the cors to a file.
c.calculateCoRsAsync(mesh, [&c](std::vector<glm::vec3> &cors) {
c.saveCoRsToBinaryFile("/path/to/my/output/file.cors", cors);
c.saveCoRsToTextFile("/path/to/my/debug/inspection/file.txt", cors);
});
// Loading can be performed from binary files only so far.
std::vector<glm::vec3> cors = c.loadCoRsFromBinaryFile("/path/to/another/output/file.cors");
}