[Plugin] cimulator - collision detection and physics simulation
#66

Код:
enum MatrixParts
{
	mp_PITCH,
	mp_ROLL,
	mp_YAW,
	mp_POS
};

enum MatrixIndicator
{
	Float:mi_X,
	Float:mi_Y,
	Float:mi_Z
};

stock GetVehicleMatrix(vehicleid,Mat4x3[MatrixParts][MatrixIndicator])
{
//initial processing step - gathering information
	new
		Float:x,
		Float:y,
		Float:z,
		Float:w,
		Float:Pos[3];

	GetVehicleRotationQuat(vehicleid,w,x,y,z);
	GetVehiclePos(vehicleid,Pos[0],Pos[1],Pos[2]);
	new
		Float:x2 = x * x,
	 	Float:y2 = y * y,
	 	Float:z2 = z * z,
	 	Float:xy = x * y,
	 	Float:xz = x * z,
		Float:yz = y * z,
		Float:wx = w * x,
		Float:wy = w * y,
		Float:wz = w * z;
	Mat4x3[mp_PITCH][mi_X] = 1.0 - 2.0 * (y2 + z2);
	Mat4x3[mp_PITCH][mi_Y] = 2.0 * (xy - wz);
	Mat4x3[mp_PITCH][mi_Z] = 2.0 * (xz + wy);
	Mat4x3[mp_ROLL][mi_X] = 2.0 * (xy + wz);
	Mat4x3[mp_ROLL][mi_Y] = 1.0 - 2.0 * (x2 + z2);
	Mat4x3[mp_ROLL][mi_Z] = 2.0 * (yz - wx);
 	Mat4x3[mp_YAW][mi_X] = 2.0 * (xz - wy);
 	Mat4x3[mp_YAW][mi_Y] = 2.0 * (yz + wx);
 	Mat4x3[mp_YAW][mi_Z] = 1.0 - 2.0 * (x2 + y2);
  	Mat4x3[mp_POS][mi_X] = Pos[0];
  	Mat4x3[mp_POS][mi_Y] = Pos[1];
  	Mat4x3[mp_POS][mi_Z] = Pos[2];
  	
	return 1;
}

stock PositionFromVehicleOffset(vehicle,Float:offX,Float:offY,Float:offZ,&Float:x,&Float:y,&Float:z)
{
    new Mat4x3[MatrixParts][MatrixIndicator];
    GetVehicleMatrix(vehicle,Mat4x3);


	x = offX * Mat4x3[mp_PITCH][mi_X] + offY * Mat4x3[mp_ROLL][mi_X] + offZ * Mat4x3[mp_YAW][mi_X] + Mat4x3[mp_POS][mi_X];
	y = offX * Mat4x3[mp_PITCH][mi_Y] + offY * Mat4x3[mp_ROLL][mi_Y] + offZ * Mat4x3[mp_YAW][mi_Y] + Mat4x3[mp_POS][mi_Y];
	z = offX * Mat4x3[mp_PITCH][mi_Z] + offY * Mat4x3[mp_ROLL][mi_Z] + offZ * Mat4x3[mp_YAW][mi_Z] + Mat4x3[mp_POS][mi_Z];

	return 1;
}
use:
Код:
PositionFromVehicleOffset(vehid,0.0, 0.0, 2.0,x, y, z);
CreateObject(343, x, y, z, 0.0, 0.0, 0.0); // creates a point at a height of 2 meters from the car no matter how it is tilted
Reply


