Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, alibaba), 1,426 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 7 of 9 1 2 3 4 5 6 7 8 9
Re: Fluid Dynamics for lower editions [Re: the_mehmaster] #278274
07/12/09 21:50
07/12/09 21:50
Joined: Dec 2008
Posts: 528
Wagga, Australia
the_mehmaster Offline OP
User
the_mehmaster  Offline OP
User

Joined: Dec 2008
Posts: 528
Wagga, Australia
Dammit. I forgot that posts expire after 1 week, so i can't change the front page.

VeT is a mod.. Could you please change the percentage of completion for frame rate independancy to 'DONE'? that would be much appreciated.

Re: Fluid Dynamics for lower editions [Re: the_mehmaster] #278279
07/12/09 22:05
07/12/09 22:05
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Re-write was a write-off. The whole concept is just not suitable for time-scaling.
(With my limited brainpower anyway, too long since school for this aging old brain)

Heres what Ive got so far.
Its basically done, visvosity works well,
but I just cant get the size-scale-factor to work right.
That is, getting the ripples to "spread" out faster or slower.

Oh, yeah. Looking at the code code, you'll see a new line of array elements
being added to tmp. The 'original' code you gave me calculated this
average based on the 4 up-down-left-right vertices.
My additional line now takes the diagonal vertices into account too.
Give the ripples a much more circular pattern...

Feel free to play and comment or suggest.
Any questions welcome too.
Im going to rest from this problem for a few hours, but Im still around.
Enjoy.
Code:
#include <acknex.h>
#include <default.c>


#define	scale		skill1		//INPUT/OUTPUT  - scale of the terrain
#define	viscosity		skill2		//INPUT/OUTPUT  - "density" of the fluid.  1=Water, 2=EngineOil, 3=Honey
#define	vertex_wide	skill3		//OUTPUT - width of HMP in vertices
#define	vertex_high	skill4		//OUTPUT - height of HMP in vertices

action fluid_action()
{
	//validate if a valid entity for fluid simulation (must be a terrain)
	if(!ent_status(my,2)||!ent_status(my,3))	return;		//this is NOT a terrain.
	//create and initialise "workspace" variables & pointers
	CONTACT* c;		
	var x, y, f, tmp, frametime=0;
	var size_x=ent_status(my,2)+1, size_y=ent_status(my,3)+1;
	//create and initialise "workspace" arrays
	var ***data = malloc(sizeof(var)*2);
	for(f=0; f<2; f++)	
	{	data[f] = malloc(sizeof(var)*size_x);
		for(x=0; x<size_x; x++)	
		{	(data[f])[x] = malloc(sizeof(var)*size_y);
			for(y=0; y<size_y; y++)		((data[f])[x])[y]  = 0;
	}	}
	//setup feedback skills
	if(!my.scale)	
	{
		//auto-calculate  scale based on VETs idea.
		c = ent_getvertex(my,NULL,1);
		x=c.v.x;	y=c.v.z;
		c = ent_getvertex(my,NULL,2+size_y);
		x-=c.v.x;	y-=c.v.z;
		my.scale = (abs(x) + abs(y))/2/2.54;	//quants per "square"  (2.54qu = scale of 1.0)
	}
	if(!my.viscosity)	my.viscosity = 1;		//default to "water" viscosity
	my.vertex_wide  = size_x;
	my.vertex_high	= size_y;
	//
	var sim_fps	= 10;	//Simulation FPS. AVOID changing if possible, because
	//					//if changed, it will skew BOTH Scale & Viscosity ranges
	//
	while(me)
	{	
		my.scale=clamp(my.scale,0.5,50);
		frametime += time_frame;
		if(frametime>(16/sim_fps*my.scale*2))
		{
			frametime -= (16/sim_fps*(my.scale*2));
			f = !f;
			my.viscosity=clamp(my.viscosity,0.9,5);
			for(y=1; y<(size_y-1); y++)   for(x=1; x<(size_x-1); x++)   
			{	
				c = ent_getvertex(my,NULL,(y*size_x)+x+1);    
				if((c.v.y!=((data[0])[x])[y])&&(c.v.y!=((data[1])[x])[y]))
				{	((data[f])[x])[y] = ((data[!f])[x])[y] = c.v.y;
					c = ent_getvertex(my,NULL,((y--)*size_x)+(x--)+1);		}
				tmp  = (((data[!f])[x-1])[y]+((data[!f])[x+1])[y]+((data[!f])[x])[y-1]+((data[!f])[x])[y+1]);
				tmp += (((data[!f])[x-1])[y-1]+((data[!f])[x-1])[y+1]+((data[!f])[x+1])[y-1]+((data[!f])[x+1])[y+1])/2;
				((data[f])[x])[y] = ((tmp/4*(my.scale))-((data[f])[x])[y])*(0.3*(3/my.viscosity));
				((data[f])[x])[y] = c.v.y = integer(((data[f])[x])[y]*10000)/10000;	//idle-damping
				ent_setvertex(my,c,(y*size_x)+x+1);
			}
		}		
		wait(1);
	}	
	//cleanup "workspace" arrays
	for(x=0; x<size_x; x++)	{   free((data[0])[x]);   free((data[1])[x]);   }
	free(data[0]);		free(data[1]);	 	free(data);	 
}



