35 #include "LinearMath/btVector3.h"
64 origin = btVector3(0,0,0);
69 origin = btVector3(center.getX(), center.getY(), center.getZ());
78 const tgBox::Config boxConfig(c.width, c.height, c.density, c.friction, c.rollFriction, c.restitution);
86 spec.addBuilder(
"box",
new tgBoxInfo(boxConfig));
104 throw std::invalid_argument(
"dt is not positive");
124 const int nBoxes = 4;
127 btVector3 rotationPoint = origin;
128 btVector3 rotationAxis = btVector3(0, 1, 0);
129 double rotationAngle = M_PI/2;
136 for(
int i=0;i<nodes.size();i+=2) {
139 s.
addRotation(rotationPoint, rotationAxis, rotationAngle);
142 s.move(btVector3(0, -5, 0));
145 void CraterDeep::addBoxNodes() {
155 btVector3 rotationPoint = btVector3((x2-x1)/2, (y2-y1)/2, (z2-z1)/2);
156 btVector3 rotationAxis = btVector3(0, 1, 0);
157 double rotationAngle = 0;
159 node =
tgNode(x1, y1, z1,
"node");
160 node.
addRotation(rotationPoint, rotationAxis, rotationAngle);
161 nodes.push_back(node);
163 node =
tgNode(x2, y2, z2,
"node");
164 node.
addRotation(rotationPoint, rotationAxis, rotationAngle);
165 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)
void addRotation(const btVector3 &fixedPoint, const btVector3 &fromOrientation, const btVector3 &toOrientation)
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)
Definition of class tgNode.
Definition of class tgStructure.
Definition of class tgStructureInfo.
virtual void step(double dt)
Definition of class tgBuildSpec.
Contains the definition of class CraterDeep. Specifically, this crater is defined as a series of boxe...
void notifyStep(double dt)
void buildInto(tgModel &model, tgWorld &world)
void addNode(double x, double y, double z, std::string tags="")