physics in water

Posted By: Anonymous

physics in water - 05/23/03 07:18

I let fall the following ball on/in a passable block (water). I really get stange behaviour (the ball becomes like a shark, hehehe!) . What do you think about? Is there a way of improvement?

code:
VAR earthgravity[3] = 0,0, -386;

ACTION physik_ball
{
ph_setgravity( earthgravity );

phent_settype(my, PH_RIGID, PH_SPHERE);
phent_setmass(my, 50, PH_SPHERE);
phent_setfriction(my, 90); phent_setelasticity(my, 90, 10);
phent_setdamping(my, 30, 20 );
}


Posted By: ventilator

Re: physics in water - 05/23/03 10:30

i don't think there is a simple solution for this. after watching the halflife2 videos i also thought about how this could be done...

there would be some kind of force field needed inside the water which causes light (low density) objects to swim and heavy objects to sink.
Posted By: Anonymous

Re: physics in water - 05/23/03 16:37

Yes, I learned a long time before in physics that you call that density (mass/volume). I did't test to give the water physic properties. Theoretically, if I give the water a mass, maybe the engine count the density(?). But I think that's not the only problem. I also noticed very strange turbulance forces (I gave the water the turbulence texture flag) and my balls (the ones in the game, hehehe) played crazy.

PS: @Marco Grubert: Gratulation, the physic engine is a real great and phantastic stuff!!
Posted By: Phantom88

Re: physics in water - 05/23/03 22:22

