Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

exploding 3D text with particle system (Swift - SceneKit)

I am making some exploding 3D text with Swift SceneKit. Here is the text:

let text = SCNText(string: "Exploding Text", extrusionDepth: 5)
let node = SCNNode(geometry: SCNText)
scene.rootNode.addChildNode(node)

and here is my particle system:

let exp = SCNParticleSystem()
exp.loops = false
exp.birthRate = 5000
exp.emissionDuration = 0.01
exp.spreadingAngle = 180
exp.particleDiesOnCollision = true
exp.particleLifeSpan = 0.5
exp.particleLifeSpanVariation = 0.3
exp.particleVelocity = 500
exp.particleVelocityVariation = 3
exp.particleSize = 0.05
exp.stretchFactor = 0.05
exp.particleColor = UIColor.blueColor()
scene.addParticleSystem(exp, withTransform: SCNMatrix4MakeRotation(0, 0, 0, 0))

Right now the particles emit from a single point in the center of the text. Is there any way to latch the particles to the surface of the text and then run the system to simulate exploding text?

If not, can this be done with any other geometric object like a cube?

like image 421
quemeful Avatar asked Aug 19 '14 12:08

quemeful


1 Answers

You can specify the emitter shape with

particleSystem.emitterShape = aGeometry;

and then specify the "birthLocation" to SCNParticleBirthLocationSurface or SCNParticleBirthLocationVertex

to emit from the surface or vertex of the text/cube

like image 160
Toyos Avatar answered Oct 23 '22 14:10

Toyos