Rotate A Map
#1

I have no idea how to rotate a map and have it retain its original shape/layout. I came close, but the best I could do was a bit messy.

Quick Example of what I mean:
pawn Код:
stock CreateMap(Float:x, Float:y, Float:z, Float:rotation)
{
    CreateObject(978, x+ 4.69,  y+ 0.0, z+ 0.0,   0.0, 0.0, rotation+ 0.0);
    CreateObject(978, x+ -4.69, y+ 0.0, z+ 0.0,   0.0, 0.0, rotation+ 0.0);
    CreateObject(978, x+ 9.23,  y+ 4.6, z+ 0.0,   0.0, 0.0, rotation+ 90.0);
    CreateObject(978, x+ -9.23, y+ 4.6, z+ 0.0,   0.0, 0.0, rotation+ 270.0);
}
The above will only keep the original layout with rotation 0.0. The offset calculation to keep the original layout is what I am not able to figure out.
Reply
#2

Check Pottus map editor.

http://forum.sa-mp.com/member.php?u=169807

I think you can rotate maps in it.
Reply
#3

Yes you can import and rotate on any axis you please it may be a bit slow depending on how many objects there is and the speed of your hard drive.

You can also use Map Mover if you don't need so many advanced features.
https://sampforum.blast.hk/showthread.php?tid=506610
Reply
#4

Quote:
Originally Posted by davve95
Посмотреть сообщение
Check Pottus map editor.

http://forum.sa-mp.com/member.php?u=169807

I think you can rotate maps in it.
Quote:
Originally Posted by Pottus
Посмотреть сообщение
Yes you can import and rotate on any axis you please it may be a bit slow depending on how many objects there is and the speed of your hard drive.

You can also use Map Mover if you don't need so many advanced features.
https://sampforum.blast.hk/showthread.php?tid=506610
I've come across multiple map editors that are capable of rotating a map, but that's not what I am looking for.

If any of you know the calculation to doing the above, I'd appreciate it if you would share.

Thanks.
Reply
#5

Sure here you go if your doing multiple objects you will need to select a point to rotate the objects around.

(Credits: Stylock)
pawn Код:
stock AttachPoint(Float:offx, Float:offy, Float:offz, Float:offrx, Float:offry, Float:offrz, Float:px, Float:py, Float:pz, Float:prx, Float:pry, Float:prz, &Float:RetX, &Float:RetY, &Float:RetZ, &Float:RetRX, &Float:RetRY, &Float:RetRZ, sync_rotation = 1)
{
    new
        Float:g_sin[3],
        Float:g_cos[3],
        Float:off_x,
        Float:off_y,
        Float:off_z;

    EDIT_FloatEulerFix(prx, pry, prz);

    off_x = offx - px; // static offset
    off_y = offy - py; // static offset
    off_z = offz - pz; // static offset

    // Calculate the new position
    EDIT_FloatConvertValue(prx, pry, prz, g_sin, g_cos);
    RetX = px + off_x * g_cos[1] * g_cos[2] - off_x * g_sin[0] * g_sin[1] * g_sin[2] - off_y * g_cos[0] * g_sin[2] + off_z * g_sin[1] * g_cos[2] + off_z * g_sin[0] * g_cos[1] * g_sin[2];
    RetY = py + off_x * g_cos[1] * g_sin[2] + off_x * g_sin[0] * g_sin[1] * g_cos[2] + off_y * g_cos[0] * g_cos[2] + off_z * g_sin[1] * g_sin[2] - off_z * g_sin[0] * g_cos[1] * g_cos[2];
    RetZ = pz - off_x * g_cos[0] * g_sin[1] + off_y * g_sin[0] + off_z * g_cos[0] * g_cos[1];

    if (sync_rotation)
    {
        // Calculate the new rotation
        EDIT_FloatConvertValue(asin(g_cos[0] * g_cos[1]), atan2(g_sin[0], g_cos[0] * g_sin[1]) + offrz, atan2(g_cos[1] * g_cos[2] * g_sin[0] - g_sin[1] * g_sin[2], g_cos[2] * g_sin[1] - g_cos[1] * g_sin[0] * -g_sin[2]), g_sin, g_cos);
        EDIT_FloatConvertValue(asin(g_cos[0] * g_sin[1]), atan2(g_cos[0] * g_cos[1], g_sin[0]), atan2(g_cos[2] * g_sin[0] * g_sin[1] - g_cos[1] * g_sin[2], g_cos[1] * g_cos[2] + g_sin[0] * g_sin[1] * g_sin[2]), g_sin, g_cos);
        EDIT_FloatConvertValue(atan2(g_sin[0], g_cos[0] * g_cos[1]) + offrx, asin(g_cos[0] * g_sin[1]), atan2(g_cos[2] * g_sin[0] * g_sin[1] + g_cos[1] * g_sin[2], g_cos[1] * g_cos[2] - g_sin[0] * g_sin[1] * g_sin[2]), g_sin, g_cos);

        RetRX = asin(g_cos[1] * g_sin[0]);
        RetRY = atan2(g_sin[1], g_cos[0] * g_cos[1]) + offry;
        RetRZ = atan2(g_cos[0] * g_sin[2] - g_cos[2] * g_sin[0] * g_sin[1], g_cos[0] * g_cos[2] + g_sin[0] * g_sin[1] * g_sin[2]);
    }
}





stock EDIT_FloatConvertValue(Float:rot_x, Float:rot_y, Float:rot_z, Float:sin[3], Float:cos[3])
{
    sin[0] = floatsin(rot_x, degrees);
    sin[1] = floatsin(rot_y, degrees);
    sin[2] = floatsin(rot_z, degrees);
    cos[0] = floatcos(rot_x, degrees);
    cos[1] = floatcos(rot_y, degrees);
    cos[2] = floatcos(rot_z, degrees);
    return 1;
}

/*
 * Fixes a bug that causes objects to not rotate
 * correctly when rotating on the Z axis only.
 */

stock EDIT_FloatEulerFix(&Float:rot_x, &Float:rot_y, &Float:rot_z)
{
    EDIT_FloatGetRemainder(rot_x, rot_y, rot_z);
    if((!floatcmp(rot_x, 0.0) || !floatcmp(rot_x, 360.0))
    && (!floatcmp(rot_y, 0.0) || !floatcmp(rot_y, 360.0)))
    {
        rot_y = 0.00000002;
    }
    return 1;
}

stock EDIT_FloatGetRemainder(&Float:rot_x, &Float:rot_y, &Float:rot_z)
{
    EDIT_FloatRemainder(rot_x, 360.0);
    EDIT_FloatRemainder(rot_y, 360.0);
    EDIT_FloatRemainder(rot_z, 360.0);
    return 1;
}

stock EDIT_FloatRemainder(&Float:remainder, Float:value)
{
    if(remainder >= value)
    {
        while(remainder >= value)
        {
            remainder = remainder - value;
        }
    }
    else if(remainder < 0.0)
    {
        while(remainder < 0.0)
        {
            remainder = remainder + value;
        }
    }
    return 1;
}
Reply
#6

Exactly what I needed.
Cheers, Pottus!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)