This tutorial shows how to create a geometry with geometric primitives like spheres, boxes and cylinders.
A geometry model has a part data generator that can be used to tessellate various geometric primitives.
In this tutorial you will create your own geometry model parts and apply some part settings.
Create the following parts:
The box should be colored yellow.
The DataGenerator can tessellate a box and return it as DataIndexedTriangles. This is fed into the constructor of the Part.
Add a box part. The box is defined by the center point and the full extent of the box. Then add it to the geometry model.
Add the sphere part. The sphere is defined the center position, the radius of the sphere and the number of subdivisions. Then add it to the geometry model.
Add the cylinder part. The cylinder is defined by the bottom center position, outer and inner radius (no inner radius in this example so it is a full cylinder), the direction of the cylinder and the length (height) and finally the number of sub divisions, which controls the resolution of the tessellation. Then add it to the geometry model.
We use the effect system of the geometry model to control how the parts are visualized. To set the color of the part, use the PartEffectColor. Below we set the color of the box and cylinder part. The sphere part is not set and will have the default color as there are no color effects defined on that part.
The model is ready to use and can be added to the view. Exactly where the view exists depends on the platform and solution. These examples uses Qt and the view is set up in a cee::qt::ViewerWidget.