NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
tgSphereInfo.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_SPHERE_H
20 #define BTEN_SPHERE_H
21 
30 // This library
31 #include "tgNode.h"
32 #include "tgRigidInfo.h"
33 // The NTRT Core Library
34 #include "tgUtil.h"
35 #include "core/tgSphere.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 tgSphereInfo : public tgRigidInfo {
49 public:
50 
56  tgSphereInfo(const tgSphere::Config& config);
57 
63  tgSphereInfo(const tgSphere::Config& config, tgTags tags);
64 
71  tgSphereInfo(const tgSphere::Config& config, const tgNode& node);
72 
79  tgSphereInfo(const tgSphere::Config& config, tgTags tags, const tgNode& node);
80 
84  virtual ~tgSphereInfo() {}
85 
89  tgRigidInfo* createRigidInfo(const tgNode& node);
90 
97  virtual void initRigidBody(tgWorld& world);
98 
99  tgModel* createModel(tgWorld& world);
100 
105  const tgSphere::Config& getConfig() const { return m_config; }
106 
111  const btVector3& getNode() const { return m_node; }
112 
117  virtual btCollisionShape* getCollisionShape(tgWorld& world) const;
118 
123  virtual btTransform getTransform() const
124  {
125  return tgUtil::getTransform(getNode());
126  }
127 
133  virtual double getMass() const;
139  virtual btVector3 getCenterOfMass() const
140  {
141  return getNode();
142  }
143 
152  virtual btVector3
153  getConnectionPoint(const btVector3& referencePoint,
154  const btVector3& destinationPoint) const;
155 
165  virtual btVector3
166  getConnectionPoint(const btVector3& referencePoint,
167  const btVector3& destinationPoint,
168  const double rotation) const;
169 
175  virtual tgCompoundRigidInfo* getCompound() { return 0; }
176 
182  virtual const tgCompoundRigidInfo* getCompound() const { return 0; }
183 
190  virtual std::set<tgRigidInfo*> getLeafRigids();
191 
197  virtual bool containsNode(const btVector3& nodeVector) const
198  {
199  return (getNode() == nodeVector);
200  }
201 
206  virtual std::set<btVector3> getContainedNodes() const;
207 
208 private:
209 
211  tgSphereInfo(const tgSphereInfo&);
212 
214  tgSphereInfo& operator=(const tgSphereInfo&);
215 
216 private:
217 
219  const tgNode m_node;
220 
222  const tgSphere::Config m_config;
223 
224 };
225 
232 inline std::ostream& operator<<(std::ostream& os, const tgSphereInfo& sphere)
233 {
234  os << "tgSphereInfo(" << sphere.getNode() <<")";
235  return os;
236 }
237 
238 #endif
Definition of abstract class tgRigidInfo.
virtual btTransform getTransform() const
Definition: tgSphereInfo.h:123
const btVector3 & getNode() const
Definition: tgSphereInfo.h:111
virtual bool containsNode(const btVector3 &nodeVector) const
Definition: tgSphereInfo.h:197
Contains the definition of class tgSphere.
tgSphereInfo(const tgSphere::Config &config)
virtual void initRigidBody(tgWorld &world)
virtual btVector3 getCenterOfMass() const
Definition: tgSphereInfo.h:139
tgRigidInfo * createRigidInfo(const tgNode &node)
virtual btCollisionShape * getCollisionShape(tgWorld &world) const
const tgSphere::Config & getConfig() const
Definition: tgSphereInfo.h:105
virtual double getMass() const
std::ostream & operator<<(std::ostream &os, const tgSphereInfo &sphere)
Definition: tgSphereInfo.h:232
Definition of class tgNode.
static btTransform getTransform(const btVector3 &startOrientation, const btVector3 &start, const btVector3 &end)
Definition: tgUtil.h:92
virtual std::set< tgRigidInfo * > getLeafRigids()
Definition: tgNode.h:45
virtual btVector3 getConnectionPoint(const btVector3 &referencePoint, const btVector3 &destinationPoint) const
virtual tgCompoundRigidInfo * getCompound()
Definition: tgSphereInfo.h:175
Rand seeding simular to the evolution and terrain classes.
virtual std::set< btVector3 > getContainedNodes() const
Definition: tgTags.h:44
virtual ~tgSphereInfo()
Definition: tgSphereInfo.h:84
virtual const tgCompoundRigidInfo * getCompound() const
Definition: tgSphereInfo.h:182