35 #include "LinearMath/btVector3.h"
63 origin = btVector3(0,0,0);
67 origin = btVector3(center.getX(), center.getY(), center.getZ());
73 const tgBox::Config boxConfig(c.width, c.height, c.density, c.friction, c.rollFriction, c.restitution);
81 spec.addBuilder(
"box",
new tgBoxInfo(boxConfig));
99 throw std::invalid_argument(
"dt is not positive");
118 const int nBoxes = 4;
121 btVector3 rotationPoint = origin;
122 btVector3 rotationAxis = btVector3(0, 1, 0);
123 double rotationAngle = M_PI/2;
130 for(
int i=0;i<nodes.size();i+=2) {
133 s.
addRotation(rotationPoint, rotationAxis, rotationAngle);
136 s.move(btVector3(0, -5, 0));
139 void Crater::addBoxNodes() {
141 const double shift = 20;
142 const double vshift = 2;
143 const double node_h = c.height/2 + vshift;
144 const double node_w = c.width/2;
146 double x1 = -shift-node_w;
147 double x2 = shift+node_w;
150 double z1 = -shift-node_w;
151 double z2 = shift+node_w;
153 btVector3 rotationPoint = btVector3((x2-x1)/2, (y2-y1)/2, (z2-z1)/2);
154 btVector3 rotationAxis = btVector3(0, 1, 0);
155 double rotationAngle = M_PI/4;
157 node =
tgNode(x1, y1, z1,
"node");
158 node.
addRotation(rotationPoint, rotationAxis, rotationAngle);
159 nodes.push_back(node);
161 node =
tgNode(x2, y2, z2,
"node");
162 node.
addRotation(rotationPoint, rotationAxis, rotationAngle);
163 nodes.push_back(node);
virtual void onVisit(tgModelVisitor &r)
Create a box shape as an obstacle or add it to your tensegrity.
virtual void setup(tgWorld &world)
void addRotation(const btVector3 &fixedPoint, const btVector3 &fromOrientation, const btVector3 &toOrientation)
virtual void step(double dt)
virtual void step(double dt)
virtual void setup(tgWorld &world)
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="")
void addRotation(const btVector3 &fixedPoint, const btVector3 &axis, double angle)
Contains the definition of class Crater. Specifically, a crater is defined as a series of boxes which...
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="")