I really think I can say that you have really done something groundbreaking in the engine!
Well, thanks. Personally, I thought rewriting Kloot's GLSL so that it would run on my hardware and on ATi was a lot more challenging than this mini-project, tbh.
And zxswg deserves the main credit anyhow, for going ahead and writing the first demonstration of these ideas on the engine. I guess you missed that screen he posted. I just decided that if he'd gotten it done to that extent, I should probably figure out how to get it working in a way that's actually feasible.
I should say, also, that this is not some panacea, nor a real breakthrough, in terms of polish.
It has serious problems with the engine (see shadowmap projection issues, etc.) so it's more of a technical stunt than a practical approach to building maps atm, unfortunately. I can mitigate the errors by doing some tricks with the drawing (get rid of the shadowmap pass for the unitIDs used to generate the objects, for a start) but there are other issues, like the fact that none of the ARB shaders designed for SMF work when the map isn't being drawn (which is stupid, since the heightmap's still there, but whatever, that's a feature request).
All that said, it could probably become a credible alternative to SMF... if the engine can be adjusted in a few ways, and people built enough tiles, and we had some better tech for a few things. Meh, I'll talk about that stuff later.
That link you posted shows exactly how to do it... So what are you actually asking for here?
I am asking for some hand-holding, basically. I don't know how to translate that from C to Lua, the syntax is completely different.
OK... source...
Code: Select all
int pnpoly(int nvert, float *vertx, float *verty, float testx, float testy)
{
int i, j, c = 0;
for (i = 0, j = nvert-1; i < nvert; j = i++) {
if ( ((verty[i]>testy) != (verty[j]>testy)) &&
(testx < (vertx[j]-vertx[i]) * (testy-verty[i]) / (verty[j]-verty[i]) + vertx[i]) )
c = !c;
}
return c;
}
Arguments:
nvert = Number of vertices in the polygon. Whether to repeat the first vertex at the end is discussed below.
vertx, verty = Arrays containing the x- and y-coordinates of the polygon's vertices.
testx, testy = X and Y coordinate of the test point.
So... for example... how would I express this in Lua?
Code: Select all
for (i = 0, j = nvert-1; i < nvert; j = i++)
And what does *vertx mean? Does it mean it's a member of that array? I know it may seem stupid, but I really don't know how to translate this into Lua, which is the primary problem here.