3 registered members (VoroneTZ, monk12, Quad),
829
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Newton 2 wrapper
[Re: VeT]
#250539
02/08/09 15:36
02/08/09 15:36
|
Joined: Oct 2007
Posts: 5,210 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
|
i tried with
car(200) wheels(20) car(200) wheels(25) car(200) wheels(50) car(20) wheels(3)
3333333333
|
|
|
Re: Newton 2 wrapper
[Re: VeT]
#250880
02/10/09 13:33
02/10/09 13:33
|
Joined: Oct 2007
Posts: 5,210 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
|
2 Quadraxas i didnt worked with cars yet, but i think you can try to make wheel's mass larger than car body... car starts to fly when it touches the ground.
Last edited by Quadraxas; 02/10/09 13:33.
3333333333
|
|
|
Re: Newton 2 wrapper
[Re: VeT]
#251402
02/12/09 21:29
02/12/09 21:29
|
Joined: Oct 2007
Posts: 5,210 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
|
ENTITY* car;
var camerapanmodifier = 0;
void tireUpdate(const NewtonJoint* vehicle)
{
int tireId;
float m[16];
ENTITY* tireModel;
for (tireId = NewtonVehicleGetFirstTireID (vehicle); tireId!=NULL; tireId = NewtonVehicleGetNextTireID (vehicle, tireId))
{
tireModel = NewtonVehicleGetTireUserData (vehicle, tireId);
NewtonVehicleGetTireMatrix( vehicle,tireId, m);
ent_setmatrix_rb(tireModel,m);
}
}
action Visual_Car(){
while(car!=NULL){
vec_set(my.x,car.x);
vec_set(my.pan,car.pan);
wait(1);
}
}
action Newton_Car()
{
car = me;
set(my,INVISIBLE);//hide the physical proxy
while(!newton_running){wait(1);}
NewtonBody* car_body=newton_addentity(me, 100, NEWTON_CONVEXHULL, onforceandtorque);
NewtonBodySetAutoFreeze( car_body, 0);
NewtonBodySetLinearDamping(car_body,0.03);
ent_create("kasa1.mdl",nullvector,Visual_Car);//car model
float upDirection[] = {0.0, 0.0, 1.0};
NewtonJoint* car_joint = NewtonConstraintCreateVehicle(nworld, upDirection[0], car_body);
NewtonVehicleSetTireCallback(car_joint, tireUpdate);
int tireMass = 10;
float suspensionLength = 0.1;
float suspensionSpring =3000.0;
float suspensionShock = 10.0;
float wheelradius = 0.5;
float tirePin[] = {0.0, 1.0, 0.0};
D3DXMATRIX tire_offset;
VECTOR tirepos;
vec_for_bone(tirepos,me,"osol");//f left
vec_sub(tirepos,my.x);
D3DXMatrixTranslation(&tire_offset, tirepos.x * QUANTTOMETER,tirepos.y * QUANTTOMETER,tirepos.z * QUANTTOMETER);
NewtonVehicleAddTire(car_joint, &tire_offset, tirePin[0], tireMass, wheelradius, wheelradius, suspensionShock,suspensionSpring,suspensionLength, ent_create("teker1.mdl",nullvector,NULL), 0);
vec_for_bone(tirepos,me,"osag");//f right
vec_sub(tirepos,my.x);
D3DXMatrixTranslation(&tire_offset, tirepos.x * QUANTTOMETER,tirepos.y * QUANTTOMETER,tirepos.z * QUANTTOMETER);
NewtonVehicleAddTire(car_joint, &tire_offset, tirePin[0], tireMass, wheelradius, wheelradius, suspensionShock,suspensionSpring,suspensionLength, ent_create("teker1.mdl",nullvector,NULL), 1);
vec_for_bone(tirepos,me,"asol");//r left
vec_sub(tirepos,my.x);
D3DXMatrixTranslation(&tire_offset, tirepos.x * QUANTTOMETER,tirepos.y * QUANTTOMETER,tirepos.z * QUANTTOMETER);
NewtonVehicleAddTire(car_joint, &tire_offset, tirePin[0], tireMass, wheelradius, wheelradius, suspensionShock,suspensionSpring,suspensionLength, ent_create("teker1.mdl",nullvector,NULL), 2);
vec_for_bone(tirepos,me,"asag");//r left
vec_sub(tirepos,my.x);
D3DXMatrixTranslation(&tire_offset, tirepos.x * QUANTTOMETER,tirepos.y * QUANTTOMETER,tirepos.z * QUANTTOMETER);
NewtonVehicleAddTire(car_joint, &tire_offset, tirePin[0], tireMass, wheelradius, wheelradius, suspensionShock,suspensionSpring,suspensionLength, ent_create("teker1.mdl",nullvector,NULL), 3);
while(1){
wait(1);
camera.pan = my.pan + camerapanmodifier;
camerapanmodifier += mouse_force.x*time_step*10;
camera.x = my.x - 700*cosv(camera.pan);
camera.y = my.y - sinv(camera.pan)*700;
camera.z = my.z + 200;
camera.tilt =-15;
}
}
my car setup (both works with your and ventilator's wrapper.both same result) and this is the ent_create i use ent_create("kasa1fiz.mdl",vector(100,0,350),Newton_Car);//create car i use diffrent models for visual and physical models: car,physics proxy and tire models: http://rapidshare.com/files/197359812/carmodelparts.zip.html
3333333333
|
|
|
|