-
Notifications
You must be signed in to change notification settings - Fork 384
Expand file tree
/
Copy pathTriangleModel.cpp
More file actions
48 lines (39 loc) · 1.15 KB
/
TriangleModel.cpp
File metadata and controls
48 lines (39 loc) · 1.15 KB
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
41
42
43
44
45
46
47
48
#include "TriangleModel.h"
#include "PositionBasedDynamics/PositionBasedRigidBodyDynamics.h"
#include "PositionBasedDynamics/PositionBasedDynamics.h"
using namespace PBD;
TriangleModel::TriangleModel() :
m_particleMesh()
{
m_restitutionCoeff = static_cast<Real>(0.6);
m_frictionCoeff = static_cast<Real>(0.2);
}
TriangleModel::~TriangleModel(void)
{
cleanupModel();
}
void TriangleModel::cleanupModel()
{
m_particleMesh.release();
}
void TriangleModel::updateMeshNormals(const ParticleData &pd)
{
m_particleMesh.updateNormals(pd, m_indexOffset);
m_particleMesh.updateVertexNormals(pd);
}
void TriangleModel::initMesh(const unsigned int nPoints, const unsigned int nFaces, const unsigned int indexOffset, unsigned int* indices, const ParticleMesh::UVIndices& uvIndices, const ParticleMesh::UVs& uvs)
{
m_indexOffset = indexOffset;
m_particleMesh.release();
m_particleMesh.initMesh(nPoints, nFaces * 2, nFaces);
for (unsigned int i = 0; i < nFaces; i++)
{
m_particleMesh.addFace(&indices[3 * i]);
}
m_particleMesh.copyUVs(uvIndices, uvs);
m_particleMesh.buildNeighbors();
}
unsigned int TriangleModel::getIndexOffset() const
{
return m_indexOffset;
}