Newton skripting

Posted By: Efrint

Newton skripting - 01/12/05 04:12

Hi Leute,

ich hab das aum skript für bouncing ball etwas abgewandelt. Wie schaffe ich es jetzt die newton physik engiene zu verwenden ohne die templates zu nutzen? Bei den templates funktioniert alles wunderbar, d.h. wenn ich rollenderweise gegen ein fass laufe wird es weggeschoben, hüpfe ich mit dem aum-skript gegen ein fass passiert gar nichts! Das fass hat in beiden fällen das newton
skript "NewtonWoodEntity"(oder so ähnlich).

Mein skript sieht so aus:
________________________________________________________________________________
action bouncing_ball
{
ball = my;
my.enable_block = on;
my.enable_entity = on;
my.event = reverse_speed;


while (1)
{

if (key_cuu == on)
{
ball_speed.x = 3 * time;
my.tilt -= 8 * time;

}
if (key_cud == on)
{
ball_speed.x = -3 * time;
my.tilt += 8 * time;
}
if ((key_cuu == off) && (key_cud == off))
{
ball_speed.x = 0;
}
if (key_cul == on)
{
ball_speed.y = 3 * time;
my.roll -= 8 * time;
}
if (key_cur == on)
{
ball_speed.y = -3 * time;
my.roll += 8 * time;
}
if ((key_cuu == off) && (key_cud == off))
{
ball_speed.x = 0;
}
if ((key_cul == off) && (key_cur == off))
{
ball_speed.y = 0;
}
vec_set (temp, my.x);
temp.z -= 1000;
trace_mode = ignore_me + ignore_passable + use_box; // use a thick trace ray (don't allow the ball to get stuck)
trace_dist = trace(my.x, temp);
if (trace_dist > max_height) // the ball has reached its maximum height?
{
ball_speed.z = -abs(ball_speed.z); // then give the ball a negative speed
}
ent_move (nullvector, ball_speed);
wait(1);
}
}

function reverse_speed()
{
ball_speed.z *= -1;
}
________________________________________________________________________________

Ich hoffe, mir kann jemand helfen!

Efrint
Posted By: Efrint

Re: Newton skripting - 01/12/05 21:47

Kann mir keiner helfen?
Posted By: ShooterMaker

Re: Newton skripting - 01/12/05 23:36

also wenn ich dich nun richtig verstehe meinst du jemand soll dir dieses skript so umendern das es mit der newton-physikengiene leuft -oder?
wenn ja dann stell es doch ins newton forum da kann man dir dann sicher helfen

mfg:

ShooterMaker
Posted By: Efrint

Re: Newton skripting - 01/13/05 03:12

He, das ist gar keine so blöde Idee...werd ich machen...
aber kann mir vielleicht sonst noch jemand helfen, in diesem forum?
Ich hab nämlich gar keine peil, wieso nur das prefab skript geht. Wie funktioniert das? Ist das mit einem pointer auf die entity XYZ geregelt, oder wie?
Danke schonmal für die Antwort!

Efrint


Eine Antwort wäre mir 24 Sterne wert!(soviele gibts aber nich)
Posted By: ShooterMaker

Re: Newton skripting - 01/13/05 03:18

öhhh also wenn es dir direkt um das skript geht kann ich dir leider nicht helfen, da ich in newton auch noch nicht ganz durchblicke, aber wenn es dir um so einen ball geht, es giebt so ein fertiges ball skript in der newton demo

mfg:

ShooterMaker
Posted By: fastlane69

Re: Newton skripting - 01/13/05 03:34

Take Shooter's advice: the answers to newton related problems are to be found on the Newton forum, not the 3DGS Physics Forum.

These forums are strictly for postings related to the 3DGS Physics Engine and not any other physics engine.

Good Luck with your project! Hope the Newton Forums help you out...if not you can always use the 3DGS Physics Engine and come back here for help!
Posted By: ventilator

Re: Newton skripting - 01/13/05 03:47

many newton questions (like this one) are more about having no clue about 3dgs scripting than anything else and don't really belong to the newton forum either. but i agree that newton topics shouldn't be posted in the 3dgs physics forum but in the beginner's, scripting or general tools forum.
Posted By: StOrM

Re: Newton skripting - 01/15/05 06:28

