Archived

This topic is now archived and is closed to further replies.

Non hard coded particle effects

This topic is 5319 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I''m trying to make a particle engine as a little challenge for myself but i''ve come across something that I can''t quite figure out. What I want to do is make a ''deflector'' (an invisible plane) that well, deflects particles when they come into contact with it. My problem is that I can''t figure out how to do this without hard coding it. eg. As a little test I said if the particles Y position is less than 0 then sit still. This simulates an infinite floor... Could anyone point me in the direction of a tutorial or theory or *anything* that would help me to be able to create deflectors without hard coding them into the engine? ie. Load them from a file at startup.

Share on other sites
Just store NX NY NZ D coordinates for your planes in a text file, read them in at runtime, and perform simple collision detection with them every frame.

In your example the solution is very easy. First of all find a point on each plane that lies on the plane (just solve the cartesian equation for any x, y). Dot the plane normal with a vector between this precomputed point and your particle. If the dot product is negative, the particle is on the reverse side of the plane, therefore it must be projected back onto the plane.

To do this, we just find the point on the plane which is closest to the particle.

http://www.euclideanspace.com/maths/geometry/elements/plane/

It would also be a good idea to detect orthogonal planes when you''re reading them in from the text file. That would get you basically free collision against the floor plane, edges of the room, etc.

Share on other sites
Basically, you would want to look into scripting languages and/or API, like LUA. Google for it

ph0ng^_^wh0ng

Share on other sites
If you support an arbitrary plane for reflection (not just "y >= YY") hard-coded, then that''s step 1. Typically, you do this by sending in a normal vector, and comparing to some constant:

if( dot3( myParticle.pos, plane.normal ) < plane.constant ) {  hit the floor}

To make this data driven, all you have to do is figure out a way to make "plane.normal" and "plane.constant" be read from some data file, instead of hard-coded. That text file probably also defines angles of particle emission, what texture(s) to use, etc.

1. 1
2. 2
Rutin
25
3. 3
4. 4
5. 5

• 10
• 10
• 13
• 20
• 14
• Forum Statistics

• Total Topics
632947
• Total Posts
3009364
• Who's Online (See full list)

There are no registered users currently online

×