3DCoat can combine meshes, creating mesh that you need. 3DCoat supports three types of boolean operations:
- Add
- Subtract
- Intersect
Lets see how we can do this with scripts.
Lets create two spheres and see what 3DCoat can do with it. There will be an example code in each section that you may simply copy it and run.
Take a note that in the end you get a complete mesh with accurate structure. You may press 'W' key to toggle wireframe mode.
(Add)
void main() {
SculptRoom room;
room.clear().toSurface();
Builder builder;
Mesh a = builder.sphere()
.radius( 70 )
.details( 0.1 )
.build();
Mesh b = builder.sphere()
.radius( 40 )
.position( Vec3( 30, 40, 50 ) )
.details( 0.5 )
.build();
Mesh result = a | b;
room += result;
}
(Subtract)
void main() {
SculptRoom room;
room.clear().toSurface();
Builder builder;
Mesh a = builder.sphere()
.radius( 70 )
.details( 0.1 )
.build();
Mesh b = builder.sphere()
.radius( 40 )
.position( Vec3( 30, 40, 50 ) )
.details( 0.5 )
.build();
Mesh result = a - b;
room += result;
}
(Intersect)
void main() {
SculptRoom room;
room.clear().toSurface();
Builder builder;
Mesh a = builder.sphere()
.radius( 70 )
.details( 0.1 )
.build();
Mesh b = builder.sphere()
.radius( 40 )
.position( Vec3( 30, 40, 50 ) )
.details( 0.5 )
.build();
Mesh result = a & b;
room += result;
}
- Combination
As you would probably like to make something more complex than a single mesh in the scene, lets combine all examples of boolean operations used previously, and put all created objects in the scene.
You’ll need to know about transform methods.
void main() {
SculptRoom room;
room.clear().toSurface();
Builder builder;
Mesh a = builder.sphere()
.radius( 70 )
.details( 0.1 )
.build();
Mesh b = builder.sphere()
.radius( 40 )
.position( Vec3( 30, 40, 50 ) )
.details( 0.5 )
.build();
const Vec3 floorShift( 0, 200, 0 );
Mesh add = a | b;
Vec3 floor = Vec3( 0 );
add.tools().transform().position( floor ).run();
room += add;
Mesh subtract = a - b;
floor += floorShift;
subtract.tools().transform().position( floor ).run();
room += subtract;
Mesh intersect = a & b;
floor += floorShift;
intersect.tools().transform().position( floor ).run();
room += intersect;
}
As a result you must get a “pyramid” made with spheres after they’ve been added, subtracted and intersected.
More complex code might require for debugging. There is such an option in 3DCoat scripting
- See Also
- 🌀 How to make a script
-
🌀 Making meshes out of primitives
-
🌀 Mesh Transform
-
🌀 Script debugging