NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
tgBlockField.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2014, United States Government, as represented by the
3  * Administrator of the National Aeronautics and Space Administration.
4  * All rights reserved.
5  *
6  * The NASA Tensegrity Robotics Toolkit (NTRT) v1 platform is licensed
7  * under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * http://www.apache.org/licenses/LICENSE-2.0.
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
15  * either express or implied. See the License for the specific language
16  * governing permissions and limitations under the License.
17  */
18 
19 #ifndef TG_BLOCK_FIELD
20 #define TG_BLOCK_FIELD
21 
31 // This library
32 #include "core/tgModel.h"
33 // The Bullet Physics Library
34 #include "LinearMath/btVector3.h"
35 // The C++ Standard Library
36 #include <vector>
37 
38 // Forward declarations
39 class tgModelVisitor;
40 class tgStructure;
41 class tgWorld;
42 
47 class tgBlockField : public tgModel
48 {
49 public:
50 
51  struct Config
52  {
53  public:
54  Config(btVector3 origin = btVector3(0.0, 0.0, 0.0),
55  btScalar friction = 0.5,
56  btScalar restitution = 0.0,
57  btVector3 minPos = btVector3(-100.0, 0.0, -100.0),
58  btVector3 maxPos = btVector3(100.0, 0.0, 100.0),
59  size_t nBlocks = 500,
60  double blockLength = 5.0,
61  double blockWidth = 5.0,
62  double blockHeight = 5.0);
63 
65  btVector3 m_origin;
66 
68  btScalar m_friction;
69 
71  btScalar m_restitution;
72 
74  btVector3 m_minPos;
75 
77  btVector3 m_maxPos;
78 
80  size_t m_nBlocks;
81 
83  double m_length;
84 
86  double m_width;
87 
89  double m_height;
90  };
91 
95  tgBlockField();
96 
102 
107  virtual ~tgBlockField();
108 
113  virtual void setup(tgWorld& world);
114 
119  virtual void step(double dt);
120 
128  virtual void onVisit(tgModelVisitor& r);
129 
134  void teardown();
135 
136 private:
137 
144  void addNodes(tgStructure& s);
145 
146  tgBlockField::Config m_config;
147 
148 };
149 
150 #endif // TETRA_COLLISIONS_WALL
Contains the definition of class tgModel.
virtual void step(double dt)
virtual ~tgBlockField()
virtual void setup(tgWorld &world)
virtual void onVisit(tgModelVisitor &r)