Something I wrote for TommyB for getting the world positions of vehicle components. Does not take X and Y rotations into account.
PHP Code:
stock GetVehiclePartAbsolutePos(vehicleid, Float:partX, Float:partY, Float:partZ, &Float:x, &Float:y, &Float:z) {
? ?if (!IsValidVehicle(vehicleid)) {
? ? ? ?return 0;
? ?}
? ?new Float:a;
? ?GetVehiclePos(vehicleid, x, y, z);
? ?GetVehicleZAngle(vehicleid, a);
? ?x = partX * floatcos(a, degrees) partY * floatsin(-a, degrees);
? ?y = partX * floatsin(a, degrees) paryY * floatcos(-a, degrees);
? ?z = partZ;
? ?return 1;
}
// boot:
GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_SIZE, x, y, z);
GetVehiclePartAbsolutePos(vehicleid, 0.0, -y / 2.0, 0.0, x, y, z);
// bonnet:
GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_SIZE, x, y, z);
GetVehiclePartAbsolutePos(vehicleid, 0.0, y / 2.0, 0.0, x, y, z);
// front right tire:
GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_WHEELSFRONT, x, y, z);
GetVehiclePartAbsolutePos(vehicleid, x, y, z, x, y, z);
// front left tire:
GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_WHEELSFRONT, x, y, z);
GetVehiclePartAbsolutePos(vehicleid, -x, y, z, x, y, z);