16.03.2017, 08:32
Necesito ayuda con esta funciуn que es obtener las posiciones de los objetos atados.
El problema es que no me revuelve la posiciуn en donde estб.
Posiciуn con los objetos adjuntos.
Nueva posiciуn del objeto.
Posiciуn obtenida con la funciуn AttachObjectToObjectEx
funcion
El problema es que no me revuelve la posiciуn en donde estб.
Posiciуn con los objetos adjuntos.
Nueva posiciуn del objeto.
Posiciуn obtenida con la funciуn AttachObjectToObjectEx
Код:
new Float:newPOS[6]; new Float:oldPOS[6]; for(new d=0; d<sizeof asd; d++){ GetObjectPos(asd[d], oldPOS[0],oldPOS[1],oldPOS[2]); GetObjectRot(asd[d], oldPOS[3],oldPOS[4],oldPOS[5]); AttachObjectToObjectEx(asd[d], base, oldPOS[0],oldPOS[1],oldPOS[2], oldPOS[3],oldPOS[4],oldPOS[5], newPOS[0],newPOS[1],newPOS[2], newPOS[3],newPOS[4],newPOS[5]); printf("CreateObject(%d,%f,%f,%f,%f,%f,%f);",GetObjectModel(asd[d]), newPOS[0],newPOS[1],newPOS[2], newPOS[3],newPOS[4],newPOS[5] ); }
Код:
stock AttachObjectToObjectEx(objectid, attachoid, Float:off_x, Float:off_y, Float:off_z, Float:rot_x, Float:rot_y, Float:rot_z, &Float:X, &Float:Y, &Float:Z, &Float:RX, &Float:RY, &Float:RZ){ // By Stylock static Float:sin[3], Float:cos[3], Float:pos[3], Float:rot[3]; GetObjectPos(attachoid, pos[0], pos[1], pos[2]); GetObjectRot(attachoid, rot[0], rot[1], rot[2]); cos[0] = floatcos(rot[0], degrees); cos[1] = floatcos(rot[1], degrees); cos[2] = floatcos(rot[2], degrees); sin[0] = floatsin(rot[0], degrees); sin[1] = floatsin(rot[1], degrees); sin[2] = floatsin(rot[2], degrees); pos[0] = pos[0] + off_x * cos[1] * cos[2] - off_x * sin[0] * sin[1] * sin[2] - off_y * cos[0] * sin[2] + off_z * sin[1] * cos[2] + off_z * sin[0] * cos[1] * sin[2]; pos[1] = pos[1] + off_x * cos[1] * sin[2] + off_x * sin[0] * sin[1] * cos[2] + off_y * cos[0] * cos[2] + off_z * sin[1] * sin[2] - off_z * sin[0] * cos[1] * cos[2]; pos[2] = pos[2] - off_x * cos[0] * sin[1] + off_y * sin[0] + off_z * cos[0] * cos[1]; rot[0] = asin(cos[0] * cos[1]); rot[1] = atan2(sin[0], cos[0] * sin[1]) + rot_z; rot[2] = atan2(cos[1] * cos[2] * sin[0] - sin[1] * sin[2], cos[2] * sin[1] - cos[1] * sin[0] * -sin[2]); cos[0] = floatcos(rot[0], degrees); cos[1] = floatcos(rot[1], degrees); cos[2] = floatcos(rot[2], degrees); sin[0] = floatsin(rot[0], degrees); sin[1] = floatsin(rot[1], degrees); sin[2] = floatsin(rot[2], degrees); rot[0] = asin(cos[0] * sin[1]); rot[1] = atan2(cos[0] * cos[1], sin[0]); rot[2] = atan2(cos[2] * sin[0] * sin[1] - cos[1] * sin[2], cos[1] * cos[2] + sin[0] * sin[1] * sin[2]); cos[0] = floatcos(rot[0], degrees); cos[1] = floatcos(rot[1], degrees); cos[2] = floatcos(rot[2], degrees); sin[0] = floatsin(rot[0], degrees); sin[1] = floatsin(rot[1], degrees); sin[2] = floatsin(rot[2], degrees); rot[0] = atan2(sin[0], cos[0] * cos[1]) + rot_x; rot[1] = asin(cos[0] * sin[1]); rot[2] = atan2(cos[2] * sin[0] * sin[1] + cos[1] * sin[2], cos[1] * cos[2] - sin[0] * sin[1] * sin[2]); cos[0] = floatcos(rot[0], degrees); cos[1] = floatcos(rot[1], degrees); cos[2] = floatcos(rot[2], degrees); sin[0] = floatsin(rot[0], degrees); sin[1] = floatsin(rot[1], degrees); sin[2] = floatsin(rot[2], degrees); rot[0] = asin(cos[1] * sin[0]); rot[1] = atan2(sin[1], cos[0] * cos[1]) + rot_y; rot[2] = atan2(cos[0] * sin[2] - cos[2] * sin[0] * sin[1], cos[0] * cos[2] + sin[0] * sin[1] * sin[2]); SetObjectPos(objectid, pos[0], pos[1], pos[2]); SetObjectRot(objectid, rot[0], rot[1], rot[2]); X = pos[0]; Y = pos[1]; Z = pos[2]; RX = rot[0]; RY = rot[1]; RZ = rot[2]; }