Hi,
yesterday i was testing the Phyiscs Engine, i read the help file and practice it and i just want to see how its really work for cars.
so i took the car and tires from Newton Engine because i dont have other models and i was try to make stuff work and this thing drive me crazy!!!
i have two main problems:
1) Wheels problems like in this picture:
2) i have motoraized my wheels and when the wheel is spinning there is no friction and the body dont move....
here is my code:
Code:
//Physics demo test
//Non-Public
//Writed by Matan Golan
//Starting Var's:
string level_str = <test.WMB>;
var video_mode = 8;
var video_screen = 2;
var d3d_lightres = on;
//Panel Fonts:
font digit_font = "arial",1,20;
//Information Panel:
panel video_memory
{
pos_x = 0; pos_y = 0;
digits = 0, 0, 5, digit_font, 1,d3d_texskins; //Level models
digits = 0,20, 5, digit_font, 1,d3d_texsurfs; //Surface
digits = 0,40, 5, digit_font, 1,d3d_texsmaps; //shadows
digits = 0,60, 5, digit_font, 1,d3d_texbmaps; //bmaps
flags = VISIBLE;
}
//Vars:
var bodymass = 800;
var tiremass = 30;
var gravity[3] = 0,0,-10;
entity* cbody;
entity* ctire;
entity* floor;
var conID;
function main_quit()
{
exit;
}
function camera_control()
{
var force[3];
while(1)
{
if(!mouse_right)
{
camera.pan-=20*mouse_force.x*time;
camera.tilt+=20*mouse_force.y*time;
}
vec_set(force,nullvector);
if(key_a)
{
force.x-=1;
}
if(key_d)
{
force.x+=1;
}
if(key_w)
{
force.y+=1;
}
if(key_s)
{
force.y-=1;
}
if(key_a & key_shift)
{
force.x-=3;
}
if(key_d & key_shift)
{
force.x+=3;
}
if(key_w & key_shift)
{
force.y+=3;
}
if(key_s & key_shift)
{
force.y-=3;
}
camera.x+=20*cos(camera.pan)*cos(camera.tilt)*force.y*time;
camera.y+=20*sin(camera.pan)*cos(camera.tilt)*force.y*time;
camera.z+=20*sin(camera.tilt)*force.y*time;
camera.x-=20*cos(camera.pan+90)*force.x*time;
camera.y-=20*sin(camera.pan+90)*force.x*time;
wait(1);
}
}
function setcon()
{
conID = phcon_add(ph_wheel,cbody,ctire);
phcon_getposition(conID, temp);
vec_set(cbody.x, temp);
//phcon_setmotor(conID,vector(10, 50,0),nullvector,nullvector);
phcon_setparams1 (conID, ctire.x, vector(0,0,1), vector(1,0,0));
phcon_setparams2 (conID, vector(-45, 90, 0) ,nullvector,vector(90000,100,0));
while(1)
{
if(key_k)
{
phcon_setmotor(conID,nullvector,vector(50, 50,0),nullvector);
}
wait(1);
}
}
Action Body
{
cbody = my;
phent_settype(cbody,ph_rigid,ph_poly);
phent_setmass(cbody,bodymass,ph_box);
phent_setdamping(cbody,20,20);
phent_setfriction(cbody,40);
}
Action Tire
{
ctire = my;
phent_settype(ctire,ph_rigid,PH_CYLINDER);
phent_setmass(ctire,tiremass,ph_sphere);
phent_setdamping(ctire,50,50);
phent_setfriction(ctire,40);
setcon();
}
//Main Starting Function:
function main()
{
level_load(level_str);
wait(3);
clip_size = 1;
d3d_anisotropy = 5;
d3d_mipmapping = 3;
d3d_shadowdepth = 24;
camera_control(); // get camera control by WASD
//All engine pre-setes are defined
//Call further function here:
ph_setgravity(gravity);
}
on_F9 = _sshot;