Messages In This Thread
cimulator - collision detection and physics simulation - by codectile - 25.11.2015, 15:25
Re: cimulator - collision detection and physics simulation - by Pottus - 25.11.2015, 15:29
Re: cimulator - collision detection and physics simulation - by codectile - 25.11.2015, 15:44
Re: cimulator - collision detection and physics simulation - by Stanford - 03.12.2015, 15:34
Re: cimulator - collision detection and physics simulation - by SkittlesAreFalling - 03.12.2015, 15:37
Re: cimulator - collision detection and physics simulation - by codectile - 03.12.2015, 18:08
Re: cimulator - collision detection and physics simulation - by TwinkiDaBoss - 03.12.2015, 19:01
Re: cimulator - collision detection and physics simulation - by codectile - 04.12.2015, 01:54
Re: cimulator - collision detection and physics simulation - by Crayder - 04.12.2015, 03:03
Re: cimulator - collision detection and physics simulation - by codectile - 04.12.2015, 03:45
Re: cimulator - collision detection and physics simulation - by Crayder - 04.12.2015, 04:38
Re: cimulator - collision detection and physics simulation - by codectile - 04.12.2015, 11:44
Re: cimulator - collision detection and physics simulation - by Stanford - 04.12.2015, 12:28
Re: cimulator - collision detection and physics simulation - by Cypress - 05.12.2015, 19:57
Re: cimulator - collision detection and physics simulation - by DRIFT_HUNTER - 05.12.2015, 20:50
Re: cimulator - collision detection and physics simulation - by codectile - 06.12.2015, 03:48
Re: cimulator - collision detection and physics simulation - by Crayder - 06.12.2015, 14:46
Re: cimulator - collision detection and physics simulation - by codectile - 06.12.2015, 16:13
Re: cimulator - collision detection and physics simulation - by Crayder - 06.12.2015, 19:09
Re: cimulator - collision detection and physics simulation - by codectile - 07.12.2015, 01:48
Re: cimulator - collision detection and physics simulation - by iWhite - 07.12.2015, 13:12
Re: cimulator - collision detection and physics simulation - by Stanford - 07.12.2015, 13:49
Re: cimulator - collision detection and physics simulation - by Romz - 07.12.2015, 13:52
Re: cimulator - collision detection and physics simulation - by Crayder - 07.12.2015, 16:03
Re: cimulator - collision detection and physics simulation - by codectile - 07.12.2015, 17:03
Re: cimulator - collision detection and physics simulation - by Romz - 09.12.2015, 14:30
Re: cimulator - collision detection and physics simulation - by codectile - 10.12.2015, 09:17
Re: cimulator - collision detection and physics simulation - by Riddick94 - 16.12.2015, 20:53
Re: cimulator - collision detection and physics simulation - by DRIFT_HUNTER - 16.12.2015, 22:06
Re: cimulator - collision detection and physics simulation - by codectile - 17.12.2015, 02:18
Re: cimulator - collision detection and physics simulation - by DRIFT_HUNTER - 17.12.2015, 06:59
Re: cimulator - collision detection and physics simulation - by Stanford - 31.12.2015, 16:10
Re: cimulator - collision detection and physics simulation - by codectile - 31.12.2015, 17:32
Re: cimulator - collision detection and physics simulation - by Stanford - 31.12.2015, 18:12
Re: cimulator - collision detection and physics simulation - by codectile - 01.01.2016, 05:09
Re: cimulator - collision detection and physics simulation - by Romz - 03.01.2016, 16:11
Re: cimulator - collision detection and physics simulation - by codectile - 03.01.2016, 16:26
Re: cimulator - collision detection and physics simulation - by Stanford - 03.01.2016, 16:32
Re: cimulator - collision detection and physics simulation - by Romz - 03.01.2016, 17:55
Re: cimulator - collision detection and physics simulation - by Sublime - 04.01.2016, 12:16
Re: cimulator - collision detection and physics simulation - by codectile - 04.01.2016, 12:34
Re: cimulator - collision detection and physics simulation - by Stanford - 06.01.2016, 03:51
Re: cimulator - collision detection and physics simulation - by Crayder - 06.01.2016, 04:23
Re: cimulator - collision detection and physics simulation - by Stanford - 06.01.2016, 04:54
Re: cimulator - collision detection and physics simulation - by Crayder - 06.01.2016, 05:13
Re: cimulator - collision detection and physics simulation - by codectile - 06.01.2016, 12:29
Re: cimulator - collision detection and physics simulation - by Stanford - 06.01.2016, 18:51
Re: cimulator - collision detection and physics simulation - by codectile - 07.01.2016, 08:46
Re: cimulator - collision detection and physics simulation - by Stanford - 07.01.2016, 10:00
Re: cimulator - collision detection and physics simulation - by tungki - 07.01.2016, 13:18
Respuesta: Re: cimulator - collision detection and physics simulation - by ipsBruno - 30.03.2016, 07:22
Re: cimulator - collision detection and physics simulation - by codectile - 30.03.2016, 09:10
Respuesta: Re: cimulator - collision detection and physics simulation - by ipsBruno - 30.03.2016, 12:57
Re: Respuesta: Re: cimulator - collision detection and physics simulation - by Crayder - 30.03.2016, 14:34
Respuesta: Re: Respuesta: Re: cimulator - collision detection and physics simulation - by ipsBruno - 30.03.2016, 15:34
Re: Respuesta: Re: Respuesta: Re: cimulator - collision detection and physics simulation - by Crayder - 30.03.2016, 16:07
Re: cimulator - collision detection and physics simulation - by Finn - 30.03.2016, 19:11
Re: cimulator - collision detection and physics simulation - by codectile - 03.04.2016, 15:50
Re: cimulator - collision detection and physics simulation - by Pottus - 03.05.2016, 01:09
Re: cimulator - collision detection and physics simulation - by AIped - 03.05.2016, 08:05
Re: cimulator - collision detection and physics simulation - by Sanady - 03.05.2016, 09:55
Re: cimulator - collision detection and physics simulation - by Sanady - 03.05.2016, 09:59
Re: cimulator - collision detection and physics simulation - by codectile - 03.05.2016, 10:47
Re: cimulator - collision detection and physics simulation - by Sanady - 03.05.2016, 11:31
Re: cimulator - collision detection and physics simulation - by codectile - 03.05.2016, 12:10
Re: cimulator - collision detection and physics simulation - by VAWYLoN - 14.05.2016, 03:26
Re: cimulator - collision detection and physics simulation - by Crayder - 16.05.2016, 13:19
Re: cimulator - collision detection and physics simulation - by VAWYLoN - 17.05.2016, 08:47
Re: cimulator - collision detection and physics simulation - by codectile - 24.06.2016, 08:48
Re: cimulator - collision detection and physics simulation - by Crayder - 24.06.2016, 19:59
Re: cimulator - collision detection and physics simulation - by usersamp - 05.08.2016, 12:44

Forum Jump:


Users browsing this thread: 1 Guest(s)