本文整理汇总了C++中SimpleSceneManager类的典型用法代码示例。如果您正苦于以下问题:C++ SimpleSceneManager类的具体用法?C++ SimpleSceneManager怎么用?C++ SimpleSceneManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SimpleSceneManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wheelEvent
void OpenSGWidget::wheelEvent( QWheelEvent *ev )
{
mgr->mouseButtonPress(ev->delta() > 0 ? SimpleSceneManager::MouseUp
: SimpleSceneManager::MouseDown,
ev->x(), ev->y());
ev->accept();
update();
}
示例2: switch
void OpenSGWidget::mouseReleaseEvent( QMouseEvent *ev )
{
UInt32 button;
switch ( ev->button() )
{
case Qt::LeftButton: button = SimpleSceneManager::MouseLeft; break;
case Qt::MidButton: button = SimpleSceneManager::MouseMiddle; break;
case Qt::RightButton: button = SimpleSceneManager::MouseRight; break;
default: return;
}
mgr->mouseButtonRelease(button, ev->x(), ev->y());
update();
}
示例3: 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;
}
示例4: 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));
// Make Torus Node (creates Torus in background of scene)
NodeRecPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);
// Make Main Scene Node and add the Torus
NodeRecPtr scene = Node::create();
scene->setCore(Group::create());
scene->addChild(TorusGeometryNode);
// Create the Graphics
GraphicsRecPtr TutorialGraphics = Graphics2D::create();
// Initialize the LookAndFeelManager to enable default settings
LookAndFeelManager::the()->getLookAndFeel()->init();
// Create a simple Font to be used with the TextField
UIFontRecPtr sampleFont = UIFont::create();
sampleFont->setSize(16);
/******************************************************
Create and edit the TextField. A TextField is
a Component which allows a single line of text
to be displayed. Text can be entered via the
keyboard, and selected with arrow keys or
the Mouse.
-setTextColor(Color4f): Determine the
Text Color.
setSelectionBoxColor(Color4f): Determine
the Color of highlighting around
selected Text.
-setSelectionTextColor(Color4f): Determine
the Color of selected Text.
-setText("TextToBeDisplayed"): Determine
initial Text within TextField.
-setFont(FontName): Determine the Font
used within TextField.
-setSelectionStart(StartCharacterNumber):
Determine the character with which
the selection will initially start.
-setSelectionEnd(EndCharacterNumber):
Determine the character which the
selection ends before.
-setAlignment(float): Determine
the alignment of the text.
The float is a percentage is from the
top of the text [0.0-1.0]. Note: be
sure to visually verify this, as due
to font size and line size this does
not always place it exactly
at the percentage point.
******************************************************/
// Create a TextField component
TextFieldRecPtr ExampleTextField = TextField::create();
ExampleTextField->setPreferredSize(Vec2f(100, 50));
ExampleTextField->setTextColor(Color4f(0.0, 0.0, 0.0, 1.0));
ExampleTextField->setSelectionBoxColor(Color4f(0.0, 0.0, 1.0, 1.0));
ExampleTextField->setSelectionTextColor(Color4f(1.0, 1.0, 1.0, 1.0));
ExampleTextField->setText("What");
ExampleTextField->setFont(sampleFont);
// The next two functions will select the "a" from above
ExampleTextField->setSelectionStart(2);
ExampleTextField->setSelectionEnd(3);
ExampleTextField->setAlignment(Vec2f(0.0,0.5));
// Create another TextField Component
TextFieldRecPtr ExampleTextField2 = TextField::create();
ExampleTextField2->setText("");
ExampleTextField2->setEmptyDescText("Write in me, please");
ExampleTextField2->setPreferredSize(Vec2f(200.0f,ExampleTextField2->getPreferredSize().y()));
// 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));
//.........这里部分代码省略.........
示例5: 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));
// Make Torus Node (creates Torus in background of scene)
NodeRecPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);
// Make Main Scene Node and add the Torus
NodeRecPtr scene = Node::create();
scene->setCore(Group::create());
scene->addChild(TorusGeometryNode);
// Create the Graphics
GraphicsRecPtr TutorialGraphics = Graphics2D::create();
// Initialize the LookAndFeelManager to enable default settings
LookAndFeelManager::the()->getLookAndFeel()->init();
/******************************************************
Create and edit a CheckboxButton.
Note: the only function call shown
specific to CheckboxButton is setSelected.
In DefaultLookAndFeel, the options
for changing the style of the CheckBox
are shown. CheckboxButton also
inherits off Button so all features
of Button may be used.
-setSelected(bool): Determines if the
CheckboxButton is checked(true) or
not checked(false).
******************************************************/
CheckboxButtonRecPtr ExampleCheckboxButton = CheckboxButton::create();
ExampleCheckboxButton->setMinSize(Vec2f(50, 25));
ExampleCheckboxButton->setMaxSize(Vec2f(300, 100));
ExampleCheckboxButton->setPreferredSize(Vec2f(200, 50));
ExampleCheckboxButton->setEnabled(true);
ExampleCheckboxButton->setText("Checkbox Button");
ExampleCheckboxButton->setAlignment(Vec2f(0.5,0.5));
ExampleCheckboxButton->setSelected(true);
// 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();
InternalWindowRecPtr MainInternalWindow = InternalWindow::create();
MainInternalWindow->pushToChildren(ExampleCheckboxButton);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRecPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRecPtr TutorialUIForeground = UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
// Tell the Manager what to manage
sceneManager.setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRecPtr TutorialViewport = sceneManager.getWindow()->getPort(0);
TutorialViewport->addForeground(TutorialUIForeground);
// Show the whole Scene
//.........这里部分代码省略.........
示例6: 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));
// Make Torus Node (creates Torus in background of scene)
NodeRecPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);
// Make Main Scene Node and add the Torus
NodeRecPtr scene = Node::create();
scene->setCore(Group::create());
scene->addChild(TorusGeometryNode);
// Create the Graphics
GraphicsRecPtr TutorialGraphics = Graphics2D::create();
// Initialize the LookAndFeelManager to enable default settings
LookAndFeelManager::the()->getLookAndFeel()->init();
/******************************************************
Create a Spinner Model. This dictates
how the Spinner functions.
-setMaximum(int): Determine the Maximum
value the Spinner can have.
-setMinimum(int): Determine the Minimum
value the Spinner can have.
-setStepSize(int): Determine the
incremental step size.
-setValue(SharedFieldRecPtr(new SFInt32(int)):
Determine initial starting value
of the Spinner.
Note: the StepSize can be changed
dynamically as done in this
Tutorial with ButtonSelectedListeners.
******************************************************/
//Int32SpinnerModelPtr TheModel(new Int32SpinnerModel());
Int32SpinnerModelPtr TheModel(new Int32SpinnerModel());
TheModel->setMaximum(100);
TheModel->setMinimum(-100);
TheModel->setStepSize(1);
TheModel->setValue(boost::any(Int32(0)));
/******************************************************
Create a Spinner and and assign it a
Model.
******************************************************/
SpinnerRecPtr ExampleSpinner = Spinner::create();
ExampleSpinner->setModel(TheModel);
/******************************************************
Create a RadioButtonPanel to allow
for certain characteristics of the
Spinner to be changed dynamically.
See 14RadioButton for more
information about RadioButtons.
******************************************************/
RadioButtonRecPtr SingleIncrementButton = RadioButton::create();
RadioButtonRecPtr DoubleIncrementButton = RadioButton::create();
SingleIncrementButton->setText("Increment by 1");
SingleIncrementButton->setPreferredSize(Vec2f(100, 50));
SingleIncrementButton->connectButtonSelected(boost::bind(handleSingleIncbuttonSelected, _1,
TheModel));
DoubleIncrementButton->setText("Increment by 2");
DoubleIncrementButton->setPreferredSize(Vec2f(100, 50));
DoubleIncrementButton->connectButtonSelected(boost::bind(handleDoubleIncbuttonSelected, _1,
TheModel));
RadioButtonGroupRecPtr SelectionRadioButtonGroup = RadioButtonGroup::create();
SelectionRadioButtonGroup->addButton(SingleIncrementButton);
SelectionRadioButtonGroup->addButton(DoubleIncrementButton);
SingleIncrementButton->setSelected(true);
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
//.........这里部分代码省略.........
示例7: 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));
// Make Torus Node (creates Torus in background of scene)
NodeRecPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);
// Make Main Scene Node and add the Torus
NodeRecPtr scene = Node::create();
scene->setCore(Group::create());
scene->addChild(TorusGeometryNode);
// Create the Graphics
GraphicsRecPtr TutorialGraphics = Graphics2D::create();
// Initialize the LookAndFeelManager to enable default settings
LookAndFeelManager::the()->getLookAndFeel()->init();
// Create a simple Font to be used with the PasswordField
UIFontRecPtr ExampleFont = UIFont::create();
ExampleFont->setSize(16);
/******************************************************
Create and edit a PasswordField.
A PasswordField is a TextField
which allows for text to be
entered secretly.
-setEchoCar("char"): Determine
which character replaces text in the
PasswordField.
See 16TextField for more information.
******************************************************/
TextFieldRecPtr ExampleTextField = TextField::create();
ExampleTextField->setText("");
ExampleTextField->setEmptyDescText("username");
ExampleTextField->setPreferredSize(Vec2f(130.0f,ExampleTextField->getPreferredSize().y()));
PasswordFieldRecPtr ExamplePasswordField = PasswordField::create();
ExamplePasswordField->setPreferredSize(Vec2f(130, ExamplePasswordField->getPreferredSize().y()));
ExamplePasswordField->setTextColor(Color4f(0.0, 0.0, 0.0, 1.0));
ExamplePasswordField->setSelectionBoxColor(Color4f(0.0, 0.0, 1.0, 1.0));
ExamplePasswordField->setSelectionTextColor(Color4f(1.0, 1.0, 1.0, 1.0));
//ExamplePasswordField->setText("Text");
// "Text" will be replaced by "####" in the PasswordField
ExamplePasswordField->setEchoChar("#");
ExamplePasswordField->setEditable(true);
ExamplePasswordField->setFont(ExampleFont);
ExamplePasswordField->setSelectionStart(2);
ExamplePasswordField->setSelectionEnd(3);
ExamplePasswordField->setAlignment(Vec2f(0.0,0.5));
ExamplePasswordField->setEmptyDescText("password");
// 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));
FlowLayoutRecPtr MainInternalWindowLayout = FlowLayout::create();
MainInternalWindowLayout->setOrientation(FlowLayout::VERTICAL_ORIENTATION);
InternalWindowRecPtr MainInternalWindow = InternalWindow::create();
MainInternalWindow->pushToChildren(ExampleTextField);
MainInternalWindow->pushToChildren(ExamplePasswordField);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRecPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
//.........这里部分代码省略.........
示例8: main
int main(int argc, char **argv)
{
preloadSharedObject("OSGImageFileIO");
// 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->connectMouseMoved(boost::bind(mouseMoved, _1, &sceneManager));
TutorialWindow->connectMouseDragged(boost::bind(mouseDragged, _1, &sceneManager));
TutorialWindow->connectMouseWheelMoved(boost::bind(mouseWheelMoved, _1, &sceneManager));
// Creating the Particle System Material
// Here, the image is loaded. The entire image sequence is conatined in one image,
// which reduces texture memory overhead and runs faster.
TextureObjChunkRefPtr QuadTextureChunk = TextureObjChunk::create();
ImageRefPtr LoadedImage = ImageFileHandler::the()->read("Data/SpriteExplode.png");
QuadTextureChunk->setImage(LoadedImage);
TextureEnvChunkRefPtr QuadTextureEnvChunk = TextureEnvChunk::create();
QuadTextureEnvChunk->setEnvMode(GL_MODULATE);
BlendChunkRefPtr PSBlendChunk = BlendChunk::create();
PSBlendChunk->setSrcFactor(GL_SRC_ALPHA);
PSBlendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);
MaterialChunkRefPtr PSMaterialChunk = MaterialChunk::create();
PSMaterialChunk->setAmbient(Color4f(0.3f,0.0f,0.0f,1.0f));
PSMaterialChunk->setDiffuse(Color4f(0.7f,0.0f,0.0f,1.0f));
PSMaterialChunk->setSpecular(Color4f(0.9f,0.0f,0.0f,1.0f));
PSMaterialChunk->setColorMaterial(GL_AMBIENT_AND_DIFFUSE);
ChunkMaterialRefPtr PSMaterial = ChunkMaterial::create();
PSMaterial->addChunk(QuadTextureChunk);
PSMaterial->addChunk(QuadTextureEnvChunk);
PSMaterial->addChunk(PSMaterialChunk);
PSMaterial->addChunk(PSBlendChunk);
//Particle System
ParticleSystemRecPtr ExampleParticleSystem = ParticleSystem::create();
ExampleParticleSystem->attachUpdateProducer(TutorialWindow);
//Age Particle Function. Controls which image is shown when, based on the age of a particle.
AgeParticleFunctionRecPtr AgeFunc = AgeParticleFunction::create();
AgeFunc->setSequenceTime(0.1f); // image changes every 0.1 seconds.
AgeFunc->setSequenceOrder(AgeParticleFunction::CUSTOM); // using the custom sequence below.
/*
Here, a custom sequence for the image ordering is assembled. The image sequence will be shown in
the order specified here. Once the end of the sequence is reached, the sequence repeats.
*/
AgeFunc->editMFCustomSequence()->push_back(0);
AgeFunc->editMFCustomSequence()->push_back(1);
AgeFunc->editMFCustomSequence()->push_back(2);
AgeFunc->editMFCustomSequence()->push_back(3);
AgeFunc->editMFCustomSequence()->push_back(4);
AgeFunc->editMFCustomSequence()->push_back(5);
AgeFunc->editMFCustomSequence()->push_back(4);
AgeFunc->editMFCustomSequence()->push_back(3);
AgeFunc->editMFCustomSequence()->push_back(2);
AgeFunc->editMFCustomSequence()->push_back(1);
//Particle System Drawer -
QuadSequenceParticleSystemDrawerRecPtr ExampleParticleSystemDrawer = QuadSequenceParticleSystemDrawer::create();
// image dimensions (in pixels) are required if there is a border on the images.
ExampleParticleSystemDrawer->setImageDimensions(Vec2us(780,520));
// The "dimensions" of the sequence contained in the image. For this image,
// there are 3 images in the "x" direction, and two in the "y" direction, for a
// total of 6.
ExampleParticleSystemDrawer->setSequenceDimensions(Vec2b(3,2));
// width of the border on each side of the image, in pixels.
ExampleParticleSystemDrawer->setBorderOffsets(Vec2b(0,0));
// this is the age function we just created above.
ExampleParticleSystemDrawer->setSequenceFunction(AgeFunc);
RateParticleGeneratorRecPtr ExampleParticleGenerator = RateParticleGenerator::create();
//Attach the function objects to the Generator
ExampleParticleGenerator->setPositionDistribution(createPositionDistribution());
ExampleParticleGenerator->setLifespanDistribution(createLifespanDistribution());
ExampleParticleGenerator->setVelocityDistribution(createVelocityDistribution());
ExampleParticleGenerator->setAccelerationDistribution(createAccelerationDistribution());
ExampleParticleGenerator->setSizeDistribution(createSizeDistribution());
ExampleParticleGenerator->setGenerationRate(40.0f);
//Particle System Node
ParticleSystemCoreRefPtr ParticleNodeCore = ParticleSystemCore::create();
ParticleNodeCore->setSystem(ExampleParticleSystem);
//.........这里部分代码省略.........
示例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));
TutorialWindow->connectKeyTyped(boost::bind(keyTyped, _1));
// Tell the Manager what to manage
sceneManager.setWindow(TutorialWindow);
// Make Torus Node (creates Torus in background of scene)
NodeRefPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);
// Make Main Scene Node and add the Torus
NodeRefPtr scene = OSG::Node::create();
scene->setCore(OSG::Group::create());
scene->addChild(TorusGeometryNode);
// Create the Graphics
GraphicsRefPtr TutorialGraphics = OSG::Graphics2D::create();
// Initialize the LookAndFeelManager to enable default settings
LookAndFeelManager::the()->getLookAndFeel()->init();
/******************************************************
Create an Button Component and
a simple Font.
See 17Label_Font for more
information about Fonts.
******************************************************/
ButtonRefPtr ExampleButton = OSG::Button::create();
UIFontRefPtr ExampleFont = OSG::UIFont::create();
ExampleFont->setSize(16);
/******************************************************
Edit the Button's characteristics.
Note: the first 4 functions can
be used with any Component and
are not specific to Button.
-setMinSize(Vec2f): Determine the
Minimum Size of the Component.
Some Layouts will automatically
resize Components; this prevents
the Size from going below a
certain value.
-setMaxSize(Vec2f): Determine the
Maximum Size of the Component.
-setPreferredSize(Vec2f): Determine
the Preferred Size of the Component.
This is what the Component will
be displayed at unless changed by
another Component (such as a
Layout).
-setToolTipText("Text"): Determine
what text is displayed while
Mouse is hovering above Component.
The word Text will be displayed
in this case.
Functions specfic to Button:
-setText("DesiredText"): Determine
the Button's text. It will read
DesiredText in this case.
-setFont(FontName): Determine the
Font to be used on the Button.
-setTextColor(Color4f): Determine the
Color for the text.
-setRolloverTextColor(Color4f): Determine
what the text Color will be when
the Mouse Cursor is above the
Button.
-setActiveTextColor(Color4f): Determine
what the text Color will be when
the Button is pressed (denoted by
Active).
-setAlignment(Vec2f):
Determine the Vertical Alignment
of the text. The value is
in [0.0, 1.0].
******************************************************/
ExampleButton->setMinSize(Vec2f(50, 25));
ExampleButton->setMaxSize(Vec2f(200, 100));
ExampleButton->setPreferredSize(Vec2f(100, 50));
ExampleButton->setToolTipText("Button 1 ToolTip");
//.........这里部分代码省略.........
示例10: 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));
// Make Torus Node (creates Torus in background of scene)
NodeRecPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);
// Make Main Scene Node and add the Torus
NodeRecPtr scene = Node::create();
scene->setCore(Group::create());
scene->addChild(TorusGeometryNode);
// Create the Graphics
GraphicsRecPtr TutorialGraphics = Graphics2D::create();
// Initialize the LookAndFeelManager to enable default settings
LookAndFeelManager::the()->getLookAndFeel()->init();
/******************************************************
Create a Panel containing Buttons to
add to ScrollPanel using a function
(located at bottom of this file)
******************************************************/
PanelRecPtr ExampleViewablePanel = createPanelWithButtons();
/******************************************************
Create a UIViewport to use with the
ScrollPanel. This sets up a secondary
TutorialViewport inside the ScrollPanel.
Without this, the ScrollPanel would
not function correctly.
The Panel created above is added to be
viewed in the UIViewport and the size
and position are set.
******************************************************/
UIViewportRecPtr ScrollPanelUIViewport = UIViewport::create();
ScrollPanelUIViewport->setViewComponent(ExampleViewablePanel);
ScrollPanelUIViewport->setViewPosition(Pnt2f(150,150));
ScrollPanelUIViewport->setPreferredSize(Vec2f(200,200));
/******************************************************
Create the ScrollPanel itself.
-setHorizontalResizePolicy(ScrollPanel::
ENUM): Determines the Horizontal
resize policy. The ScrollPanel will
automatically resize itself to the
Size of its Component within for
RESIZE_TO_VIEW, or add a ScrollBar
as needed for NO_RESIZE. Takes
NO_RESIZE and RESIZE_TO_VIEW
arguments.
-setVerticalResizePolicy(ScrollPanel::
ENUM): Determines the Vertical
resize policy. The ScrollPanel will
automatically resize itself to the
Size of its Component within for
RESIZE_TO_VIEW, or add a ScrollBar
as needed for NO_RESIZE. Takes
NO_RESIZE and RESIZE_TO_VIEW
arguments.
-setViewComponent(Component): Determine
which Component will be added into
the ScrollPanel. Note that this
must be the same as the UIViewport
created above and does not require
a begin/endEditCP.
******************************************************/
ScrollPanelRecPtr ExampleScrollPanel = ScrollPanel::create();
ExampleScrollPanel->setPreferredSize(Vec2f(100,100));
ExampleScrollPanel->setVerticalScrollBarAlignment(ScrollPanel::SCROLLBAR_ALIGN_LEFT);
ExampleScrollPanel->setHorizontalScrollBarAlignment(ScrollPanel::SCROLLBAR_ALIGN_BOTTOM);
//ExampleScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
//ExampleScrollPanel->setVerticalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
//.........这里部分代码省略.........
示例11: 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));
//Torus Material
SimpleMaterialUnrecPtr TheTorusMaterial = SimpleMaterial::create();
TheTorusMaterial->setAmbient(Color3f(0.3,0.3,0.3));
TheTorusMaterial->setDiffuse(Color3f(0.7,0.7,0.7));
TheTorusMaterial->setSpecular(Color3f(1.0,1.0,1.0));
TheTorusMaterial->setShininess(20.0);
//Torus Geometry
GeometryUnrecPtr TorusGeometry = makeTorusGeo(.5, 2, 32, 32);
TorusGeometry->setMaterial(TheTorusMaterial);
NodeUnrecPtr TorusGeometryNode = Node::create();
TorusGeometryNode->setCore(TorusGeometry);
//Make Torus Node
NodeUnrecPtr TorusNode = Node::create();
TransformUnrecPtr TorusNodeTrans = Transform::create();
setName(TorusNodeTrans, std::string("TorusNodeTransformationCore"));
TorusNode->setCore(TorusNodeTrans);
TorusNode->addChild(TorusGeometryNode);
//Make Main Scene Node
NodeUnrecPtr scene = Node::create();
ComponentTransformUnrecPtr Trans = ComponentTransform::create();
setName(Trans, std::string("MainTransformationCore"));
scene->setCore(Trans);
// add the torus as a child
scene->addChild(TorusNode);
AnimationGroupUnrecPtr TheAnimation = setupAnimation(TheTorusMaterial, TorusNodeTrans);
TutorialWindow->connectKeyPressed(boost::bind(keyPressed, _1,
TheAnimation.get(),
TutorialWindow.get()));
TheAnimation->attachUpdateProducer(TutorialWindow);
TheAnimation->start();
// tell the manager what to manage
sceneManager.setRoot (scene);
//Create the Documentation
SimpleScreenDoc TheSimpleScreenDoc(&sceneManager, TutorialWindow);
// show the whole scene
sceneManager.showAll();
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"07AnimationGroup");
//Enter main Loop
TutorialWindow->mainLoop();
}
osgExit();
return 0;
}
示例12: 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);
//Attach to events
TutorialWindow->connectMousePressed(boost::bind(mousePressed, _1, &sceneManager));
TutorialWindow->connectMouseReleased(boost::bind(mouseReleased, _1, &sceneManager));
TutorialWindow->connectMouseMoved(boost::bind(mouseMoved, _1, &sceneManager));
TutorialWindow->connectMouseDragged(boost::bind(mouseDragged, _1, &sceneManager));
TutorialWindow->connectMouseWheelMoved(boost::bind(mouseWheelMoved, _1, &sceneManager));
//Particle System Material
MaterialChunkRefPtr PSMaterialChunkChunk = MaterialChunk::create();
PSMaterialChunkChunk->setAmbient(Color4f(0.3f,0.3f,0.3f,1.0f));
PSMaterialChunkChunk->setDiffuse(Color4f(0.7f,0.7f,0.7f,1.0f));
PSMaterialChunkChunk->setSpecular(Color4f(0.9f,0.9f,0.9f,1.0f));
PSMaterialChunkChunk->setColorMaterial(GL_AMBIENT_AND_DIFFUSE);
ChunkMaterialRefPtr PSMaterial = ChunkMaterial::create();
PSMaterial->addChunk(PSMaterialChunkChunk);
Distribution3DRefPtr PositionDistribution = createPositionDistribution();
Pnt3f PositionReturnValue;
//Particle System
ParticleSystemRecPtr ExampleParticleSystem = ParticleSystem::create();
for(UInt32 i(0) ; i<500 ; ++i)//controls how many particles are created
{
if(PositionDistribution != NULL)
{
PositionReturnValue = Pnt3f(PositionDistribution->generate());
}
ExampleParticleSystem->addParticle(
PositionReturnValue,
PositionReturnValue,
Vec3f(0.0f,0.0f,1.0f),
Color4f(1.0,0.0,0.0,1.0),
Vec3f(1.0,1.0,1.0),
-1, 0,
Vec3f(0.0,0.0,0.0), Vec3f(0.0f,0.0f,0.0f), //Velocity
Vec3f(0.0f,0.0f,0.0f), //acceleration
StringToUInt32Map() );
}
ExampleParticleSystem->attachUpdateProducer(TutorialWindow);
RandomMovementParticleAffectorRecPtr ExampleRMA = RandomMovementParticleAffector::create();
ExampleRMA->setAmplitude(100.0f);
AttributeAttractRepelParticleAffectorRecPtr ExampleAttributeAttractRepelParticleAffector = AttributeAttractRepelParticleAffector::create();
ExampleAttributeAttractRepelParticleAffector->setAttributeAffected(RandomMovementParticleAffector::POSITION_ATTRIBUTE);
ExampleAttributeAttractRepelParticleAffector->setMinDistance(0.0);
ExampleAttributeAttractRepelParticleAffector->setMaxDistance(10000000000000.0);
ExampleAttributeAttractRepelParticleAffector->setQuadratic(0.01);
ExampleAttributeAttractRepelParticleAffector->setLinear(0.01);
ExampleAttributeAttractRepelParticleAffector->setConstant(0.0);
ExampleParticleSystem->pushToAffectors(ExampleRMA);
ExampleParticleSystem->pushToAffectors(ExampleAttributeAttractRepelParticleAffector);
ExampleParticleSystem->setUpdateSecAttribs(false);
//Particle System Drawer
QuadParticleSystemDrawerRefPtr ExampleParticleSystemDrawer = QuadParticleSystemDrawer::create();
//Particle System Node
ParticleSystemCoreRefPtr ParticleNodeCore = ParticleSystemCore::create();
ParticleNodeCore->setSystem(ExampleParticleSystem);
ParticleNodeCore->setDrawer(ExampleParticleSystemDrawer);
ParticleNodeCore->setMaterial(PSMaterial);
NodeRefPtr ParticleNode = Node::create();
ParticleNode->setCore(ParticleNodeCore);
// Make Main Scene Node
NodeRefPtr scene = Node::create();
scene->setCore(Group::create());
scene->addChild(ParticleNode);
TutorialWindow->connectKeyTyped(boost::bind(keyTyped, _1,
&sceneManager,
ExampleParticleSystem.get(),
//.........这里部分代码省略.........
示例13: main
// Initialize WIN32 & OpenSG and set up the scene
int main(int argc, char **argv)
{
std::cout << "\n\nKEY COMMANDS:" << std::endl
<< "space Play/Pause the playing sounds" << std::endl
<< "1 Play Pop Sound" << std::endl
<< "2 Play Click Sound" << std::endl
<< "CTRL-Q Exit\n\n" << std::endl;
// 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->connectMouseMoved(boost::bind(mouseMoved, _1, &sceneManager));
TutorialWindow->connectMouseDragged(boost::bind(mouseDragged, _1, &sceneManager));
TutorialWindow->connectMouseWheelMoved(boost::bind(mouseWheelMoved, _1, &sceneManager));
// create the scene
NodeUnrecPtr scene = makeTorus(1.0, 2.0, 16, 16);
//Initialize the Sound Manager
SoundManager::the()->attachUpdateProducer(TutorialWindow);
SoundManager::the()->setCamera(sceneManager.getCamera());
//Create Pop Sound
SoundRecPtr ZapSound = SoundManager::the()->createSound();
ZapSound->setFile(BoostPath("./Data/zap.wav"));
ZapSound->setVolume(1.0);
ZapSound->setStreaming(false);
ZapSound->setLooping(1);
//Attach Sound Events
ZapSound->connectSoundPlayed (boost::bind(handleSoundPlayed, _1));
ZapSound->connectSoundStopped (boost::bind(handleSoundStopped, _1));
ZapSound->connectSoundPaused (boost::bind(handleSoundPaused, _1));
ZapSound->connectSoundUnpaused(boost::bind(handleSoundUnpaused, _1));
ZapSound->connectSoundLooped (boost::bind(handleSoundLooped, _1));
//Create Click Sound
SoundRecPtr ClickSound = SoundManager::the()->createSound();
ClickSound->setFile(BoostPath("./Data/click.wav"));
ClickSound->setVolume(1.0);
ClickSound->setStreaming(false);
ClickSound->setLooping(0);
//Attach Sound Events
ClickSound->connectSoundPlayed (boost::bind(handleSoundPlayed, _1));
ClickSound->connectSoundStopped (boost::bind(handleSoundStopped, _1));
ClickSound->connectSoundPaused (boost::bind(handleSoundPaused, _1));
ClickSound->connectSoundUnpaused(boost::bind(handleSoundUnpaused, _1));
ClickSound->connectSoundLooped (boost::bind(handleSoundLooped, _1));
TutorialWindow->connectKeyTyped(boost::bind(&KeyTypedHandler::keyTyped,
_1,
ZapSound.get(),
ClickSound.get()));
// tell the manager what to manage
sceneManager.setRoot (scene);
// show the whole scene
sceneManager.showAll();
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"01 DefaultSound Window");
//Enter main loop
TutorialWindow->mainLoop();
}
osgExit();
return 0;
}
示例14: main
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
{
TheLuaManager->init();
// 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);
//Setup the Lua Manager
BoostPath ModulePath("./Data/");
std::string PackagePath = std::string("?;")
+ (ModulePath / "?.lua" ).file_string() + ";"
+ (ModulePath / "?" / "init.lua").file_string();
TheLuaManager->setPackagePath(PackagePath);
// Make Torus Node (creates Torus in background of scene)
GeometryRefPtr TorusGeometry = makeTorusGeo(.5, 2, 16, 16);
setName(TorusGeometry,"Torus Geometry");
//calcVertexTangents(TorusGeometry,0,Geometry::TexCoords7FieldId, Geometry::TexCoords6FieldId);
NodeRefPtr TorusGeometryNode = Node::create();
setName(TorusGeometryNode,"Torus Geometry Node");
TorusGeometryNode->setCore(TorusGeometry);
//Torus Transformation Node
TransformRefPtr TheTorusNodeTransform = Transform::create();
NodeRefPtr TheTorusTransfromNode = Node::create();
TheTorusTransfromNode->setCore(TheTorusNodeTransform);
TheTorusTransfromNode->addChild(TorusGeometryNode);
setName(TheTorusTransfromNode,"Torus Transform Node");
// Make Main Scene Node and add the Torus
NodeRefPtr scene = Node::create();
scene->setCore(Group::create());
scene->addChild(TheTorusTransfromNode);
setName(scene,"Scene Node");
//Light Beacon Node
TransformRefPtr TheLightBeaconNodeTransform = Transform::create();
NodeRefPtr TheLightBeaconNode = Node::create();
TheLightBeaconNode->setCore(TheLightBeaconNodeTransform);
setName(TheLightBeaconNode,"Light Beacon Node");
//Light Node
DirectionalLightRefPtr TheLightCore = DirectionalLight::create();
TheLightCore->setDirection(Vec3f(1.0,0.0,0.0));
TheLightCore->setAmbient(Color4f(1.0,1.0,1.0,1.0));
TheLightCore->setDiffuse(Color4f(1.0,1.0,1.0,1.0));
TheLightCore->setSpecular(Color4f(1.0,1.0,1.0,1.0));
TheLightCore->setBeacon(TheLightBeaconNode);
NodeRefPtr TheLightNode = Node::create();
TheLightNode->setCore(TheLightCore);
TheLightNode->addChild(scene);
setName(TheLightNode,"Light Node");
NodeRefPtr RootNode = Node::create();
RootNode->setCore(Group::create());
RootNode->addChild(TheLightNode);
RootNode->addChild(TheLightBeaconNode);
setName(RootNode,"Root Node");
// Create the Graphics
GraphicsRefPtr TutorialGraphics = Graphics2D::create();
// Initialize the LookAndFeelManager to enable default settings
LookAndFeelManager::the()->getLookAndFeel()->init();
//Create the Main interface
LuaDebuggerInterface TheLuaDebuggerInterface;
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
BorderLayoutRefPtr MainInternalWindowLayout = BorderLayout::create();
//Split Panel
BorderLayoutConstraintsRefPtr SplitPanelConstraints = BorderLayoutConstraints::create();
SplitPanelConstraints->setRegion(BorderLayoutConstraints::BORDER_CENTER);
TheLuaDebuggerInterface.getMainSplitPanel()->setConstraints(SplitPanelConstraints);
//.........这里部分代码省略.........
示例15: 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));
// Make Torus Node (creates Torus in background of scene)
NodeRecPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);
// Make Main Scene Node and add the Torus
NodeRecPtr scene = Node::create();
scene->setCore(Group::create());
scene->addChild(TorusGeometryNode);
// Create the Graphics
GraphicsRecPtr TutorialGraphics = Graphics2D::create();
// Initialize the LookAndFeelManager to enable default settings
LookAndFeelManager::the()->getLookAndFeel()->init();
//Create the nessicary parts for a viewport
Matrix TransformMatrix;
TransformMatrix.setTranslate(0.0f,0.0f, 0.0f);
TransformRecPtr CameraBeaconTransform = Transform::create();
CameraBeaconTransform->setMatrix(TransformMatrix);
NodeRecPtr CameraBeaconNode = Node::create();
CameraBeaconNode->setCore(CameraBeaconTransform);
// Make Torus Node (creates Torus in background of scene)
NodeRecPtr GeometryNode = makeTorus(.5, 2, 32, 32);
//Make a light Node
NodeRecPtr LightBeaconNode = makeCoredNode<Transform>();
DirectionalLightRecPtr SceneLight = DirectionalLight::create();
SceneLight->setAmbient(Color4f(0.3f,0.3f,0.3f,1.0f));
SceneLight->setDiffuse(Color4f(0.8f,0.8f,0.8f,1.0f));
SceneLight->setSpecular(Color4f(1.0f,1.0f,1.0f,1.0f));
SceneLight->setOn(true);
SceneLight->setBeacon(LightBeaconNode);
NodeRecPtr LightNode = makeNodeFor(SceneLight);
LightNode->addChild(GeometryNode);
// Make Main Scene Node and add the Torus
NodeRecPtr DefaultRootNode = Node::create();
DefaultRootNode->setCore(Group::create());
DefaultRootNode->addChild(LightNode);
DefaultRootNode->addChild(LightBeaconNode);
DefaultRootNode->addChild(CameraBeaconNode);
//Camera
PerspectiveCameraRecPtr DefaultCamera = PerspectiveCamera::create();
DefaultCamera->setBeacon(CameraBeaconNode);
DefaultCamera->setFov (osgDegree2Rad(60.f));
DefaultCamera->setNear (0.1f);
DefaultCamera->setFar (100.f);
//Background
GradientBackgroundRecPtr DefaultBackground = GradientBackground::create();
DefaultBackground->addLine(Color3f(0.0f,0.0f,0.0f), 0.0f);
DefaultBackground->addLine(Color3f(0.0f,0.0f,1.0f), 1.0f);
//Viewport
ViewportRecPtr DefaultViewport = Viewport::create();
DefaultViewport->setCamera (DefaultCamera);
DefaultViewport->setRoot (DefaultRootNode);
DefaultViewport->setSize (0.0f,0.0f, 1.0f,1.0f);
DefaultViewport->setBackground (DefaultBackground);
//GL Viewport Component
LineBorderRecPtr TheGLViewportBorder = LineBorder::create();
TheGLViewportBorder->setColor(Color4f(1.0,0.0,0.0,1.0));
TheGLViewportBorder->setWidth(3.0);
GLViewportRecPtr TheGLViewport = GLViewport::create();
TheGLViewport->setPort(DefaultViewport);
TheGLViewport->setPreferredSize(Vec2f(400.0f,400.0f));
TheGLViewport->setBorders(TheGLViewportBorder);
TheGLViewport->lookAt(Pnt3f(0.0f,0.0f,10.0f), //From
Pnt3f(0.0f,0.0f,0.0f), //At
Vec3f(0.0f,1.0f,0.0f)); //Up
ButtonRecPtr ExampleButton = Button::create();
//.........这里部分代码省略.........