Getting a good spark effect?

Is there a good way to get a spark effect that bounces off of models? Actually, I want all of my particles to do this now that I think about it.



Also, how would I make the direction of a particle effect (where a bullet hits a wall) be the same as the face it hit’s normal? I assume this would be more of a physics related question but since I’m already on the subject I figured I’d throw it in. Thanks for any help in advance!

I am assuming you have a bullet or something hitting a model. In that case, you have a ray and a collision result. You can get the normal vector from that collision result. Take the normal and use Quaternion.lookAt(normal, someUpValue) to set a rotation, then rotate the particle emitter in that direction. The sparks will fly out of that normal direction.

Or you can set the initial velocity of the particles in the direction of the normal (no quaternion needed):

sparkEmitter.getParticleInfluencer().setInitialVelocity(normal);

Doing it this way will let gravity affect them still.

Actually, I’m not using rays. I’m actually doing a physically simulated bullet (so I can have simulated bullet drop, travel time, etc.). I have an idea for it, but I still need an answer as to how I could get my particle effects to bounce/collide/not just go through all of my models. Is this possible yet?

The point of particles is being resource effective, this is kind of the opposite :wink: Try simulating it by giving the influencer other data.

You could either do ray tests, do bullet raytests or use bullet collision shapes.



I would go with on of the two ray tests, as they are probably way faster. (note: does not apply to jbullet)

Alright. My thought was that it really messes with realism when a particle effect just floats through a mesh. I have no idea how exactly I’d go about limiting this, even to a small degree. My only idea I have is to try making a custom particle effect controller that I only use for some effects (i.e. smoke, fire, explosions) that has an area it’s allowed in. I could just make it rise, and if the particle is inside the mesh (it’d be a very low detail shape, sort of like a collision shape) then it’s up motion is limited. Maybe do a check with rays to see if it can go side to side, or front-back, and move it in those directions. Idunno, just throwing out random ideas now.



As for the bullets, I wanted bullets similar to how Battlefield 3’s bullets behave. Visible, not instantaneous, and you have to sort of try to hit your target. I have an idea though, I could just add a Vector3f to the bullet’s class (a bullet is simulated as it’s own class, BulletControl extends RigidBodyControl. It disappears after 5 seconds, which is configurable, or when it hits something.) and make it so whenever the bullet is fired it saves that location as startVec, then where it hits is marked as endVec. Cast a ray from startVec to endVec, get the collision data, emit particles.



On that note of custom particle controllers, would there be an easy way to do this or would I have to completely start from scratch?



Edit: This has sort of strayed away from an effects topic to a physics topic, my bad. :stuck_out_tongue: