View Full Version : Generating Particles from Surface

12-28-2007, 10:19 AM
This is one thing I have never attempted with the SDK and am unclear
if its 'conventionally' possible but can I generate particles from a
sub'd or heck I'd be happy if it had to be a frozen surface like I can
within LW itself?

At first I thought sure no problems then I ran into problems and well
I now have no clue how to proceed. Any sage words of advise pro or con
would be greatly appreciated!

FYI, I do mean distributed across the surface and not just at the
vertices, that I have done numerous times.

12-28-2007, 11:03 AM
Hey aurora,

I haven't done it myself, but here is something that I think could work for you:

Take a look at the paragraph about Barycentric coordinates. So if you have a polygon's vertices you should be able to create three random numbers, which have a sum of 1 and none of them is below zero. Insert these three values into the equation and the new coordinate should be inside the given triangle (if you have polygons with more than three vertices you should triple them internally).
If you solved this step, it should only be a matter of time till you have something working for an entire mesh (like first tripling the mesg, then randomly picking one polygon of it and at last create Barycentric coordinates :))

Sounds logical to me, but as I said, I haven't done it myself :D

Hope I could help you

12-30-2007, 04:35 PM
Just as a thought, and I have no idea if it is plausible, but emitters themselves can be 4 sided polygons. So why not write a plug in that builds flat emitters and rotates them to the polygon normal they are replacing?

In the end, you could build a 3d object of nothing but flat particle emitters.

Mr Rid
12-30-2007, 05:34 PM
Curious what I am missing here. But you can already emit particles from a subdivided surface across the poly in Layout. :)

01-03-2008, 01:47 PM
Pomfried - Thanks thats pretty much the route I ended up going on creating my own only to find that I was getting way to many emission points to work with so I did end up using vertices instead. Would love to use an entire mesh surface but alas the calc times for what I'm doing is way to long. Tis the physics of the system that make things VERY difficult.

MiniFireDragon - a very interesting idea with some potential usage for quick work ups therer. Thats something I'll have to play with later.

Mr. Rid - Yes its true native pFX does allow particle emission from a sub'd surface but alas I need to control where each and every particle after the initial emission points are setup and thats something I can't do without a specialized plugin.

01-03-2008, 04:14 PM
Aloha Aurora,

I've never done this and it's a little late in the game, so forgive any ignorance that spews forth. Looking at the SDK under Mesh Info it looks like you could:

1. Iterate through all the polygons of the mesh using
result = scanPolys( meshinfo, polyscan_func, mydata )

2. For each poly use
nvert = polSize( meshinfo, polygon )
and also point = polVertex( meshinfo, polygon, vert_index )
to get all the points in the poly

3. use pntBasePos( meshinfo, point, pos ) to get the points position

4. average the points for the center or calculate where you need to emit from. This could be kinda cool since if you calculate the area - you could emit several particles for large polygons.

OR use

hasnormal = pntBaseNormal( meshinfo, polygon, point, normal ) (LW9.0+)
Get the base normal of a vertex. If the polygon ID is defined, the normal will be calculated taking surface smoothness parameters and the surrounding polygons into account. If the polygon ID is not defined (0), an averaged normal of the surrounding polygons is computed. Returns 1 if the vertex has a valid normal, returns 2 if the normal is not smoothed, 0 for an invalid normal.

and emit from the normal....

I'm not sure how deformations would be handled - that boggles my mind a little.