41 #include "LinearMath/btVector3.h"
48 FlemonsSpineModelLearning::FlemonsSpineModelLearning(
int segments) :
53 FlemonsSpineModelLearning::~FlemonsSpineModelLearning()
65 const double density = 4.2/300.0;
66 const double radius = 0.5;
78 tetra.
addNode( v_size, v_size, v_size);
79 tetra.
addNode( v_size, -v_size, -v_size);
80 tetra.
addNode(-v_size, v_size, -v_size);
81 tetra.
addNode(-v_size, -v_size, v_size);
83 tetra.
addPair(0, 1,
"front rod");
84 tetra.
addPair(0, 2,
"right rod");
85 tetra.
addPair(0, 3,
"back rod");
86 tetra.
addPair(0, 4,
"left rod");
90 tetra.move(btVector3(0.0,15.0,100.0));
96 btVector3 offset(0.0, 0.0, -v_size * 1.15);
97 for (std::size_t i = 0; i < m_segments; i++)
103 p->addTags(
tgString(
"segment num", i + 1));
104 p->move((i + 1.0) * offset);
112 std::vector<tgStructure*> children = snake.
getChildren();
113 for (std::size_t i = 1; i < children.size(); i++)
115 tgNodes n0 = children[i - 1]->getNodes();
116 tgNodes n1 = children[i]->getNodes();
140 spec.addBuilder(
"rod",
new tgRodInfo(rodConfig));
150 structureInfo.buildInto(*
this, world);
153 m_allMuscles = tgCast::filter<tgModel, tgLinearString> (
getDescendants());
155 m_allSegments = this->find<tgModel> (
"segment");
159 std::cout <<
"StructureInfo:" << std::endl;
160 std::cout << structureInfo << std::endl;
162 std::cout <<
"Model: " << std::endl;
163 std::cout << *
this << std::endl;
const std::vector< tgStructure * > & getChildren() const
virtual void setup(tgWorld &world)
void addChild(tgStructure *child)
Definition of class tgRodInfo.
Convenience function for combining strings with ints, mostly for naming structures.
Utility class for class casting and filtering collections by type.
Implementing the tetrahedral complex spine inspired by Tom Flemons.
virtual void setup(tgWorld &world)
void addPair(int fromNodeIdx, int toNodeIdx, std::string tags="")
virtual void step(double dt)
Contains the definition of class tgLinearString.
std::string tgString(std::string s, int i)
Definition of class tgStructure.
Definition of class tgStructureInfo.
Definition of class tgLinearStringInfo.
Contains the definition of class tgUtil and overloaded operator<<() free functions.
Definition of class tgBuildSpec.
virtual void step(double dt)
std::vector< tgModel * > getDescendants() const
void addNode(double x, double y, double z, std::string tags="")