本文整理汇总了C++中ParticleSystemRefPtr::pushToSystemAffectors方法的典型用法代码示例。如果您正苦于以下问题:C++ ParticleSystemRefPtr::pushToSystemAffectors方法的具体用法?C++ ParticleSystemRefPtr::pushToSystemAffectors怎么用?C++ ParticleSystemRefPtr::pushToSystemAffectors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParticleSystemRefPtr
的用法示例。
在下文中一共展示了ParticleSystemRefPtr::pushToSystemAffectors方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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->connectMouseMoved(boost::bind(mouseMoved, _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
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 = 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->attachUpdateProducer(TutorialWindow);
//Particle System Drawer
PointParticleSystemDrawerRefPtr ExampleParticleSystemDrawer = PointParticleSystemDrawer::create();
//Create an CollectiveGravityParticleSystemAffector
CollectiveGravityParticleSystemAffectorRefPtr ExampleCollectiveGravityParticleSystemAffector = CollectiveGravityParticleSystemAffector::create();
ExampleCollectiveGravityParticleSystemAffector->setParticleMass(1000000.0f);
ExampleParticleSystem->pushToSystemAffectors(ExampleCollectiveGravityParticleSystemAffector);
//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());
//.........这里部分代码省略.........
示例2: 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);
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(1.0f,0.0f,0.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);
//NodeRefPtr ParticlePrototypeNode = makeTorus(1.0,4.0,16,16);
NodeRefPtr ParticlePrototypeNode = SceneFileHandler::the()->read("Data/rocket.obj");
if(ParticlePrototypeNode == NULL)
{
ParticlePrototypeNode = makeTorus(.5, 2, 16, 16);
}
//Particle System Node
NodeParticleSystemCoreRefPtr NodeParticleNodeCore = OSG::NodeParticleSystemCore::create();
NodeParticleNodeCore->setSystem(ExampleParticleSystem);
NodeParticleNodeCore->setPrototypeNode(ParticlePrototypeNode);
NodeParticleNodeCore->setNormalSource(NodeParticleSystemCore::NORMAL_VELOCITY);
NodeParticleNodeCore->setUpSource(NodeParticleSystemCore::UP_STATIC);
NodeParticleNodeCore->setUp(Vec3f(0.0f,1.0f,0.0f));
NodeRefPtr ParticleNode = OSG::Node::create();
ParticleNode->setCore(NodeParticleNodeCore);
//Create an CollectiveGravityParticleSystemAffector
CollectiveGravityParticleSystemAffectorRefPtr ExampleCollectiveGravityParticleSystemAffector = OSG::CollectiveGravityParticleSystemAffector::create();
ExampleCollectiveGravityParticleSystemAffector->setParticleMass(10000000000.0f);
ExampleParticleSystem->pushToSystemAffectors(ExampleCollectiveGravityParticleSystemAffector);
// 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,
"12NodeParticleDrawer");
//Enter main Loop
TutorialWindow->mainLoop();
//.........这里部分代码省略.........
示例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);
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
ParticleSystemRefPtr ExampleParticleSystem = OSG::ParticleSystem::create();
ExampleParticleSystem->attachUpdateListener(TutorialWindow);
PointParticleSystemDrawerRefPtr ExamplePointParticleSystemDrawer = OSG::PointParticleSystemDrawer::create();
//NodeRefPtr ParticlePrototypeNode = makeTorus(1.0,4.0,16,16);
//NodeRefPtr CollisionNode = makeBox(5.0,5.0,5.0,1,1,1);//makeSphere(4,10.0f);
NodeRefPtr CollisionNode = makeSphere(2,4.0f);
//Particle System Material
PointChunkRefPtr PSPointChunk = PointChunk::create();
PSPointChunk->setSize(5.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(1.0f,0.0f,0.0f,1.0f));
PSMaterialChunkChunk->setDiffuse(Color4f(1.0f,0.0f,0.0f,1.0f));
PSMaterialChunkChunk->setSpecular(Color4f(1.0f,0.0f,0.0f,1.0f));
PSMaterialChunkChunk->setColorMaterial(GL_NONE);
//PSMaterialChunkChunk->setLit(false);
ChunkMaterialRefPtr PSMaterial = ChunkMaterial::create();
PSMaterial->addChunk(PSPointChunk);
PSMaterial->addChunk(PSMaterialChunkChunk);
PSMaterial->addChunk(PSBlendChunk);
ParticleSystemCoreRefPtr ParticleNodeCore = OSG::ParticleSystemCore::create();
ParticleNodeCore->setSystem(ExampleParticleSystem);
ParticleNodeCore->setDrawer(ExamplePointParticleSystemDrawer);
ParticleNodeCore->setMaterial(PSMaterial);
NodeRefPtr ParticleNode = OSG::Node::create();
ParticleNode->setCore(ParticleNodeCore);
//Generator
//Attach the function objects to the Generator
RateParticleGeneratorRefPtr ExampleGenerator= RateParticleGenerator::create();
ExampleGenerator->setPositionDistribution(createPositionDistribution());
ExampleGenerator->setLifespanDistribution(createLifespanDistribution());
ExampleGenerator->setGenerationRate(20.0);
ExampleGenerator->setVelocityDistribution(createVelocityDistribution());
//Geometry Collision Affector
GeometryCollisionParticleSystemAffectorRefPtr ExampleGeometryCollisionParticleSystemAffector = GeometryCollisionParticleSystemAffector::create();
ExampleGeometryCollisionParticleSystemAffector->setCollisionNode(CollisionNode);
TutorialParticleCollisionListener TheCollisionListener;
ExampleGeometryCollisionParticleSystemAffector->addParticleGeometryCollisionListener(&TheCollisionListener);
ExampleParticleSystem->pushToSystemAffectors(ExampleGeometryCollisionParticleSystemAffector);
ExampleParticleSystem->pushToGenerators(ExampleGenerator);
// Make Main Scene Node and add the Torus
NodeRefPtr scene = OSG::Node::create();
scene->setCore(OSG::Group::create());
scene->addChild(ParticleNode);
scene->addChild(CollisionNode);
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,
"13CollisionGeometry");
//.........这里部分代码省略.........
示例4: main
//.........这里部分代码省略.........
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);
//Smoke
SmokeGenerator = OSG::RateParticleGenerator::create();
//Attach the function objects to the Generator
SmokePositionDistribution = createSmokePositionDistribution();
SmokeGenerator->setPositionDistribution(SmokePositionDistribution);
SmokeGenerator->setLifespanDistribution(createSmokeLifespanDistribution());
SmokeGenerator->setGenerationRate(50.0);
SmokeGenerator->setVelocityDistribution(createSmokeVelocityDistribution());
//Attach the function objects the Affectors
SmokeAgeFadeParticleAffector = OSG::AgeFadeParticleAffector::create();
SmokeAgeFadeParticleAffector->setFadeInTime(2.0f);
SmokeAgeFadeParticleAffector->setFadeOutTime(5.0f);
SmokeAgeFadeParticleAffector->setStartAlpha(0.0f);
SmokeAgeFadeParticleAffector->setFadeToAlpha(0.2f);
SmokeAgeFadeParticleAffector->setEndAlpha(0.0f);
SmokeAgeSizeParticleAffector = OSG::AgeSizeParticleAffector::create();
//ages
SmokeAgeSizeParticleAffector->editMFAges()->push_back(0.1);
SmokeAgeSizeParticleAffector->editMFAges()->push_back(0.2);
SmokeAgeSizeParticleAffector->editMFAges()->push_back(0.3);
SmokeAgeSizeParticleAffector->editMFAges()->push_back(0.5);
SmokeAgeSizeParticleAffector->editMFAges()->push_back(0.7);
SmokeAgeSizeParticleAffector->editMFAges()->push_back(0.8);
SmokeAgeSizeParticleAffector->editMFAges()->push_back(1.0);
//sizes
SmokeAgeSizeParticleAffector->editMFSizes()->push_back(Vec3f(0.5,0.5,0.5));
SmokeAgeSizeParticleAffector->editMFSizes()->push_back(Vec3f(1.0,1.0,1.0));
SmokeAgeSizeParticleAffector->editMFSizes()->push_back(Vec3f(2.0,2.0,2.0));