36 #include "LinearMath/btVector3.h"
64 origin = btVector3(0,0,0);
68 origin = btVector3(center.getX(), center.getY(), center.getZ());
74 const tgBox::Config boxConfig(c.width, c.height, c.density, c.friction, c.rollFriction, c.restitution);
82 spec.addBuilder(
"box",
new tgBoxInfo(boxConfig));
100 throw std::invalid_argument(
"dt is not positive");
121 const int nBoxes = 4;
122 #endif // Supress compiler warning unused variable
124 btVector3 rotationPoint = origin;
125 btVector3 rotationAxis = btVector3(0, 1, 0);
126 double rotationAngle = M_PI/2;
133 for(std::size_t i=0;i<nodes.size();i+=2) {
136 s.
addRotation(rotationPoint, rotationAxis, rotationAngle);
139 s.move(btVector3(0, -5, 0));
142 void tgCraterShallow::addBoxNodes() {
144 const double shift = 20;
145 const double vshift = 2;
146 const double node_h = c.height/2 + vshift;
147 const double node_w = c.width/2;
149 double x1 = -shift-node_w;
150 double x2 = shift+node_w;
153 double z1 = -shift-node_w;
154 double z2 = shift+node_w;
156 btVector3 rotationPoint = btVector3((x2-x1)/2, (y2-y1)/2, (z2-z1)/2);
157 btVector3 rotationAxis = btVector3(0, 1, 0);
158 double rotationAngle = M_PI/4;
160 node =
tgNode(x1, y1, z1,
"node");
161 node.
addRotation(rotationPoint, rotationAxis, rotationAngle);
162 nodes.push_back(node);
164 node =
tgNode(x2, y2, z2,
"node");
165 node.
addRotation(rotationPoint, rotationAxis, rotationAngle);
166 nodes.push_back(node);
Create a box shape as an obstacle or add it to your tensegrity.
virtual void setup(tgWorld &world)
virtual void onVisit(tgModelVisitor &r)
Contains the definition of class tgCraterShallow. Specifically, a crater is defined as a series of bo...
void addRotation(const btVector3 &fixedPoint, const btVector3 &fromOrientation, const btVector3 &toOrientation)
virtual void step(double dt)
virtual void setup(tgWorld &world)
virtual ~tgCraterShallow()
virtual void onVisit(const tgModelVisitor &r) const
Class that interfaces with Bullet to build the boxes.
void addPair(int fromNodeIdx, int toNodeIdx, std::string tags="")
virtual void step(double dt)
void addRotation(const btVector3 &fixedPoint, const btVector3 &axis, double angle)
Definition of class tgNode.
Definition of class tgStructure.
Definition of class tgStructureInfo.
Definition of class tgBuildSpec.
void notifyStep(double dt)
void buildInto(tgModel &model, tgWorld &world)
void addNode(double x, double y, double z, std::string tags="")