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
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
1 registered members (henrybane), 1,499 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19054 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
[Newton] How to do some things with Newton #85760
08/13/06 09:43
08/13/06 09:43
Joined: Apr 2006
Posts: 265
V
vartan_s Offline OP
Member
vartan_s  Offline OP
Member
V

Joined: Apr 2006
Posts: 265
I recently found Newton, but was unable (manual only tells you basics) to do some of the things. So I was wondering how to do the following:

Work out the pan and tilt of a Newton entity (does it change the pan?)

Add forces to Newton entities, eg to mov it with bullets by adding forces (since I'm not using templates)

Turn the limited collision of Newton entities with non-newton entities off.

I was wondering how you did the above three things, so could anyone tell me? Thanks in advance.

Re: [Newton] How to do some things with Newton [Re: vartan_s] #85761
08/13/06 16:01
08/13/06 16:01
Joined: Jul 2006
Posts: 783
London, UK
sheefo Offline
User
sheefo  Offline
User

Joined: Jul 2006
Posts: 783
London, UK
This is how I made ball movement. It was mostly taken from the example (although I had to work most of it out myself):

Code:

var force[3];
function movement_forces(body)
{
var bodyMass;
bodyMass = NewtonGetBodyMass(body);
NewtonBodyAddForce(body, 0, 0, bodyMass * (newtonGravity + force.z));
NewtonBodyAddTorque(body, bodyMass * my.move_vec_x, bodyMass * my.move_vec_y, bodyMass * my.move_vec_z);
}
////////////////////////////////////////////////////////////
// Player Initialization
////////////////////////////////////////////////////////////
define move_vec_x, skill98;
define move_vec_y, skill99;
define move_vec_z, skill100;
action initialize_player
{
player = my;

var body;
my.collision_sph_box = on; // sphere?
my.mass = 10;
my.linear_drag = 0.1;
my.angular_drag_x = 0.1;
my.angular_drag_y = 0.1;
my.angular_drag_z = 0.1;
my.start_active = on;
my.shape_factor = 0.9; // density
NewtonCreateGravityEntity(ivory_material);
dll_handle = newtonHandle;

body = NewtonGetBody(my);
NewtonSetBodyAutoActiveState(body, 0);
NewtonSetBodyActiveState(body, 1);
// asign a special force event to the rover
NewtonSetBodyForceAndTorque(body, movement_forces);

while(1)
{
vec_set(my.move_vec_x, nullvector);
vec_set(force, nullvector);
my.move_vec_x = key_cur - key_cul;
my.move_vec_y = key_cuu - key_cud;
if(key_space)
{
force.z = 1000;
}
//vec_rotate(my.move_vec_x, vector(camera.pan, 0, 0));
vec_normalize(my.move_vec_x, 100);
wait(1);
}
}



Re: [Newton] How to do some things with Newton [Re: sheefo] #85762
08/13/06 18:32
08/13/06 18:32
Joined: Apr 2006
Posts: 265
V
vartan_s Offline OP
Member
vartan_s  Offline OP
Member
V

Joined: Apr 2006
Posts: 265
Thanks a lot. Unfortunately, I don't know enough to understand it.
eg:
Code:
 
NewtonBodyAddForce(body, 0, 0, bodyMass * (newtonGravity + force.z));
NewtonBodyAddTorque(body, bodyMass * my.move_vec_x, bodyMass * my.move_vec_y, bodyMass * my.move_vec_z);



I don't really know what the parameters between the brackets mean... if you could help me out by explaining to me the useful functions for newton I'd be greatful. Thanks.

Re: [Newton] How to do some things with Newton [Re: vartan_s] #85763
08/13/06 18:54
08/13/06 18:54
Joined: Jul 2006
Posts: 783
London, UK
sheefo Offline
User
sheefo  Offline
User

Joined: Jul 2006
Posts: 783
London, UK
Well, I don't know but here’s my guess:

This is meant to be the direction of gravity, the first argument is the object, and then the last three are the xyz vector stuff. You can add wind blowing it off a ledge with this.
Code:

NewtonBodyAddForce(body, 0, 0, bodyMass * (newtonGravity + force.z));


The same applies with this, but this is the movement of the object. It uses user-defined skill vectors, 'move_vec_x', 'move_vec_y' and 'move_vec_x' for the direction relitive to the object. Its maths is simple, BodyMass * move_vec, so it’s weight can effect its movement speed.
Code:

NewtonBodyAddTorque(body, bodyMass * my.move_vec_x, bodyMass * my.move_vec_y, bodyMass * my.move_vec_z);



This is just what I think it is, I may be wrong. But it appears to make sense. I hope that was of some help to you...?

Re: [Newton] How to do some things with Newton [Re: sheefo] #85764
08/14/06 11:59
08/14/06 11:59
Joined: Apr 2006
Posts: 265
V
vartan_s Offline OP
Member
vartan_s  Offline OP
Member
V

Joined: Apr 2006
Posts: 265
Thanks, a lot, that got me started... I looked through the newton script and found that what I wanted was impulse... problem is, the script was too ambiguous to tell me how to use it, and I still need to turn off collision with non newton entities... anyone got info? thanks in advance

Re: [Newton] How to do some things with Newton [Re: vartan_s] #85765
08/15/06 11:28
08/15/06 11:28
Joined: Jul 2006
Posts: 783
London, UK
sheefo Offline
User
sheefo  Offline
User

Joined: Jul 2006
Posts: 783
London, UK
Turn of Newton collision for one object? Err... I'm not sure, but I will work on it.


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