CGI/exercise2/src/Smoothing.cpp

29 lines
674 B
C++
Raw Normal View History

2018-09-06 12:35:43 +00:00
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute!
// Copyright (C) CGV TU Dresden - All Rights Reserved
#include "Smoothing.h"
#include <random>
void SmoothUniformLaplacian(HEMesh& m, float lambda, unsigned int iterations)
{
/*Task 2.2.4*/
}
void AddNoise(HEMesh& m)
{
std::mt19937 rnd;
std::normal_distribution<float> dist;
for (auto v : m.vertices())
{
OpenMesh::Vec3f n;
m.calc_vertex_normal_correct(v, n); //normal scales with area
float areaScale = n.norm();
float lengthScale = sqrt(areaScale);
n = lengthScale / areaScale * n;
m.point(v) += 0.1f * dist(rnd) * n;
}
}