本文整理汇总了C++中fcfiletype::FCPtrStore类的典型用法代码示例。如果您正苦于以下问题:C++ FCPtrStore类的具体用法?C++ FCPtrStore怎么用?C++ FCPtrStore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FCPtrStore类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:Langkamp,项目名称:OpenSGToolbox,代码行数:27,代码来源:15LoadXMLAnimation.cpp
示例2: handleTreeNodeExport
void handleTreeNodeExport(ActionEventDetails* const details,
Tree* const editorTree)
{
boost::any SelectedComp(editorTree->getLastSelectedPathComponent());
//Get the tree selection
try
{
FieldContainerTreeModel::ContainerFieldIdPair ThePair(boost::any_cast<FieldContainerTreeModel::ContainerFieldIdPair>(SelectedComp));
if(ThePair._FieldID == 0 &&
ThePair._Container != NULL)
{
std::vector<WindowEventProducer::FileDialogFilter> ExportFileFilters;
ExportFileFilters.push_back(WindowEventProducer::FileDialogFilter("Field Container File","xml"));
ExportFileFilters.push_back(WindowEventProducer::FileDialogFilter("All Files","*"));
//Export File
BoostPath InitialFilePath("./Export.xml");
WindowEventProducer* MainWindow(editorTree->getParentWindow()->getParentDrawingSurface()->getEventProducer());
BoostPath ExportFilePath;
ExportFilePath =MainWindow->saveFileDialog("Save Field Container",
ExportFileFilters,
InitialFilePath.filename(),
InitialFilePath.parent_path(),
true);
if(!ExportFilePath.empty())
{
if(ExportFilePath.extension().empty())
{
ExportFilePath = ExportFilePath.string() + ".xml";
}
FCFileType::FCPtrStore Containers;
Containers.insert(ThePair._Container);
FCFileType::FCTypeVector IgnoreTypes;
FCFileHandler::the()->write(Containers,ExportFilePath,IgnoreTypes);
}
}
}
catch(boost::bad_any_cast &ex)
{
SWARNING << ex.what() << std::endl;
}
}
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:49,代码来源:OSGFieldContainerEditorDialog.cpp
示例3: 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);
}
开发者ID:pjcamp,项目名称:KabalaEngine,代码行数:16,代码来源:KECreditsWindow.cpp
示例4: 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;
}
开发者ID:Langkamp,项目名称:OpenSGToolbox,代码行数:21,代码来源:OSGXMLLookAndFeel.cpp
示例5: 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));
}
}
}
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:24,代码来源:03XMLSceneLoader.cpp
示例6: main
//.........这里部分代码省略.........
gridGeo->setNormals(gridNorms);
gridGeo->setColors(gridColors);
// assign a material to the geometry to make it visible. The details
// of materials are defined later.
gridGeo->setMaterial(AxesMaterial);
}
endEditCP (gridGeo, Geometry::TypesFieldMask |
Geometry::LengthsFieldMask |
Geometry::PositionsFieldMask |
Geometry::NormalsFieldMask |
Geometry::MaterialFieldMask |
Geometry::ColorsFieldMask );
//Create unbound geometry Node
Axes = osg::Node::create();
beginEditCP(Axes, Node::CoreFieldMask);
Axes->setCore(axesGeo);
endEditCP(Axes, Node::CoreFieldMask);
//Create unbound geometry Node
Grid = osg::Node::create();
beginEditCP(Grid, Node::CoreFieldMask);
Grid->setCore(gridGeo);
endEditCP(Grid, Node::CoreFieldMask);
//Import scene from an XML file
ChunkMaterialPtr ExampleMaterial;
std::vector<SkeletonPtr> SkeletonPtrs;
std::vector<SkeletonBlendedGeometryPtr> SkeletonBlendedGeometryPtrs;
std::vector<GeometryPtr> GeometryPtrs;
FCFileType::FCPtrStore NewContainers;
NewContainers = FCFileHandler::the()->read(Path("./Data/21SceneFromMaya.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 TheSkeletonAnimation to the Animation we just read in
TheSkeletonAnimation = (Animation::Ptr::dcast(*Itor));
}
if( (*Itor)->getType() == (Geometry::getClassType()))
{
//Add the Geometry we just read in to GeometryPtrs
GeometryPtrs.push_back(Geometry::Ptr::dcast(*Itor));
}
}
//Create unbound geometry Node (to show the mesh in its bind pose)
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:67,代码来源:21LoadXMLSceneFromMaya.cpp
示例7: 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;
}
开发者ID:Langkamp,项目名称:OpenSGToolbox,代码行数:80,代码来源:04XMLSoundLoading.cpp
示例8: 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());
}
//.........这里部分代码省略.........
开发者ID:Langkamp,项目名称:OpenSGToolbox,代码行数:101,代码来源:01LoadFBO.cpp
示例9: main
int main(int argc, char **argv)
{
// 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);
TutorialWindow->connectKeyTyped(boost::bind(keyPressed, _1));
NodeRecPtr Root(NULL);
if(argc == 2)
{
Root = SceneFileHandler::the()->read(argv[1]);
}
if(Root == NULL)
{
// Make Torus Node (creates Torus in background of Root)
NodeRecPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);
NodeRecPtr TorusNode = Node::create();
TorusNode->setCore(Transform::create());
TorusNode->addChild(TorusGeometryNode);
NodeRecPtr SphereGeometryNode = makeSphere(2,1.0f);
NodeRecPtr BoxGeometryNode = makeBox(1.0,1.0,1.0,1,1,1);
// Make Main Scene Node and add the Torus
Root = Node::create();
Root->setCore(Group::create());
Root->addChild(TorusNode);
Root->addChild(SphereGeometryNode);
Root->addChild(BoxGeometryNode);
}
// Create the Graphics
GraphicsRecPtr TutorialGraphics = Graphics2D::create();
// Initialize the LookAndFeelManager to enable default settings
LookAndFeelManager::the()->getLookAndFeel()->init();
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRecPtr MainInternalWindowBackground = ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
LayoutRecPtr MainInternalWindowLayout = FlowLayout::create();
//Import InternalWindow(s) from XML file
std::vector<InternalWindowRecPtr> StoreWindows;
FCFileType::FCPtrStore NewContainers;
NewContainers = FCFileHandler::the()->read(BoostPath("./Data/55ComponentTree.xml"));
//Store each window found in the XML in the vector
FCFileType::FCPtrStore::iterator Itor;
for(Itor = NewContainers.begin(); Itor != NewContainers.end(); ++Itor)
{
if( (*Itor)->getType() == (InternalWindow::getClassType()))
{
StoreWindows.push_back(dynamic_pointer_cast<InternalWindow>(*Itor));
}
}
//Tree Model
FieldContainerTreeModelRecPtr TheTreeModel = FieldContainerTreeModel::create();
TheTreeModel->setRoot(StoreWindows.front());
//TheTreeModel->setShowPtrFields(false);
//TheTreeModel->setShowDataFields(false);
//TheTreeModel->setShowParentPtrFields(false);
//TheTreeModel->setShowChildPtrFields(false);
TheTreeModel->setShowAttachments(false);
//TheTreeModel->setShowCallbackFunctors(false);
//Tree Component Generator
FieldContainerFieldPathComponentGeneratorRecPtr TheTreeComponentGenerator = FieldContainerFieldPathComponentGenerator::create();
//Create the Tree
TreeRecPtr TheTree = Tree::create();
TheTree->setPreferredSize(Vec2f(100, 500));
TheTree->setRootVisible(true);
TheTree->setModel(TheTreeModel);
TheTree->setCellGenerator(TheTreeComponentGenerator);
setName(TheTree, std::string("TheTree"));
// Create a ScrollPanel for easier viewing of the List (see 27ScrollPanel)
ScrollPanelRecPtr ExampleScrollPanel = ScrollPanel::create();
ExampleScrollPanel->setPreferredSize(Vec2f(350,500));
//ExampleScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
//.........这里部分代码省略.........
开发者ID:achvas88,项目名称:OpenSGToolbox,代码行数:101,代码来源:56FieldContainerTree.cpp
示例10: 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();
//.........这里部分代码省略.........
开发者ID:danguilliams,项目名称:OpenSGToolbox,代码行数:101,代码来源:14SkeletonLoader.cpp
示例11: 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();
//.........这里部分代码省略.........
开发者ID:danguilliams,项目名称:OpenSGToolbox,代码行数:101,代码来源:15FCFileTypeIO.cpp
示例12: main
//.........这里部分代码省略.........
Vec3f(1.0,1.0,1.0),
-1,
Vec3f(0.0,0.0,0.0),
Vec3f(0.0,0.0,0.0));
ExampleParticleSystem->addParticle(Pnt3f(40.0,0.0,0.0),
Vec3f(0.0,1.0,0.0),
Color4f(1.0,1.0,1.0,1.0),
Vec3f(1.0,1.0,1.0),
-1,
Vec3f(0.0,0.0,0.0),
Vec3f(0.0,0.0,0.0));
PointParticleSystemDrawerRecPtr ExamplePointParticleSystemDrawer = PointParticleSystemDrawer::create();
ExamplePointParticleSystemDrawer->setForcePerParticleSizing(false);
Matrix ExampleMatrix;
ExampleMatrix.setTransform(Vec3f(10.0,10.0,10.0));
TransformRefPtr ExampleXform = Transform::create();
ExampleXform->setMatrix(ExampleMatrix);
NodeRefPtr ExampleNode = Node::create();
ExampleNode->setCore(ExampleXform);
RateParticleGeneratorRecPtr ExampleGenerator = RateParticleGenerator::create();
// ExampleGenerator->setEmitInWorldSpace(true);
ExampleGenerator->setBeacon(ExampleNode);
ExampleGenerator->setGenerationRate(5.0);
ExampleGenerator->setPositionDistribution(createPositionDistribution());
ExampleGenerator->setLifespanDistribution(createLifespanDistribution());
NewtonParticleAffectorRefPtr ExampleAffector = NewtonParticleAffector::create();
ExampleAffector->setBeacon(ExampleNode);
ExampleAffector->setMaxDistance(-1.0);
ConditionalParticleAffectorRecPtr ExampleConditionalAffector = ConditionalParticleAffector::create();
ExampleConditionalAffector->setConditionalAttribute("active");
ExampleConditionalAffector->setConditionalOperator(4); //greater than
ExampleConditionalAffector->setConditionalValue(0); // testing if the value associated with "test" = 1
ExampleConditionalAffector->pushToAffectors(ExampleAffector);
DistanceAttractRepelParticleAffectorRefPtr ExampleAttractRepelAffector = DistanceAttractRepelParticleAffector::create();
ExampleAttractRepelAffector->setDistanceFromSource(DistanceParticleAffector::DISTANCE_FROM_NODE);
//Attach the Generators and affectors to the Particle System
ExampleParticleSystem->setBeacon(ExampleNode);
//ExampleParticleSystem->pushToGenerators(ExampleGenerator);
ExampleParticleSystem->pushToAffectors(ExampleConditionalAffector);
// ExampleParticleSystem->pushToAffectors(ExampleAttractRepelAffector);
ExampleParticleSystem->setMaxParticles(1000);
ExampleParticleSystem->setDynamic(true);
//Particle System Core
ParticleSystemCoreRecPtr ParticleNodeCore = ParticleSystemCore::create();
ParticleNodeCore->setSystem(ExampleParticleSystem);
ParticleNodeCore->setDrawer(ExamplePointParticleSystemDrawer);
ParticleNodeCore->setMaterial(PSMaterial);
ParticleNodeCore->setSortingMode(ParticleSystemCore::BACK_TO_FRONT);
NodeRefPtr PSNode = Node::create();
PSNode->setCore(ParticleNodeCore);
// Make Main Scene Node and add the Torus
NodeRefPtr scene = Node::create();
scene->setCore(Group::create());
scene->addChild(PSNode);
TutorialWindow->connectKeyTyped(boost::bind(keyTyped, _1, &sceneManager,
ParticleNodeCore.get(),
ExamplePointParticleSystemDrawer.get(),
ExampleParticleSystem.get(),
ExampleConditionalAffector.get()));
sceneManager.setRoot(scene);
// Show the whole Scene
sceneManager.showAll();
sceneManager.getCamera()->setFar(1000.0);
sceneManager.getCamera()->setNear(0.10);
FCFileType::FCPtrStore Containers;
Containers.insert(scene);
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"16FullTest");
//Enter main Loop
TutorialWindow->mainLoop();
}
osgExit();
return 0;
}
开发者ID:ahuballah,项目名称:OpenSGToolbox,代码行数:101,代码来源:16FullTest.cpp
示例13: main
//.........这里部分代码省略.........
ExampleSkeleton->addJointBlending(36,RightHand,1.0f);
ExampleSkeleton->addJointBlending(37,RightHand,1.0f);
ExampleSkeleton->addJointBlending(38,RightFingers,1.0f);
ExampleSkeleton->addJointBlending(39,RightFingers,1.0f);
//Left Hip
ExampleSkeleton->addJointBlending(40,Pelvis,1.0f);
ExampleSkeleton->addJointBlending(41,Pelvis,1.0f);
ExampleSkeleton->addJointBlending(42,LeftHip,1.0f);
ExampleSkeleton->addJointBlending(43,LeftHip,1.0f);
//Left Femur
ExampleSkeleton->addJointBlending(44,LeftHip,1.0f);
ExampleSkeleton->addJointBlending(45,LeftHip,1.0f);
ExampleSkeleton->addJointBlending(46,LeftKnee,1.0f);
ExampleSkeleton->addJointBlending(47,LeftKnee,1.0f);
//Left Tibia
ExampleSkeleton->addJointBlending(48,LeftKnee,1.0f);
ExampleSkeleton->addJointBlending(49,LeftKnee,1.0f);
ExampleSkeleton->addJointBlending(50,LeftFoot,1.0f);
ExampleSkeleton->addJointBlending(51,LeftFoot,1.0f);
//Left Foot
ExampleSkeleton->addJointBlending(52,LeftFoot,1.0f);
ExampleSkeleton->addJointBlending(53,LeftFoot,1.0f);
ExampleSkeleton->addJointBlending(54,LeftToes,1.0f);
ExampleSkeleton->addJointBlending(55,LeftToes,1.0f);
//Right Hip
ExampleSkeleton->addJointBlending(56,Pelvis,1.0f);
ExampleSkeleton->addJointBlending(57,Pelvis,1.0f);
ExampleSkeleton->addJointBlending(58,RightHip,1.0f);
ExampleSkeleton->addJointBlending(59,RightHip,1.0f);
//Right Femur
ExampleSkeleton->addJointBlending(60,RightHip,1.0f);
ExampleSkeleton->addJointBlending(61,RightHip,1.0f);
ExampleSkeleton->addJointBlending(62,RightKnee,1.0f);
ExampleSkeleton->addJointBlending(63,RightKnee,1.0f);
//Right Tibia
ExampleSkeleton->addJointBlending(64,RightKnee,1.0f);
ExampleSkeleton->addJointBlending(65,RightKnee,1.0f);
ExampleSkeleton->addJointBlending(66,RightFoot,1.0f);
ExampleSkeleton->addJointBlending(67,RightFoot,1.0f);
//Right Foot
ExampleSkeleton->addJointBlending(68,RightFoot,1.0f);
ExampleSkeleton->addJointBlending(69,RightFoot,1.0f);
ExampleSkeleton->addJointBlending(70,RightToes,1.0f);
ExampleSkeleton->addJointBlending(71,RightToes,1.0f);
MeshNode = Node::create();
MeshNode->setCore(ExampleSkeleton);
//Create scene node
NodeUnrecPtr scene = Node::create();
scene->setCore(Group::create());
scene->addChild(UnboundGeometry);
scene->addChild(SkeletonNode);
scene->addChild(MeshNode);
mgr->setRoot(scene);
//Setup the Animation
setupAnimation();
//Save to an xml file
FCFileType::FCPtrStore Containers;
Containers.insert(ExampleSkeleton);
Containers.insert(PelvisNode);
Containers.insert(TheSkeletonAnimation);
//Use an empty Ignore types vector
FCFileType::FCTypeVector IgnoreTypes;
//IgnoreTypes.push_back(Node::getClassType().getId());
//Write the Field Containers to a xml file
FCFileHandler::the()->write(Containers,BoostPath("./13Output.xml"),IgnoreTypes);
// Show the whole Scene
mgr->showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"13MeshBlending");
//Main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
开发者ID:msteners,项目名称:OpenSGToolbox,代码行数:101,代码来源:13MeshBlending.cpp
示例14: 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);
//.........这里部分代码省略.........
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:101,代码来源:20LoadXMLBlendedGeometry.cpp
示例15: 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;
}
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:68,代码来源:04Xml2Osb.cpp
示例16: 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]);
|
请发表评论