Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Nymphodora), 1,466 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
converted physX car #369372
05/03/11 19:47
05/03/11 19:47
Joined: Feb 2010
Posts: 886
Random Offline OP
User
Random  Offline OP
User

Joined: Feb 2010
Posts: 886
I converted a physical car (it was ode) to physX.
Someewere I read a few times that some peapol would like to see that script converted.
So if anybody needs it;

Click to reveal..
var constr_front_left;
var constr_front_right;

var constr_back_left;
var constr_back_right;

VECTOR mom_speed;
var max_angle;
var stear_contr;

var max_speed = 1500;
var ang_force;
var speed_contr;

ENTITY* chassis;

function wheel_physics_init()
{
set (my, SHADOW);
pXent_settype (my, PH_RIGID, PH_SPHERE);
pXent_setmass (my, 30, PH_SPHERE);
pXent_setgroup (my, 2);
pXent_setfriction (my, 100);
pXent_setdamping (my, 20, 20);
pXent_setelasticity (my, 0, 100);
}

function front_tyre_left()
{
wheel_physics_init();
pXcon_add(PH_WHEEL, chassis, my);
pXcon_setparams1 (constr_front_left, my.x, vector (0,0,1), nullvector);
pXcon_setparams2 (constr_front_left, nullvector, nullvector, nullvector);
}

function front_tyre_right()
{
wheel_physics_init();
pXcon_add(PH_WHEEL, chassis, my);
pXcon_setparams1 (constr_front_right, my.x, vector (0,0,1), nullvector);
pXcon_setparams2 (constr_front_right, nullvector, nullvector, nullvector);
}

function back_tyre_left()
{
wheel_physics_init();
pXcon_add(PH_WHEEL, chassis, my);
pXcon_setparams1 (constr_back_left, my.x, vector (0,0,1), nullvector);
pXcon_setparams2 (constr_back_left, nullvector, nullvector, nullvector);
}

function back_tyre_right()
{
wheel_physics_init();
pXcon_add(PH_WHEEL, chassis, my);
pXcon_setparams1 (constr_back_right, my.x, vector (0,0,1), nullvector);
pXcon_setparams2 (constr_back_right, nullvector, nullvector, nullvector);
}

action chassis()
{
my.armor = 100;
chassis = my;
set (chassis, SHADOW);

pXent_settype (chassis, PH_RIGID, PH_BOX);
pXent_setmass (chassis, 15, PH_BOX);
pXent_setgroup (chassis, 2);

pXent_setfriction (chassis, 20);
pXent_setdamping (chassis, 5, 5);
pXent_setelasticity (chassis, 10, 100);

ent_create ("car_tyre_left.mdl", vector (chassis.x - 65, chassis.y - 45, chassis.z - 20), back_tyre_left);
ent_create ("car_tyre_right.mdl", vector (chassis.x - 65, chassis.y + 45, chassis.z - 20), back_tyre_right);
ent_create ("car_tyre_left.mdl", vector (chassis.x + 65, chassis.y - 45, chassis.z - 20), front_tyre_left);
ent_create ("car_tyre_right.mdl", vector (chassis.x + 65, chassis.y + 45, chassis.z - 20), front_tyre_right);
while(my.armor>0)
{
stear_contr = (key_d - key_a);
max_angle += stear_contr * 3 * time_step;
max_angle = clamp (max_angle, -30, 30);
if (stear_contr != 0)
{
pXcon_setparams2 (constr_front_left, vector (max_angle, max_angle, 0), nullvector, vector (95000, 500, 0));
pXcon_setparams2 (constr_front_right, vector (max_angle, max_angle, 0), nullvector, vector (95000, 500, 0));
}
else
{
max_angle = max_angle * (1 - (0.25 * time_step));
if (abs(max_angle) < 1)
max_angle = 0;
pXcon_setparams2 (constr_front_left, vector (max_angle, max_angle, 0), nullvector, vector (95000, 500, 0));
pXcon_setparams2 (constr_front_right, vector (max_angle, max_angle, 0), nullvector, vector (95000, 500, 0));
}
speed_contr = (key_w - key_s);//w = 1, s = -1, w & s = 0
ang_force = speed_contr * 1000 * time_step;

pXcon_setmotor (constr_back_left, nullvector, vector(-ang_force, max_speed, 0), nullvector);
pXcon_setmotor (constr_back_left, nullvector, vector(-ang_force, max_speed, 0), nullvector);

camera.x = chassis.x - 250 * cos(chassis.pan);
camera.y = chassis.y - 250 * sin(chassis.pan);
camera.pan = chassis.pan;
camera.z = chassis.z + 50;
camera.tilt = -15;

wait(1);
}
}


Random



Re: converted physX car [Re: Random] #370357
05/12/11 16:32
05/12/11 16:32
Joined: Sep 2004
Posts: 178
J
jweb Offline
Member
jweb  Offline
Member
J

Joined: Sep 2004
Posts: 178
Hi Random

Thanks for this work.

I see pXcon_setmotor is new ab Version 8.12. This is a good News.
I work with 8.10.
Which Version a you use for coding this Sample ?

THX
JW

Re: converted physX car [Re: jweb] #370593
05/14/11 13:44
05/14/11 13:44
Joined: Feb 2010
Posts: 886
Random Offline OP
User
Random  Offline OP
User

Joined: Feb 2010
Posts: 886
3d gamestudio commercial 8.10

I hope it helps



Re: converted physX car [Re: Random] #370599
05/14/11 15:16
05/14/11 15:16
Joined: Sep 2009
Posts: 496
P
Progger Offline
Senior Member
Progger  Offline
Senior Member
P

Joined: Sep 2009
Posts: 496
but there is something wrong which also was wron in the other version

in this lines

instead of

Code:
pXcon_setmotor (constr_back_left, nullvector, vector(-ang_force, max_speed, 0), nullvector);
pXcon_setmotor (constr_back_left, nullvector, vector(-ang_force, max_speed, 0), nullvector);




this


pXcon_setmotor (constr_back_left, nullvector, vector(-ang_force, max_speed, 0), nullvector);
pXcon_setmotor (constr_back_right, nullvector, vector(-ang_force, max_speed, 0), nullvector);

Last edited by Progger; 05/14/11 15:18.

asking is the best Way to get help laugh laugh laugh
Re: converted physX car [Re: Progger] #370880
05/16/11 13:25
05/16/11 13:25
Joined: Feb 2010
Posts: 886
Random Offline OP
User
Random  Offline OP
User

Joined: Feb 2010
Posts: 886
ups, sorry grin



Re: converted physX car [Re: Random] #371747
05/24/11 20:08
05/24/11 20:08
Joined: Sep 2009
Posts: 496
P
Progger Offline
Senior Member
Progger  Offline
Senior Member
P

Joined: Sep 2009
Posts: 496
Well its a little old but this version doesnt work.Did you test it or you though no mistakes and then put in inside here?
The parameters are wrong and you gave an action the same name as an Entity well totally buggy

Last edited by Progger; 05/24/11 20:18.

asking is the best Way to get help laugh laugh laugh
Re: converted physX car [Re: Progger] #371833
05/25/11 20:55
05/25/11 20:55
Joined: Sep 2004
Posts: 178
J
jweb Offline
Member
jweb  Offline
Member
J

Joined: Sep 2004
Posts: 178
yes the code doesent work for me to.

Re: converted physX car [Re: jweb] #372043
05/27/11 16:13
05/27/11 16:13
Joined: Sep 2009
Posts: 496
P
Progger Offline
Senior Member
Progger  Offline
Senior Member
P

Joined: Sep 2009
Posts: 496
Php Code:
#include <default.c>
#include <acknex.h>
#include <ackphysx.h>

function mass ()
{
	pXent_setmass(my,60);
	pXent_setfriction (my, 100);
	pXent_setdamping (my, 20, 20);
	pXent_setelasticity (my,20);
   //pXent_addforcecentral (my,vector(0,0,2000));
}


function simple_car()
{
	ENTITY* car = ent_create("bmw.mdl",vector(300,-1000,5),NULL); 
	pXent_settype(car,PH_RIGID,PH_BOX);
	pXent_setmass(car,30);
	ENTITY* BLwheel = ent_create("bmwwheel.mdl",vector(car.x-50,car.y-24,car.z-12),mass);
	ENTITY* BRwheel = ent_create("bmwwheel.mdl",vector(car.x-50,car.y+24,car.z-12),mass);
	ENTITY* FLwheel = ent_create("bmwwheel.mdl",vector(car.x+56,car.y-24,car.z-12),mass);
	ENTITY* FRwheel = ent_create("bmwwheel.mdl",vector(car.x+56,car.y+24,car.z-12),mass);
	pXcon_add ( PH_WHEEL, FLwheel, car, 0 );
	pXcon_add ( PH_WHEEL, FRwheel, car, 0 );
	pXcon_add ( PH_WHEEL, BLwheel, car, 0 );
	pXcon_add ( PH_WHEEL, BRwheel, car, 0 );
	//drive the car		
	while(1)
	{
		speed=clamp(speed,-2000,2000);
		lenk=clamp(lenk,-20,20);
		
		if(key_w)
		{
			speed-=100;
		}
		else
		if(key_w==0)
		speed+=10;
		
		if(key_s)
		{
			speed+=100;
		}
		
		if(key_a)
		{
			lenk-=2;
		}
		
		if(key_d)
		{
			lenk+=2;
		}
		
		DEBUG_VAR(lenk,200);
		pXcon_setwheel (FLwheel,lenk,0,0);
		pXcon_setwheel (FRwheel,lenk,0,0); // steer to the right
		pXcon_setwheel (BLwheel,0,speed,0);
		pXcon_setwheel (BRwheel,0,speed,0);
		
 
		
		
		//	var max_speed = 3000;
		//	 var speed_contr =5*(key_w - key_s);//w = 1, s = -1, w & s = 0
		//		
		//		var ang_force = speed_contr * 1000 * time_step;
		//		
		//		pXcon_setmotor (car, vector(-ang_force, max_speed, 0), nullvector);
		//		pXcon_setmotor (car,vector(-ang_force, max_speed, 0), nullvector);
		
		   pXent_addvelcentral(car,vector(0,0,-10));
//			pXent_addvelcentral(FLwheel,vector(0,0,-50));
//			pXent_addvelcentral(FRwheel,vector(0,0,-50));
//			pXent_addvelcentral(BLwheel,vector(0,0,-50));
//			pXent_addvelcentral(BRwheel,vector(0,0,-50));

		camera.x = car.x - 250 *cos(car.pan);
		camera.y = car.y - 250 *sin(car.pan);
		camera.z = car.z + 50;
		camera.pan = car.pan;
		
		
		wait(1);
	}
}

void main()
{
	fps_max=60;
	
	video_mode=12;
	//ph_fps_max_lock=120;
	physX_open();
	level_load ("testlevel.wmb");
	simple_car();
	wait(5);
} 




It is buggy but it still does a little bit of what a car should do grin


asking is the best Way to get help laugh laugh laugh
Re: converted physX car [Re: Progger] #372130
05/28/11 21:22
05/28/11 21:22
Joined: Sep 2004
Posts: 178
J
jweb Offline
Member
jweb  Offline
Member
J

Joined: Sep 2004
Posts: 178
eheh Super THX you Progger


Moderated by  HeelX, Spirit 

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