NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
tgBoxInfo.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2012, 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 BTEN_BOX_H
20 #define BTEN_BOX_H
21 
30 // This library
31 #include "tgPairs.h"
32 #include "tgRigidInfo.h"
33 // The NTRT Core Library
34 #include "tgUtil.h"
35 #include "core/tgBox.h"
36 
37 // The Bullet Physics library
38 #include "btBulletDynamicsCommon.h"
39 
40 class btVector3;
41 
42 // @todo: Need to take tags into account...
43 
48 class tgBoxInfo : public tgRigidInfo {
49 public:
50 
56  tgBoxInfo(const tgBox::Config& config);
57 
63  tgBoxInfo(const tgBox::Config& config, tgTags tags);
64 
72  tgBoxInfo(const tgBox::Config& config, const tgPair& pair);
73 
81  tgBoxInfo(const tgBox::Config& config, tgTags tags, const tgPair& pair);
82 
86  virtual ~tgBoxInfo() {}
87 
91  tgRigidInfo* createRigidInfo(const tgPair& pair);
92 
99  virtual void initRigidBody(tgWorld& world);
100 
101  virtual tgModel* createModel(tgWorld& world);
102 
107  const tgBox::Config& getConfig() const { return m_config; }
108 
110  const btVector3& getFrom() const { return m_pair.getFrom(); }
111 
113  const btVector3& getTo() const { return m_pair.getTo(); }
114 
119  virtual btCollisionShape* getCollisionShape(tgWorld& world) const;
120 
125  virtual btTransform getTransform() const
126  {
127  return tgUtil::getTransform(getFrom(), getTo());
128  }
129 
135  virtual double getMass() const;
141  virtual btVector3 getCenterOfMass() const
142  {
143  return (getFrom() + getTo()) / 2.0;
144  }
145 
154  virtual btVector3
155  getConnectionPoint(const btVector3& referencePoint,
156  const btVector3& destinationPoint) const;
157 
166  virtual btVector3
167  getConnectionPoint(const btVector3& referencePoint,
168  const btVector3& destinationPoint,
169  const double rotation) const;
170 
176  virtual tgCompoundRigidInfo* getCompound() { return 0; }
177 
183  virtual const tgCompoundRigidInfo* getCompound() const { return 0; }
184 
191  virtual std::set<tgRigidInfo*> getLeafRigids();
192 
198  virtual bool containsNode(const btVector3& nodeVector) const
199  {
200  return ((getFrom() - nodeVector).fuzzyZero() || (getTo() - nodeVector).fuzzyZero());
201  }
202 
207  virtual std::set<btVector3> getContainedNodes() const;
208 
213  double getLength() const {
214  return getFrom().distance(getTo());
215  }
216 
217 private:
218 
220  tgBoxInfo(const tgBoxInfo&);
221 
223  tgBoxInfo& operator=(const tgBoxInfo&);
224 
225 private:
226 
228  const tgPair m_pair;
229 
231  const tgBox::Config m_config;
232 
233 };
234 
241 inline std::ostream& operator<<(std::ostream& os, const tgBoxInfo& box)
242 {
243  os << "tgBoxInfo(" << box.getFrom() << ", " << box.getTo() <<")";
244  return os;
245 }
246 
247 #endif
virtual btVector3 getConnectionPoint(const btVector3 &referencePoint, const btVector3 &destinationPoint) const
Definition: tgBoxInfo.cpp:135
Definition of abstract class tgRigidInfo.
Create a box shape as an obstacle or add it to your tensegrity.
virtual double getMass() const
Definition: tgBoxInfo.cpp:119
virtual ~tgBoxInfo()
Definition: tgBoxInfo.h:86
tgRigidInfo * createRigidInfo(const tgPair &pair)
Definition: tgBoxInfo.cpp:68
virtual std::set< tgRigidInfo * > getLeafRigids()
Definition: tgBoxInfo.cpp:188
virtual btTransform getTransform() const
Definition: tgBoxInfo.h:125
std::ostream & operator<<(std::ostream &os, const tgBoxInfo &box)
Definition: tgBoxInfo.h:241
virtual bool containsNode(const btVector3 &nodeVector) const
Definition: tgBoxInfo.h:198
virtual void initRigidBody(tgWorld &world)
Definition: tgBoxInfo.cpp:73
virtual btCollisionShape * getCollisionShape(tgWorld &world) const
Definition: tgBoxInfo.cpp:100
const btVector3 & getFrom() const
Definition: tgBoxInfo.h:110
Definition of class tgPairs.
const tgBox::Config & getConfig() const
Definition: tgBoxInfo.h:107
virtual std::set< btVector3 > getContainedNodes() const
Definition: tgBoxInfo.cpp:195
const btVector3 & getTo() const
Definition: tgBoxInfo.h:113
virtual tgCompoundRigidInfo * getCompound()
Definition: tgBoxInfo.h:176
static btTransform getTransform(const btVector3 &startOrientation, const btVector3 &start, const btVector3 &end)
Definition: tgUtil.h:92
Definition: tgPair.h:48
virtual btVector3 getCenterOfMass() const
Definition: tgBoxInfo.h:141
tgBoxInfo(const tgBox::Config &config)
Definition: tgBoxInfo.cpp:44
virtual const tgCompoundRigidInfo * getCompound() const
Definition: tgBoxInfo.h:183
double getLength() const
Definition: tgBoxInfo.h:213
Rand seeding simular to the evolution and terrain classes.
btVector3 & getTo()
Definition: tgPair.cpp:76
btVector3 & getFrom()
Definition: tgPair.cpp:52
Definition: tgTags.h:44