本文整理汇总了C++中tgStructure::addChild方法的典型用法代码示例。如果您正苦于以下问题:C++ tgStructure::addChild方法的具体用法?C++ tgStructure::addChild怎么用?C++ tgStructure::addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tgStructure
的用法示例。
在下文中一共展示了tgStructure::addChild方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addChild
void TensegrityModel::addChild(tgStructure& structure, const std::string &parentPath,
const std::string& childName, const Yam& childStructurePath, tgBuildSpec& spec) {
if (!childStructurePath) return;
std::string childPath = childStructurePath.as<std::string>();
// if path is relative, use path relative to parent structure
if (childPath[0] != '/') {
childPath = parentPath.substr(0, parentPath.rfind("/") + 1) + childPath;
}
tgStructure childStructure = tgStructure(childName);
buildStructure(childStructure, childPath, spec);
structure.addChild(childStructure);
}
示例2: addSegments
void VerticalSpineModel::addSegments(tgStructure& snake, const tgStructure& tetra,
double edge, size_t segmentCount)
{
//const btVector3 offset(0, 0, -edge * 1.15);
const btVector3 offset(0, 7.5, 0);
for (size_t i = 1; i < segmentCount; ++i)
{
tgStructure* const t = new tgStructure(tetra);
t->addTags(tgString("segment", i + 1));
t->move((i + 1) * offset);
// Add a child to the snake
snake.addChild(t);
}
}
示例3: addSegments
void BigDoxieNoFeet::addSegments(tgStructure& puppy, tgStructure& vertebra, tgStructure& hip, tgStructure& leg, tgStructure& foot,
double r){
const double offsetDist = r+1;
const double offsetDist2 = offsetDist*8;
const double offsetDist3 = offsetDist2+4;
const double yOffset_leg = -(2*r+1);
const double yOffset_foot = -(2*r+6);
//Vertebrae
btVector3 offset(offsetDist,0.0,0);
//Hips
btVector3 offset1(offsetDist*2,0.0,offsetDist);
btVector3 offset2(offsetDist2,0.0,offsetDist);
btVector3 offset3(offsetDist*2,0.0,-offsetDist);
btVector3 offset4(offsetDist2,0.0,-offsetDist);
//Lower legs
btVector3 offset5(offsetDist3,yOffset_leg,offsetDist);
btVector3 offset6(offsetDist3,yOffset_leg,-offsetDist);
btVector3 offset7(r*2,yOffset_leg,offsetDist);
btVector3 offset8(r*2,yOffset_leg,-offsetDist);
//Feet
btVector3 offset9(offsetDist3+1,yOffset_foot,offsetDist);
btVector3 offset10(offsetDist3+1,yOffset_foot,-offsetDist);
btVector3 offset11(r*2+1,yOffset_foot,offsetDist);
btVector3 offset12(r*2+1,yOffset_foot,-offsetDist);
for(std::size_t i = 0; i < m_segments; i++) { //Connect segments for spine of puppy
tgStructure* t = new tgStructure (vertebra);
t->addTags(tgString("spine segment num", i + 1));
t->move((i + 1)*offset);
if (i % 2 == 1){
t->addRotation(btVector3((i + 1) * offsetDist, 0.0, 0.0), btVector3(1, 0, 0), 0.0);
}
else{
t->addRotation(btVector3((i + 1) * offsetDist, 0.0, 0.0), btVector3(1, 0, 0), M_PI/2.0);
}
puppy.addChild(t); //Add a segment to the puppy
}
for(std::size_t i = m_segments; i < (m_segments + 2); i++) {//deal with right hip and shoulder first
tgStructure* t = new tgStructure (hip);
t->addTags(tgString("segment num", i + 1));
if(i % 2 == 0){
t->move(offset2);
t->addRotation(btVector3(offsetDist2, 0.0, offsetDist), btVector3(0, 1, 0), M_PI);
}
else{
t->move(offset1);
t->addRotation(btVector3(offsetDist*2, 0.0, offsetDist), btVector3(0, 1, 0), M_PI);
}
puppy.addChild(t); //Add a segment to the puppy
}
for(std::size_t i = (m_segments + 2); i < (m_segments + m_hips); i++) {//deal with left hip and shoulder now
tgStructure* t = new tgStructure (hip);
t->addTags(tgString("segment num", i + 1));
if(i % 2 == 0){
t->move(offset4);
}
else{
t->move(offset3);
}
puppy.addChild(t); //Add a segment to the puppy
}
for(std::size_t i = (m_segments + m_hips); i < (m_segments + m_hips + 2); i++) {//right front and back legs
tgStructure* t = new tgStructure (leg);
t->addTags(tgString("segment num", i + 1));
if(i % 2 == 0){
t->move(offset5);
t->addRotation(btVector3(offsetDist3, yOffset_leg, offsetDist), btVector3(0, 1, 0), M_PI);
}
else{
t->move(offset7);
t->addRotation(btVector3(r*2, yOffset_leg, offsetDist), btVector3(0, 1, 0), M_PI);
//the rotations for the legs are a remnant of the earlier design. Removing them now
//would mean changing all my muscle attachments. I will do this someday.
}
puppy.addChild(t); //Add a segment to the puppy
}
for(std::size_t i = (m_segments + m_hips + 2); i < (m_segments + m_hips + m_legs); i++) {//left front and back legs
tgStructure* t = new tgStructure (leg);
t->addTags(tgString("segment num", i + 1));
//.........这里部分代码省略.........