Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
iMSTK
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ben Boeckel
iMSTK
Commits
420ec7cb
Commit
420ec7cb
authored
4 years ago
by
Sreekanth Arikatla
Browse files
Options
Downloads
Patches
Plain Diff
REFAC: Minor refactoring of the cloth example
parent
7e570027
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Examples/PBD/PBDCloth/pbdClothExample.cpp
+17
-11
17 additions, 11 deletions
Examples/PBD/PBDCloth/pbdClothExample.cpp
with
17 additions
and
11 deletions
Examples/PBD/PBDCloth/pbdClothExample.cpp
+
17
−
11
View file @
420ec7cb
...
...
@@ -40,13 +40,15 @@ const int nCols = 16;
/// \brief Creates cloth geometry
///
static
std
::
unique_ptr
<
SurfaceMesh
>
makeClothGeometry
(
const
double
width
,
const
double
height
,
const
int
nRows
,
const
int
nCols
)
makeClothGeometry
(
const
double
width
,
const
double
height
,
const
int
nRows
,
const
int
nCols
)
{
// Create surface mesh
std
::
unique_ptr
<
SurfaceMesh
>
clothMesh
=
std
::
make_unique
<
SurfaceMesh
>
();
StdVectorOfVec3d
vertList
;
auto
clothMesh
=
std
::
make_unique
<
SurfaceMesh
>
();
StdVectorOfVec3d
vertList
;
vertList
.
resize
(
nRows
*
nCols
);
const
double
dy
=
width
/
(
double
)(
nCols
-
1
);
const
double
dx
=
height
/
(
double
)(
nRows
-
1
);
...
...
@@ -97,7 +99,11 @@ makeClothGeometry(
/// \brief Creates cloth object
///
static
std
::
shared_ptr
<
PbdObject
>
makeClothObj
(
const
std
::
string
&
name
,
double
width
,
double
height
,
int
nRows
,
int
nCols
)
makeClothObj
(
const
std
::
string
&
name
,
const
double
width
,
const
double
height
,
const
int
nRows
,
const
int
nCols
)
{
auto
clothObj
=
std
::
make_shared
<
PbdObject
>
(
name
);
...
...
@@ -109,7 +115,7 @@ makeClothObj(const std::string& name, double width, double height, int nRows, in
pbdParams
->
enableConstraint
(
PbdConstraint
::
Type
::
Distance
,
1e2
);
pbdParams
->
enableConstraint
(
PbdConstraint
::
Type
::
Dihedral
,
1e1
);
pbdParams
->
m_fixedNodeIds
=
{
0
,
static_cast
<
size_t
>
(
nCols
)
-
1
};
pbdParams
->
m_uniformMassValue
=
width
*
height
/
(
nRows
*
nCols
);
pbdParams
->
m_uniformMassValue
=
width
*
height
/
(
(
double
)
nRows
*
(
double
)
nCols
);
pbdParams
->
m_gravity
=
Vec3d
(
0
,
-
9.8
,
0
);
pbdParams
->
m_defaultDt
=
0.005
;
pbdParams
->
m_iterations
=
5
;
...
...
@@ -156,16 +162,16 @@ main()
// Light (red)
auto
colorLight
=
std
::
make_shared
<
SpotLight
>
(
"colorLight"
);
colorLight
->
setPosition
(
Vec3d
(
-
5
,
-
3
,
5
));
colorLight
->
setFocalPoint
(
Vec3d
(
0
,
-
5
,
5
));
colorLight
->
setIntensity
(
100
);
colorLight
->
setPosition
(
Vec3d
(
-
5
.
,
-
3
.
,
5
.
));
colorLight
->
setFocalPoint
(
Vec3d
(
0
.
,
-
5
.
,
5
.
));
colorLight
->
setIntensity
(
100
.
);
colorLight
->
setColor
(
Color
::
Red
);
colorLight
->
setSpotAngle
(
30
);
scene
->
addLight
(
colorLight
);
// Adjust camera
scene
->
getCamera
()
->
setFocalPoint
(
0
,
-
5
,
5
);
scene
->
getCamera
()
->
setPosition
(
-
15.
,
-
5.
0
,
15.
0
);
scene
->
getCamera
()
->
setFocalPoint
(
0
.
,
-
5
.
,
5
.
);
scene
->
getCamera
()
->
setPosition
(
-
15.
,
-
5.
,
15.
);
// Start
simManager
->
setActiveScene
(
scene
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment