//This is simple template of 3D-Coat's script. Script language is very close to c++ and based on angelscript.
//You will usually see it if you used Scripts->Create new script
//Read general syntax description at http://angelcode.com/angelscript/sdk/docs/manual/doc_script.html and
//http://angelcode.com/angelscript/sdk/docs/manual/doc_understanding_as.html
//But if you know c/c++ it will be easy to write scripts. For beginning you may just use mostly one command 
//cmd("Some UI command");
//With this command you may execute any item in UI. It is easy to get UI item command - hover required comamnd in UI and press MMB and RMB simultaneously. 
//Corresponding command will be copied to clipboard. You may read about other commands in scripting manual.

void main() {

    Angles a;
    a.pitch = 181;
    a.yaw = -40.5;
    a.roll = 365;
    const Angles recoveryA = a;
    ModalDialog( a.pitch + " " + a.yaw + " " + a.roll, "a" );

    Angles b( 10, 90, 270 );
    ModalDialog( b.pitch + " " + b.yaw + " " + b.roll, "b" );

    Angles c = b;
    ModalDialog( c.pitch + " " + c.yaw + " " + c.roll, "c = b" );

    a += b;
    ModalDialog( a.pitch + " " + a.yaw + " " + a.roll, "a += b" );
    a = recoveryA;
    
    a -= b;
    ModalDialog( a.pitch + " " + a.yaw + " " + a.roll, "a -= b" );
    a = recoveryA;

    a *= 1.2;
    ModalDialog( a.pitch + " " + a.yaw + " " + a.roll, "a *= 1.2" );
    a = recoveryA;
    
    a /= 1.2;
    ModalDialog( a.pitch + " " + a.yaw + " " + a.roll, "a /= 1.2" );
    a = recoveryA;

    ModalDialog( (a == a) ? "true" : "false", "a == a" );
    ModalDialog( (a != a) ? "true" : "false", "a != a" );
    ModalDialog( (a == b) ? "true" : "false", "a == b" );
    ModalDialog( (a != b) ? "true" : "false", "a != b" );

    Angles d = a + b;
    ModalDialog( d.pitch + " " + d.yaw + " " + d.roll, "a + b" );
    d = a - b;
    ModalDialog( d.pitch + " " + d.yaw + " " + d.roll, "a - b" );
    d = a * 100;
    ModalDialog( d.pitch + " " + d.yaw + " " + d.roll, "a * 100" );
    d = a / 100;
    ModalDialog( d.pitch + " " + d.yaw + " " + d.roll, "a / 100" );

    ModalDialog( " " + a.lengthSquared(), "a.lengthSquared()" );
    ModalDialog( " " + a.length(), "a.length()" );

    a.normalize360();
    ModalDialog( a.pitch + " " + a.yaw + " " + a.roll, "a.normalize360()" );
    a = recoveryA;
    
    a.normalize180();
    ModalDialog( a.pitch + " " + a.yaw + " " + a.roll, "a.normalize180()" );
    a = recoveryA;

    a.round();
    ModalDialog( a.pitch + " " + a.yaw + " " + a.roll, "a.round()" );
    a = recoveryA;

    ModalDialog( " " + a.distance( b ), "a.distance( b )" );

    Angles lerp = a.lerp( b, 0.1 );
    ModalDialog( lerp.pitch + " " + lerp.yaw + " " + lerp.roll, "a.lerp( b, 0.1 )" );

    const Angles min( 200, -100, 300 );
    const Angles max( 360, 0, 360 );
    a.clamp( min, max );
    ModalDialog( a.pitch + " " + a.yaw + " " + a.roll, "a.clamp( min, max )" );
    a = recoveryA;

    Quat quat = a.toQuat();
    ModalDialog( quat.x + " " + quat.y + " " + quat.z + " " + quat.w, "a.toQuat()" );

    Mat3 m3 = a.toMat3();
    ModalDialog(
        "| " + m3.get( 0, 0 ) + "  " + m3.get( 0, 1 ) + "  " + m3.get( 0, 2 ) + " |\n"
        "| " + m3.get( 1, 0 ) + "  " + m3.get( 1, 1 ) + "  " + m3.get( 1, 2 ) + " |\n"
        "| " + m3.get( 2, 0 ) + "  " + m3.get( 2, 1 ) + "  " + m3.get( 2, 2 ) + " |\n",
        "a.toMat3()" );

    Mat4 m4 = a.toMat4();
    ModalDialog(
        "| " + m4.get( 0, 0 ) + "  " + m4.get( 0, 1 ) + "  " + m4.get( 0, 2 ) + "  " + m4.get( 0, 3 ) + " |\n"
        "| " + m4.get( 1, 0 ) + "  " + m4.get( 1, 1 ) + "  " + m4.get( 1, 2 ) + "  " + m4.get( 1, 3 ) + " |\n"
        "| " + m4.get( 2, 0 ) + "  " + m4.get( 2, 1 ) + "  " + m4.get( 2, 2 ) + "  " + m4.get( 2, 3 ) + " |\n"
        "| " + m4.get( 3, 0 ) + "  " + m4.get( 3, 1 ) + "  " + m4.get( 3, 2 ) + "  " + m4.get( 3, 3 ) + " |\n",
        "a.toMat4()" );    

    Vec3 forward = a.toForward();
    ModalDialog( forward.x + " " + forward.y + " " + forward.z, "a.toForward()" );
    Vec3 right = a.toRight();
    ModalDialog( right.x + " " + right.y + " " + right.z, "a.toRight()" );
    Vec3 up = a.toUp();
    ModalDialog( up.x + " " + up.y + " " + up.z, "a.toUp()" );
}
