本文整理汇总了C++中Switch::addChild方法的典型用法代码示例。如果您正苦于以下问题:C++ Switch::addChild方法的具体用法?C++ Switch::addChild怎么用?C++ Switch::addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Switch
的用法示例。
在下文中一共展示了Switch::addChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ANIMLoadSketchBook
/***************************************************************
* Function: ANIMLoadSketchBook()
***************************************************************/
void ANIMLoadSketchBook(PositionAttitudeTransform** xformScaleFwd, PositionAttitudeTransform** xformScaleBwd,
int &numPages, ANIMPageEntry ***pageEntryArray)
{
*xformScaleFwd = new PositionAttitudeTransform;
*xformScaleBwd = new PositionAttitudeTransform;
MatrixTransform *sketchbookTrans = new MatrixTransform;
Matrixf transMat, scaleMat;
transMat.makeTranslate(Vec3(0, 0, ANIM_VIRTUAL_SPHERE_RADIUS));
scaleMat.makeScale(Vec3(ANIM_PARA_PAINT_FRAME_ZOOM_FACTOR,
ANIM_PARA_PAINT_FRAME_ZOOM_FACTOR,
ANIM_PARA_PAINT_FRAME_ZOOM_FACTOR));
sketchbookTrans->setMatrix(transMat * scaleMat);
(*xformScaleFwd)->addChild(sketchbookTrans);
(*xformScaleBwd)->addChild(sketchbookTrans);
// load sketch book node from VRML file, create page geodes
Node* sketchbookNode = osgDB::readNodeFile(ANIMDataDir() + "VRMLFiles/SketchBook.WRL");
sketchbookTrans->addChild(sketchbookNode);
// Load floorplan filenames from config file
bool isFile = true;
int j = 0, numTex;
std::string file = "", dir, path;
std::vector<std::string> filenames;
dir = cvr::ConfigManager::getEntry("dir", "Plugin.CaveCADBeta.Floorplans", "/home/cehughes");
dir = dir + "/";
path = "Plugin.CaveCADBeta.Floorplans.0";
file = cvr::ConfigManager::getEntry(path, "", &isFile);
while (isFile)
{
filenames.push_back(dir + file);
j++;
char buf[50];
sprintf(buf, "Plugin.CaveCADBeta.Floorplans.%d", j);
std::string path = std::string(buf);
file = cvr::ConfigManager::getEntry(path, "", &isFile);
}
numPages = j;
//numPages = 3;
// create tree structured page entry array
*pageEntryArray = new ANIMPageEntry*[numPages];
for (int i = 0; i < numPages; i++)
{
/* char idxStr[16];
if (i < 10)
{
sprintf(idxStr, "0%d", i);
}
else if (i < 100)
{
sprintf(idxStr, "%d", i);
}*/
string filename = filenames[i];//ANIMDataDir() + "Textures/Floorplans/Floorplan" + string(idxStr) + string(".JPG");
(*pageEntryArray)[i] = new ANIMPageEntry;
Switch *singlePageSwitch = new Switch;
PositionAttitudeTransform *flipUpTrans = new PositionAttitudeTransform;
PositionAttitudeTransform *flipDownTrans = new PositionAttitudeTransform;
sketchbookTrans->addChild(singlePageSwitch);
singlePageSwitch->addChild(flipUpTrans);
singlePageSwitch->addChild(flipDownTrans);
singlePageSwitch->setAllChildrenOff();
// set up flip up / flip down animation paths for each page
Geode *flipUpGeode, *flipDownGeode;
AnimationPathCallback *flipUpCallback, *flipDownCallback;
ANIMCreateSinglePageGeodeAnimation(filename, &flipUpGeode, &flipDownGeode, &flipUpCallback, &flipDownCallback);
flipUpTrans->addChild(flipUpGeode);
flipUpTrans->setUpdateCallback(flipUpCallback);
flipDownTrans->addChild(flipDownGeode);
flipDownTrans->setUpdateCallback(flipDownCallback);
// write into page entry array record
(*pageEntryArray)[i]->mSwitch = singlePageSwitch;
(*pageEntryArray)[i]->mFlipUpAnim = flipUpCallback;
(*pageEntryArray)[i]->mFlipDownAnim = flipDownCallback;
(*pageEntryArray)[i]->mPageGeode = flipDownGeode;
(*pageEntryArray)[i]->mTexFilename = filename;
}
(*pageEntryArray)[0]->mSwitch->setSingleChildOn(1);
(*pageEntryArray)[1]->mSwitch->setSingleChildOn(0);
// size of floorplan
//.........这里部分代码省略.........
示例2: ANIMLoadSketchBook
/***************************************************************
* Function: ANIMLoadSketchBook()
***************************************************************/
void ANIMLoadSketchBook(PositionAttitudeTransform** xformScaleFwd, PositionAttitudeTransform** xformScaleBwd,
int &numPages, ANIMPageEntry ***pageEntryArray)
{
*xformScaleFwd = new PositionAttitudeTransform;
*xformScaleBwd = new PositionAttitudeTransform;
MatrixTransform *sketchbookTrans = new MatrixTransform;
Matrixf transMat, scaleMat;
transMat.makeTranslate(Vec3(0, 0, ANIM_VIRTUAL_SPHERE_RADIUS));
scaleMat.makeScale(Vec3(ANIM_PARA_PAINT_FRAME_ZOOM_FACTOR,
ANIM_PARA_PAINT_FRAME_ZOOM_FACTOR,
ANIM_PARA_PAINT_FRAME_ZOOM_FACTOR));
sketchbookTrans->setMatrix(transMat * scaleMat);
(*xformScaleFwd)->addChild(sketchbookTrans);
(*xformScaleBwd)->addChild(sketchbookTrans);
/* load sketch book node from VRML file, create page geodes */
Node* sketchbookNode = osgDB::readNodeFile(ANIMDataDir() + "VRMLFiles/SketchBook.WRL");
sketchbookTrans->addChild(sketchbookNode);
/* create tree structured page entry array */
numPages = 3;
*pageEntryArray = new ANIMPageEntry*[numPages];
for (int i = 0; i < numPages; i++)
{
char idxStr[16];
if (i < 10) sprintf(idxStr, "0%d", i);
else if (i < 100) sprintf(idxStr, "%d", i);
string filename = ANIMDataDir() + "Textures/Floorplans/Floorplan" + string(idxStr) + string(".JPG");
(*pageEntryArray)[i] = new ANIMPageEntry;
Switch *singlePageSwitch = new Switch;
PositionAttitudeTransform *flipUpTrans = new PositionAttitudeTransform;
PositionAttitudeTransform *flipDownTrans = new PositionAttitudeTransform;
sketchbookTrans->addChild(singlePageSwitch);
singlePageSwitch->addChild(flipUpTrans);
singlePageSwitch->addChild(flipDownTrans);
singlePageSwitch->setAllChildrenOff();
/* set up flip up / flip down animation paths for each page */
Geode *flipUpGeode, *flipDownGeode;
AnimationPathCallback *flipUpCallback, *flipDownCallback;
ANIMCreateSinglePageGeodeAnimation(filename, &flipUpGeode, &flipDownGeode, &flipUpCallback, &flipDownCallback);
flipUpTrans->addChild(flipUpGeode);
flipUpTrans->setUpdateCallback(flipUpCallback);
flipDownTrans->addChild(flipDownGeode);
flipDownTrans->setUpdateCallback(flipDownCallback);
/* write into page entry array record */
(*pageEntryArray)[i]->mSwitch = singlePageSwitch;
(*pageEntryArray)[i]->mFlipUpAnim = flipUpCallback;
(*pageEntryArray)[i]->mFlipDownAnim = flipDownCallback;
(*pageEntryArray)[i]->mPageGeode = flipDownGeode;
(*pageEntryArray)[i]->mTexFilename = filename;
}
(*pageEntryArray)[0]->mSwitch->setSingleChildOn(1);
(*pageEntryArray)[1]->mSwitch->setSingleChildOn(0);
/* size of floorplan */
(*pageEntryArray)[0]->mLength = 32; (*pageEntryArray)[0]->mWidth = 16; (*pageEntryArray)[0]->mAlti = -1.5f;
(*pageEntryArray)[1]->mLength = 128; (*pageEntryArray)[1]->mWidth = 128; (*pageEntryArray)[1]->mAlti = -1.5f;
(*pageEntryArray)[2]->mLength = 32; (*pageEntryArray)[2]->mWidth = 16; (*pageEntryArray)[2]->mAlti = -1.5f;
/* set up the forward / backward scale animation paths for sketch book root switch */
AnimationPath* animationPathScaleFwd = new AnimationPath;
AnimationPath* animationPathScaleBwd = new AnimationPath;
animationPathScaleFwd->setLoopMode(AnimationPath::NO_LOOPING);
animationPathScaleBwd->setLoopMode(AnimationPath::NO_LOOPING);
Vec3 scaleFwd, scaleBwd;
float step = 1.f / ANIM_VIRTUAL_SPHERE_NUM_SAMPS;
for (int i = 0; i < ANIM_VIRTUAL_SPHERE_NUM_SAMPS + 1; i++)
{
float val = i * step;
scaleFwd = Vec3(val, val, val);
scaleBwd = Vec3(1.f-val, 1.f-val, 1.f-val);
animationPathScaleFwd->insert(val, AnimationPath::ControlPoint(Vec3(),Quat(), scaleFwd));
animationPathScaleBwd->insert(val, AnimationPath::ControlPoint(Vec3(),Quat(), scaleBwd));
}
AnimationPathCallback *animCallbackFwd = new AnimationPathCallback(animationPathScaleFwd,
0.0, 1.f / ANIM_VIRTUAL_SPHERE_LAPSE_TIME);
AnimationPathCallback *animCallbackBwd = new AnimationPathCallback(animationPathScaleBwd,
0.0, 1.f / ANIM_VIRTUAL_SPHERE_LAPSE_TIME);
(*xformScaleFwd)->setUpdateCallback(animCallbackFwd);
(*xformScaleBwd)->setUpdateCallback(animCallbackBwd);
}