Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
M1 Oversampling
by 11honza11. 04/20/24 20:57
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (rki), 405 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 5
Page 15 of 16 1 2 13 14 15 16
Re: newton [Re: croman] #206123
05/11/08 10:59
05/11/08 10:59
Joined: May 2002
Posts: 7,441
ventilator Offline OP
Senior Expert
ventilator  Offline OP
Senior Expert

Joined: May 2002
Posts: 7,441
it's an array/vector of 3 floats like that:
float updir[3] = {0.0, 0.0, 1.0};

Re: newton [Re: ventilator] #206124
05/11/08 11:07
05/11/08 11:07
Joined: Nov 2007
Posts: 1,032
Croatia
croman Offline
Serious User
croman  Offline
Serious User

Joined: Nov 2007
Posts: 1,032
Croatia
nope, still not working. engine shuts down every time...

here's my code:::

// add world geometry
n_world = ent_create("newton_playground.mdl", nullvector, NULL);
n_world->flags |= FLAG8; // flag8 -> will be added to world collision geometry

newton_start();
on_close = quit;
on_space = drop_it;

const float updir[3] = {0.0, 0.0, 9.8};

car = ent_create("car.mdl", vector(100,200,500), NULL);
NewtonBody *car_body = newton_addentity(car, 80, NEWTON_CONVEXHULL, onforceandtorque);
car_joint = NewtonConstraintCreateVehicle (n_world, &updir[0], car_body);



Ubi bene, ibi Patria.
Re: newton [Re: croman] #206427
05/13/08 13:54
05/13/08 13:54
Joined: Nov 2007
Posts: 1,032
Croatia
croman Offline
Serious User
croman  Offline
Serious User

Joined: Nov 2007
Posts: 1,032
Croatia
anyone?



Ubi bene, ibi Patria.
Re: newton [Re: croman] #206431
05/13/08 14:42
05/13/08 14:42
Joined: May 2002
Posts: 7,441
ventilator Offline OP
Senior Expert
ventilator  Offline OP
Senior Expert

Joined: May 2002
Posts: 7,441
the updir is supposed to be a unit vector (0,0,1) but it's unlikely that that would cause a crash.

did you look at the official newton examples for creating vehicles and try to do it similarly?

can you post you whole vehicle code (also the tires)?

Re: newton [Re: ventilator] #206435
05/13/08 14:56
05/13/08 14:56
Joined: Nov 2007
Posts: 1,032
Croatia
croman Offline
Serious User
croman  Offline
Serious User

Joined: Nov 2007
Posts: 1,032
Croatia
that's the problem. i didn't get so far. currently i'm trying to make my model be vehicle joint

[code]
#include <acknex.h>
#include <default.c>
#include <d3d9.h>

// newton works with meters!
// 1 meter = 32 quants
float QUANTTOMETER = 0.03125;
float METERTOQUANT = 32;

#include "newton.h"
#include "matrix.c"
#include "newton_main.c"
#include "newton_debug.c"


ENTITY* n_world;
//ENTITY* car_body;
ENTITY* car;
ENTITY* cam_ctrl;
//ENTITY* car_joint;

//--------------------------------------------------------------------------------------- onforceandtorque()
// callback which applies gravity to active physics entities
//---------------------------------------------------------------------------------------
void onforceandtorque(NewtonBody* body)
{
float mass, ixx, iyy, izz;
NewtonBodyGetMassMatrix(body, &mass, &ixx, &iyy, &izz);
NewtonBodySetForce(body, vectorf(0, 0, -9.8 * mass));
}

//--------------------------------------------------------------------------------------- quit()
// gets called when the engine closes
//---------------------------------------------------------------------------------------
void quit(){newton_stop();}
function camera_upd();

function drop_it()
{
you = ent_create("car.mdl", camera.x, NULL);
you->pan += camera->pan;
NewtonBody *body = newton_addentity(you, 10, NEWTON_CONVEXHULL, onforceandtorque);
}

