本文整理汇总了C++中fcfiletype::FCPtrStore::end方法的典型用法代码示例。如果您正苦于以下问题:C++ FCPtrStore::end方法的具体用法?C++ FCPtrStore::end怎么用?C++ FCPtrStore::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fcfiletype::FCPtrStore
的用法示例。
在下文中一共展示了FCPtrStore::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupAnimation
void setupAnimation(void)
{
//Read animation data from XML file
FCFileType::FCPtrStore NewContainers;
NewContainers = FCFileHandler::the()->read(BoostPath("./Data/15TestAnimations.xml"));
FCFileType::FCPtrStore::iterator Itor;
for(Itor = NewContainers.begin() ; Itor != NewContainers.end() ; ++Itor)
{
if( (*Itor)->getType().isDerivedFrom(Animation::getClassType()))
{
//Set the animation to the one we just read in
TheAnimation = (dynamic_pointer_cast<Animation>(*Itor));
}
else if( (*Itor)->getType() == (SimpleMaterial::getClassType()))
{
//Set torus material
TheTorusMaterial = (dynamic_pointer_cast<SimpleMaterial>(*Itor));
//Attach torus material to torus geometry
TorusGeometry->setMaterial(TheTorusMaterial);
}
}
TheAnimation->attachUpdateProducer(TutorialWindow->editEventProducer());
TheAnimation->start();
}
示例2: loadCreditsWindow
DialogWindowTransitPtr loadCreditsWindow(const BoostPath& WindowDefinitionFile)
{
FCFileType::FCPtrStore NewContainers;
NewContainers = FCFileHandler::the()->read(WindowDefinitionFile);
for(FCFileType::FCPtrStore::iterator Itor(NewContainers.begin()) ; Itor!= NewContainers.end() ; ++Itor)
{
if((*Itor)->getType() == DialogWindow::getClassType())
{
return DialogWindowTransitPtr(dynamic_pointer_cast<DialogWindow>(*Itor));
}
}
SFATAL << "Failed to load Builder Credits Window definition from file: " << WindowDefinitionFile.string() << std::endl;
return DialogWindowTransitPtr(NULL);
}
示例3: create
XMLLookAndFeelUnrecPtr XMLLookAndFeel::create(const BoostPath& LoadFile)
{
XMLLookAndFeelUnrecPtr Result = NULL;
if(boost::filesystem::exists(LoadFile))
{
FCFileType::FCPtrStore Containers;
Containers = FCFileHandler::the()->read(LoadFile);
FCFileType::FCPtrStore::iterator ContainerItor;
for(ContainerItor = Containers.begin(); ContainerItor != Containers.end(); ++ContainerItor)
{
if((*ContainerItor)->getType() == XMLLookAndFeel::getClassType())
{
Result = dynamic_pointer_cast<XMLLookAndFeel>(*ContainerItor);
break;
}
}
}
return Result;
}
示例4: LoadXML
void LoadXML(std::string FilePath, std::vector<NodePtr>& RootNodes, std::vector<CameraPtr>& Cameras)
{
RootNodes.clear();
Cameras.clear();
std::cout << "Loading xml File: " << FilePath << std::endl;
FCFileType::FCPtrStore NewContainers;
NewContainers = FCFileHandler::the()->read(Path(FilePath));
FCFileType::FCPtrStore::iterator Itor;
for(Itor = NewContainers.begin() ; Itor != NewContainers.end() ; ++Itor)
{
if( (*Itor)->getType() == Node::getClassType() &&
Node::Ptr::dcast(*Itor)->getParent() == NullFC)
{
RootNodes.push_back(Node::Ptr::dcast(*Itor));
}
else if( (*Itor)->getType().isDerivedFrom( Camera::getClassType() ))
{
Cameras.push_back(Camera::Ptr::dcast(*Itor));
}
}
}
示例5: main
// Initialize WIN32 & OpenSG and set up the scene
int main(int argc, char **argv)
{
preloadSharedObject("OSGTBFileIO");
// OSG init
osgInit(argc,argv);
{
// Set up Window
WindowEventProducerRecPtr TutorialWindow = createNativeWindow();
TutorialWindow->initWindow();
// Create the SimpleSceneManager helper
SimpleSceneManager sceneManager;
TutorialWindow->setDisplayCallback(boost::bind(display, &sceneManager));
TutorialWindow->setReshapeCallback(boost::bind(reshape, _1, &sceneManager));
// Tell the Manager what to manage
sceneManager.setWindow(TutorialWindow);
//Attach to events
TutorialWindow->connectMousePressed(boost::bind(mousePressed, _1, &sceneManager));
TutorialWindow->connectMouseReleased(boost::bind(mouseReleased, _1, &sceneManager));
TutorialWindow->connectMouseDragged(boost::bind(mouseDragged, _1, &sceneManager));
TutorialWindow->connectMouseWheelMoved(boost::bind(mouseWheelMoved, _1, &sceneManager));
TutorialWindow->connectKeyTyped(boost::bind(keyTyped, _1));
// create the scene
NodeUnrecPtr scene = makeTorus(1.0, 2.0, 16, 16);
sceneManager.setRoot (scene);
//Create the Documentation
SimpleScreenDoc TheSimpleScreenDoc(&sceneManager, TutorialWindow);
// show the whole scene
sceneManager.showAll();
//Load Sound Definitions
FCFileType::FCPtrStore NewContainers;
NewContainers = FCFileHandler::the()->read(BoostPath("Data/04SoundData.xml"));
FCFileType::FCPtrStore::iterator Itor;
for(Itor = NewContainers.begin() ; Itor != NewContainers.end() ; ++Itor)
{
//Get Sounds
if( (*Itor)->getType().isDerivedFrom(Sound::getClassType()))
{
Sounds.push_back(dynamic_pointer_cast<Sound>(*Itor));
Sounds.back()->connectSoundPlayed (boost::bind(handleSoundPlayed, _1));
Sounds.back()->connectSoundStopped (boost::bind(handleSoundStopped, _1));
Sounds.back()->connectSoundPaused (boost::bind(handleSoundPaused, _1));
Sounds.back()->connectSoundUnpaused(boost::bind(handleSoundUnpaused, _1));
Sounds.back()->connectSoundLooped (boost::bind(handleSoundLooped, _1));
}
//Get Sound Groups
if( (*Itor)->getType().isDerivedFrom(SoundGroup::getClassType()))
{
SoundGroups.push_back(dynamic_pointer_cast<SoundGroup>(*Itor));
}
}
//Initialize the Sound Manager
SoundManager::the()->attachUpdateProducer(TutorialWindow);
SoundManager::the()->setCamera(sceneManager.getCamera());
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"04 XML Sound Loading Window");
//Enter main loop
TutorialWindow->mainLoop();
}
osgExit();
return 0;
}
示例6: main
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
// Set up Window
TutorialWindow = createNativeWindow();
TutorialWindow->initWindow();
TutorialWindow->setDisplayCallback(display);
TutorialWindow->setReshapeCallback(reshape);
//Add Window Listener
TutorialKeyListener TheKeyListener;
TutorialWindow->addKeyListener(&TheKeyListener);
TutorialMouseListener TheTutorialMouseListener;
TutorialMouseMotionListener TheTutorialMouseMotionListener;
TutorialWindow->addMouseListener(&TheTutorialMouseListener);
TutorialWindow->addMouseMotionListener(&TheTutorialMouseMotionListener);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
//Print key command info
std::cout << "\n\nKEY COMMANDS:" << std::endl;
std::cout << "CTRL-Q Exit\n\n" << std::endl;
//SkeletonDrawer System Material
LineChunkUnrecPtr ExampleLineChunk = LineChunk::create();
ExampleLineChunk->setWidth(2.0f);
ExampleLineChunk->setSmooth(true);
BlendChunkUnrecPtr ExampleBlendChunk = BlendChunk::create();
ExampleBlendChunk->setSrcFactor(GL_SRC_ALPHA);
ExampleBlendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);
MaterialChunkUnrecPtr ExampleMaterialChunk = MaterialChunk::create();
ExampleMaterialChunk->setAmbient(Color4f(1.0f,1.0f,1.0f,1.0f));
ExampleMaterialChunk->setDiffuse(Color4f(0.0f,0.0f,0.0f,1.0f));
ExampleMaterialChunk->setSpecular(Color4f(0.0f,0.0f,0.0f,1.0f));
ChunkMaterialUnrecPtr ExampleMaterial = ChunkMaterial::create();
ExampleMaterial->addChunk(ExampleLineChunk);
ExampleMaterial->addChunk(ExampleMaterialChunk);
ExampleMaterial->addChunk(ExampleBlendChunk);
//Joint Node Hierarchy
NodeRecPtr ExampleJointNode;
//Create a new skeleton
SkeletonBlendedGeometryRecPtr ExampleSkeleton;
//Load skeleton from an XML file
FCFileType::FCPtrStore NewContainers;
NewContainers = FCFileHandler::the()->read(BoostPath("./Data/14Skeleton.xml"));
FCFileType::FCPtrStore::iterator Itor;
for(Itor = NewContainers.begin() ; Itor != NewContainers.end() ; ++Itor)
{
//We only want the skeleton; ignore anything else saved in the XML file
if( (*Itor)->getType() == (SkeletonBlendedGeometry::getClassType()))
{
ExampleSkeleton = (dynamic_pointer_cast<SkeletonBlendedGeometry>(*Itor));
}
if( (*Itor)->getType() == (Node::getClassType()) &&
(dynamic_pointer_cast<Node>(*Itor)->getParent() == NULL))
{
ExampleJointNode = (dynamic_pointer_cast<Node>(*Itor));
}
}
//SkeletonDrawer
SkeletonDrawableUnrecPtr ExampleSkeletonDrawable = SkeletonDrawable::create();
ExampleSkeletonDrawable->setSkeleton(ExampleSkeleton);
ExampleSkeletonDrawable->setMaterial(ExampleMaterial);
//Skeleton Node
NodeUnrecPtr SkeletonNode = Node::create();
SkeletonNode->setCore(ExampleSkeletonDrawable);
// Make Main Scene Node and add the Torus
NodeUnrecPtr scene = Node::create();
scene->setCore(Group::create());
scene->addChild(SkeletonNode);
mgr->setRoot(scene);
// Show the whole Scene
mgr->showAll();
//.........这里部分代码省略.........
示例7: main
// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
{
// Set up Window
WindowEventProducerRecPtr TutorialWindow = createNativeWindow();
//Initialize Window
TutorialWindow->initWindow();
SimpleSceneManager sceneManager;
TutorialWindow->setDisplayCallback(boost::bind(display, &sceneManager));
TutorialWindow->setReshapeCallback(boost::bind(reshape, _1, &sceneManager));
// Tell the Manager what to manage
sceneManager.setWindow(TutorialWindow);
//Attach to events
TutorialWindow->connectMousePressed(boost::bind(mousePressed, _1, &sceneManager));
TutorialWindow->connectMouseReleased(boost::bind(mouseReleased, _1, &sceneManager));
TutorialWindow->connectMouseDragged(boost::bind(mouseDragged, _1, &sceneManager));
TutorialWindow->connectMouseWheelMoved(boost::bind(mouseWheelMoved, _1, &sceneManager));
BoostPath FilePath("../Animation/Data/Nanobot.dae");
if(argc >= 2)
{
FilePath = BoostPath(argv[1]);
if(!boost::filesystem::exists(FilePath))
{
std::cerr << "Could not load file: "<< FilePath.string()
<< ", because no such files exists."<< std::endl;
FilePath = BoostPath("../Animation/Data/Nanobot.dae");
}
}
NodeRefPtr LoadedRoot;
std::vector<AnimationRecPtr> LoadedAnimations;
FCFileType::FCPtrStore ObjStore;
try
{
ObjStore = FCFileHandler::the()->read(FilePath);
}
catch(std::exception &ex)
{
std::cerr << "Failed to load file: " << FilePath.string() << ", error:"
<< ex.what() << std::endl;
return -1;
}
for(FCFileType::FCPtrStore::iterator StorItor(ObjStore.begin());
StorItor != ObjStore.end();
++StorItor)
{
//Animations
if((*StorItor)->getType().isDerivedFrom(Animation::getClassType()))
{
LoadedAnimations.push_back(dynamic_pointer_cast<Animation>(*StorItor));
LoadedAnimations.back()->attachUpdateProducer(TutorialWindow);
LoadedAnimations.back()->start();
}
//Root Node
if((*StorItor)->getType() == Node::getClassType() &&
dynamic_pointer_cast<Node>(*StorItor)->getParent() == NULL)
{
LoadedRoot = dynamic_pointer_cast<Node>(*StorItor);
}
}
if(LoadedRoot == NULL)
{
LoadedRoot = SceneFileHandler::the()->read(FilePath.string().c_str());
}
if(LoadedRoot == NULL)
{
LoadedRoot= makeTorus(.5, 2, 32, 32);
}
//Make the fog node
PostShaderStageRecPtr PostShaderStageCore = PostShaderStage::create();
PostShaderStageCore->clearPasses();
PostShaderStageCore->addPass("", generateNoEffectProg());
DirectionalLightRecPtr SceneLightCore = DirectionalLight::create();
SceneLightCore->setAmbient(Color4f(0.2f, 0.2f, 0.2f, 1.0f));
SceneLightCore->setDiffuse(Color4f(0.8f, 0.8f, 0.8f, 1.0f));
SceneLightCore->setSpecular(Color4f(1.0f, 1.0f, 1.0f, 1.0f));
NodeRefPtr SceneLight = makeNodeFor(SceneLightCore);
SceneLight->addChild(LoadedRoot);
NodeRefPtr PostShaderStageNode = makeNodeFor(PostShaderStageCore);
PostShaderStageNode->addChild(SceneLight);
//Make Main Scene Node
NodeRefPtr scene = makeCoredNode<Group>();
//.........这里部分代码省略.........
示例8: main
// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
if(argc != 2)
{
std::cout << "Usage: 04Xml2Osb.exe [Filename]" << std::endl;
return -1;
}
Path FilePath(argv[1]);
if(!boost::filesystem::exists(FilePath))
{
std::cout << "No file by name: "<< FilePath.string() << " exists." << std::endl;
return -1;
}
// OSG init
osgInit(argc,argv);
NodePtr TheScene(NullFC);
//Load the Scene
FCFileType::FCPtrStore NewContainers;
NewContainers = FCFileHandler::the()->read(FilePath);
FCFileType::FCPtrStore::iterator Itor;
for(Itor = NewContainers.begin() ; Itor != NewContainers.end() ; ++Itor)
{
if( (*Itor)->getType() == Node::getClassType() &&
Node::Ptr::dcast(*Itor)->getParent() == NullFC)
{
TheScene = Node::Ptr::dcast(*Itor);
}
}
//Check if the scene was loaded
if(TheScene == NullFC)
{
std::cout << "Failed to load a scene from: "<< FilePath.string() << "." << std::endl;
return -1;
}
//Run Graph optimizations
GraphOpSeq *graphop = new GraphOpSeq;
graphop->addGraphOp(new VerifyGeoGraphOp);
graphop->addGraphOp(new StripeGraphOp);
//graphop->addGraphOp(new MaterialMergeGraphOp);
//graphop->addGraphOp(new SharePtrGraphOp);
if(graphop != NULL)
{
graphop->run(TheScene);
}
//Export the Scene to an osb file
std::string ExportFileName(FilePath.string().substr(0,FilePath.string().size()-3) + "osb");
SceneFileHandler::the().write(TheScene, ExportFileName.c_str());
// OSG exit
osgExit();
return 0;
}
示例9: main
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
// Set up Window
TutorialWindowEventProducer = createDefaultWindowEventProducer();
WindowPtr MainWindow = TutorialWindowEventProducer->initWindow();
TutorialWindowEventProducer->setDisplayCallback(display);
TutorialWindowEventProducer->setReshapeCallback(reshape);
TutorialUpdateListener TheTutorialUpdateListener;
TutorialWindowEventProducer->addUpdateListener(&TheTutorialUpdateListener);
//Add Window Listener
TutorialKeyListener TheKeyListener;
TutorialWindowEventProducer->addKeyListener(&TheKeyListener);
TutorialMouseListener TheTutorialMouseListener;
TutorialMouseMotionListener TheTutorialMouseMotionListener;
TutorialWindowEventProducer->addMouseListener(&TheTutorialMouseListener);
TutorialWindowEventProducer->addMouseMotionListener(&TheTutorialMouseMotionListener);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(MainWindow);
//Print key command info
std::cout << "\n\nKEY COMMANDS:" << std::endl;
std::cout << "space Play/Pause the animation" << std::endl;
std::cout << "G Show/Hide the grid" << std::endl;
std::cout << "A Show/Hide the axes" << std::endl;
std::cout << "B Show/Hide the bind pose skeleton" << std::endl;
std::cout << "SHIFT-B Show/Hide the bind pose mesh" << std::endl;
std::cout << "P Show/Hide the current pose skeleton" << std::endl;
std::cout << "SHIFT-P Show/Hide the current pose mesh" << std::endl;
std::cout << "CTRL-Q Exit\n\n" << std::endl;
//Setup axes
LineChunkPtr AxesLineChunk = LineChunk::create();
beginEditCP(AxesLineChunk);
AxesLineChunk->setWidth(0.0f);
AxesLineChunk->setSmooth(true);
endEditCP(AxesLineChunk);
//Axes material
ChunkMaterialPtr AxesMaterial = ChunkMaterial::create();
beginEditCP(AxesMaterial, ChunkMaterial::ChunksFieldMask);
AxesMaterial->addChunk(AxesLineChunk);
endEditCP(AxesMaterial, ChunkMaterial::ChunksFieldMask);
//Grid material
ChunkMaterialPtr gridMaterial = ChunkMaterial::create();
beginEditCP(gridMaterial, ChunkMaterial::ChunksFieldMask);
gridMaterial->addChunk(AxesLineChunk);
endEditCP(gridMaterial, ChunkMaterial::ChunksFieldMask);
//Axes should render as lines
GeoPTypesPtr axesType = GeoPTypesUI8::create();
beginEditCP(axesType, GeoPTypesUI8::GeoPropDataFieldMask);
{
axesType->addValue(GL_LINES);
}
endEditCP (axesType, GeoPTypesUI8::GeoPropDataFieldMask);
//Grid type
GeoPTypesPtr gridType = GeoPTypesUI8::create();
beginEditCP(gridType, GeoPTypesUI8::GeoPropDataFieldMask);
{
gridType->addValue(GL_LINES);
}
endEditCP (gridType, GeoPTypesUI8::GeoPropDataFieldMask);
//Axes lens
GeoPLengthsPtr axesLens = GeoPLengthsUI32::create();
beginEditCP(axesLens, GeoPLengthsUI32::GeoPropDataFieldMask);
{
axesLens->addValue(6);
}
endEditCP (axesLens, GeoPLengthsUI32::GeoPropDataFieldMask);
//Grid lens
GeoPLengthsPtr gridLens = GeoPLengthsUI32::create();
beginEditCP(gridLens, GeoPLengthsUI32::GeoPropDataFieldMask);
{
gridLens->addValue(84);
}
endEditCP (gridLens, GeoPLengthsUI32::GeoPropDataFieldMask);
//Axes points
GeoPositions3fPtr axesPnts = GeoPositions3f::create();
beginEditCP(axesPnts, GeoPositions3f::GeoPropDataFieldMask);
{
// X-Axis
//.........这里部分代码省略.........
示例10: main
// Initialize WIN32 & OpenSG and set up the scene
int main(int argc, char **argv)
{
std::cout << "\n\nKEY COMMANDS:" << std::endl
<< "1-9 Play Sounds 1-9" << std::endl
<< "p Pause Sounds" << std::endl
<< "u Unpause Sounds" << std::endl
<< "- Decrease Sound Group Volume" << std::endl
<< "= Increase Sound Group Volume" << std::endl
<< "CTRL-Q Exit\n\n" << std::endl;
// OSG init
osgInit(argc,argv);
TheWindowEventProducer = createNativeWindow();
TheWindowEventProducer->initWindow();
TheWindowEventProducer->setDisplayCallback(display);
TheWindowEventProducer->setReshapeCallback(reshape);
//Attach Mouse Listener
TutorialMouseListener TheTutorialMouseListener;
MouseEventConnection = TheWindowEventProducer->addMouseListener(&TheTutorialMouseListener);
//Attach Key Listener
TutorialKeyListener TheTutorialKeyListener;
TheWindowEventProducer->addKeyListener(&TheTutorialKeyListener);
//Attach MouseMotion Listener
TutorialMouseMotionListener TheTutorialMouseMotionListener;
TheWindowEventProducer->addMouseMotionListener(&TheTutorialMouseMotionListener);
// create the scene
NodeUnrecPtr scene = makeTorus(1.0, 2.0, 16, 16);
// create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// tell the manager what to manage
mgr->setWindow(TheWindowEventProducer );
mgr->setRoot (scene);
// show the whole scene
mgr->showAll();
//Load Sound Definitions
FCFileType::FCPtrStore NewContainers;
NewContainers = FCFileHandler::the()->read(BoostPath("Data/04SoundData.xml"));
FCFileType::FCPtrStore::iterator Itor;
TutorialSoundListener TheSoundListerner;
for(Itor = NewContainers.begin() ; Itor != NewContainers.end() ; ++Itor)
{
//Get Sounds
if( (*Itor)->getType().isDerivedFrom(Sound::getClassType()))
{
Sounds.push_back(dynamic_pointer_cast<Sound>(*Itor));
dynamic_pointer_cast<Sound>(*Itor)->addSoundListener(&TheSoundListerner);
}
//Get Sound Groups
if( (*Itor)->getType().isDerivedFrom(SoundGroup::getClassType()))
{
SoundGroups.push_back(dynamic_pointer_cast<SoundGroup>(*Itor));
}
}
//Initialize the Sound Manager
SoundManager::the()->attachUpdateProducer(TheWindowEventProducer);
SoundManager::the()->setCamera(mgr->getCamera());
Vec2f WinSize(TheWindowEventProducer->getDesktopSize() * 0.85f);
Pnt2f WinPos((TheWindowEventProducer->getDesktopSize() - WinSize) *0.5);
TheWindowEventProducer->openWindow(WinPos,
WinSize,
"04 XML Sound Loading Window");
//Enter main loop
TheWindowEventProducer->mainLoop();
osgExit();
return 0;
}
示例11: main
// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
// Set up Window
TutorialWindowEventProducer = createDefaultWindowEventProducer();
WindowPtr MainWindow = TutorialWindowEventProducer->initWindow();
TutorialWindowEventProducer->setDisplayCallback(display);
TutorialWindowEventProducer->setReshapeCallback(reshape);
//Add Window Listener
TutorialKeyListener TheKeyListener;
TutorialWindowEventProducer->addKeyListener(&TheKeyListener);
TutorialMouseListener TheTutorialMouseListener;
TutorialMouseMotionListener TheTutorialMouseMotionListener;
TutorialWindowEventProducer->addMouseListener(&TheTutorialMouseListener);
TutorialWindowEventProducer->addMouseMotionListener(&TheTutorialMouseMotionListener);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindowEventProducer->getWindow());
Path FBOFilePath;
if(argc < 2)
{
FWARNING(("No FBO file given!\n"));
FBOFilePath = Path("./Data/01LoadFBO.xml");
}
else
{
FBOFilePath = Path(std::string(argv[1]));
}
std::cout << "Loading xml File: " << FBOFilePath << std::endl;
FCFileType::FCPtrStore NewContainers;
NewContainers = FCFileHandler::the()->read(FBOFilePath);
FCFileType::FCPtrStore::iterator Itor;
for(Itor = NewContainers.begin() ; Itor != NewContainers.end() ; ++Itor)
{
if( (*Itor)->getType() == FBOViewport::getClassType())
{
TheFBOViewport = FBOViewport::Ptr::dcast(*Itor);
}
}
ChunkMaterialPtr BoxMaterial = ChunkMaterial::create();
GeometryPtr BoxGeoCore = makeBoxGeo(1.0,1.0,1.0,2,2,2);
beginEditCP(BoxGeoCore, Geometry::MaterialFieldMask);
BoxGeoCore->setMaterial(BoxMaterial);
endEditCP(BoxGeoCore, Geometry::MaterialFieldMask);
NodePtr BoxGeoNode = Node::create();
beginEditCP(BoxGeoNode, Node::CoreFieldMask);
BoxGeoNode->setCore(BoxGeoCore);
endEditCP(BoxGeoNode, Node::CoreFieldMask);
NodePtr SceneNode = Node::create();
beginEditCP(SceneNode, Node::CoreFieldMask | Node::ChildrenFieldMask);
SceneNode->setCore(Group::create());
SceneNode->addChild(BoxGeoNode);
endEditCP(SceneNode, Node::CoreFieldMask | Node::ChildrenFieldMask);
// tell the manager what to manage
mgr->setRoot (SceneNode);
// show the whole scene
mgr->showAll();
if(TheFBOViewport != NullFC)
{
//Add the texture chunk of the FBO to the Material for the box
beginEditCP(BoxMaterial, ChunkMaterial::ChunksFieldMask);
BoxMaterial->addChunk(TheFBOViewport->editTextures(0));
endEditCP(BoxMaterial, ChunkMaterial::ChunksFieldMask);
//Add The FBO Viewport the the Window
beginEditCP(TheFBOViewport, FBOViewport::ParentFieldMask);
TheFBOViewport->setParent(TutorialWindowEventProducer->getWindow());
endEditCP(TheFBOViewport, FBOViewport::ParentFieldMask);
beginEditCP(TutorialWindowEventProducer->getWindow());
ViewportPtr vp = TutorialWindowEventProducer->getWindow()->getPort(0);
addRefCP(vp);
TutorialWindowEventProducer->getWindow()->subPort(0);
//Put the FBO Vieport in front, so it is rendered first
TutorialWindowEventProducer->getWindow()->addPort(TheFBOViewport);
TutorialWindowEventProducer->getWindow()->addPort(vp );
endEditCP (TutorialWindowEventProducer->getWindow());
}
//.........这里部分代码省略.........
示例12: main
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
// Set up Window
TutorialWindow = createNativeWindow();
TutorialWindow->initWindow();
TutorialWindow->setDisplayCallback(display);
TutorialWindow->setReshapeCallback(reshape);
//Add Window Listener
TutorialKeyListener TheKeyListener;
TutorialWindow->addKeyListener(&TheKeyListener);
TutorialMouseListener TheTutorialMouseListener;
TutorialMouseMotionListener TheTutorialMouseMotionListener;
TutorialWindow->addMouseListener(&TheTutorialMouseListener);
TutorialWindow->addMouseMotionListener(&TheTutorialMouseMotionListener);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
//SkeletonDrawer System Material
LineChunkUnrecPtr ExampleLineChunk = LineChunk::create();
ExampleLineChunk->setWidth(2.0f);
ExampleLineChunk->setSmooth(true);
BlendChunkUnrecPtr ExampleBlendChunk = BlendChunk::create();
ExampleBlendChunk->setSrcFactor(GL_SRC_ALPHA);
ExampleBlendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);
MaterialChunkUnrecPtr ExampleMaterialChunk = MaterialChunk::create();
ExampleMaterialChunk->setAmbient(Color4f(1.0f,1.0f,1.0f,1.0f));
ExampleMaterialChunk->setDiffuse(Color4f(0.0f,0.0f,0.0f,1.0f));
ExampleMaterialChunk->setSpecular(Color4f(0.0f,0.0f,0.0f,1.0f));
ChunkMaterialUnrecPtr ExampleMaterial = ChunkMaterial::create();
ExampleMaterial->addChunk(ExampleLineChunk);
//Read skeleton from XML file
FCFileType::FCPtrStore NewContainers;
NewContainers = FCFileHandler::the()->read(BoostPath("./Data/16Skeleton.xml"));
SkeletonUnrecPtr ExampleSkeleton;
FCFileType::FCPtrStore::iterator Itor;
for(Itor = NewContainers.begin() ; Itor != NewContainers.end() ; ++Itor)
{
//Only import skeleton data; we ignore anything else saved in the XML file
if( (*Itor)->getType() == (Skeleton::getClassType()))
{
//Set the Skeleton to the one we just read in
ExampleSkeleton = (dynamic_pointer_cast<Skeleton>(*Itor));
}
}
//SkeletonDrawer
SkeletonDrawableUnrecPtr ExampleSkeletonDrawable = SkeletonDrawable::create();
ExampleSkeletonDrawable->setSkeleton(ExampleSkeleton);
ExampleSkeletonDrawable->setMaterial(ExampleMaterial);
//Skeleton Particle System Node
NodeUnrecPtr SkeletonNode = Node::create();
SkeletonNode->setCore(ExampleSkeletonDrawable);
//Torus Node
NodeUnrecPtr TorusNode = makeTorus(.5, 2, 32, 32);
// Make Main Scene Node and add the Torus
NodeUnrecPtr scene = Node::create();
scene->setCore(Group::create());
scene->addChild(SkeletonNode);
//scene->addChild(TorusNode);
scene->addChild(makeCoordAxis(10.0));
mgr->setRoot(scene);
mgr->turnHeadlightOff();
// Show the whole Scene
mgr->showAll();
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"16LoadXMLSkeleton");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
//.........这里部分代码省略.........
示例13: main
// Initialize OpenSG and set up the scene
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
// Set up Window
TutorialWindowEventProducer = createDefaultWindowEventProducer();
WindowPtr MainWindow = TutorialWindowEventProducer->initWindow();
TutorialWindowEventProducer->setDisplayCallback(display);
TutorialWindowEventProducer->setReshapeCallback(reshape);
//Add Window Listener
TutorialKeyListener TheKeyListener;
TutorialWindowEventProducer->addKeyListener(&TheKeyListener);
TutorialMouseListener TheTutorialMouseListener;
TutorialMouseMotionListener TheTutorialMouseMotionListener;
TutorialWindowEventProducer->addMouseListener(&TheTutorialMouseListener);
TutorialWindowEventProducer->addMouseMotionListener(&TheTutorialMouseMotionListener);
TutorialUpdateListener TheTutorialUpdateListener;
TutorialWindowEventProducer->addUpdateListener(&TheTutorialUpdateListener);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(MainWindow);
//Print key command info
std::cout << "\n\nKEY COMMANDS:" << std::endl;
std::cout << "space Play/Pause the animation" << std::endl;
std::cout << "B Show/Hide the bind pose skeleton" << std::endl;
std::cout << "SHIFT-B Show/Hide the bind pose mesh" << std::endl;
std::cout << "P Show/Hide the current pose skeleton" << std::endl;
std::cout << "SHIFT-P Show/Hide the current pose mesh" << std::endl;
std::cout << "O Toggle override status of TheSecondAnimation" << std::endl;
std::cout << "CTRL-Q Exit\n\n" << std::endl;
//Import scene from XML
ChunkMaterialPtr ExampleMaterial;
std::vector<SkeletonPtr> SkeletonPtrs;
std::vector<SkeletonBlendedGeometryPtr> SkeletonBlendedGeometryPtrs;
std::vector<GeometryPtr> GeometryPtrs;
//Skeleton materaial
LineChunkPtr SkelLineChunk = LineChunk::create();
beginEditCP(SkelLineChunk);
SkelLineChunk->setWidth(0.0f);
SkelLineChunk->setSmooth(true);
endEditCP(SkelLineChunk);
ChunkMaterialPtr SkelMaterial = ChunkMaterial::create();
beginEditCP(SkelMaterial, ChunkMaterial::ChunksFieldMask);
SkelMaterial->addChunk(SkelLineChunk);
endEditCP(SkelMaterial, ChunkMaterial::ChunksFieldMask);
//LOAD FIRST ANIMATION
FCFileType::FCPtrStore NewContainers;
NewContainers = FCFileHandler::the()->read(BoostPath("./Data/23WalkingAnimation.xml"));
FCFileType::FCPtrStore::iterator Itor;
for(Itor = NewContainers.begin() ; Itor != NewContainers.end() ; ++Itor)
{
if( (*Itor)->getType() == (ChunkMaterial::getClassType()))
{
//Set ExampleMaterial to the ChunkMaterial we just read in
ExampleMaterial = (ChunkMaterial::Ptr::dcast(*Itor));
}
if( (*Itor)->getType() == (Skeleton::getClassType()))
{
//Add the Skeleton we just read in to SkeletonPtrs
SkeletonPtrs.push_back(Skeleton::Ptr::dcast(*Itor));
}
if( (*Itor)->getType() == (SkeletonBlendedGeometry::getClassType()))
{
//Add the SkeletonBlendedGeometry we just read in to SkeletonBlendedGeometryPtrs
SkeletonBlendedGeometryPtrs.push_back(SkeletonBlendedGeometry::Ptr::dcast(*Itor));
}
if( (*Itor)->getType().isDerivedFrom(SkeletonAnimation::getClassType()))
{
//Set TheWalkingAnimation to the SkeletonAnimation we just read in
TheWalkingAnimation = (SkeletonAnimation::Ptr::dcast(*Itor));
}
if( (*Itor)->getType() == (Geometry::getClassType()))
{
//Add the Geometry we just read in to GeometryPtrs
GeometryPtrs.push_back(Geometry::Ptr::dcast(*Itor));
}
}
//LOAD SECOND ANIMATION
NewContainers = FCFileHandler::the()->read(BoostPath("./Data/23SamAnimation.xml"));
for(Itor = NewContainers.begin() ; Itor != NewContainers.end() ; ++Itor)
{
//Import only the skeletonAnimation from the second XML file; we've already imported the skeleton and the geometry
if( (*Itor)->getType().isDerivedFrom(SkeletonAnimation::getClassType()))
//.........这里部分代码省略.........
示例14: main
// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
// Set up Window
TutorialWindow = createNativeWindow();
TutorialWindow->initWindow();
TutorialWindow->setDisplayCallback(display);
TutorialWindow->setReshapeCallback(reshape);
//Add Key Listener
TutorialKeyListener TheKeyListener;
TutorialWindow->addKeyListener(&TheKeyListener);
//Add Mouse Listeners
TutorialMouseListener TheTutorialMouseListener;
TutorialMouseMotionListener TheTutorialMouseMotionListener;
TutorialWindow->addMouseListener(&TheTutorialMouseListener);
TutorialWindow->addMouseMotionListener(&TheTutorialMouseMotionListener);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
// open window
/* Set up complete, now performing XML import */
BoostPath ExecutableDirectory(argv[0]);
ExecutableDirectory.remove_leaf();
BoostPath FilePath;
if(argc > 1)
{
FilePath = BoostPath(argv[1]);
}
else
{
FilePath = BoostPath("./Data/mayaExport1.xml");
}
if(!boost::filesystem::exists(FilePath))
{
std::cerr << "Could not find file by path: " << FilePath.string() << std::endl;
osgExit();
return -1;
}
// parse XML file to get field container data
FCFileType::FCPtrStore NewContainers;
NewContainers = FCFileHandler::the()->read(FilePath);
// find root node from container, attach update listeners to particle systems
std::vector<NodeRefPtr> RootNodes;
for(FCFileType::FCPtrStore::iterator Itor = NewContainers.begin() ; Itor != NewContainers.end() ; ++Itor)
{
// get root node
if( (*Itor)->getType() == Node::getClassType() &&
dynamic_pointer_cast<Node>(*Itor)->getParent() == NULL)
{
RootNodes.push_back(dynamic_pointer_cast<Node>(*Itor));
}
else if( (*Itor)->getType() == ParticleSystem::getClassType()) //attach update listeners to particle systems present
{
ParticleSystemRefPtr ExampleParticleSystems = dynamic_pointer_cast<ParticleSystem>(*Itor);
ExampleParticleSystems->attachUpdateListener(TutorialWindow);
}
}
// get root node that was extracted from XML file
if(RootNodes.size() > 0)
{
NodeRefPtr scene = RootNodes[0];
// set root node
mgr->setRoot(scene);
}
// Show the whole Scene
mgr->showAll();
mgr->setHeadlight(true);
mgr->getCamera()->setFar(10000);
// main loop
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"15FCFileTypeIO");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
//.........这里部分代码省略.........
示例15: main
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
// Set up Window
TutorialWindowEventProducer = createDefaultWindowEventProducer();
WindowPtr MainWindow = TutorialWindowEventProducer->initWindow();
TutorialWindowEventProducer->setDisplayCallback(display);
TutorialWindowEventProducer->setReshapeCallback(reshape);
TutorialUpdateListener TheTutorialUpdateListener;
TutorialWindowEventProducer->addUpdateListener(&TheTutorialUpdateListener);
//Add Window Listener
TutorialKeyListener TheKeyListener;
TutorialWindowEventProducer->addKeyListener(&TheKeyListener);
TutorialMouseListener TheTutorialMouseListener;
TutorialMouseMotionListener TheTutorialMouseMotionListener;
TutorialWindowEventProducer->addMouseListener(&TheTutorialMouseListener);
TutorialWindowEventProducer->addMouseMotionListener(&TheTutorialMouseMotionListener);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(MainWindow);
//Print key command info
std::cout << "\n\nKEY COMMANDS:" << std::endl;
std::cout << "space Play/Pause the animation" << std::endl;
std::cout << "B Show/Hide the bind pose skeleton" << std::endl;
std::cout << "SHIFT-B Show/Hide the bind pose mesh" << std::endl;
std::cout << "P Show/Hide the current pose skeleton" << std::endl;
std::cout << "SHIFT-P Show/Hide the current pose mesh" << std::endl;
std::cout << "CTRL-Q Exit\n\n" << std::endl;
//Import scene from XML
ChunkMaterialPtr ExampleMaterial;
SkeletonPtr ExampleSkeleton;
SkeletonBlendedGeometryPtr TheNewSkeletonGeometry;
GeometryPtr ExampleGeometry;
FCFileType::FCPtrStore NewContainers;
NewContainers = FCFileHandler::the()->read(Path("./Data/20BlendedGeometry.xml"));
FCFileType::FCPtrStore::iterator Itor;
for(Itor = NewContainers.begin() ; Itor != NewContainers.end() ; ++Itor)
{
if( (*Itor)->getType() == (ChunkMaterial::getClassType()))
{
//Set ExampleMaterial to the ChunkMaterial we just read in
ExampleMaterial = (ChunkMaterial::Ptr::dcast(*Itor));
}
if( (*Itor)->getType() == (Skeleton::getClassType()))
{
//Set ExampleSkeleton to the Skeleton we just read in
ExampleSkeleton = (Skeleton::Ptr::dcast(*Itor));
}
if( (*Itor)->getType() == (Geometry::getClassType()))
{
//Set ExampleGeometry to the geometry we just read in
ExampleGeometry = (Geometry::Ptr::dcast(*Itor));
}
if( (*Itor)->getType() == (SkeletonBlendedGeometry::getClassType()))
{
//Set TheNewSkeletonGeometry to the SkeletonBlendedGeometry we just read in
TheNewSkeletonGeometry = (SkeletonBlendedGeometry::Ptr::dcast(*Itor));
}
if( (*Itor)->getType().isDerivedFrom(Animation::getClassType()))
{
//Set TheSkeletonAnimation to the Animation we just read in
TheSkeletonAnimation = (Animation::Ptr::dcast(*Itor));
}
}
//UnboundGeometry
UnboundGeometry = Node::create();
beginEditCP(UnboundGeometry, Node::CoreFieldMask | Node::TravMaskFieldMask);
UnboundGeometry->setCore(ExampleGeometry);
UnboundGeometry->setTravMask(0);
endEditCP(UnboundGeometry, Node::CoreFieldMask | Node::TravMaskFieldMask);
//SkeletonDrawer
SkeletonDrawablePtr ExampleSkeletonDrawable = osg::SkeletonDrawable::create();
beginEditCP(ExampleSkeletonDrawable, SkeletonDrawable::SkeletonFieldMask | SkeletonDrawable::MaterialFieldMask | SkeletonDrawable::DrawBindPoseFieldMask | SkeletonDrawable::BindPoseColorFieldMask | SkeletonDrawable::DrawPoseFieldMask | SkeletonDrawable::PoseColorFieldMask);
ExampleSkeletonDrawable->setSkeleton(ExampleSkeleton);
ExampleSkeletonDrawable->setMaterial(ExampleMaterial);
ExampleSkeletonDrawable->setDrawBindPose(false); //By default, we don't draw the skeleton's bind pose
ExampleSkeletonDrawable->setBindPoseColor(Color4f(0.0, 1.0, 0.0, 1.0)); //When drawn, the skeleton's bind pose renders in green
ExampleSkeletonDrawable->setDrawPose(true); //By default, we do draw the skeleton's current pose
ExampleSkeletonDrawable->setPoseColor(Color4f(0.0, 0.0, 1.0, 1.0)); //The skeleton's current pose renders in blue
endEditCP(ExampleSkeletonDrawable, SkeletonDrawable::SkeletonFieldMask | SkeletonDrawable::MaterialFieldMask | SkeletonDrawable::DrawBindPoseFieldMask | SkeletonDrawable::BindPoseColorFieldMask | SkeletonDrawable::DrawPoseFieldMask | SkeletonDrawable::PoseColorFieldMask);
//Skeleton Node
SkeletonNode = osg::Node::create();
beginEditCP(SkeletonNode, Node::CoreFieldMask);
//.........这里部分代码省略.........