|
Re: newton
[Re: ventilator]
#206124
05/11/08 11:07
05/11/08 11:07
|
Joined: Nov 2007
Posts: 1,032 Croatia
croman
Serious User
|
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: ventilator]
#206435
05/13/08 14:56
05/13/08 14:56
|
Joined: Nov 2007
Posts: 1,032 Croatia
croman
Serious User
|
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
Serious User
|
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
|
|
|
Re: newton
[Re: VeT]
#206486
05/13/08 20:05
05/13/08 20:05
|
Joined: May 2002
Posts: 7,441
ventilator
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2002
Posts: 7,441
|
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: VeT]
#206574
05/14/08 12:32
05/14/08 12:32
|
Joined: Nov 2007
Posts: 1,032 Croatia
croman
Serious User
|
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.
|
|
|
|