Add HandmadeMath.

Add simple morphing code.
This commit is contained in:
Syoyo Fujita 2018-10-08 14:20:45 +09:00
parent f02c504481
commit 04d8d637fc
3 changed files with 2530 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,22 @@
#include <vector>
#include <cstdlib>
#include <cassert>
void MorthTargets(std::vector<float> &weights,
std::vector<std::vector<float>> &targets,
std::vector<float> *output)
{
assert(weights.size() > 0);
assert(targets.size() > 0);
assert(weights.size() == targets.size());
// Assume all position has same number of vertices;
// TODO(parallelize)
for (size_t v = 0; v < targets[0].size(); v++) { // for each vertex
(*output)[v] = 0.0f;
for (size_t i = 0; i < weights.size(); i++) {
(*output)[v] += weights[i] * targets[i][v];
}
}
}

View File

@ -18,7 +18,7 @@ solution "skinning"
kind "ConsoleApp"
language "C++"
cppdialect "C++11"
files { "main.cc", "skinning.cc", "../common/trackball.cc", "../common/matrix.cc" }
files { "main.cc", "skinning.cc", "morph-targets.cc", "../common/trackball.cc", "../common/matrix.cc" }
includedirs { "./" }
includedirs { "../../" }