Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 01:28
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
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Ayumi), 877 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Gravity force equivalent #318202
04/05/10 21:27
04/05/10 21:27
Joined: Apr 2010
Posts: 38
D
deianthropus Offline OP
Newbie
deianthropus  Offline OP
Newbie
D

Joined: Apr 2010
Posts: 38
I am trying to set a force equal to gravity... however I am not having much success. For a particular entity, I want to exert a force equal to gravity in order to maintain its .z, but so that it can still be acted upon in a collision.

i've tried setting a force to (0,0,(obj_mass*-1*grav) because f(grav)=mg and the new vector must oppose gravity. However, this does not work for me. What am I missing?

Re: Gravity force equivalent [Re: deianthropus] #318294
04/06/10 19:44
04/06/10 19:44
Joined: Apr 2010
Posts: 38
D
deianthropus Offline OP
Newbie
deianthropus  Offline OP
Newbie
D

Joined: Apr 2010
Posts: 38
I can simulate the effect of gravity for the entity, and that works fine, but it seems kinda redundant to have to assign it for each entity I want gravity to apply to.

(the object in question can only use the gravity counter-force at certain times and in varying amounts according to a coefficient of the 1:1 antigrav force, but that's not the issue.)

Can anyone at least tell me the algorithm the gravity function uses? because it doesn't seem to follow the F = ma; a=f/m rule of acceleration and force, or maybe the force parameter for phent_addcentralforce is something other than the force equivelant to the mass times the acceleration? I just don't get it.

Last edited by deianthropus; 04/06/10 19:45.
Re: Gravity force equivalent [Re: deianthropus] #318615
04/08/10 18:06
04/08/10 18:06
Joined: Aug 2009
Posts: 1,438
Spain
painkiller Offline
Serious User
painkiller  Offline
Serious User

Joined: Aug 2009
Posts: 1,438
Spain
the gravity function accelerates all physics entity with the direction and acceleration that you have set on the vector. Example: if you set ph_setgravity(0, 0, -1); your entities will go down with an acceleration of -1 quant per sec per sec


3D Gamestudio A8 Pro
AMD FX 8350 4.00 Ghz
16GB RAM
Gigabyte GeForce GTX 960 4GB
Re: Gravity force equivalent [Re: painkiller] #318625
04/08/10 19:21
04/08/10 19:21
Joined: Apr 2010
Posts: 38
D
deianthropus Offline OP
Newbie
deianthropus  Offline OP
Newbie
D

Joined: Apr 2010
Posts: 38
That's how I interpreted the manual, but my calculations did not succeed along those guidelines. for example, if I have an entity with mass 15, and my gravity is -386 (z), then I apply a force of 386 * 15 (m*g = weight = force of gravity), but this does not bring my acceleration to 0, as one would reason it should. The object continues to fall to the floor.

Last edited by deianthropus; 04/08/10 19:21.
Re: Gravity force equivalent [Re: deianthropus] #318634
04/08/10 20:11
04/08/10 20:11
Joined: Oct 2009
Posts: 149
Germany
M
muffel Offline
Member
muffel  Offline
Member
M

Joined: Oct 2009
Posts: 149
Germany
I have tested it on my own.
The code:
Click to reveal..

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

///////////////////////////////
ENTITY *look_at;
VECTOR direction;
action my_action()
{
   look_at = me;
   set(my,SHADOW|CAST);
   while(!key_space)wait(1);
   if(0==phent_settype(me,PH_RIGID,PH_BOX))beep();
   phent_setmass(me,10,PH_BOX);
   phent_setdamping (me, 0, 0 );
   phent_setelasticity (me, 50, 0);
   phent_setfriction (me, 50 );
   phent_addcentralforce(me,vector(0,0,386*10));
   while(me)
   {
	phent_getvelocity (me, direction, nullvector ); 
	wait(1);
   }
}
function main()
{
  vec_set(screen_size,vector(800,400,0));
  vec_set(screen_color,vector(50,1,1)); // dark blue
  vec_set(sky_color,vector(50,1,1)); // dark blue
  video_window(NULL,NULL,0,"My New Game");
  d3d_antialias = 1;
  shadow_stencil = 3;
  
  level_load("");
  vec_set(camera.x,vector(-250,0,50));
  vec_set(camera.pan,vector(0,-15,0));
	ph_setgravity (vector(0,0,-386 ));
	ent_create("box.mdl",nullvector,my_action);

}




if the line while(!key_space)wait(1); is comment out everything works like expected.
but if it isn't comment out, nothing works as expected.
the object accelerats downwards.

my only explaination is that the problem is caused by ODE itselfs.

muffel


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