Heres a largely fixed version of your code, it turns out that the BIG reason
that every second vertex was zero was purely because there was no wait between
the first vertex-loop and the second.
All other changes Ive made were mostly part of my fault hunting process and can probably be reversed.
Im going to try and do a more "self-contained" and flexible version of this tonight,
but there wont be much of your code left in it Im afraid, cause I will start from scratch,
based on the webpage you sent me, rather than any of your code.
I'll post it here if I have any luck. And if my version gets posted in contributions, I'll credit you.
#include <acknex.h>
#include <default.c>
var dest[20][20];
var source[20][20];
ENTITY* waterent;
PANEL* skeletonpan =
{
pos_x = 0; pos_y = 0;
digits( 0, 0, "nexus: %f", "Arial#18b", 1, nexus);
digits( 0, 20, "tempv: %f", "Arial#18b", 1, tempv);
flags = VISIBLE;
}
action fluid_action()
{
CONTACT* c;
var tempv, iloop, eloop;
//
// Initialise arrays
for(iloop=0; iloop<20; iloop++)
{
for(eloop=0; eloop<20; eloop++)
{
dest[iloop][eloop] = 0;
source[iloop][eloop] = 0;
}
}
//
//
while(1)
{
for(iloop=1; iloop<19; iloop++)
{
for(eloop=1; eloop<19; eloop++)
{
//perform simulation
dest[iloop][eloop] = (source[iloop-1][eloop]+source[iloop+1][eloop]+source[iloop][eloop-1]+source[iloop][eloop+1])/2-dest[iloop][eloop];
dest[iloop][eloop] *= 0.95;
vec_to_mesh(vector(0,0,dest[iloop][eloop]), my, iloop*20+eloop+1);
//debugging
tempv = source[iloop+1][eloop+1];
}
}
wait(1);
for(iloop=1; iloop<19; iloop++)
{
for(eloop=1; eloop<19; eloop++)
{
//perform simulation
source[iloop][eloop] = (dest[iloop-1][eloop]+dest[iloop+1][eloop]+dest[iloop][eloop-1]+dest[iloop][eloop+1])/2-source[iloop][eloop];
source[iloop][eloop] *= 0.95;
vec_to_mesh (vector(0,0,source[iloop][eloop]), my, iloop*20+eloop+1);
//debugging
//tempv = source[iloop+1][eloop+1];
}
}
wait(1);
}
}
function main()
{
video_mode = 10;
video_screen = 1;
level_load("");
vec_set(camera.x, vector(0,50,50));
vec_set(camera.pan, vector(270,-45,0));
waterent = ent_create("waterent.hmp", nullvector, fluid_action);
//
while(1)
{
if(key_cuu)
{
source[10][10]+=10;
while(key_cuu) wait(1);
}
wait(1);
}
}
[Off-topic]Im in Wallsend, Newcastle, NSW myself, on the far side of Sydney from you.
So Im not really too far away, Im at work here, but I live in Morisset, a half-hour south.