本文整理汇总了C++中WindowEventProducerPtr类的典型用法代码示例。如果您正苦于以下问题:C++ WindowEventProducerPtr类的具体用法?C++ WindowEventProducerPtr怎么用?C++ WindowEventProducerPtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WindowEventProducerPtr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: keyPressed
virtual void keyPressed(const KeyEventPtr e)
{
if(e->getKey() == KeyEvent::KEY_Q && e->getModifiers() & KeyEvent::KEY_MODIFIER_COMMAND)
{
TutorialWindowEventProducer->closeWindow();
}
switch(e->getKey())
{
case KeyEvent::KEY_S:
{
buildSphere();
}
break;
case KeyEvent::KEY_B:
{
buildBox();
}
break;
case KeyEvent::KEY_Z:
{
//SceneFileHandler::the().write(rootNode, "scene.osb");
}
break;
case KeyEvent::KEY_T:
{
buildTriMesh();
}
break;
}
}
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:30,代码来源:21Collisions.cpp
示例2: keyPressed
virtual void keyPressed(const KeyEventPtr e)
{
if(e->getKey() == KeyEvent::KEY_Q && e->getModifiers() & KeyEvent::KEY_MODIFIER_CONTROL)
{
TutorialWindowEventProducer->closeWindow();
}
}
开发者ID:Langkamp,项目名称:OpenSGToolbox,代码行数:7,代码来源:11InventoryMultiClasses.cpp
示例3: keyPressed
virtual void keyPressed(const KeyEventPtr e)
{
if(e->getKey() == KeyEvent::KEY_Q && e->getModifiers() & KeyEvent::KEY_MODIFIER_COMMAND)
{
TutorialWindowEventProducer->closeWindow();
}
switch(e->getKey())
{
case KeyEvent::KEY_T:
break;
}
}
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:13,代码来源:01LoadFBO.cpp
示例4: keyPressed
virtual void keyPressed(const KeyEventPtr e)
{
if(e->getKey() == KeyEvent::KEY_Q && e->getModifiers() & KeyEvent::KEY_MODIFIER_CONTROL)
{
TutorialWindowEventProducer->closeWindow();
}
if(e->getKey() == KeyEvent::KEY_T)
{
std::cout << "toggling" << std::endl;
//TheAnimcationAdvancer->stop();
}
}
开发者ID:Langkamp,项目名称:OpenSGToolbox,代码行数:14,代码来源:24AnimationAction.cpp
示例5: keyPressed
virtual void keyPressed(const KeyEventPtr e)
{
if(e->getKey() == KeyEvent::KEY_Q && e->getModifiers() & KeyEvent::KEY_MODIFIER_CONTROL)
{
TutorialWindowEventProducer->closeWindow();
}
switch(e->getKey())
{
case KeyEvent::KEY_S:
statFlag = !statFlag;
mgr->setStatistics(statFlag);
break;
case KeyEvent::KEY_EQUALS:
{
Vec3f Translation;
Quaternion Rotation;
Vec3f Scale;
Quaternion ScaleOrient;
Matrix ThePointLightMat = ThePointLightBeaconTransform->getMatrix();
ThePointLightMat.getTransform(Translation,Rotation,Scale,ScaleOrient);
Translation = Translation + Vec3f(0.0,10.0,0.0);
ThePointLightMat.setTranslate(Translation);
beginEditCP(ThePointLightBeaconTransform);
ThePointLightBeaconTransform->setMatrix(ThePointLightMat);
endEditCP(ThePointLightBeaconTransform);
}
break;
case KeyEvent::KEY_MINUS:
{
Vec3f Translation;
Quaternion Rotation;
Vec3f Scale;
Quaternion ScaleOrient;
Matrix ThePointLightMat = ThePointLightBeaconTransform->getMatrix();
ThePointLightMat.getTransform(Translation,Rotation,Scale,ScaleOrient);
Translation = Translation + Vec3f(0.0,-10.0,0.0);
ThePointLightMat.setTranslate(Translation);
beginEditCP(ThePointLightBeaconTransform);
ThePointLightBeaconTransform->setMatrix(ThePointLightMat);
endEditCP(ThePointLightBeaconTransform);
}
break;
case KeyEvent::KEY_T:
beginEditCP(TheBlinnMat, BlinnMaterial::DiffuseTextureFieldMask);
endEditCP(TheBlinnMat, BlinnMaterial::DiffuseTextureFieldMask);
break;
}
}
开发者ID:Langkamp,项目名称:OpenSGToolbox,代码行数:49,代码来源:06Heightmap.cpp
示例6: keyPressed
virtual void keyPressed(const KeyEventPtr e)
{
if(e->getKey() == KeyEvent::KEY_Q && e->getModifiers() & KeyEvent::KEY_MODIFIER_COMMAND)
{
TutorialWindowEventProducer->closeWindow();
}
float TranslateAmount(0.05f);
float RotateAmount(0.1f);
switch(e->getKey())
{
default:
break;
}
}
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:16,代码来源:01RubberBandCamera.cpp
示例7: 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
示例8: 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()))
//.........这里部分代码省略.........
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:101,代码来源:23BlendXMLAnimations.cpp
示例9: keyPressed
virtual void keyPressed(const KeyEventPtr e)
{
//Exit
if(e->getKey() == KeyEvent::KEY_Q && e->getModifiers() & KeyEvent::KEY_MODIFIER_COMMAND)
{
TutorialWindowEventProducer->closeWindow();
}
//Toggle animation
if(e->getKey() == KeyEvent::KEY_SPACE)
{
if(animationPaused)
animationPaused = false;
else
animationPaused = true;
}
//Toggle bind pose
if(e->getKey() == KeyEvent::KEY_B)
{
if(e->getModifiers() & KeyEvent::KEY_MODIFIER_SHIFT)
{
//Toggle mesh
for(int i(0); i < UnboundGeometries.size(); ++i)
{
if(UnboundGeometries[i]->getTravMask() == 0)
{
beginEditCP(UnboundGeometries[i], Node::TravMaskFieldMask);
UnboundGeometries[i]->setTravMask(1);
endEditCP(UnboundGeometries[i], Node::TravMaskFieldMask);
}
else
{
beginEditCP(UnboundGeometries[i], Node::TravMaskFieldMask);
UnboundGeometries[i]->setTravMask(0);
endEditCP(UnboundGeometries[i], Node::TravMaskFieldMask);
}
}
}
else
{
//Toggle skeleton
for(int i(0); i < SkeletonNodes.size(); ++i)
{
if(SkeletonDrawable::Ptr::dcast(SkeletonNodes[i]->getCore())->getDrawBindPose() == false)
{
beginEditCP(SkeletonDrawable::Ptr::dcast(SkeletonNodes[i]->getCore()), SkeletonDrawable::DrawBindPoseFieldMask);
SkeletonDrawable::Ptr::dcast(SkeletonNodes[i]->getCore())->setDrawBindPose(true);
endEditCP(SkeletonDrawable::Ptr::dcast(SkeletonNodes[i]->getCore()), SkeletonDrawable::DrawBindPoseFieldMask);
}
else
{
beginEditCP(SkeletonDrawable::Ptr::dcast(SkeletonNodes[i]->getCore()), SkeletonDrawable::DrawBindPoseFieldMask);
SkeletonDrawable::Ptr::dcast(SkeletonNodes[i]->getCore())->setDrawBindPose(false);
endEditCP(SkeletonDrawable::Ptr::dcast(SkeletonNodes[i]->getCore()), SkeletonDrawable::DrawBindPoseFieldMask);
}
}
}
}
//Toggle current pose
if(e->getKey() == KeyEvent::KEY_P)
{
if(e->getModifiers() & KeyEvent::KEY_MODIFIER_SHIFT)
{
//Toggle mesh
for(int i(0); i < MeshNodes.size(); ++i)
{
if(MeshNodes[i]->getTravMask() == 0)
{
beginEditCP(MeshNodes[i], Node::TravMaskFieldMask);
MeshNodes[i]->setTravMask(1);
endEditCP(MeshNodes[i], Node::TravMaskFieldMask);
}
else
{
beginEditCP(MeshNodes[i], Node::TravMaskFieldMask);
MeshNodes[i]->setTravMask(0);
endEditCP(MeshNodes[i], Node::TravMaskFieldMask);
}
}
}
else
{
//Toggle skeleton
for(int i(0); i < SkeletonNodes.size(); ++i)
{
if(SkeletonDrawable::Ptr::dcast(SkeletonNodes[i]->getCore())->getDrawPose() == false)
{
beginEditCP(SkeletonDrawable::Ptr::dcast(SkeletonNodes[i]->getCore()), SkeletonDrawable::DrawPoseFieldMask);
SkeletonDrawable::Ptr::dcast(SkeletonNodes[i]->getCore())->setDrawPose(true);
endEditCP(SkeletonDrawable::Ptr::dcast(SkeletonNodes[i]->getCore()), SkeletonDrawable::DrawPoseFieldMask);
}
else
{
beginEditCP(SkeletonDrawable::Ptr::dcast(SkeletonNodes[i]->getCore()), SkeletonDrawable::DrawPoseFieldMask);
SkeletonDrawable::Ptr::dcast(SkeletonNodes[i]->getCore())->setDrawPose(false);
endEditCP(SkeletonDrawable::Ptr::dcast(SkeletonNodes[i]->getCore()), SkeletonDrawable::DrawPoseFieldMask);
}
//.........这里部分代码省略.........
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:101,代码来源:23BlendXMLAnimations.cpp
示例10: 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);
TutorialKeyListener TheKeyListener;
TutorialWindowEventProducer->addKeyListener(&TheKeyListener);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(MainWindow);
// Make Torus Node (creates Torus in background of scene)
NodePtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);
// Make Main Scene Node and add the Torus
NodePtr scene = osg::Node::create();
beginEditCP(scene, Node::CoreFieldMask | Node::ChildrenFieldMask);
scene->setCore(osg::Group::create());
scene->addChild(TorusGeometryNode);
endEditCP(scene, Node::CoreFieldMask | Node::ChildrenFieldMask);
//Create the Image
Path ImagePath("./Data/TutorialImage.jpg");
ImagePtr TheImage = ImageFileHandler::the().read(ImagePath.string().c_str());
//Create the texture
TextureChunkPtr TheTextureChunk = TextureChunk::create();
beginEditCP(TheTextureChunk);
TheTextureChunk->setImage(TheImage);
TheTextureChunk->setMinFilter(GL_NEAREST);
TheTextureChunk->setMagFilter(GL_NEAREST);
TheTextureChunk->setWrapS(GL_CLAMP_TO_EDGE);
TheTextureChunk->setWrapR(GL_CLAMP_TO_EDGE);
TheTextureChunk->setScale(false);
TheTextureChunk->setNPOTMatrixScale(true);
TheTextureChunk->setEnvMode(GL_REPLACE);
endEditCP(TheTextureChunk);
//Create a Texture Source
TextureSourceTextureFilterPtr TutorialTextureSourceTextureFilter = TextureSourceTextureFilter::create();
beginEditCP(TutorialTextureSourceTextureFilter, TextureSourceTextureFilter::TextureFieldMask);
TutorialTextureSourceTextureFilter->setTexture(TheTextureChunk);
endEditCP(TutorialTextureSourceTextureFilter, TextureSourceTextureFilter::TextureFieldMask);
//Create a Grayscale filter
std::string GrayScaleFragProg = "uniform sampler2D Slot0Texture; void main() { gl_FragColor = vec4(vec3( dot(vec3(0.3,0.59,0.11), texture2D(Slot0Texture,gl_TexCoord[0].st).rgb)), 1.0); }";
//Create a shader Filter
ShaderTextureFilterPtr GrayscaleTextureFilter = ShaderTextureFilter::create();
GrayscaleTextureFilter->attachSource(TutorialTextureSourceTextureFilter, 0, 0);
GrayscaleTextureFilter->setFragmentSource(GrayScaleFragProg);
//Create a Color Mult filter
std::string ColorMultFragProg = "uniform sampler2D Slot0Texture; void main() { gl_FragColor = vec4(vec3(1.0,0.0,0.0) * texture2D(Slot0Texture,gl_TexCoord[0].st).rgb, 1.0); }";
//Create a shader Filter
ShaderTextureFilterPtr ColorMultTextureFilter = ShaderTextureFilter::create();
ColorMultTextureFilter->attachSource(GrayscaleTextureFilter,0,0);
ColorMultTextureFilter->setFragmentSource(ColorMultFragProg);
////Create a Blur filter
//std::string BlurFragProg = "";
//BlurFragProg +=
//"uniform sampler2D Slot0Texture;"
//"void main()"
//"{"
//" vec2 offsets[9];"
//" offsets[0] = vec2(-0.000625,0.00111111111);"
//" offsets[1] = vec2(0.0,0.00111111111);"
//" offsets[2] = vec2(0.000625,0.00111111111);"
//" offsets[3] = vec2(-0.000625,0.0);"
//" offsets[4] = vec2(0.0,0.0);"
//" offsets[5] = vec2(0.0,0.0);"
//" offsets[6] = vec2(-0.000625,-0.00111111111);"
//" offsets[7] = vec2(0.0,-0.00111111111);"
//" offsets[8] = vec2(0.000625,-0.00111111111);"
//" vec4 kernel[9];"
////" kernel[0] = vec4(0.0);"
////" kernel[1] = vec4(0.0);"
////" kernel[2] = vec4(0.0);"
////" kernel[3] = vec4(0.0);"
////" kernel[4] = vec4(1.0);"
////" kernel[5] = vec4(0.0);"
////" kernel[6] = vec4(0.0);"
//.........这里部分代码省略.........
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:101,代码来源:02SimpleImagePipeline.cpp
示例11: main
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
TutorialWindowEventProducer = createDefaultWindowEventProducer();
WindowPtr MainWindow = TutorialWindowEventProducer->initWindow();
TutorialWindowEventProducer->setDisplayCallback(display);
TutorialWindowEventProducer->setReshapeCallback(reshape);
TutorialKeyListener TheKeyListener;
TutorialWindowEventProducer->addKeyListener(&TheKeyListener);
// Make Torus Node (creates Torus in background of scene)
NodePtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);
// Make Main Scene Node and add the Torus
NodePtr scene = osg::Node::create();
beginEditCP(scene, Node::CoreFieldMask | Node::ChildrenFieldMask);
scene->setCore(osg::Group::create());
scene->addChild(TorusGeometryNode);
endEditCP(scene, Node::CoreFieldMask | Node::ChildrenFieldMask);
// Create the Graphics
GraphicsPtr TutorialGraphics = osg::Graphics2D::create();
// Initialize the LookAndFeelManager to enable default settings
LookAndFeelManager::the()->getLookAndFeel()->init();
//Create InventoryItems
ExampleInventory = Inventory::create();
GenericInventoryItemPtr ExampleItem1 = GenericInventoryItem::create();
GenericInventoryItemPtr ExampleItem2 = GenericInventoryItem::create();
GenericInventoryItemPtr ExampleItem3 = GenericInventoryItem::create();
GenericInventoryItemPtr ExampleItem4 = GenericInventoryItem::create();
GenericInventoryItemPtr ExampleItem5 = GenericInventoryItem::create();
GenericInventoryItemPtr ExampleItem6 = GenericInventoryItem::create();
GenericInventoryItemPtr ExampleItem7 = GenericInventoryItem::create();
beginEditCP(ExampleItem1, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask);
ExampleItem1->setName(std::string("David K"));
ExampleItem1->setDetails(std::string("Major: Human Computer Interaction \nDegree: PhD \nDepartment: Computer Science \nCollege: LAS"));
endEditCP(ExampleItem1, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask);
beginEditCP(ExampleItem2, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask);
ExampleItem2->setName(std::string("Eve W"));
ExampleItem2->setDetails(std::string("Department: Genetics Development and Cell Biology\n\nCollege: Agriculture"));
endEditCP(ExampleItem2, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask);
beginEditCP(ExampleItem3, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask);
ExampleItem3->setName(std::string("Will S"));
ExampleItem3->setDetails(std::string("Major: Art And Design\nDegree: BFA\nDepartment: Art and Design\nCollege: Design"));
endEditCP(ExampleItem3, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask);
beginEditCP(ExampleItem4, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask);
ExampleItem4->setName(std::string("Eric L"));
ExampleItem4->setDetails(std::string("Major: Software Engineering\nDegree: BS\nDepartment: Software Engineering\nCollege: Engineering"));
endEditCP(ExampleItem4, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask);
beginEditCP(ExampleItem5, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask);
ExampleItem5->setName(std::string("Jeffery F"));
ExampleItem5->setDetails(std::string("Major: Integrated Studio Arts\nDegree: BFA\nDepartment: Art and Design\nCollege: Design"));
endEditCP(ExampleItem5, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask);
beginEditCP(ExampleItem6, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask);
ExampleItem6->setName(std::string("Tao L"));
ExampleItem6->setDetails(std::string("Major: Computer Engineering\nDegree: PhD\nDepartment: Computer Engineering\nCollege: Engineering"));
endEditCP(ExampleItem6, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask);
beginEditCP(ExampleItem7, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask);
ExampleItem7->setName(std::string("Daniel G"));
ExampleItem7->setDetails(std::string("Major: Computer Engineering\nDegree: BS\nDepartment: Computer Engineering\nCollege: Engineering"));
endEditCP(ExampleItem7, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask);
ExampleInventory->addItem(ExampleItem1);
ExampleInventory->addItem(ExampleItem2);
ExampleInventory->addItem(ExampleItem3);
ExampleInventory->addItem(ExampleItem4);
ExampleInventory->addItem(ExampleItem5);
ExampleInventory->addItem(ExampleItem6);
ExampleInventory->addItem(ExampleItem7);
/******************************************************
Create a List. A List has several
parts to it:
-ListModel: Contains the data which is to be
displayed in the List. Data is added
as shown below
-ListCellRenderer: Creates the Components to
be used within the List (the default
setting is to create Labels using
the desired text).
-ListSelectionModel: Determines how
the List may be selected.
To add values to the list:
//.........这里部分代码省略.........
开发者ID:Langkamp,项目名称:OpenSGToolbox,代码行数:101,代码来源:11InventoryMultiClasses.cpp
示例12: 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
//.........这里部分代码省略.........
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:101,代码来源:21LoadXMLSceneFromMaya.cpp
示例13: 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);
TutorialKeyListener TheKeyListener;
TutorialWindowEventProducer->addKeyListener(&TheKeyListener);
TutorialUpdateListener TheUpdateListener;
TutorialWindowEventProducer->addUpdateListener(&TheUpdateListener);
// Create the SceneManager
mgr = new SceneManager;
// Tell the Manager what to manage
mgr->setWindow(MainWindow);
// Make Torus Node (creates Torus in background of scene)
NodePtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);
// Make Torus Node (creates Torus in background of scene)
NodePtr BoxGeometryNode = makeBox(0.5,0.5,0.5,50,2,2);
//Set the Camera Beacon Node
Matrix Offset;
//Offset.setTranslate(0.0f,2.5f,6.0f);
Offset.setTranslate(0.0f,0.0,6.0f);
CameraBeaconTransform = Transform::create();
beginEditCP(CameraBeaconTransform, Transform::MatrixFieldMask);
CameraBeaconTransform->setMatrix(Offset);
endEditCP(CameraBeaconTransform, Transform::MatrixFieldMask);
NodePtr CameraBeaconNode = Node::create();
beginEditCP(CameraBeaconNode, Node::CoreFieldMask | Node::ChildrenFieldMask);
CameraBeaconNode->setCore(CameraBeaconTransform);
endEditCP(CameraBeaconNode, Node::CoreFieldMask | Node::ChildrenFieldMask);
//Set the Box Transform Node
BoxTransform = Transform::create();
NodePtr BoxNode = Node::create();
beginEditCP(BoxNode, Node::CoreFieldMask | Node::ChildrenFieldMask);
BoxNode->setCore(BoxTransform);
BoxNode->addChild(BoxGeometryNode);
BoxNode->addChild(CameraBeaconNode);
endEditCP(BoxNode, Node::CoreFieldMask | Node::ChildrenFieldMask);
// Make Main Scene Node and add the Torus
NodePtr scene = osg::Node::create();
beginEditCP(scene, Node::CoreFieldMask | Node::ChildrenFieldMask);
scene->setCore(osg::Group::create());
scene->addChild(TorusGeometryNode);
scene->addChild(BoxNode);
endEditCP(scene, Node::CoreFieldMask | Node::ChildrenFieldMask);
//Set the Root node to the Scene Manager
mgr->setRoot(scene);
//The perspective decoratee camera
CameraPtr PCamera = PerspectiveCamera::create();
beginEditCP(PerspectiveCameraPtr::dcast(PCamera));
PerspectiveCameraPtr::dcast(PCamera)->setBeacon(CameraBeaconNode);
PerspectiveCameraPtr::dcast(PCamera)->setFov (deg2rad(60.f));
PerspectiveCameraPtr::dcast(PCamera)->setNear (0.1f);
PerspectiveCameraPtr::dcast(PCamera)->setFar (10000.f);
endEditCP(PerspectiveCameraPtr::dcast(PCamera));
//Create the Rubber band Camera
Vec3f PositionCoefficients(0.1,1.5,1.5);
Vec3f OrientationCoefficients(0.1,2.5,2.5);
RubberCamera = RubberBandCamera::create();
beginEditCP(RubberCamera, RubberBandCamera::DecorateeFieldMask | RubberBandCamera::BeaconFieldMask | RubberBandCamera::PositionCoefficientsFieldMask | RubberBandCamera::OrientationCoefficientsFieldMask);
RubberCamera->setDecoratee(PCamera);
RubberCamera->setBeacon(CameraBeaconNode);
RubberCamera->setPositionCoefficients(PositionCoefficients);
RubberCamera->setOrientationCoefficients(OrientationCoefficients);
endEditCP(RubberCamera, RubberBandCamera::DecorateeFieldMask | RubberBandCamera::BeaconFieldMask | RubberBandCamera::PositionCoefficientsFieldMask | RubberBandCamera::OrientationCoefficientsFieldMask);
RubberCamera->setToBeacon();
mgr->setCamera(RubberCamera);
// Show the whole Scene
//mgr->showAll();
//Open Window
Vec2f WinSize(TutorialWindowEventProducer->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindowEventProducer->getDesktopSize() - WinSize) *0.5);
TutorialWindowEventProducer->openWindow(WinPos,
WinSize,
"01RubberBandCamera");
//Enter main Loop
//.........这里部分代码省略.........
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:101,代码来源:01RubberBandCamera.cpp
示例14: keyPressed
virtual void keyPressed(const KeyEventPtr e)
{
//Exit
if(e->getKey() == KeyEvent::KEY_Q && e->getModifiers() & KeyEvent::KEY_MODIFIER_COMMAND)
{
TutorialWindowEventProducer->closeWindow();
}
//Toggle animation
if(e->getKey() == KeyEvent::KEY_SPACE)
{
if(animationPaused)
animationPaused = false;
else
animationPaused = true;
}
//Toggle bind pose
if(e->getKey() == KeyEvent::KEY_B)
{
if(e->getModifiers() & KeyEvent::KEY_MODIFIER_SHIFT)
{
//Toggle mesh
if(UnboundGeometry->getTravMask() == 0)
{
beginEditCP(UnboundGeometry, Node::TravMaskFieldMask);
UnboundGeometry->setTravMask(1);
endEditCP(UnboundGeometry, Node::TravMaskFieldMask);
}
else
{
beginEditCP(UnboundGeometry, Node::TravMaskFieldMask);
UnboundGeometry->setTravMask(0);
endEditCP(UnboundGeometry, Node::TravMaskFieldMask);
}
}
else
{
//Toggle skeleton
if(SkeletonDrawable::Ptr::dcast(SkeletonNode->getCore())->getDrawBindPose() == false)
{
beginEditCP(SkeletonDrawable::Ptr::dcast(SkeletonNode->getCore()), SkeletonDrawable::DrawBindPoseFieldMask);
SkeletonDrawable::Ptr::dcast(SkeletonNode->getCore())->setDrawBindPose(true);
endEditCP(SkeletonDrawable::Ptr::dcast(SkeletonNode->getCore()), SkeletonDrawable::DrawBindPoseFieldMask);
}
else
{
beginEditCP(SkeletonDrawable::Ptr::dcast(SkeletonNode->getCore()), SkeletonDrawable::DrawBindPoseFieldMask);
SkeletonDrawable::Ptr::dcast(SkeletonNode->getCore())->setDrawBindPose(false);
endEditCP(SkeletonDrawable::Ptr::dcast(SkeletonNode->getCore()), SkeletonDrawable::DrawBindPoseFieldMask);
}
}
}
//Toggle current pose
if(e->getKey() == KeyEvent::KEY_P)
{
if(e->getModifiers() & KeyEvent::KEY_MODIFIER_SHIFT)
{
//Toggle mesh
if(MeshNode->getTravMask() == 0)
{
beginEditCP(MeshNode, Node::TravMaskFieldMask);
MeshNode->setTravMask(1);
endEditCP(MeshNode, Node::TravMaskFieldMask);
}
else
{
beginEditCP(MeshNode, Node::TravMaskFieldMask);
MeshNode->setTravMask(0);
endEditCP(MeshNode, Node::TravMaskFieldMask);
}
}
else
{
//Toggle skeleton
if(SkeletonDrawable::Ptr::dcast(SkeletonNode->getCore())->getDrawPose() == false)
{
beginEditCP(SkeletonDrawable::Ptr::dcast(SkeletonNode->getCore()), SkeletonDrawable::DrawPoseFieldMask);
SkeletonDrawable::Ptr::dcast(SkeletonNode->getCore())->setDrawPose(true);
endEditCP(SkeletonDrawable::Ptr::dcast(SkeletonNode->getCore()), SkeletonDrawable::DrawPoseFieldMask);
}
else
{
beginEditCP(SkeletonDrawable::Ptr::dcast(SkeletonNode->getCore()), SkeletonDrawable::DrawPoseFieldMask);
SkeletonDrawable::Ptr::dcast(SkeletonNode->getCore())->setDrawPose(false);
endEditCP(SkeletonDrawable::Ptr::dcast(SkeletonNode->getCore()), SkeletonDrawable::DrawPoseFieldMask);
}
}
}
}
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:92,代码来源:20LoadXMLBlendedGeometry.cpp
示例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);
//.........这里部分代码省略.........
开发者ID:Himbeertoni,项目名称:OpenSGToolbox, |
请发表评论