If you already can create meshes, then you're ready to learn how to transform them.
Now with scripts you may make 3 changes to a mesh like:
- Mesh position
- Rotation
- Scale
Position
Complete example for changing coordinates of the existing mesh:
void main() {
SculptRoom room;
room.clear().toSurface();
Builder builder;
Mesh mesh = builder.capsule()
.startPosition( Vec3( 0 ) )
.endPosition( Vec3( 40, 50, 60 ) )
.startRadius( 30 )
.endRadius( 50 )
.details( 0.1 )
.build();
mesh.tools().transform()
.position( Vec3( 100, 50, 200 ) )
.run();
room += mesh;
}
For mesh transformation this class is used ToolsMeshTransform.
Rotation
We'll skip mesh creation part of the code for a more compact view in the following examples.
mesh.tools().transform()
.rotation( Angles( 30, 90, 200 ) )
.run();
Scale
mesh.tools().transform()
.scale( Vec3( 2, 1.5, 0.7 ) )
.run();
Together
With fluent-interface you may simply write your code like this:
mesh.tools().transform()
.position( Vec3( 100, 50, 200 ) )
.rotation( Angles( 30, 90, 200 ) )
.scale( Vec3( 2, 1.5, 0.7 ) )
.run();
- See Also
- π Boolean operations for meshes
-
π Math for 3D graphics