Scripts in 3DCoat could be very complex, as they are written with AngelScript, which is used in many big successful projects
That's why while writing your own script you'll might need to know the values of some variables And you can.
Insert this code in the beginning of your scripts, and you'll be able to:
- print to a log-file (
log
)
- draw in scene (
drw
)
Debug dbg;
void main() {
DebugLog log = dbg.log();
log.clear();
DebugDraw drw = dbg.draw();
drw.clear().color( 0xFFFFEE00 );
}
What can we print to a log-file?
float delta = 1.2345;
log += delta;
log += pow( a, 3 ) * sqrt( 2 ) / 12;
log +=
"This is a debug-note."
" We do treat variables provisionally as constants.";
log += dbg.vars();
log += dbg.variables();
log += dbg.gvars();
log += dbg.globalVariables();
Builder builder;
const Mesh a = builder.cylinder()
.positionTop( Vec3( 0, 120, 0 ) )
.positionBottom( Vec3( 0, 0, 0 ) )
.radiusTop( 50 )
.radiusBottom( 50 )
.details( 0.1 )
();
log += a;
What can be displayed in the viewport?
drw.point( Vec3( 50, 0, 0 ) );
drw.point( Vec3( 50, 60, 0 ), Color( 0xFFAAFF33 ) );
drw.line( Vec3( 0, 0, 0 ), Vec3( 100, 50, 25 ) );
drw.line( Vec3( 0, 50, 0 ), Vec3( 0, 200, 25 ),
Color( 0xFF33FF33 ) );
drw.line( Vec3( 100, 120, 0 ), Vec3( 100, 250, 25 ),
Color( 0xFFAA0000 ), Color( 0xFF0000AA ) );
drw.circle( Vec3( 0, 0, 0 ), Vec3( 100, 50, 25 ), 20 );
drw.circle( Vec3( 0, 50, 0 ), Vec3( 0, 200, 25 ), 50,
Color( 0xFF55FFAA ) );
drw.sphere( Vec3( 0, 0, 0 ), 15 );
drw.sphere( Vec3( 0, 50, 0 ), 45,
Color( 0x9955FFAA ) );
const Vec3 a( 0, 0, 0 );
const Vec3 b( 80, 30, 70 );
const Vec3 c( 10, 25, 100 ) );
drw.triangle( a, b, c );
drw.triangle( a, b, c,
Color( 0x77AA0000 ) );
drw.triangle( a, b, c,
Color( 0xFFAA0000 ), Color( 0xFF00AA00 ), Color( 0xFF0000AA ) );
drw.note( Vec3( 0, 0, 0 ), "Note A" );
drw.note( Vec3( 0, 30, 0 ), "Note B",
Color( 0xFF33FF33 ) );
drw.note( Vec3( 0, 0, 20 ), 111 );
drw.note( Vec3( 0, 30, 20 ), 222.51,
Color( 0xFF33FF33 ) );
Vectors, Matrix, boxes and so on: apparently, that they are printed / visualized simply:
log += MyObjectThatIWantToPrint;
drw += MyObjectThatIWantToDraw;
More complex visualization can be split into layers in order to show/hide them separately:
drw += "First";
drw += "Second";
- See Also
- ๐ How to make a script
-
DebugDraw
-
DebugLog