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
1 registered members (Akow), 1,365 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How to simulate stability from lift/weight for submarine? #307127
01/27/10 11:57
01/27/10 11:57
Joined: Jan 2010
Posts: 40
Adelaide, Australia
Sub_Game Offline OP
Newbie
Sub_Game  Offline OP
Newbie

Joined: Jan 2010
Posts: 40
Adelaide, Australia
I'm mucking around with physics for my submarine model (am not yet decided if I want to write my own yet).

How can I simulate stability so that the boat will naturally gravitate to an upright neutral position?

This is what I have so far:

Code:
//--set physics--
ph_setgravity (vector(0, 0, 0));
	
phent_settype (my_submarine, PH_RIGID, PH_BOX);
phent_setmass (my_submarine, 3, PH_SPHERE);
phent_setfriction (my_submarine, 0); 
phent_setdamping (my_submarine, 30, 60); 
phent_setelasticity (my_submarine, 20, 0); 

//--INPUT--
if( key_r ) sub_thrust.x+=10;
if( key_f ) sub_thrust.x=10;
if( key_v ) sub_thrust.x-=10;
phent_addforcelocal( my_submarine, sub_thrust, nullvector );
		
if( key_a ) phent_addforcelocal( my_submarine, vector(0,-50,0), vector(-30,0,0) );

if( key_d ) phent_addforcelocal( my_submarine, vector(0,50,0), vector(-30,0,0) );

if( key_w ) phent_addforcelocal( my_submarine, vector(0,0,50), vector(50,0,0) );

if( key_s ) phent_addforcelocal( my_submarine, vector(0,0,-50), vector(50,0,0) );



Last edited by Sub_Game; 01/27/10 12:03.

A7 Commercial
First person submarine combat simulator project
http://alexanderforeman.webs.com/fightersubgame.htm
Re: How to simulate stability from lift/weight for submarine? [Re: Sub_Game] #308073
02/01/10 14:19
02/01/10 14:19
Joined: Jan 2010
Posts: 40
Adelaide, Australia
Sub_Game Offline OP
Newbie
Sub_Game  Offline OP
Newbie

Joined: Jan 2010
Posts: 40
Adelaide, Australia
Anyone???


A7 Commercial
First person submarine combat simulator project
http://alexanderforeman.webs.com/fightersubgame.htm
Re: How to simulate stability from lift/weight for submarine? [Re: Sub_Game] #308085
02/01/10 14:58
02/01/10 14:58
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline
Serious User
darkinferno  Offline
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
meaning as if resurfacing?

Re: How to simulate stability from lift/weight for submarine? [Re: darkinferno] #308150
02/01/10 20:24
02/01/10 20:24
Joined: Jan 2010
Posts: 40
Adelaide, Australia
Sub_Game Offline OP
Newbie
Sub_Game  Offline OP
Newbie

Joined: Jan 2010
Posts: 40
Adelaide, Australia
Either on the surface or underwater. Forces applied to the sub cause it to pan, tilt and roll as if it were a spacecraft. It needs to have a tendancy to go back to tilt=0 and roll=0 just like a real sub will. I could just command tilt and roll with something like tilt-=tilt/10*time_step; directly but that would defeat the purpose of using the physics yes?


A7 Commercial
First person submarine combat simulator project
http://alexanderforeman.webs.com/fightersubgame.htm
Re: How to simulate stability from lift/weight for submarine? [Re: Sub_Game] #308152
02/01/10 20:43
02/01/10 20:43
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline
Serious User
darkinferno  Offline
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
well i dont think that would work either, you cant change the pan/tilt/roll of a physics object directly, i had a helicopter in my game once and what i did was:

psuedo code:

if (my_Angle NOT_EQUAL desiredAngle)
{
rotateBack(slow)//physics force ofcourse
}

basically use a small force that constantly tries to recenter your model, this force should be lower than whatever force you use to turn your model however, else you'll lose ability to turn it

Re: How to simulate stability from lift/weight for submarine? [Re: darkinferno] #308157
02/01/10 21:16
02/01/10 21:16
Joined: Jan 2010
Posts: 145
Doc_Savage Offline
Member
Doc_Savage  Offline
Member

Joined: Jan 2010
Posts: 145
well i think you need 2 separate types of physics, one for surfaced, and one for underwater, dont forget that underwater is close to no gravity also.


Do not concern yourself with my race, personality or origin. find my record in the pits, and then make your wager.
Re: How to simulate stability from lift/weight for submarine? [Re: Doc_Savage] #308645
02/04/10 07:55
02/04/10 07:55
Joined: Jan 2010
Posts: 40
Adelaide, Australia
Sub_Game Offline OP
Newbie
Sub_Game  Offline OP
Newbie

Joined: Jan 2010
Posts: 40
Adelaide, Australia
Thanks for the suggestions.

OK - I've gotten pissed off with the awkward nature of the physics engine so I wrote my own. It works really well and the sub handles naturally. The only thing it doesn't do is transfer momentum to other objects on impact but I don't really need that anyway.

I tweaked my physics so the boats really feel like the real thing. I've got a few work-mates to test-dive the sub and they love the feel of it. I've adapted the physics for both underwater, surface and airborne (for air-drops).


A7 Commercial
First person submarine combat simulator project
http://alexanderforeman.webs.com/fightersubgame.htm

Moderated by  HeelX, Spirit 

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