Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
M1 Oversampling
by 11honza11. 04/20/24 20:57
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 177 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 9 1 2 3 4 5 6 7 8 9
Re: Fluid Dynamics for lower editions [Re: the_mehmaster] #276780
07/06/09 11:44
07/06/09 11:44
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
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.
Code:
#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.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Fluid Dynamics for lower editions [Re: EvilSOB] #276820
07/06/09 16:22
07/06/09 16:22
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
I don't think the thing's framerate independent.

The loops are executed every frame (while(1){...wait(1);}) and thus the wave reaches is end very fast. If a computer runs at 10fps it will cover 10 vertecies a second, if it runs at 60, the wave will make a speed of 60 vertecies a second.

The problem is, I don't see how to change that easily. The best way would, I think, be a sin() function that depends on time AND distance to the initial force on the water.
Btw, I think this is a very cool idea and I'd like to see it evolve more, but could you make it look coler? like make it blue and then maybe add a light so the movement is easier to see...?
As I think you want this for the extra version (did I understand that right?) I'm not recommending using shaders, otherwise I would.


~"I never let school interfere with my education"~
-Mark Twain
Re: Fluid Dynamics for lower editions [Re: Germanunkol] #276829
07/06/09 17:08
07/06/09 17:08
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline

Serious User
VeT  Offline

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
boys, new version is uploaded wink
http://depositfiles.com/files/9x1svcbe4


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: Fluid Dynamics for lower editions [Re: VeT] #276877
07/06/09 21:16
07/06/09 21:16
Joined: Dec 2008
Posts: 528
Wagga, Australia
the_mehmaster Offline OP
User
the_mehmaster  Offline OP
User

Joined: Dec 2008
Posts: 528
Wagga, Australia
@vet: Awesome work Vet!
@evilSOB: Wow! works perfectly now. I recommend setting the specular 'power' of the terrain to a high value, you can see the waves easier. I'll make a demo level later today for the public, since they'll probably want screenshots and a demo level to download. Unless you don't want to make one..

Only problem is to make it frame rate independent. I think that the 'velocity' value is in the end of the first processing line.

Other than that, you did an awesome job.

regards,
seb.

Re: Fluid Dynamics for lower editions [Re: the_mehmaster] #276881
07/06/09 21:53
07/06/09 21:53
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline

Serious User
VeT  Offline

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
I'll wait when you'd finish this work and i'll add this to the wrapper with credits for you smile


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: Fluid Dynamics for lower editions [Re: VeT] #276926
07/07/09 06:59
07/07/09 06:59
Joined: Dec 2008
Posts: 528
Wagga, Australia
the_mehmaster Offline OP
User
the_mehmaster  Offline OP
User

Joined: Dec 2008
Posts: 528
Wagga, Australia
Code:
#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])*(time_step*0.8)-dest[iloop][eloop];
				dest[iloop][eloop] *= 1*(1.1-time_step*1.1);
				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])*(time_step*0.8)-source[iloop][eloop];
				source[iloop][eloop] *= 1*(1.1-time_step*1.1);
				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;
	fps_max = 100;
	fps_min = 25;
	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]+=20;
			while(key_cuu)	wait(1);
		}
		wait(1);
	}
}


It is now frame-rate independent.
But I think i'll stop working on my code and wait for yours, because that will be neater...

EDIT: changed some values to make it work better.


Last edited by the_mehmaster; 07/07/09 07:27.
Re: Fluid Dynamics for lower editions [Re: the_mehmaster] #276933
07/07/09 07:34
07/07/09 07:34
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:
I'll wait when you'd finish this work and i'll add this to the wrapper with credits for you

smile

Just a question.. Can i use .hmp as a buoyancy plane?

Re: Fluid Dynamics for lower editions [Re: the_mehmaster] #276955
07/07/09 09:08
07/07/09 09:08
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline

Serious User
VeT  Offline

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
for now you can't, it is defined as plane.. i'll see what i can do smile


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: Fluid Dynamics for lower editions [Re: VeT] #276965
07/07/09 09:31
07/07/09 09:31
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:
for now you can't, it is defined as plane.. i'll see what i can do

It's allright, not necessary. At the moment what i am doing is modifying your buoyancy demo by putting a passable .hmp on top of the existing plane. The positions of the rigid bodies are read into predefined variables. It works.

But if you did support .hmp, that would help, especially when evilSOB rolls out the new code. smile

@evilSOB: If you want to make this work with .mdl as well you'll have to have a vec_for_mesh instruction as well as the existing vec_to_mesh, because otherwise the .mdl's vertices will be always at the same x and y coordinates. I can give an example if you want.

Are you using the new 'ent_setmesh' and 'ent_getmesh' instructions instead of the old ones? just for compatibility..

Can't wait for this to be finished! should be really cool.

Re: Fluid Dynamics for lower editions [Re: the_mehmaster] #276968
07/07/09 09:44
07/07/09 09:44
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline

Serious User
VeT  Offline

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
//Can't wait for this to be finished! should be really cool.
yep smile


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Page 2 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