ENTITY* waterent;

void poke()
{
	CONTACT* c = ent_getvertex(waterent,NULL,210);    
	c.v.y += 5;
	ent_setvertex(waterent,c,510);
}


function main()
{
	video_mode = 10;
//	video_screen = 1;
	level_load("");
	vec_set(camera.x,   vector(0,25,25));
	vec_set(camera.pan, vector(270,-45,0));
	waterent = ent_create("waterent.hmp", nullvector, fluid_action);

	on_cuu = poke;

}
//




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

Joined: Dec 2008
Posts: 528
Wagga, Australia
Wow, waves look much better! I'll wait until the autocalculation is finished before newton implementation.

Re: Fluid Dynamics for lower editions [Re: the_mehmaster] #278311
07/13/09 05:34
07/13/09 05:34
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Sorry guys, but my last post is the best I can squeeze out of it.
I give up.

But hey, its supposed to be SIMPLE fluid sim isnt it?

Sorry.


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

Joined: Dec 2008
Posts: 528
Wagga, Australia
Quote:
Sorry guys, but my last post is the best I can squeeze out of it.
I give up.

But hey, its supposed to be SIMPLE fluid sim isnt it?

Sorry.

You don't have to be sorry at all!
What you did was perfect!

Re: Fluid Dynamics for lower editions [Re: the_mehmaster] #278474
07/14/09 05:13
07/14/09 05:13
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.. Not working as expected with the new version, terrain keeps raising exponentially.

I'll just use the old version. Sorry for letting all that hard work go to waste..

Re: Fluid Dynamics for lower editions [Re: the_mehmaster] #278475
07/14/09 05:21
07/14/09 05:21
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
I dont mind. All that hard work was mostly going round in circles and
having the terrain "blow-out" every second modification.
The core algorithm is VERY delicately balanced(pronounced "unstable").

Im rather glad your using the more stable version, seeing as my name is in the credits. grin
Thanks for that.


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

Joined: Dec 2008
Posts: 528
Wagga, Australia
There probably won't be a thread in "lite-c contributions" for another week or so. I've still got another few demos to make, and a tutorial.

I can't say 'thankyou' enough for how much work you put into this. It is appreciated. Very much so.

I was wondering.. Gamestudio comes with fluid dynamics in the pro edition. Would this be the same algorithm?

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

Joined: Feb 2008
Posts: 3,232
Australia
Unlikely in my opinion, but hey, Who knows?


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Fluid Dynamics for lower editions [Re: EvilSOB] #278480
07/14/09 06:35
07/14/09 06:35
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'd like to think that this algorithm is faster than conitec's grin
That would be cool..

Page 7 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