MCPcopy Create free account
hub / github.com/OGRECave/ogre / createProceduralParticleSystem

Method createProceduralParticleSystem

Samples/ParticleGS/src/ParticleGS.cpp:49–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47 }
48
49 void Sample_ParticleGS::createProceduralParticleSystem()
50 {
51 mParticleSystem = new ProceduralManualObject();
52 mParticleSystem->_notifyManager(mSceneMgr);
53 MaterialPtr mat = MaterialManager::getSingleton().getByName("Ogre/ParticleGS/Display", "General");
54 mParticleSystem->setMaterial(mat);
55
56 // Generate the geometry that will seed the particle system.
57 ManualObject* particleSystemSeed = mSceneMgr->createManualObject("ParticleSeed");
58 // This needs to be the initial launcher particle.
59 particleSystemSeed->begin("Ogre/ParticleGS/Display", RenderOperation::OT_POINT_LIST);
60 particleSystemSeed->position(0,0,0); // Position
61 particleSystemSeed->textureCoord(1); // Timer
62 particleSystemSeed->textureCoord(0); // Type
63 particleSystemSeed->textureCoord(0,0,0); // Velocity
64 particleSystemSeed->end();
65
66 // Generate the RenderToBufferObject.
67 auto r2vb = HardwareBufferManager::getSingleton().createRenderToVertexBuffer();
68 r2vb->setRenderToBufferMaterialName("Ogre/ParticleGS/Generate");
69
70 // Apply the random texture.
71 TexturePtr randomTexture = RandomTools::generateRandomVelocityTexture();
72 r2vb->getRenderToBufferMaterial()
73 ->getTechnique(0)
74 ->getPass(0)
75 ->getTextureUnitState("RandomTexture")
76 ->setTexture(randomTexture);
77
78 r2vb->setOperationType(RenderOperation::OT_POINT_LIST);
79 r2vb->setMaxVertexCount(16000);
80 r2vb->setResetsEveryUpdate(false);
81 VertexDeclaration* vertexDecl = r2vb->getVertexDeclaration();
82 // Define input / feedback variables.
83 size_t offset = 0;
84 // Position
85 offset += vertexDecl->addElement(0, offset, VET_FLOAT3, VES_POSITION).getSize();
86 // Timer
87 offset += vertexDecl->addElement(0, offset, VET_FLOAT1, VES_TEXTURE_COORDINATES, 0).getSize();
88 // Type
89 offset += vertexDecl->addElement(0, offset, VET_FLOAT1, VES_TEXTURE_COORDINATES, 1).getSize();
90 // Velocity
91 vertexDecl->addElement(0, offset, VET_FLOAT3, VES_TEXTURE_COORDINATES, 2).getSize();
92
93 // Bind the two together.
94 r2vb->setSourceRenderable(particleSystemSeed->getSections()[0]);
95 mParticleSystem->setRenderToVertexBuffer(r2vb);
96
97 // Set bounds.
98 AxisAlignedBox aabb;
99 aabb.setMinimum(-100,-100,-100);
100 aabb.setMaximum(100,100,100);
101 mParticleSystem->setBoundingBox(aabb);
102 }
103
104 void Sample_ParticleGS::testCapabilities(const RenderSystemCapabilities* caps)
105 {

Callers

nothing calls this directly

Calls 15

createManualObjectMethod · 0.80
setTextureMethod · 0.80
getTextureUnitStateMethod · 0.80
getPassMethod · 0.80
getVertexDeclarationMethod · 0.80
getByNameMethod · 0.45
setMaterialMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected