19 #include "RBStringTest.h"
21 #include "btBulletDynamicsCommon.h"
38 RBStringTest::Config::Config(
int segments,
41 double minTotalLength) :
44 m_stringConfig(stringConf),
45 m_minTotalLength(minTotalLength)
61 const double stiffness = m_config.m_stringConfig.
stiffness;
62 const double damping = m_config.m_stringConfig.
damping;
69 double v_size = m_config.m_minTotalLength / (double) m_config.m_segments;
72 btVector3 buildVec = (*m_pEndNode - *m_pStartNode);
74 double spacing = buildVec.length() / (double) m_config.m_segments;
76 btVector3 offset = buildVec.normalize() * spacing;
82 tgNode endNode(v_size * buildVec);
88 tetra.move(*m_pStartNode);
95 for(
int i = 0; i < m_config.m_segments; i++) {
98 t->addTags(
tgString(
"segment num", i + 1));
99 t->move((i + 1)*offset);
104 std::vector<tgStructure*> children = snake.
getChildren();
105 for(
int i = 1; i < children.size(); i++) {
106 tgNodes n0 = children[i-1]->getNodes();
107 tgNodes n1 = children[i]->getNodes();
117 spec.addBuilder(
"rod",
new tgRodInfo(m_config.m_rodConfig));
128 structureInfo.buildInto(*
this, world);
131 allMuscles = tgCast::filter<tgModel, tgLinearString> (
getDescendants());
134 std::cout <<
"StructureInfo:" << std::endl;
135 std::cout << structureInfo << std::endl;
137 std::cout <<
"Model: " << std::endl;
138 std::cout << *
this << std::endl;
152 void RBStringTest::changeMuscle (
double length,
double dt)
154 for(
int i = 0; i < allMuscles.size(); i++){
155 allMuscles[i]->setRestLength(length, dt);
const std::vector< tgStructure * > & getChildren() const
void addChild(tgStructure *child)
Definition of class tgRodInfo.
Convenience function for combining strings with ints, mostly for naming structures.
virtual void step(double dt)
Utility class for class casting and filtering collections by type.
void addPair(int fromNodeIdx, int toNodeIdx, std::string tags="")
virtual void step(double dt)
Definition of class tgConnectorInfo.
Definition of class tgNode.
std::string tgString(std::string s, int i)
Definition of class tgStructure.
Definition of class tgStructureInfo.
Definition of class tgLinearStringInfo.
virtual void setup(tgWorld &world)
Contains the definition of class tgUtil and overloaded operator<<() free functions.
Definition of class tgBuildSpec.
Definition of class tgRigidAutoCompound.
void notifyStep(double dt)
std::vector< tgModel * > getDescendants() const
void addNode(double x, double y, double z, std::string tags="")