понедельник, 2 ноября 2015 г.

Scripts in 3D-Coat: Beginning

Right now I'm working on Scripts/Scripting in 3D-Coat (appeared classes 'Angles', 'Mat3', 'Mat4', 'Mesh', 'Quat', 'Vec3') and decided to, in addition to documentation, create more visual examples. I'll start here – we'll see what will happen...




Introduction for new users
  • 3D-Coat is a software for creating 3d models/sculptings, particular organic objects (for more information visit website). Here you also have retopology toolset, including Auto-retopology of voxel objects (video), plus PBR (video), plus UV mapping tools (video), exporting models for game engines, and many more... Yep, I love this program!)
  • I assume you know a programming language and know how to use documentation.
  • 3D-Coat uses AngelScript.
  • Script is a text file. It is helpful to view and edit it in Notepad++ (choose "C" syntax).
  • Run script via file menu "Scripts / Run Script".
  • Free download the 3D-Coat is here.

and some accordances for me (like memo)
  • Short, but informative posts.
  • Simple code.
  • Comments inside the code.
  • Won't spoon-feed you with anything that can otherwise be found in documentation.
  • For each post – a picture / video / 3D-sketch. 

I will maintain these rules. Have questions? Ask – the answer will be given )

First example is adding figures to a scene in "Sculpt Room" (according to 3D-Coat's terminology).
void main() {

    // preparing a scene
    SculptRoom  room;
    room.clear().toSurface();

    // initializing a random generator
    seed( 39 );

    // building some figures with random size, position and rotation
    Builder  builder;
    const int  N = 4;
    const int  A = 10;
    const int  B = 100;
    for ( int i = 0; i < N; ++i ) {
        const int  a = rand( A, B );
        const int  b = rand( A, B );
        const int  c = rand( A, B );
        Mesh  figure = builder.cube()
          .side( Vec3( a, b, c ) )
          .details( 0.1 )
          ();
        const Vec3  translation(
            rand( -B, B ) * 2,
            rand( -B, B ) * 2,
            rand( -B, B ) * 2);
        const Angles  angles(
            rand( 0, 360 ),
            rand( 0, 360 ),
            rand( 0, 360 ) );
        figure.tools().transform()
          .position( translation )
          .rotation( angles )
          ();
        room |= figure;
    } // for i
}

Result

LMB - rotate, RMB - pan, MMB - zoom.

Комментариев нет: