Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <sscanf2>
- #define IPL_NAME "test.ipl"
- public OnFilterScriptInit()
- {
- printf ("Converter started.");
- new line[1024], File: file;
- new File:output;
- new model, Float:px, Float:py, Float:pz, Float:rx, Float:ry, Float:rz, Float:qx, Float:qy, Float:qz, Float:qw;
- file = fopen(IPL_NAME, io_read);
- if (file)
- {
- printf ("Input file loaded.");
- output = fopen ("converted.txt", io_append);
- if (!output)
- {
- printf ("Output file missing.");
- return 1;
- }
- printf ("Output file loaded.");
- while (fread(file, line))
- {
- sscanf(line, "p<,>i{s[32]i}fffffff{i}", model, px, py, pz, qx, qy, qz, qw);
- printf(line);
- QuatToEulerZXY(qx, qy, qz, qw, rx, ry, rz);
- AddObject(model, px, py, pz, rx, ry, rz, output);
- }
- }
- else printf ("Input file missing.");
- fclose(file);
- fclose(output);
- return 1;
- }
- stock AddObject(model, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, File:handle)
- {
- new str[256];
- format(str, 256, "\tCreateObject(%d, %f, %f, %f, %f, %f, %f, 300.0);\n", model, x, y, z, rx, ry, rz);
- printf(str);
- fwrite(handle, str);
- return 1;
- }
- stock QuatToEulerZXY(Float:quat_x, Float:quat_y, Float:quat_z, Float:quat_w, &Float:x, &Float:y, &Float:z)
- {
- x = -asin(2 * ((quat_x * quat_z) + (quat_w * quat_y)));
- y = atan2(2 * ((quat_y * quat_z) + (quat_w * quat_x)), (quat_w * quat_w) - (quat_x * quat_x) - (quat_y * quat_y) + (quat_z * quat_z));
- z = -atan2(2 * ((quat_x * quat_y) + (quat_w * quat_z)), (quat_w * quat_w) + (quat_x * quat_x) - (quat_y * quat_y) - (quat_z * quat_z));
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement