Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, 7th_zorro), 923 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 9 1 2 3 4 5 6 7 8 9
Fluid Dynamics for lower editions #276463
07/05/09 07:28
07/05/09 07:28
Joined: Dec 2008
Posts: 528
Wagga, Australia
the_mehmaster Offline OP
User
the_mehmaster  Offline OP
User

Joined: Dec 2008
Posts: 528
Wagga, Australia
This post is updated
Firstly, I'd like to thank evilSOB for recoding the entire system, which now works great. Second, thanks to VeT for his immense interest and help.

Here's the first demo in a series:
Fluid simulation demo 1 download (hosted my own site this time, so the link won't die)
left click and drag across the plane for a nice 'liquidy' effect.

TODO and Upcoming things:
  • Improve the frame independancy(less 'shaking') - DONE
  • Release a demo (and tutorial) that works with newton physics - 70%
  • Splash particle effects - 60%


Anyone with suggestions, bug reports, or anything like that, please share!


Last edited by VeT; 07/14/09 09:42.
Re: Fluid Dynamics for lower editions [Re: the_mehmaster] #276469
07/05/09 08:51
07/05/09 08:51
Joined: Dec 2008
Posts: 528
Wagga, Australia
the_mehmaster Offline OP
User
the_mehmaster  Offline OP
User

Joined: Dec 2008
Posts: 528
Wagga, Australia
Something i need fixed:

For some reason when i call vec_to_mesh, only every second vertex works?

changing to this makes it crash:
Code:
c.z = dest[iloop+1][eloop+1];
ent_setvertex(waterent,c,counter);


anyone know why?

Last edited by the_mehmaster; 07/05/09 08:54.
Re: Fluid Dynamics for lower editions [Re: the_mehmaster] #276522
07/05/09 13:50
07/05/09 13:50
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Im looking into this for you. But my results wil be a bit "piece-meal"
as I am getting often interruped right now.
Feel free to ask questions about anything I say / fix at any time.

Firstly, debug is failing (intermittantly but often) because your
"source" and "dest" arrays are defined wrong.
Youve defined them both with "19" columns/rows, but you are writing to 20.
(element 0 is the first, through to element 19 is the 20th)
Change their declarations to
var dest[20][20];
var source[20][20];

and that problem is repaired.

Im doing some general lite-c optimisations while Im in here too.
This code looks like either you based it on an old c-script code,
or that YOU are more familiar with c-script than lite-c.
Either way, these improvements should help you grasp lite-c better.
(and make it easier for ME to debug your core code problems wink )

[EDIT]
Originally Posted By: EvilSOB
...This code looks like either you based it on an old c-script code,...
Not that Im saying you based it on someone-elses work,
but that youve used an old mesh-deformation c-script to put your water-physics onto.




Last edited by EvilSOB; 07/05/09 14:13.

"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Fluid Dynamics for lower editions [Re: EvilSOB] #276529
07/05/09 14:40
07/05/09 14:40
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Heres the closest I can get to what I think your trying to achieve.
I cant help with the array values themselves, as I dont inderstand what you are doing.
(look at the time-stamp on this post and you'll understand that laugh )
But it think its those calculations that is cancelling out every second vertex.
I tested this by adding in a random value so I THINK Im right.

Take a look and see how its going.
Im looking forward to your reply with interest...
This is an interesting topic.

Code:
#include <acknex.h>
#include <default.c>

var dest[20][20];
var source[20][20];
var tempv;

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;
}


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,NULL);



	var iloop=0, eloop=0;
	CONTACT* c;
	//
	// 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<18; iloop++)
		{
			for(eloop=1; eloop<18; eloop++)
			{
				//perform simulation
				dest[iloop+1][eloop+1] = ((source[iloop-1+1][eloop+1]+source[iloop+1+1][eloop+1]+source[iloop+1][eloop-1+1]+source[iloop+1][eloop+1+1])/2)-dest[iloop+1][eloop+1];
				dest[iloop+1][eloop+1] *= 0.95;
				vec_to_mesh(vector(0,0,dest[iloop+1][eloop+1]), waterent, iloop*20+eloop+1);
				//debugging
				tempv = source[iloop+1][eloop+1];
			}
		}
		for(iloop=1; iloop<18; iloop++)
		{
			for(eloop=1; eloop<18; eloop++)
			{
				//perform simulation
				source[iloop+1][eloop+1] = ((dest[iloop-1+1][eloop+1]+dest[iloop+1+1][eloop+1]+dest[iloop+1][eloop-1+1]+dest[iloop+1][eloop+1+1])/2)-source[iloop+1][eloop+1];
				source[iloop+1][eloop+1] *= 0.95;
				vec_to_mesh (vector(0,0,source[iloop][eloop]), waterent, iloop*20+eloop+1);
				//debugging
				//tempv = source[iloop+1][eloop+1];
			}
		}


		//
		if(key_cuu)
		{
			source[10][10]+=30;
			while(key_cuu)wait(1);
		}
		wait(1);
	}
}




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Fluid Dynamics for lower editions [Re: EvilSOB] #276658
07/05/09 21:12
07/05/09 21:12
Joined: Dec 2008
Posts: 528
Wagga, Australia
the_mehmaster Offline OP
User
the_mehmaster  Offline OP
User

Joined: Dec 2008
Posts: 528
Wagga, Australia
I found a webpage here:
http://freespace.virgin.net/hugo.elias/graphics/x_water.htm
And that's where i ported it from.

Fixing the debug panel was one of the main issues..thanks!

About adding a random value..
I tried that myself before(but to the counter variable which is now gone).
It seems to be adding twice as much as it should? i don't understand as i'v looked through this code thouroghly.. I will work on this later today(got to go to school now).

I thought this was an interesting topic too. I was originally going to do navier-stokes fluid(3d fluid) but that was too complicated. maybe when this is finished.

Thanks for your interest and help!

EDIT: i would of used 'for' loops like you but i didn't know lite-c supported them..

Last edited by the_mehmaster; 07/05/09 21:14.
Re: Fluid Dynamics for lower editions [Re: the_mehmaster] #276663
07/05/09 21:30
07/05/09 21:30
Joined: Dec 2008
Posts: 528
Wagga, Australia
the_mehmaster Offline OP
User
the_mehmaster  Offline OP
User

Joined: Dec 2008
Posts: 528
Wagga, Australia
this:
Code:
vec_to_mesh(vector(0,0,dest[iloop+1][eloop+1]), waterent, (iloop*20)/2+(eloop+1)/2);


instead of what is already there,
halfs the reference value. This works, but then only a quarter of the terrain is used. The simulation also has noticeable 'waves' with this alteration

Re: Fluid Dynamics for lower editions [Re: the_mehmaster] #276697
07/06/09 03:03
07/06/09 03:03
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Cool, I'll look into it when I get to work tonite.
About 7 hours after this post.
Im sposed to be sleeping now, oh how I hate night shift...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Fluid Dynamics for lower editions [Re: EvilSOB] #276719
07/06/09 07:56
07/06/09 07:56
Joined: Dec 2008
Posts: 528
Wagga, Australia
the_mehmaster Offline OP
User
the_mehmaster  Offline OP
User

Joined: Dec 2008
Posts: 528
Wagga, Australia
Hmm.. worked on it for about an hour and still confused.. Why every second vertex?

I tried doubling the array size then reading it at half.. Which works very well, but it's not very efficient (about 170fps, compared to 430fps), which is very slow for a water simulation..

EDIT: It must be something to do with the arrays. Hopefully that webpage helps you to understand.. Maybe you could rewrite the 2 lines of simulation?

I used to be a c++ guy. I might turn this into a DLL if it works..

Thanks again for your help..

Last edited by the_mehmaster; 07/06/09 08:06.
Re: Fluid Dynamics for lower editions [Re: the_mehmaster] #276762
07/06/09 10:14
07/06/09 10:14
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Im about to start now.
At this point, I suspect a simple typo in one of the dest[iloop+1][eloop+1] = ((source[iloop-1+1][eloop+1]+...... lines
is zeroing out every second vertex value in either array 1 or array 2.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Fluid Dynamics for lower editions [Re: EvilSOB] #276779
07/06/09 11:22
07/06/09 11:22
Joined: Dec 2008
Posts: 528
Wagga, Australia
the_mehmaster Offline OP
User
the_mehmaster  Offline OP
User

Joined: Dec 2008
Posts: 528
Wagga, Australia
I hope your right. I have talked to VeT about using this with his wrapper's buoyancy feature. The feature will be released later today.

I was also thinking of a feature (that I will code) that uses each vertex's z coordinate. It should have a threshold, and when the z value reaches that threshold it emits water particles(splashes). Just for a touch more realism..

But before any of that, this needs to be finished.

Just as an offtopic:
I noticed you also live in Australia. I live on a farm in Wagga, NSW. What town are you in at the moment?

Regards,
Seb.

Last edited by the_mehmaster; 07/06/09 11:34.
Page 1 of 9 1 2 3 4 5 6 7 8 9

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1