function main()
{
fps_max = 120;
video_mode = 8;
//video_screen = 1;

wait(3);
level_load(""); // use an empty level
wait(3);

vec_set(&sun_angle, vector(300, 30, 0));
vec_set(&camera->x, vector(0, 0, 500)); // camera start position
camera_upd();

// add world geometry
n_world = ent_create("newton_playground.mdl", nullvector, NULL);
n_world->flags |= FLAG8; // flag8 -> will be added to world collision geometry

newton_start();
on_close = quit;
on_space = drop_it;

const float updir[3] = {0.0, 0.0, 9.8};

car = ent_create("car.mdl", vector(100,200,500), NULL);
NewtonBody *car_body = newton_addentity(car, 80, NEWTON_CONVEXHULL, onforceandtorque);
NewtonJoint *car_joint = NewtonConstraintCreateVehicle (n_world, &updir[0], car_body);
}


function camera_upd()
{
VECTOR cam_move;
cam_ctrl = ent_create("ball.mdl", vector(0,0,300), NULL);
set(cam_ctrl, INVISIBLE | PASSABLE);

while(1){
cam_move.x = (key_w - key_s) * 40 * time_step;
cam_move.y = (key_a - key_d) * 30 * time_step;

c_move(cam_ctrl, cam_move, nullvector, NULL);

cam_ctrl.tilt += mouse_force.y * 15 * time_step;
cam_ctrl.pan -= mouse_force.x * 15 * time_step;

vec_set(camera.x, cam_ctrl.x);
camera.tilt = cam_ctrl.tilt;
camera.pan = cam_ctrl.pan;

wait(1);
}
}
[code/]

Last edited by cerberi_croman; 05/13/08 14:57.


Ubi bene, ibi Patria.
Re: newton [Re: croman] #206482
05/13/08 19:54
05/13/08 19:54
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline

Serious User
VeT  Offline

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
body_temp=newton_addentity(my, -35, NEWTON_BOT, MHforceandtorque);
NewtonConstraintCreateUpVector (nworld, vectorf(0,0,QUANTTOMETER), body_temp);


maybe this could help you


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: newton [Re: VeT] #206486
05/13/08 20:05
05/13/08 20:05
Joined: May 2002
Posts: 7,441
ventilator Offline OP
Senior Expert
ventilator  Offline OP
Senior Expert

Joined: May 2002
Posts: 7,441
Code:
void create_vehicle()
{
	ENTITY* car = ent_create("crate.mdl", vector(0, 0, 500), NULL);
	NewtonBody *car_body = newton_addentity(car, 80, NEWTON_CONVEXHULL, onforceandtorque);
	NewtonJoint *car_joint = NewtonConstraintCreateVehicle (nworld, vectorf(0, 0, 1), car_body);
}


this doesn't crash for me. my guess is that your n_world pointer is wrong.

Re: newton [Re: ventilator] #206550
05/14/08 08:30
05/14/08 08:30
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline

Serious User
VeT  Offline

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
i got upvector unworking wile used
//float updir[3] = {0.0, 0.0, 1.0};

but
//float updir[3] = {0.0, 0.0, QUANTTOMETER};
it work fine


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: newton [Re: VeT] #206574
05/14/08 12:32
05/14/08 12:32
Joined: Nov 2007
Posts: 1,032
Croatia
croman Offline
Serious User
croman  Offline
Serious User

Joined: Nov 2007
Posts: 1,032
Croatia
no, still not working. my world creation code is this:

n_world = ent_create("newton_playground.mdl", nullvector, NULL);
n_world->flags |= FLAG8; // flag8 -> will be added to world collision geometry


if you made it work can you post that code please?



Ubi bene, ibi Patria.
Re: newton [Re: croman] #206612
05/14/08 16:49
05/14/08 16:49
Joined: May 2002
Posts: 7,441
ventilator Offline OP
Senior Expert
ventilator  Offline OP
Senior Expert

Joined: May 2002
Posts: 7,441
nworld has to be the newton world and not a gamestudio entity. that's why it crashes.

just copy my function into the newton lite-c demo source code and call it from somewhere. it doesn't crash. then you can go on from there and try to add tires.

Page 15 of 16 1 2 13 14 15 16

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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