Theres a question I have had for a little while now with no answer, where are the official newton forums for the version which exists for 3d game studio ? I have the link to the Dark Basic Wrapper for Newton, and the main newton website, the C++ library version, so where is the support site for the 3d game studio version of newton ? If someone could help me out with a link for this I would really really appreciate it.

Thanks,

Ken
Posted By: Josh_Arldt

Re: Newton skripting - 01/15/05 06:49

This is the Newton PE website. You can get help with the gamestudio version on their forums.
www.physicsengine.com
Posted By: Drew

Re: Newton skripting - 01/22/05 11:00

I doubt you will find any new help in the newton forums... the A6 version has been discontinued for now (ventilator, please tell me Im wrong), so where else are people going to exchange answers to questions, concerning A6?
As long as the topic says "newton" in it, whats the harm?!

Posted By: Efrint

Re: Newton skripting - 01/28/05 19:40

hi, the people in the newton forum cant help me . Do you know what i can do? My script is at the top of the first page. Please help me although its a newton question!

Efrint
Posted By: Locoweed

Re: Newton skripting - 01/29/05 11:18

Hi Efrint,
I tried to translate your original message. That did not go so well. I am not sure where you should really put Newton question. I would think as long as you put Newton in the title either here or in Scripting forum would be about as good as anywhere. That's just my opinion.

Anyway, you can create a Newton moving with cursor bouncing ball by adding a new Newton material to the newtonScript2.wdl

Add this new newton material variable in declarations:

var rubber_material;

Add these skills in Declarations:

define SPEED_X, skill9;
define SPEED_Y, skill10;
define SPEED_Z, skill11;
define move_me, skill12;


Add this below NewtonWoodEnt action:

// uses mass, linear_drag, angular_drag_x, angular_drag_y, angular_drag_z, health, shape_factor, collision_groupId, collision_sph_box, start_active, compound_collision, destructible, spawn_children;
action NewtonBallEntity
{
NewtonCreateGravityEntity (rubber_material);

while (1)
{

if (key_cuu == on)
{
my.speed_x = 2 * time;
}
if (key_cud == on)
{
my.speed_x = -2 * time;
}
if (key_cul == on)
{
my.speed_y = 2 * time;
}
if (key_cur == on)
{
my.speed_y = -2 * time;
}
if ((key_cuu == off) && (key_cud == off))
{
my.speed_x = 0;
}
if ((key_cul == off) && (key_cur == off))
{
my.speed_y = 0;
}

if(my.SPEED_X || my.SPEED_Y)
{
my.MOVE_ME = ON;
NewtonGSScriptEvent();
my.MOVE_ME = OFF;
}
wait(2);
}
}

Add this in NewtonGSScriptEvent function:

if(my.MOVE_ME == ON)
{
// copy impact point on target
newtonImpulseRecord[0] = my.x;
newtonImpulseRecord[1] = my.y;
newtonImpulseRecord[2] = my.z;

// copy direction of push force
newtonImpulseRecord[3] = my.x - my.SPEED_X;
newtonImpulseRecord[4] = my.y - my.SPEED_Y;
newtonImpulseRecord[5] = my.z + .1; // give some top spin

// copy the push mass
newtonImpulseRecord[6] = 10;

// copy the some push speed, you may have to play with this
newtonImpulseRecord[7] = 5;

NewtonBodyAddImpulse (body, newtonImpulseRecord);
}

Add this in the NewtonSetupSystem() function: (notice how I set elasticity to .9)

// set material interaction propeteries (rubber_material, rubber_material)
NewtonMaterialSetFriction (rubber_material, rubber_material, 1.0, 1.0);
NewtonMaterialSetElasticity (rubber_material, rubber_material, 0.9);
NewtonMaterialSetDepthRecover (rubber_material, rubber_material, 0.2);

Now you can save newtonScript2.wdl. Close WED if it is open. Open WED place a sphere in your level. Place it up in the air. Open properties-behavior. Set action to NewtonBallEnt, set mass = 1.0, linear_drag, angular_drag_x,_y,_z all to 0.1. Check the flags for collison_sph_box and start_active. Build the level and run. The ball should fall from the air and bounce up and down a while. Use cursor keys to move.

That reminds me, when I added blocks to level the the newton_ball.mdl that came with Newton would pass through them for some reason. I made my own sphere(ball) model and it worked fine.

I hope that is close to what you wanted. It may need some fine tuning, but that ball moves, bounces around, and spins, so it should get you started.

Later,
Loco
© 2024 lite-C Forums