本文整理汇总了C++中ParticleSystemRefPtr::addParticleSystemListener方法的典型用法代码示例。如果您正苦于以下问题:C++ ParticleSystemRefPtr::addParticleSystemListener方法的具体用法?C++ ParticleSystemRefPtr::addParticleSystemListener怎么用?C++ ParticleSystemRefPtr::addParticleSystemListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParticleSystemRefPtr
的用法示例。
在下文中一共展示了ParticleSystemRefPtr::addParticleSystemListener方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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
//point 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(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 PSPointMaterial = ChunkMaterial::create();
PSPointMaterial->addChunk(PSPointChunk);
PSPointMaterial->addChunk(PSMaterialChunkChunk);
PSPointMaterial->addChunk(PSBlendChunk);
//smoke material
TextureObjChunkRefPtr QuadTextureObjChunk = TextureObjChunk::create();
ImageRefPtr LoadedImage = ImageFileHandler::the()->read("Data/Checker.jpg");
QuadTextureObjChunk->setImage(LoadedImage);
TextureEnvChunkRefPtr QuadTextureEnvChunk = TextureEnvChunk::create();
QuadTextureEnvChunk->setEnvMode(GL_MODULATE);
MaterialChunkRefPtr PSMaterialChunk = MaterialChunk::create();
PSMaterialChunk->setAmbient(Color4f(0.3f,0.3f,0.3f,1.0f));
PSMaterialChunk->setDiffuse(Color4f(0.7f,0.7f,0.7f,1.0f));
PSMaterialChunk->setSpecular(Color4f(0.9f,0.9f,0.9f,1.0f));
PSMaterialChunk->setColorMaterial(GL_AMBIENT_AND_DIFFUSE);
ChunkMaterialRefPtr PSSmokeMaterial = ChunkMaterial::create();
PSSmokeMaterial->addChunk(QuadTextureObjChunk);
PSSmokeMaterial->addChunk(PSMaterialChunk);
PSSmokeMaterial->addChunk(PSMaterialChunk);
PSSmokeMaterial->addChunk(QuadTextureEnvChunk);
//Particle System
//Rocket
RocketParticleSystem = OSG::ParticleSystem::create();
RocketParticleSystem->attachUpdateListener(TutorialWindow);
TutorialRocketParticleSystemListener TheRocketListener;
RocketParticleSystem->addParticleSystemListener(&TheRocketListener);
//smoke
SmokeParticleSystem = OSG::ParticleSystem::create();
SmokeParticleSystem->attachUpdateListener(TutorialWindow);
//Shrapnel
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);
//.........这里部分代码省略.........
示例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);
// Material point chunk, so particles are drawn as points
PointChunkRefPtr PSPointChunk = PointChunk::create();
PSPointChunk->setSize(5.0f);
PSPointChunk->setSmooth(true);
// Material blend chunk
BlendChunkRefPtr PSBlendChunk = BlendChunk::create();
PSBlendChunk->setSrcFactor(GL_SRC_ALPHA);
PSBlendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);
LineChunkRefPtr PSLineChunk = LineChunk::create();
//Texture Chunk
TextureObjChunkRefPtr PSTexChunk = OSG::TextureObjChunk::create();
//Particle System Material
MaterialChunkRefPtr PSMaterialChunkChunk = MaterialChunk::create();
PSMaterialChunkChunk->setAmbient(Color4f(1.0f,0.5f,0.3f,1.0f));
PSMaterialChunkChunk->setDiffuse(Color4f(1.0f,0.5f,0.3f,0.6f));
PSMaterialChunkChunk->setSpecular(Color4f(1.0f,0.5f,0.3f,0.6f));
PSMaterialChunkChunk->setColorMaterial(GL_AMBIENT_AND_DIFFUSE);
// Assembling materials
ChunkMaterialRefPtr PSMaterial = ChunkMaterial::create();
PSMaterial->addChunk(PSMaterialChunkChunk);
PSMaterial->addChunk(PSPointChunk);
PSMaterial->addChunk(PSBlendChunk);
PSMaterial->addChunk(PSLineChunk);
PSMaterial->addChunk(PSTexChunk);
PSMaterial->setTransparencyMode(Material::TransparencyForceTransparent);
// Creating a particle generator
RateParticleGeneratorRefPtr ExampleGenerator = OSG::RateParticleGenerator::create();
//Attach the function objects to the Generator
ExampleGenerator->setPositionDistribution(createPositionDistribution());
ExampleGenerator->setGenerationRate(8.0);
ExampleGenerator->setVelocityDistribution(createVelocityDistribution());
ExampleGenerator->setLifespanDistribution(createLifespanDistribution());
ExampleGenerator->setSizeDistribution(createSizeDistribution());
//Creating Particle System
ExampleParticleSystem = OSG::ParticleSystem::create();
// add a couple temp particles so the camera is zoomed out
ExampleParticleSystem->addParticle(OSG::Pnt3f(0,0,-100),OSG::Vec3f(0,1,0),OSG::Color4f(1,1,1,1),OSG::Vec3f(1,1,1),0.1,OSG::Vec3f(0,0,0),OSG::Vec3f(0,0,0));
ExampleParticleSystem->addParticle(OSG::Pnt3f(0,0,100),OSG::Vec3f(0,1,0),OSG::Color4f(1,1,1,1),OSG::Vec3f(1,1,1),0.1,OSG::Vec3f(0,0,0),OSG::Vec3f(0,0,0));
ExampleParticleSystem->setMaxParticles(200);
ExampleParticleSystem->attachUpdateListener(TutorialWindow);
//Creating Particle System Drawer
PointParticleSystemDrawerRefPtr ExampleParticleSystemDrawer = OSG::PointParticleSystemDrawer::create();
ExampleParticleSystemDrawer->setForcePerParticleSizing(true);
// Attaching affector and generator to the particle system
ExampleParticleSystem->pushToGenerators(ExampleGenerator);
//Particle System Core, setting its system, drawer, and material
ParticleSystemCoreRefPtr ParticleNodeCore = OSG::ParticleSystemCore::create();
ParticleNodeCore->setSystem(ExampleParticleSystem);
ParticleNodeCore->setDrawer(ExampleParticleSystemDrawer);
ParticleNodeCore->setMaterial(PSMaterial);
// Create Trail Generator(s)
// simple trail generator
ExampleTrailGenerator = OSG::SimpleParticleTrailGenerator::create();
ExampleTrailGenerator->setTrailResolution(2.5f);
ExampleTrailGenerator->setDrawMethod(SimpleParticleTrailGenerator::POINTS);
ExampleTrailGenerator->setTrailLength(3.12);
ExampleTrailGenerator->setTrailLengthMethod(ParticleTrailGenerator::TIME);
ExampleTrailGenerator->setTrailResolutionMethod(ParticleTrailGenerator::DISTANCE_SPACING);
ExampleTrailGenerator->setTrailMaterial(PSMaterial);
// attach listener for trail generator to the particle system
ExampleParticleSystem->addParticleSystemListener(ExampleTrailGenerator->getParticleSystemListener());
// Set up node with the particle system at its core
//.........这里部分代码省略.........