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));
88 structureInfo.buildInto(*
this, world);
100 throw std::invalid_argument(
"dt is not positive");
119 const int nBoxes = 4;
122 btVector3 rotationPoint = origin;
123 btVector3 rotationAxis = btVector3(0, 1, 0);
124 double rotationAngle = M_PI/2;
131 for(
int i=0;i<nodes.size();i+=2) {
134 s.
addRotation(rotationPoint, rotationAxis, rotationAngle);
137 s.move(btVector3(0, -5, 0));
140 void tgCraterShallow::addBoxNodes() {
142 const double shift = 20;
143 const double vshift = 2;
144 const double node_h = c.height/2 + vshift;
145 const double node_w = c.width/2;
147 double x1 = -shift-node_w;
148 double x2 = shift+node_w;
151 double z1 = -shift-node_w;
152 double z2 = shift+node_w;
154 btVector3 rotationPoint = btVector3((x2-x1)/2, (y2-y1)/2, (z2-z1)/2);
155 btVector3 rotationAxis = btVector3(0, 1, 0);
156 double rotationAngle = M_PI/4;
158 node =
tgNode(x1, y1, z1,
"node");
159 node.
addRotation(rotationPoint, rotationAxis, rotationAngle);
160 nodes.push_back(node);
162 node =
tgNode(x2, y2, z2,
"node");
163 node.
addRotation(rotationPoint, rotationAxis, rotationAngle);
164 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 addNode(double x, double y, double z, std::string tags="")