My water sim is working quite well, i just need to add the waves, and its perfect [Wink]
[EDIT]Heres how i do it(hey, it's not elegant, but it works [Wink] ): I go through all vertices of the model, and if the vertex is under the sea level, i apply a small force to it.[/EDIT]
Il'l maybe make a demo if i get the waves working...

~Phantom88~
Posted By: Anonymous

Re: physics in water - 05/24/03 00:21

Sounds interesting!

I didn't used a model for the water, I used a level block. I'll also make a demo to show the "crazy behaviour" in passable blocks. Give me a day...
Posted By: Anonymous

Re: physics in water - 05/24/03 04:59

Quick answer: there is no buoyancy (sp? - Auftrieb) in the physics engine. It can however be simulated manually. If you see any turbulent behavior then it's either due to a bug in the script or in the engine.
Posted By: Anonymous

Re: physics in water - 05/24/03 08:42

Ok, as promised, I made a primitiv test level with Delivery, if anybody's interested. The water is a passable level block with a horizontal mirror and a water texture from the standard WAD.

Download: here (3.5 MB)

Screenshot:

 -
Posted By: ventilator

Re: physics in water - 05/24/03 08:50

the warlock is a great dancer! [Big Grin] ...the water wasn't transparent on my computer...

the balls behave like a piece of sodium when they touch the water! [Smile]
Posted By: Anonymous

Re: physics in water - 05/24/03 15:21

code:
...the warlock is a great dancer!

Damned! I told him not to drink more than 6 glases of whisky! [Big Grin] (ACTION: patrol_path() with a simple event_function()).
Posted By: Anonymous

Re: physics in water - 05/24/03 21:34

I tested some adding functions, but the physic engine seems not to like water (passable entities) ... (?) Did anybody succeed in this stuff?

Code snipplets

code:
 Example 1

VAR earthgravity[3];
earthgravity[0] = 0;
earthgravity[1] = 0;
earthgravity[2] = 386;

VAR watergravity[3];
watergravity[0] = 0;
watergravity[1] = 0;
watergravity[2] = 6;

WHILE(1)
{
IF (IN_PASSABLE == 1)
{
ph_setgravity( watergravity );
}
ELSE
{
ph_setgravity( earthgravity );
}
wait (1);
}

Example 2

VAR force_up_in_passable[3];
force_up_in_passable[0] = 0;
force_up_in_passable[1] = 0;
force_up_in_passable[2] = 50;

WHILE(1)
{
IF (IN_PASSABLE == 1)
{
phent_addforceglobal(my,force_up_in_passable,nullvector);
}
wait (1);
}


Posted By: ventilator

Re: physics in water - 05/25/03 04:34

changing gravity is not a good idea. gravity is a global force. it affects all physics entities in the level.

what happens if you use the second example? what did you use in the demo?
Posted By: Phantom88

Re: physics in water - 05/25/03 04:38

Maybe you should chane the "air" friction. Then you would get the effect you want: The terminal velocity would drop, thus speed falling.

~Phantom88~
Posted By: ventilator

Re: physics in water - 05/25/03 05:16

you have to simulate the h2o molecules. fill the pool with millions of tiny invisible balls! [Smile]
Posted By: Anonymous

Re: physics in water - 05/25/03 06:19

quote:
You have to simulate the H2O molecules. fill the pool with millions of tiny invisible balls!
YES! YES! YES! Damned, why I didn't tried before, hehehe!!! [Wink]
Posted By: mss

Re: physics in water - 05/27/03 17:21

quote:
Originally posted by DocJoe:
I let fall the following ball on/in a passable block (water). I really get stange behaviour (the ball becomes like a shark, hehehe!) . What do you think about? Is there a way of improvement?


I think i have a code that should do. It works fine for me.

code:
 
var earthgravity[3] = 0,0, -386;
function emit_sphere(); //prototype of the function


sound whamm = <explo.wav>;
sound dump=<dump.wav>;

function shoot_event
{
if (EVENT_TYPE == EVENT_shoot)
{
ENT_playSOUND(MY,whamm,1000);
vec_set(temp,normal);
vec_scale(temp,40000);
phent_addcentralforce ( my, temp );
}

if (EVENT_TYPE == EVENT_friction)
{
ENT_playSOUND(MY,dump,1000);

}

if (EVENT_TYPE == EVENT_Block)
{

if(vec_length(bounce)>100)
{
my.skill41=snd_playing(my.skill40);
if(my.skill41==0)
{my.skill40=ENT_playSOUND(MY,dump,200);}
}

}
// etc. ...
}


function phset() //Normalbahaviour
{
phent_setmass(my, 0.5, PH_Sphere);
phent_setfriction(my, 70);
phent_setelasticity(my, 70,20);
phent_setdamping(my, 20, 20 );

}


function wphset()//Waterbehaviour
{
phent_setmass(my, 0.001, PH_Sphere);
phent_setfriction(my, 70);
phent_setelasticity(my, 70,20);
phent_setdamping(my, 95, 95 );

}



action sphere

{

var speedvec[3];//for waterbehaviour
var onwater=0;
my.metal=on;
my.shadow=on;
my.enable_block=on;
my.ENABLE_shoot = ON;
my.EVENT = shoot_event;



ph_setgravity( earthgravity );
phent_settype(my, PH_RIGID, PH_SPHERE);
phent_setmaxspeed(my,30000, 5000);

phset();
wait(5);

vec_set(speedvec,nullvector);
speedvec.z=1;

temp.x=cos(camera.pan)*cos(camera.tilt)*30000;
temp.y=sin(camera.pan)*cos(camera.tilt)*30000;
temp.z=sin(camera.tilt)*30000;

phent_addforcelocal(my,temp,nullvector);


while(1)
{

if(content(my.x)==2) // Entity on passable Block?
{
if(onwater==0)
{
wphset(); //set Physic-Params for Waterbehaviour
onwater=1;
}
phent_addcentralforce(my,speedvec);
}
else
{
if(onwater)
{
onwater=0;
phset(); //No longer in Water->reset params
}
}
wait(1);
}


}

string mdl_sphere=<sphere3.mdl>;

function emit_sphere()
{
temp.x=camera.x+cos(camera.pan)*cos(camera.tilt)*100;
temp.y=camera.y+sin(camera.pan)*cos(camera.tilt)*100;
temp.z=camera.z+sin(camera.tilt)*100;
temp.z=camera.z+sin(camera.tilt)*100;
ent_create(mdl_sphere,temp,sphere);
}

on_mouse_left=emit_sphere;



Posted By: Anonymous

Re: physics in water - 05/28/03 01:21

@mss: Ooooooops, many thanks for your big code, will try it tonight!
Posted By: Master_Joe

Re: physics in water - 05/29/03 02:27

coole waffe auf dem screenshot. [Big Grin] [Big Grin] [Big Grin] [Big Grin] [Big Grin]
Posted By: Anonymous

Re: physics in water - 05/29/03 05:08

I looked at the demo, but can not help you with the water problem right now, though I do have an idea of what might be causing the explosions.
As for the patch: does reducing the mass help in fixing the problem? I would have thought increasing the mass should be more suitable in that it makes the sphere more resistant to movement (as does increasing the damping).

Some more remarks on the demo:
- no mirror/transparency effect
- the warlock becomes invisible after being shot (is that by design?)
- nice bleeding, though it would be neat if the puddle size was varying
- great ripples, but for some reason the ripples also appear around the player's feet

If you have not done so already, download the Half-Life 2 engine/game video from E3. It's 600MB but well worth it. Many of the physics effects shown there can be reproduced with A6 (buoyancy and "soft bodies" not yet). How about recreating a GameStudio demo with that gravity weapon ? [Wink]
Posted By: mss

Re: physics in water - 05/29/03 08:37

quote:
Originally posted by Marco Grubert:
As for the patch: does reducing the mass help in fixing the problem? I would have thought increasing the mass should be more suitable in that it makes the sphere more resistant to movement (as does increasing the damping).

I have increased the mass to 1 and the speedvector.z to 1000 and it looks a bit more realistic.
Increasing the linear damping is necessary, otherwise the sphere would jumping around the waterlevel.
Posted By: ventilator

Re: physics in water - 05/29/03 11:46

quote:
Many of the physics effects shown there can be reproduced with A6 (buoyancy and "soft bodies" not yet).
i guess this mattress effect could be done with the new bonerotate commands and some invisible cubes connected with hinges.

quote:
How about recreating a GameStudio demo with that gravity weapon ?
i tried it right after seeing the halflife2 video but it was trickier than i thought. it would be easier if all physics entities (not only constraints) had motors. or do you think i should just turn off physics for the object while holding it with the grav-gun?
Posted By: Guido_Richter

Re: physics in water - 05/29/03 16:06

Marco, as you know maybe, I'm working together with Doc_Joe.So I know that the warlock must become invisible.Thats not a bug. [Wink]
Posted By: Anonymous

Re: physics in water - 05/30/03 04:02

quote:
Originally posted by ventilator:
i guess this mattress effect could be done with the new bonerotate commands and some invisible cubes connected with hinges.

If I had the demo (in order to break it) I could probably tell you how they have done that [Wink]
My guess is that they are using a simple cloth (mass-spring) system extended to 3 dimensions (as opposed to 2 for the regular cloth grid)- then just move the corner vertices, contract the springs, and interpolate the intermediate vertices. Similar to what you were suggesting with bones and invisible cubes.

quote:
i tried it right after seeing the halflife2 video but it was trickier than i thought. it would be easier if all physics entities (not only constraints) had motors. or do you think i should just turn off physics for the object while holding it with the grav-gun?
I would estimate the target position of the object using the current view vector scaled by the object's initial distance. Then take the difference between that target and the object's current location, scale this by the object's mass and framerate and use this scaled difference as parameter for addcentralforce. So basically you just add linear force correction whenever the object is not where it's supposed to be. It seemed like the Valve guys used a number of rods connected via (motorized) ball joints, similar to what you did with the crane. But that might be overkill. Of course that's all just physics- the important part is finding the right flare bitmaps [Wink]
Posted By: Anonymous

Re: physics in water - 05/30/03 04:04

quote:
Originally posted by Devilery:
Marco, as you know maybe, I'm working together with Doc_Joe.So I know that the warlock must become invisible.Thats not a bug. [Wink]

It was hard to tell- how about fading him out instead or do some spell casting if hit? [Big Grin]
Posted By: ventilator

Re: physics in water - 05/30/03 15:34

quote:
Then take the difference between that target and the object's current location, scale this by the object's mass and framerate and use this scaled difference as parameter for addcentralforce.
this is what i tried. the problem is that the object oscillates back and forth at the target a little too extreme. maybe i should try to increase damping or something like that if the entity gets closer to the target.
Posted By: ventilator

Re: physics in water - 05/30/03 20:11

yes! the gun increases damping now and that improved it! my gravitation-gun works now! [Big Grin] -> physics_demo.zip (right mouse button -> gravitation gun)

it isn't possible to shoot the entity like in halflife2 yet. i will add this later, this is just the first working version...

i think i read something about an undocumented ph_trace command somewhere? i would need that now. is this ph_trace the same as the new c_trace from the beta.txt?
Posted By: Anonymous

Re: physics in water - 05/31/03 03:22

Great demo, as usual. It's so much easier to move stuff with the gravity gun that it is with the crane. [Wink]
I am not sure about the 6.0 ph_trace implementation. The current beta and all future releases will use c_trace(vecfrom,vecto,trace_mode) for accurate tracing.

I guess the next big challenge will be to create a jointed humanoid, arachnoid, etc.
Posted By: Phantom88

Re: physics in water - 05/31/03 03:33

quote:
Originally posted by Marco Grubert:
I guess the next big challenge will be to create a jointed humanoid, arachnoid, etc.

UUUHUH!! Rag-doll physics! [Wink] Can't wait to push that warlock over a cliff [Wink]
Can't wait till i get the new beta, so i can have many physics objects...

~Phantom88~
© 2024 lite-C Forums