本文整理汇总了C++中NodeRefPtr::setCore方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeRefPtr::setCore方法的具体用法?C++ NodeRefPtr::setCore怎么用?C++ NodeRefPtr::setCore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeRefPtr
的用法示例。
在下文中一共展示了NodeRefPtr::setCore方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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->connectMouseDragged(boost::bind(mouseDragged, _1, &sceneManager));
TutorialWindow->connectMouseWheelMoved(boost::bind(mouseWheelMoved, _1, &sceneManager));
TutorialWindow->connectKeyTyped(boost::bind(keyTyped, _1, &sceneManager));
//Particle System Material
LineChunkRefPtr PSLineChunk = LineChunk::create();
PSLineChunk->setWidth(2.0f);
PSLineChunk->setSmooth(true);
BlendChunkRefPtr PSBlendChunk = BlendChunk::create();
PSBlendChunk->setSrcFactor(GL_SRC_ALPHA);
PSBlendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);
MaterialChunkRefPtr PSMaterialChunkChunk = MaterialChunk::create();
PSMaterialChunkChunk->setAmbient(Color4f(0.3f,0.3f,0.3f,0.5f));
PSMaterialChunkChunk->setDiffuse(Color4f(0.7f,0.7f,0.7f,0.5f));
PSMaterialChunkChunk->setSpecular(Color4f(0.9f,0.9f,0.9f,1.0f));
PSMaterialChunkChunk->setColorMaterial(GL_AMBIENT_AND_DIFFUSE);
ChunkMaterialRefPtr PSMaterial = ChunkMaterial::create();
PSMaterial->addChunk(PSLineChunk);
PSMaterial->addChunk(PSMaterialChunkChunk);
PSMaterial->addChunk(PSBlendChunk);
//Particle System
ParticleSystemRefPtr ExampleParticleSystem = ParticleSystem::create();
ExampleParticleSystem->addParticle(Pnt3f(-400,-400,0),
Vec3f(0.0,0.0f,1.0f),
Color4f(1.0,1.0,1.0,1.0),
Vec3f(1.0,1.0,1.0),
0.25,
Vec3f(0.0f,0.0f,0.0f), //Velocity
Vec3f(0.0f,0.0f,0.0f)
);
ExampleParticleSystem->addParticle(Pnt3f(400,400,0),
Vec3f(0.0,0.0f,1.0f),
Color4f(1.0,1.0,1.0,1.0),
Vec3f(1.0,1.0,1.0),
0.25,
Vec3f(0.0f,0.0f,0.0f), //Velocity
Vec3f(0.0f,0.0f,0.0f)
);
ExampleParticleSystem->attachUpdateProducer(TutorialWindow);
//Particle System Drawer (Line)
LineParticleSystemDrawerRefPtr ExampleParticleSystemDrawer = LineParticleSystemDrawer::create();
ExampleParticleSystemDrawer->setLineDirectionSource(LineParticleSystemDrawer::DIRECTION_VELOCITY);
ExampleParticleSystemDrawer->setLineLengthSource(LineParticleSystemDrawer::LENGTH_SPEED);
ExampleParticleSystemDrawer->setLineLengthScaling(0.001);
ExampleParticleSystemDrawer->setEndPointFading(Vec2f(0.0f,1.0f));
//Create a Rate Particle Generator
RateParticleGeneratorRefPtr ExampleGenerator = RateParticleGenerator::create();
//Attach the function objects to the Generator
ExampleGenerator->setPositionDistribution(createPositionDistribution());
ExampleGenerator->setLifespanDistribution(createLifespanDistribution());
ExampleGenerator->setGenerationRate(300.0);
ExampleGenerator->setVelocityDistribution(createVelocityDistribution());
//Attach the Generator to the Particle System
ExampleParticleSystem->pushToGenerators(ExampleGenerator);
//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 and add the Torus
NodeRefPtr scene = Node::create();
scene->setCore(Group::create());
scene->addChild(ParticleNode);
//.........这里部分代码省略.........
示例2: main
//.........这里部分代码省略.........
ShrapnelParticleSystem = OSG::ParticleSystem::create();
ShrapnelParticleSystem->attachUpdateListener(TutorialWindow);
//Fireball
FireballParticleSystem = OSG::ParticleSystem::create();
FireballParticleSystem->attachUpdateListener(TutorialWindow);
//Particle System Drawer
//Rocket does not have a drawer because it is being attached to a special node core
//Smoke
SmokeParticleSystemDrawer = OSG::QuadParticleSystemDrawer::create();
//SmokeParticleSystemDrawer->setQuadSizeScaling(Vec2f(0.5f,0.5f));
//Shrapnel
ExampleShrapnelParticleSystemDrawer = OSG::PointParticleSystemDrawer::create();
ExampleShrapnelParticleSystemDrawer->setForcePerParticleSizing(true);
//Fireball
ExampleFireballParticleSystemDrawer = OSG::PointParticleSystemDrawer::create();
ExampleFireballParticleSystemDrawer->setForcePerParticleSizing(true);
//Particle System Node
//collision node
//NodeRefPtr EnvironmentNode = makeSphere(2,4.0f);
Matrix EnvironmentTransformation;
EnvironmentTransformation.setScale(0.1f);
TransformRefPtr EnvironmentTransformCore = Transform::create();
EnvironmentTransformCore->setMatrix(EnvironmentTransformation);
NodeRefPtr EnvironmentNode = Node::create();
EnvironmentNode->setCore(EnvironmentTransformCore);
//EnvironmentNode->addChild(SceneFileHandler::the()->read("Data/Chloroplast.osb"));
EnvironmentNode->addChild(SceneFileHandler::the()->read("Data/house.obj"));
//NodeRefPtr ParticlePrototypeNode = makeTorus(1.0,4.0,16,16);
NodeRefPtr RocketParticlePrototypeNode = SceneFileHandler::the()->read("Data/rocket.obj");
if(RocketParticlePrototypeNode == NULL)
{
RocketParticlePrototypeNode = makeTorus(.5, 2, 16, 16);
}
NodeParticleSystemCoreRefPtr RocketParticleNodeCore = OSG::NodeParticleSystemCore::create();
RocketParticleNodeCore->setSystem(RocketParticleSystem);
RocketParticleNodeCore->setPrototypeNode(RocketParticlePrototypeNode);
RocketParticleNodeCore->setNormalSource(NodeParticleSystemCore::NORMAL_VELOCITY);
RocketParticleNodeCore->setUpSource(NodeParticleSystemCore::UP_PARTICLE_NORMAL);
RocketParticleNodeCore->setUp(Vec3f(0.0f,1.0f,0.0f));
//Geometry Collision Affector
GeometryCollisionParticleSystemAffectorRefPtr ExampleGeometryCollisionParticleSystemAffector = GeometryCollisionParticleSystemAffector::create();
ExampleGeometryCollisionParticleSystemAffector->setCollisionNode(EnvironmentNode);
TutorialParticleCollisionListener TheCollisionListener;
ExampleGeometryCollisionParticleSystemAffector->addParticleGeometryCollisionListener(&TheCollisionListener);
NodeRefPtr RocketParticleNode = OSG::Node::create();
RocketParticleNode->setCore(RocketParticleNodeCore);
//Attach the Affector to the Rocket Particle System
//RocketParticleSystem->pushToAffectors();
RocketParticleSystem->pushToSystemAffectors(ExampleGeometryCollisionParticleSystemAffector);
示例3: 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);
TutorialKeyListener TheKeyListener;
TutorialWindow->addKeyListener(&TheKeyListener);
// 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 and edit a few Button Components.
******************************************************/
ButtonRefPtr ExampleButton1 = OSG::Button::create();
ButtonRefPtr ExampleButton2 = OSG::Button::create();
ButtonRefPtr ExampleButton3 = OSG::Button::create();
ButtonRefPtr ExampleButton4 = OSG::Button::create();
ButtonRefPtr ExampleButton5 = OSG::Button::create();
ButtonRefPtr ExampleButton6 = OSG::Button::create();
ExampleButton1->setPreferredSize(Vec2f(200, 50));
ExampleButton4->setPreferredSize(Vec2f(50, 50));
/******************************************************
Create Flow Layout. Flow Layout arranges objects
automatically within the Frame, so that depending
on Frame size, the objects may appear in a vertical
line, horizontal line, or multiple lines. Objects
fill from the upper left hand corner of the Frame
across, then down (when the line becomes full) while
arranged Horizontally, or from the upper left hand
corner across when arranged Vertically, starting a
new column when necessary.
You can experiment with this by changing the window
size, changing the orientation, changing the
PreferredSize of the Buttons, or adding more
Buttons to the view.
Note that if the Frame is too small or resized
too much, the FlowLayout will become slightly
distorted. For Layouts which will often
be dynamically changed, FlowLayout is not
the best choice.
-setHorizontalGap(int): Determine the Horizontal
gap in pixels between Components in
FlowLayout.
-setVerticalGap(int): Determine the Vertical
gap in pixels between Components in
FlowLayout.
-setOrientation(ENUM): Determine whether the
Layout is arranged Vertically or
Horizontally. Takes HORIZONTAL_ORIENTATION
or VERTICAL_ORIENTATION arguments.
-setMajorAxisAlignment(ENUM): Determines
the alignment of the entire Layout
within its ComponentContainer. See below.
-setMinorAxistAlignment(ENUM): Determines
the alignment of Components within
the Layout. See below.
Both of the last two functions take the
following arguments: AXIS_MAX_ALIGNMENT,
AXIS_CENTER_ALIGNMENT, and AXIS_MIN_ALIGNMENT.
MAX puts it to the bottom/right, CENTER
centers it, and MIN puts it to the
top/left (for Vertical/Horizontal as
set above, respectively).
******************************************************/
FlowLayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
MainInternalWindowLayout->setHorizontalGap(3.0f);
MainInternalWindowLayout->setVerticalGap(3.0f);
MainInternalWindowLayout->setOrientation(FlowLayout::VERTICAL_ORIENTATION);
MainInternalWindowLayout->setMajorAxisAlignment(0.5f);
MainInternalWindowLayout->setMinorAxisAlignment(1.0f);
//.........这里部分代码省略.........
示例4: 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);
TutorialKeyListener TheKeyListener;
TutorialWindow->addKeyListener(&TheKeyListener);
// 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();
//Background
SolidBackgroundRefPtr TutorialBackground = SolidBackground::create();
TutorialBackground->setColor(Color3f(1.0,0.0,0.0));
TheUndoManager = UndoManager::create();
UndoManagerChangeListener TheUndoManagerChangeListener;
TheUndoManager->addChangeListener(&TheUndoManagerChangeListener);
TheCommandManager = CommandManager::create(TheUndoManager);
//UndoList
UndoRedoListModel = DefaultListModel::create();
UndoRedoListModel->pushBack(boost::any(std::string("Top")));
ListSelectionModelPtr UndoRedoListSelectionModel(new DefaultListSelectionModel());
UndoRedoList = List::create();
UndoRedoList->setPreferredSize(Vec2f(200, 300));
UndoRedoList->setOrientation(List::VERTICAL_ORIENTATION);
UndoRedoList->setModel(UndoRedoListModel);
UndoRedoList->setSelectionModel(UndoRedoListSelectionModel);
UndoRedoListListener TheUndoRedoListListener;
UndoRedoList->getSelectionModel()->addListSelectionListener(&TheUndoRedoListListener);
UndoButton = OSG::Button::create();
UndoButton->setText("Undo");
UndoButton->setEnabled(TheUndoManager->numberOfUndos() != 0);
UndoButtonActionListener TheUndoButtonActionListener;
UndoButton->addActionListener(&TheUndoButtonActionListener);
RedoButton = OSG::Button::create();
RedoButton->setText("Redo");
RedoButton->setEnabled(TheUndoManager->numberOfRedos() != 0);
RedoButtonActionListener TheRedoButtonActionListener;
RedoButton->addActionListener(&TheRedoButtonActionListener);
// Create a ScrollPanel for easier viewing of the List (see 27ScrollPanel)
ScrollPanelRefPtr UndoRedoScrollPanel = ScrollPanel::create();
UndoRedoScrollPanel->setPreferredSize(Vec2f(200,200));
UndoRedoScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
UndoRedoScrollPanel->setViewComponent(UndoRedoList);
//Background Editor Field
//FieldEditorComponentRefPtr TheEditor = FieldEditorFactory::the()->createDefaultEditor(TutorialBackground, SolidBackground::ColorFieldId, TheCommandManager);
FieldEditorComponentRefPtr TheEditor = FieldEditorFactory::the()->createDefaultEditor(RedoButton, Button::TextFieldId, TheCommandManager);
TheEditor->setPreferredSize(Vec2f(100.0f, 20.0f));
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
MainInternalWindow->pushToChildren(TheEditor);
MainInternalWindow->pushToChildren(UndoRedoScrollPanel);
MainInternalWindow->pushToChildren(UndoButton);
MainInternalWindow->pushToChildren(RedoButton);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.95f,0.95f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
//.........这里部分代码省略.........
示例5: main
//.........这里部分代码省略.........
ChunkMaterialRefPtr PSMaterial2 = ChunkMaterial::create();
PSMaterial2->addChunk(QuadTextureObjChunk2);
PSMaterial2->addChunk(PSMaterialChunk2);
PSMaterial2->addChunk(PSBlendChunk);
//Particle System
Example1ParticleSystem = OSG::ParticleSystem::create();
Example1ParticleSystem->attachUpdateListener(TutorialWindow);
Example2ParticleSystem = OSG::ParticleSystem::create();
Example2ParticleSystem->attachUpdateListener(TutorialWindow);
//Particle System Drawer
Example1ParticleSystemDrawer = OSG::QuadParticleSystemDrawer::create();
Example2ParticleSystemDrawer = OSG::QuadParticleSystemDrawer::create();
//Attach the function objects to the Generator
//Generator 1
ExampleBurstGenerator = OSG::BurstParticleGenerator::create();
ExampleBurstGenerator->setPositionDistribution(createPositionDistribution());
ExampleBurstGenerator->setLifespanDistribution(createLifespanDistribution());
ExampleBurstGenerator->setBurstAmount(50.0);
ExampleBurstGenerator->setVelocityDistribution(createVelocityDistribution());
ExampleBurstGenerator->setAccelerationDistribution(createAccelerationDistribution());
ExampleBurstGenerator->setSizeDistribution(createSizeDistribution());
//Generator 2
Example2BurstGenerator = OSG::BurstParticleGenerator::create();
Example2BurstGenerator->setPositionDistribution(createPositionDistribution());
Example2BurstGenerator->setLifespanDistribution(createLifespanDistribution());
Example2BurstGenerator->setBurstAmount(50.0);
Example2BurstGenerator->setVelocityDistribution(createVelocityDistribution2());
Example2BurstGenerator->setAccelerationDistribution(createAccelerationDistribution());
Example2BurstGenerator->setSizeDistribution(createSizeDistribution());
//Particle System Node
ParticleSystemCoreRefPtr ParticleNodeCore = OSG::ParticleSystemCore::create();
ParticleNodeCore->setSystem(Example1ParticleSystem);
ParticleNodeCore->setDrawer(Example1ParticleSystemDrawer);
ParticleNodeCore->setMaterial(PSMaterial);
NodeRefPtr ParticleNode = OSG::Node::create();
ParticleNode->setCore(ParticleNodeCore);
//Particle System Node2
ParticleSystemCoreRefPtr ParticleNodeCore2 = OSG::ParticleSystemCore::create();
ParticleNodeCore2->setSystem(Example2ParticleSystem);
ParticleNodeCore2->setDrawer(Example2ParticleSystemDrawer);
ParticleNodeCore2->setMaterial(PSMaterial2);
NodeRefPtr ParticleNode2 = OSG::Node::create();
ParticleNode2->setCore(ParticleNodeCore2);
//Ground Node
NodeRefPtr GoundNode = makePlane(30.0,30.0,10,10);
Matrix GroundTransformation;
GroundTransformation.setRotate(Quaternion(Vec3f(1.0f,0.0,0.0), -3.14195f));
TransformRefPtr GroundTransformCore = Transform::create();
GroundTransformCore->setMatrix(GroundTransformation);
NodeRefPtr GroundTransformNode = Node::create();
GroundTransformNode->setCore(GroundTransformCore);
GroundTransformNode->addChild(GoundNode);
// Make Main Scene Node and add the Torus
NodeRefPtr scene = OSG::Node::create();
scene->setCore(OSG::Group::create());
scene->addChild(ParticleNode);
scene->addChild(ParticleNode2);
scene->addChild(GroundTransformNode);
mgr->setRoot(scene);
// 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,
"06Explosion");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例6: main
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
// Set up Window
TutorialWindow = createNativeWindow();
TutorialWindow->initWindow();
TutorialWindow->setDisplayCallback(display);
TutorialWindow->setReshapeCallback(reshape);
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);
//Particle System Material
PointChunkRefPtr PSPointChunk = PointChunk::create();
PSPointChunk->setSize(20.0f);
PSPointChunk->setSmooth(true);
BlendChunkRefPtr PSBlendChunk = BlendChunk::create();
PSBlendChunk->setSrcFactor(GL_SRC_ALPHA);
PSBlendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);
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(PSPointChunk);
PSMaterial->addChunk(PSMaterialChunkChunk);
PSMaterial->addChunk(PSBlendChunk);
Distribution3DRefPtr PositionDistribution = createPositionDistribution();
Distribution1DRefPtr LifespanDistribution = createLifespanDistribution();
Pnt3f PositionReturnValue;
Time LifespanReturnValue = -1;
//Particle System
ParticleSystemRefPtr ExampleParticleSystem = OSG::ParticleSystem::create();
for(UInt32 i(0) ; i<200 ; ++i)//controls how many particles are created
{
if(PositionDistribution != NULL)
{
PositionReturnValue = Pnt3f(PositionDistribution->generate());
}
if(LifespanDistribution != NULL)
{
LifespanReturnValue = LifespanDistribution->generate();
}
ExampleParticleSystem->addParticle(
PositionReturnValue,
Vec3f(0.0f,0.0f,1.0f),
Color4f(1.0,0.0,0.0,1.0),
Vec3f(1.0,1.0,1.0),
LifespanReturnValue,
Vec3f(0.0f,0.0f,0.0f), //Velocity
Vec3f(0.0f,0.0f,0.0f) //acceleration
);
}
ExampleParticleSystem->attachUpdateListener(TutorialWindow);
//Particle System Drawer
PointParticleSystemDrawerRefPtr ExampleParticleSystemDrawer = OSG::PointParticleSystemDrawer::create();
//Create an CollectiveGravityParticleSystemAffector
CollectiveGravityParticleSystemAffectorRefPtr ExampleCollectiveGravityParticleSystemAffector = OSG::CollectiveGravityParticleSystemAffector::create();
ExampleCollectiveGravityParticleSystemAffector->setParticleMass(10000000000.0f);
ExampleParticleSystem->pushToSystemAffectors(ExampleCollectiveGravityParticleSystemAffector);
//Particle System Node
ParticleSystemCoreRefPtr ParticleNodeCore = OSG::ParticleSystemCore::create();
ParticleNodeCore->setSystem(ExampleParticleSystem);
ParticleNodeCore->setDrawer(ExampleParticleSystemDrawer);
ParticleNodeCore->setMaterial(PSMaterial);
NodeRefPtr ParticleNode = OSG::Node::create();
ParticleNode->setCore(ParticleNodeCore);
// Make Main Scene Node and add the Torus
NodeRefPtr scene = OSG::Node::create();
scene->setCore(OSG::Group::create());
scene->addChild(ParticleNode);
//.........这里部分代码省略.........
示例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(keyTyped, _1));
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 EffectFilePath("./Data/goochyPt.cgfx");
if(argc >= 2)
{
EffectFilePath = BoostPath(argv[1]);
if(!boost::filesystem::exists(EffectFilePath))
{
std::cerr << "Could not load file: "<< EffectFilePath.string()
<< ", because no such files exists."<< std::endl;
EffectFilePath = BoostPath("./Data/goochyPt.cgfx");
}
}
//Make the CgFX Material
CgFXMaterialRecPtr ExampleMaterial = CgFXMaterial::create();
ExampleMaterial->setEffectFile(EffectFilePath.string());
// Make Torus Node (creates Torus in background of scene)
GeometryRefPtr TorusGeometry = makeTorusGeo(.5, 2, 16, 16);
//GeometryRefPtr TorusGeometry = makeBoxGeo(1.0,1.0,1.0,1,1,1);
TorusGeometry->setMaterial(ExampleMaterial);
TorusGeometry->setDlistCache(false);
NodeRefPtr TorusGeometryNode = makeNodeFor(TorusGeometry);
// Make Main Scene Node and add the Torus
NodeRefPtr scene = OSG::Node::create();
scene->setCore(OSG::Group::create());
scene->addChild(TorusGeometryNode);
sceneManager.setRoot(scene);
//Create the Documentation Foreground and add it to the viewport
SimpleScreenDoc TheSimpleScreenDoc(&sceneManager, TutorialWindow);
// Show the whole Scene
sceneManager.showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"04CgFXMaterial");
commitChanges();
//Enter main Loop
TutorialWindow->mainLoop();
}
osgExit();
return 0;
}
示例8: 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);
TutorialKeyListener TheKeyListener;
TutorialWindow->addKeyListener(&TheKeyListener);
// 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 Components to add to MenuBar
Menus. Each MenuBar has multiple Menus
which contain multiple MenuItems.
-setAcceleratorKey(KeyEvent::KEY_*): This
links the key "*" as a shortcut to
selecting the item it is attached to.
An example of this would be Q with
Control+Q causing programs to quit.
-setAcceleratorModifiers(KeyEvent::KEY_MODIFIER_*):
This adds the "*" key as another
requirement to cause the item to be
selected. Things such as "CONTROL" are
likely to be used here (as mentioned
above, both Control and Q are specified).
Note: These shortcuts will be shown in the list
with the MenuItem they are attached to.
-setMnemonicKey(KeyEvent::KEY_****): sets the key
"****" to be underlined within the Menu
itself
******************************************************/
// Creates MenuItems as in 25PopupMenu
MenuItemRefPtr NewMenuItem = MenuItem::create();
MenuItemRefPtr OpenMenuItem = MenuItem::create();
MenuItemRefPtr CloseMenuItem = MenuItem::create();
MenuItemRefPtr ExitMenuItem = MenuItem::create();
MenuItemRefPtr UndoMenuItem = MenuItem::create();
MenuItemRefPtr RedoMenuItem = MenuItem::create();
//Edits MenuItems
NewMenuItem->setText("New ...");
NewMenuItem->setAcceleratorKey(KeyEvent::KEY_N);
NewMenuItem->setAcceleratorModifiers(KeyEvent::KEY_MODIFIER_COMMAND);
NewMenuItem->setMnemonicKey(KeyEvent::KEY_N);
OpenMenuItem->setText("Open ...");
OpenMenuItem->setAcceleratorKey(KeyEvent::KEY_P);
OpenMenuItem->setAcceleratorModifiers(KeyEvent::KEY_MODIFIER_COMMAND);
OpenMenuItem->setMnemonicKey(KeyEvent::KEY_P);
CloseMenuItem->setText("Close ...");
CloseMenuItem->setAcceleratorKey(KeyEvent::KEY_W);
CloseMenuItem->setAcceleratorModifiers(KeyEvent::KEY_MODIFIER_COMMAND);
CloseMenuItem->setMnemonicKey(KeyEvent::KEY_C);
ExitMenuItem->setText("Quit");
ExitMenuItem->setAcceleratorKey(KeyEvent::KEY_Q);
ExitMenuItem->setAcceleratorModifiers(KeyEvent::KEY_MODIFIER_COMMAND);
ExitMenuItem->setMnemonicKey(KeyEvent::KEY_Q);
UndoMenuItem->setText("Undo");
UndoMenuItem->setAcceleratorKey(KeyEvent::KEY_Z);
UndoMenuItem->setAcceleratorModifiers(KeyEvent::KEY_MODIFIER_COMMAND);
UndoMenuItem->setMnemonicKey(KeyEvent::KEY_U);
RedoMenuItem->setText("Redo");
RedoMenuItem->setEnabled(false);
RedoMenuItem->setMnemonicKey(KeyEvent::KEY_R);
// Create an ActionListener and assign it to ExitMenuItem
// This is defined above, and will cause the program to quit
// when that MenuItem is selected or Control + Q hit
QuitActionListener TheQuitActionListener;
ExitMenuItem->addActionListener( &TheQuitActionListener);
//.........这里部分代码省略.........
示例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);
//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));
//Particle System Material
PointChunkRefPtr PSPointChunk = PointChunk::create();
PSPointChunk->setSize(10.0f);
PSPointChunk->setSmooth(true);
BlendChunkRefPtr PSBlendChunk = BlendChunk::create();
PSBlendChunk->setSrcFactor(GL_SRC_ALPHA);
PSBlendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);
MaterialChunkRefPtr PSMaterialChunkChunk = MaterialChunk::create();
PSMaterialChunkChunk->setAmbient(Color4f(0.2f,0.6f,0.5f,0.3f));
PSMaterialChunkChunk->setDiffuse(Color4f(0.2f,0.9f,0.1f,0.3f));
PSMaterialChunkChunk->setSpecular(Color4f(0.5f,0.4f,0.2f,0.6f));
PSMaterialChunkChunk->setEmission(Color4f(0.2f,0.6f,0.5f,0.3f));
PSMaterialChunkChunk->setColorMaterial(GL_NONE);
//enable depth test
DepthChunkRefPtr PSDepthChunk = DepthChunk::create();
ChunkMaterialRefPtr PSMaterial = ChunkMaterial::create();
PSMaterial->addChunk(PSPointChunk);
PSMaterial->addChunk(PSMaterialChunkChunk);
PSMaterial->addChunk(PSBlendChunk);
PSMaterial->addChunk(PSDepthChunk);
//Particle System
ParticleSystemRefPtr ExampleParticleSystem = ParticleSystem::create();
ExampleParticleSystem->attachUpdateProducer(TutorialWindow);
//Particle System Drawer
//Point
PointParticleSystemDrawerRecPtr ExamplePointParticleSystemDrawer = PointParticleSystemDrawer::create();
//ExamplePointParticleSystemDrawer->setForcePerParticleSizing(true);
//Line
LineParticleSystemDrawerRecPtr ExampleLineParticleSystemDrawer = LineParticleSystemDrawer::create();
ExampleLineParticleSystemDrawer->setLineDirectionSource(LineParticleSystemDrawer::DIRECTION_NORMAL);//DIRECTION_VELOCITY_CHANGE);
ExampleLineParticleSystemDrawer->setLineLengthSource(LineParticleSystemDrawer::LENGTH_SIZE_X);
ExampleLineParticleSystemDrawer->setEndPointFading(Vec2f(1.0,0.0));
//Quad
QuadParticleSystemDrawerRecPtr ExampleQuadParticleSystemDrawer = QuadParticleSystemDrawer::create();
ExampleQuadParticleSystemDrawer->setQuadSizeScaling(Vec2f(0.1,0.1));
ExampleQuadParticleSystemDrawer->setNormalAndUpSource(QuadParticleSystemDrawer::NORMAL_PARTICLE_NORMAL,QuadParticleSystemDrawer::UP_STATIC);
RateParticleGeneratorRefPtr ExampleGeneratorTheSequel = RateParticleGenerator::create();
//Attach the function objects to the Generator
ExampleGeneratorTheSequel->setPositionDistribution(createPositionDistribution());
ExampleGeneratorTheSequel->setLifespanDistribution(createLifespanDistribution());
ExampleGeneratorTheSequel->setGenerationRate(300.0);
ExampleGeneratorTheSequel->setVelocityDistribution(createVelocityDistribution());
//Attach the Generator to the Particle System
//ExampleParticleSystem->pushToGenerators(ExampleGenerator);
ExampleParticleSystem->setMaxParticles(500);
ExampleParticleSystem->pushToGenerators(ExampleGeneratorTheSequel);
//Particle System Node
ParticleSystemCoreRecPtr ParticleNodeCore = ParticleSystemCore::create();
ParticleNodeCore->setSystem(ExampleParticleSystem);
ParticleNodeCore->setDrawer(ExampleQuadParticleSystemDrawer);
ParticleNodeCore->setMaterial(PSMaterial);
ParticleNodeCore->setSortingMode(ParticleSystemCore::BACK_TO_FRONT);
NodeRefPtr ParticleNode = Node::create();
ParticleNode->setCore(ParticleNodeCore);
// Make Main Scene Node and add the Torus
NodeRefPtr scene = Node::create();
scene->setCore(Group::create());
scene->addChild(ParticleNode);
TutorialWindow->connectKeyTyped(boost::bind(keyTyped, _1, &sceneManager,
ParticleNodeCore.get(),
//.........这里部分代码省略.........
示例10: main
//.........这里部分代码省略.........
//Creating Particle System
ParticleSystemRecPtr ExampleParticleSystem = ParticleSystem::create();
ExampleParticleSystem->addParticle(Pnt3f(0,0,-100),Vec3f(0,1,0),Color4f(1,1,1,1),Vec3f(1,1,1),0.1,Vec3f(0,0,0),Vec3f(0,0,0));
ExampleParticleSystem->addParticle(Pnt3f(0,0,100),Vec3f(0,1,0),Color4f(1,1,1,1),Vec3f(1,1,1),0.1,Vec3f(0,0,0),Vec3f(0,0,0));
ExampleParticleSystem->setMaxParticles(5); // 5 rockets max to avoid collisions. they are bad.
ExampleParticleSystem->pushToAffectors(AgeFadeAffector);
ExampleParticleSystem->attachUpdateProducer(TutorialWindow);
//Creating Particle System Drawer
QuadParticleSystemDrawerRefPtr ExampleParticleSystemDrawer = QuadParticleSystemDrawer::create();
ExampleParticleSystemDrawer->setNormalAndUpSource(QuadParticleSystemDrawer::NORMAL_VIEW_DIRECTION,
QuadParticleSystemDrawer::UP_VELOCITY);
QuadParticleSystemDrawerRefPtr ExampleTrailDrawer = QuadParticleSystemDrawer::create();
//ExampleTrailDrawer->setNormalAndUpSource(QuadParticleSystemDrawer::NORMAL_VIEW_DIRECTION,
//QuadParticleSystemDrawer::UP_PARTICLE_NORMAL);
// Attaching affector and generator to the particle system
ExampleParticleSystem->pushToGenerators(ExampleGenerator);
//Particle System Core, setting its system, drawer, and material
ParticleSystemCoreRefPtr ParticleNodeCore = ParticleSystemCore::create();
ParticleNodeCore->setSystem(ExampleParticleSystem);
ParticleNodeCore->setDrawer(ExampleParticleSystemDrawer);
ParticleNodeCore->setMaterial(PSMaterial);
// create Particle System Particle Trail generator
ParticleSystemParticleTrailGeneratorRecPtr ExamplePSTrailGenerator = ParticleSystemParticleTrailGenerator::create();
ExamplePSTrailGenerator->setTrailResolution(0.05f);
ExamplePSTrailGenerator->setTrailLength(1.2);
ExamplePSTrailGenerator->setTrailLengthMethod(ParticleTrailGenerator::TIME);
ExamplePSTrailGenerator->setTrailResolutionMethod(ParticleTrailGenerator::TIME_SPACING);
ExamplePSTrailGenerator->setTrailMaterial(TrailMaterial);
ExamplePSTrailGenerator->setTrailDrawer(ExampleTrailDrawer);
ExamplePSTrailGenerator->setSizeDistribution(createTrailSizeDistribution());
ExamplePSTrailGenerator->setColorDistribution(createColorDistribution());
ExamplePSTrailGenerator->setNormalDistribution(createNormalDistribution());
ExamplePSTrailGenerator->setVelocityDistribution(createNormalDistribution());
// create affectors for particle trails
GravityParticleAffectorRefPtr GravAffector = GravityParticleAffector::create();
GravAffector->setBeacon(ExamplePSTrailGenerator);
AgeFadeParticleAffectorRefPtr TrailAgeFadeAffector = AgeFadeParticleAffector::create();
TrailAgeFadeAffector->setFadeInTime(0.2f);
TrailAgeFadeAffector->setStartAlpha(0.0f);
TrailAgeFadeAffector->setEndAlpha(0.0f);
TrailAgeFadeAffector->setFadeOutTime(1.0f);
TrailAgeFadeAffector->setFadeToAlpha(0.6f);
// now we attach the affector to the particle trail generator's particle system
ExamplePSTrailGenerator->getParticleSystem()->pushToAffectors(TrailAgeFadeAffector);
// attach listener for trail generator to the particle system
ExamplePSTrailGenerator->setSystemToTrail(ExampleParticleSystem);
//Attach the the update producer to the particle system particle trail generator.
ExamplePSTrailGenerator->attachUpdateProducer(TutorialWindow);
// Set up node with the particle system at its core
NodeRefPtr ParticleNode = Node::create();
ParticleNode->setCore(ParticleNodeCore);
ParticleNode->addChild(ExamplePSTrailGenerator);
// Make Main Scene Node
NodeRefPtr scene = Node::create();
scene->setCore(Group::create());
scene->addChild(ParticleNode);
TutorialWindow->connectKeyPressed(boost::bind(keyPressed, _1, &sceneManager, ExampleParticleSystem.get(), ExamplePSTrailGenerator.get()));
sceneManager.setRoot(scene);
//Create the Documentation
SimpleScreenDoc TheSimpleScreenDoc(&sceneManager, TutorialWindow);
// Show the whole Scene
sceneManager.getNavigator()->set(Pnt3f(0.0,0.0,100.0), Pnt3f(0.0,0.0,0.0), Vec3f(0.0,1.0,0.0));
sceneManager.getNavigator()->setMotionFactor(1.0f);
sceneManager.getCamera()->setFar(10000.0f);
sceneManager.getCamera()->setNear(0.1f);
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"02ParticleSystemParticleTrail");
//Enter main Loop
TutorialWindow->mainLoop();
}
osgExit();
return 0;
}
示例11: main
//.........这里部分代码省略.........
Vec3f(1.0,1.0,1.0),
0.1,
Vec3f(0.0f,0.0f,0.0f), //Velocity
Vec3f(0.0f,0.0f,0.0f)
);
ExampleParticleSystem->addParticle(Pnt3f(0,100,0),
Vec3f(0.0,0.0f,1.0f),
Color4f(1.0,1.0,1.0,1.0),
Vec3f(1.0,1.0,1.0),
0.1,
Vec3f(0.0f,0.0f,0.0f), //Velocity
Vec3f(0.0f,0.0f,0.0f)
);
ExampleParticleSystem->attachUpdateProducer(TutorialWindow);
//Particle System Drawer (Point)
PointParticleSystemDrawerRecPtr ExamplePointParticleSystemDrawer = PointParticleSystemDrawer::create();
//Particle System Drawer (line)
LineParticleSystemDrawerRecPtr ExampleLineParticleSystemDrawer = LineParticleSystemDrawer::create();
ExampleLineParticleSystemDrawer->setLineDirectionSource(LineParticleSystemDrawer::DIRECTION_VELOCITY);
ExampleLineParticleSystemDrawer->setLineLengthSource(LineParticleSystemDrawer::LENGTH_SIZE_X);
ExampleLineParticleSystemDrawer->setLineLength(2.0f);
ExampleLineParticleSystemDrawer->setEndPointFading(Vec2f(0.0f,1.0f));
//Create a Rate Particle Generator
RateParticleGeneratorRefPtr ExampleGenerator = RateParticleGenerator::create();
//Attach the function objects to the Generator
ExampleGenerator->setPositionDistribution(createPositionDistribution());
ExampleGenerator->setLifespanDistribution(createLifespanDistribution());
ExampleGenerator->setGenerationRate(60.0);
ExampleGenerator->setVelocityDistribution(createVelocityDistribution());
VortexParticleAffectorRecPtr ExampleVortexAffector = VortexParticleAffector::create();
ExampleVortexAffector->setMagnitude(20.0);
ExampleVortexAffector->setVortexAxis(Vec3f(0.0,0.0,1.0)); // field rotates around z axis
NodeRefPtr VortexBeacon = Node::create();
ExampleVortexAffector->setBeacon(VortexBeacon); // set to 'emulate' from (0,0,0)
ExampleVortexAffector->setMaxDistance(-1.0); // particles affected regardless of distance
ExampleVortexAffector->setAttenuation(0.25); // strength of uniform field dimishes by dist^attenuation
//Attach the Generator and Affector to the Particle System
ExampleParticleSystem->pushToGenerators(ExampleGenerator);
ExampleParticleSystem->pushToAffectors(ExampleVortexAffector);
ExampleParticleSystem->setMaxParticles(800);
//Particle System Node
ParticleSystemCoreRecPtr ParticleNodeCore = ParticleSystemCore::create();
ParticleNodeCore->setSystem(ExampleParticleSystem);
ParticleNodeCore->setDrawer(ExamplePointParticleSystemDrawer);
ParticleNodeCore->setMaterial(PSMaterial);
NodeRefPtr ParticleNode = Node::create();
ParticleNode->setCore(ParticleNodeCore);
// Make Main Scene Node and add the Torus
NodeRefPtr scene = Node::create();
scene->setCore(Group::create());
scene->addChild(ParticleNode);
TutorialWindow->connectKeyTyped(boost::bind(keyTyped, _1,
&sceneManager,
ParticleNodeCore.get(),
ExamplePointParticleSystemDrawer.get(),
ExampleLineParticleSystemDrawer.get(),
ExampleVortexAffector.get()));
sceneManager.setRoot(scene);
// Show the whole Scene
sceneManager.showAll();
sceneManager.getCamera()->setFar(1000.0);
std::cout << "Vortex Particle Affector Tutorial Controls:\n"
<< "1: Use point drawer\n"
<< "2: Use line drawer\n"
<< "3: Decrease vortex magnitude\n"
<< "4: Increase vortex magnitude\n"
<< "Ctrl + Q: Exit Tutorial";
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"22VortexParticleAffector");
//Enter main Loop
TutorialWindow->mainLoop();
}
osgExit();
return 0;
}
示例12: main
//.........这里部分代码省略.........
PSMaterial->addChunk(QuadTextureEnvChunk);
PSMaterial->addChunk(PSMaterialChunk);
PSMaterial->addChunk(PSBlendChunk);
//Particle System
ExampleParticleSystem = OSG::ParticleSystem::create();
ExampleParticleSystem->attachUpdateListener(TutorialWindow);
//Age Particle Function. Controls which image is shown when, based on the age of a particle.
AgeFunc = OSG::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 -
ExampleParticleSystemDrawer = OSG::QuadSequenceParticleSystemDrawer::create();
// image dimensions (in pixels) are required if there is a border on the images.
ExampleParticleSystemDrawer->setImageDimensions(OSG::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(OSG::Vec2b(3,2));
// width of the border on each side of the image, in pixels.
ExampleParticleSystemDrawer->setBorderOffsets(OSG::Vec2b(0,0));
// this is the age function we just created above.
ExampleParticleSystemDrawer->setSequenceFunction(AgeFunc);
ExampleParticleGenerator = OSG::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(2.0f);
//Particle System Node
ParticleSystemCoreRefPtr ParticleNodeCore = OSG::ParticleSystemCore::create();
ParticleNodeCore->setSystem(ExampleParticleSystem);
ParticleNodeCore->setDrawer(ExampleParticleSystemDrawer);
ParticleNodeCore->setMaterial(PSMaterial);
ParticleNodeCore->setSortingMode(ParticleSystemCore::BACK_TO_FRONT);
NodeRefPtr ParticleNode = OSG::Node::create();
ParticleNode->setCore(ParticleNodeCore);
ExampleParticleSystem->addParticle(Pnt3f(10.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),
0.01,
Vec3f(0.0,0.0,0.0),
Vec3f(0.0,0.0,0.0));
ExampleParticleSystem->addParticle(Pnt3f(-10.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),
0.01,
Vec3f(0.0,0.0,0.0),
Vec3f(0.0,0.0,0.0));
ExampleParticleSystem->pushToGenerators(ExampleParticleGenerator);
// Make Main Scene Node and add the Torus
NodeRefPtr scene = OSG::Node::create();
scene->setCore(OSG::Group::create());
scene->addChild(ParticleNode);
mgr->setRoot(scene);
// 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,
"05a - QuadSequenceParticleDrawer");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}