PeriDyno 1.0.0
Loading...
Searching...
No Matches
StaticMeshLoader.cpp
Go to the documentation of this file.
1#include "StaticMeshLoader.h"
2
4
5#include "Topology/TriangleSet.h"
6
7namespace dyno
8{
10
11 template<typename TDataType>
13 : ParametricModel<TDataType>()
14 {
15 auto triSet = std::make_shared<TriangleSet<TDataType>>();
16 this->stateTriangleSet()->setDataPtr(triSet);
17
18 this->stateInitialTriangleSet()->setDataPtr(std::make_shared<TriangleSet<TDataType>>());
19
20 auto surfaceRender = std::make_shared<GLSurfaceVisualModule>();
21 surfaceRender->setColor(Color(0.8f, 0.52f, 0.25f));
22 surfaceRender->setVisible(true);
23 this->stateTriangleSet()->connect(surfaceRender->inTriangleSet());
24 this->graphicsPipeline()->pushModule(surfaceRender);
25
26 auto callFileLoader = std::make_shared<FCallBackFunc>(
27 [=]() {
28 auto initTopo = this->stateInitialTriangleSet()->getDataPtr();
29 auto curTopo = this->stateTriangleSet()->getDataPtr();
30
31 std::string fileName = this->varFileName()->getValue().string();
32
33 if (fileName != "")
34 {
35 initTopo->loadObjFile(fileName);
36 curTopo->copyFrom(*initTopo);
37
38 curTopo->scale(this->varScale()->getValue());
39 curTopo->rotate(this->varRotation()->getValue() * M_PI / 180);
40 curTopo->translate(this->varLocation()->getValue());
41
42 curTopo->update();
43 }
44 }
45 );
46 this->varFileName()->attach(callFileLoader);
47
48 auto transform = std::make_shared<FCallBackFunc>(
49 [=]() {
50 auto initTopo = this->stateInitialTriangleSet()->getDataPtr();
51 auto curTopo = this->stateTriangleSet()->getDataPtr();
52
53 curTopo->copyFrom(*initTopo);
54 curTopo->scale(this->varScale()->getValue());
55 curTopo->rotate(this->varRotation()->getValue() * M_PI / 180);
56 curTopo->translate(this->varLocation()->getValue());
57 }
58 );
59 this->varLocation()->attach(transform);
60 this->varScale()->attach(transform);
61 this->varRotation()->attach(transform);
62
63 this->stateTriangleSet()->promoteOuput();
64 }
65
67}
#define DEFINE_CLASS(name)
Definition Object.h:140
#define IMPLEMENT_TCLASS(name, T1)
Definition Object.h:103
#define M_PI
Definition Typedef.inl:36
std::shared_ptr< GraphicsPipeline > graphicsPipeline()
Definition Node.cpp:320
A node containing a TriangleSet object.
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25