Image Component Library (ICL)
PhysicsPaper.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2014 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLPhysics/src/ICLPhysics/PhysicsPaper.h **
10 ** Module : ICLPhysics **
11 ** Author : Christof Elbrechter, Matthias Esau **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 #pragma once
31 
32 #include <ICLPhysics/SoftObject.h>
33 #include <ICLCore/Img.h>
34 #include <ICLUtils/Array2D.h>
36 #include <ICLGeom/PlaneEquation.h>
37 #include <map>
38 
40 class btSoftBody;
43 namespace icl{
44 namespace physics{
45 
47  class PhysicsWorld;
50  class ICLPhysics_API PhysicsPaper : public SoftObject{
52 
53  friend class PaperTexturePrimitive;
54 
55  SceneObject *so;
58 
59  protected:
60  std::vector<BendingConstraint> constraints;
61  std::vector<float> originalRestLengths;
62 
63 
64  public:
65  PhysicsPaper(const PhysicsWorld &scene,
66  int nxCells, int nyCells,
67  const geom::Vec *init, bool initWithCorners,
68  const core::Img8u *texture = 0,
69  const core::Img8u *backfaceTexture=0);
70 
72  virtual void updateSceneObject();
73 
75  void moveVertex(const utils::Point &xy, const geom::Vec &pos, float factor);
76 
78  void movePosition(const utils::Point32f &paperPos, const geom::Vec &pos, float factor);
79 
80  utils::Point getNodeIndex(const geom::Vec &v);
81  void setDraggedNode(const utils::Point &xy);
82 
83  inline const utils::Size &getDimensions() const { return cells; }
84  geom::Vec getNodePosition(int x, int y) const;
86  return getNodePosition(p.x,p.y);
87  }
88  void setNodeMass(const utils::Point &xy, float mass);
89  void setNodeMass(const geom::Vec &v, float mass);
90  void setTotalMass(float mass);
91 
92  core::Img32f getVelocityMap() const;
93 
95 
106  virtual void adaptRowStiffness(float val, int row);
107  virtual void adaptColStiffness(float val, int col);
108  virtual void adaptGlobalStiffness(float val);
109 
111  void adaptStiffnessAlongIntersection(const geom::PlaneEquation &plane,
112  float val);
113 
114  virtual void memorizeDeformation();
115  virtual void resetDeformation();
116 
118  utils::Point32f getPaperCoordinates(const geom::ViewRay &ray);
119 
121  geom::Vec getInterpolatedPosition(const utils::Point32f &paperPos);
122 
124  geom::Vec getPosFromPhysics(int x, int y) const;
125 
127  geom::Vec getNormalFromPhysics(int x, int y);
128 
129 
130  protected:
131  void randomizeLinks();
132 
133  };
134 }
135 }
Utility structure for calculation of view-ray / plane intersections.
Definition: PlaneEquation.h:41
bool hasBackfaceTexture
Definition: PhysicsPaper.h:57
undocument this line if you encounter any issues!
Definition: Any.h:37
std::vector< float > originalRestLengths
Definition: PhysicsPaper.h:61
A physical world that handles physical objects.
Definition: PhysicsWorld.h:56
SceneObject * so
Definition: PhysicsPaper.h:55
utils::Size cells
Definition: PhysicsPaper.h:56
const utils::Size & getDimensions() const
Definition: PhysicsPaper.h:83
Size class of the ICL.
Definition: Size.h:61
geom::Vec getNodePosition(const utils::Point &p) const
Definition: PhysicsPaper.h:85
This class represents cloth or paper like soft-body objects.
Definition: PhysicsPaper.h:51
#define ICLPhysics_API
Definition: CompatMacros.h:181
This is a view-ray's line equation in parameter form.
Definition: ViewRay.h:49
Single precission 3D Vectors Point class of the ICL.
Definition: Point32f.h:41
Point class of the ICL used e.g. for the Images ROI offset.
Definition: Point.h:58
std::vector< BendingConstraint > constraints
Definition: PhysicsPaper.h:60