cee::geo::DataGenerator
-
class DataGenerator
Helper class for generating various primitives (spheres, cylinders, boxes, etc) for use in the Geometry Model.
The methods produces Data* which can easily be used to create a cee::geo::Part.
Example:
cee::geo::Part* part = new cee::geo::Part(cee::geo::DataGenerator::createSphere(cee::Vec3d( 1, 1, 0), 0.5, 50).get()); part->settings()->addEffect(new cee::geo::EffectColor(cee::Color3f(0.83f, 0.62f, 0.38f))); myGeometryModel->addPart(part);
See also
GeometryModel, Part, DataIndexedTriangles, and DataIndexedPolylines
Public Static Functions
-
static PtrRef<DataIndexedTriangles> createSphere(const Vec3d ¢erPos, double radius, size_t numSubDivisions)
Returns a DataIndexedTriangles containing a sphere with the given settings.
The sphere will be positioned in the centerPos and have the specified radius. The numSubDivisions parameter specifies the number of longitude and latitude lines in the tessellated sphere. A higher number will give a more smooth sphere, but will result in more triangles per sphere and thus (somewhat) decreased performance.
Example:
cee::geo::Part* part = new cee::geo::Part(cee::geo::DataGenerator::createSphere(cee::Vec3d( 1, 1, 0), 0.5, 50).get()); part->settings()->addEffect(new cee::geo::EffectColor(cee::Color3f(0.83f, 0.62f, 0.38f))); myGeometryModel->addPart(part);
-
static PtrRef<DataIndexedTriangles> createCylinder(const Vec3d &bottomCenterPos, double outerRadius, double innerRadius, const Vec3d &heightDirection, double height, size_t numSubDivisions)
Returns a DataIndexedTriangles containing a cylinder with the given settings.
The center of the bottom of the cylinder will be in bottomCenterPos and the direction of the cylinder will be will be heightDirection and have the given height. innerRadius must be smaller than outerRadius, and if the innerRadius is greater than zero the cylinder will have an empty part in the center. If innerRadius is zero it will be a normal cylinder.
The numSubDivisions parameter specifies the number of longitude and latitude lines in the tessellated cylinder. A higher number will give a more smooth cylinder, but will result in more triangles per cylinder and thus (somewhat) decreased performance.
Example:
cee::geo::Part* part = new cee::geo::Part(cee::geo::DataGenerator::createCylinder(cee::Vec3d(0, 0, 0), 1.0, 0.0, cee::Vec3d(0,0,1), 3.0, 10).get()); part->settings()->addEffect(new cee::geo::EffectColor(cee::Color3f(0.83f, 0.62f, 0.38f))); myGeometryModel->addPart(part);
-
static PtrRef<DataIndexedPolylines> createCircle(const Vec3d ¢erPos, double radius, const Vec3d &normal, size_t numSubDivisions)
Returns a DataIndexedPolylines containing a circle with the given settings.
The circle is drawn in the plane defined by centerPos and normal. The center of the circle will be in centerPos and the size given by radius.
The numSubDivisions parameter specifies the number of line segments in the circle. A higher number will give a more smooth circle, but will result in more line segments per circle and thus (somewhat) decreased performance.
Example:
cee::geo::Part* part = new cee::geo::Part(cee::geo::DataGenerator::createCircle(cee::Vec3d(0, 0, 0), 1.0, cee::Vec3d(0, 0, 1), 30).get()); part->settings()->addEffect(new cee::geo::EffectColor(cee::Color3f(0.83f, 0.62f, 0.38f))); myGeometryModel->addPart(part);
-
static PtrRef<DataIndexedPolylines> createArc(const Vec3d ¢erPos, double radius, const Vec3d &normal, const Vec3d &startDirection, double angle, size_t numSubDivisions)
Returns a DataIndexedPolylines containing an arc with the given settings.
The arc is drawn in the plane defined by centerPos and normal. The center of the arcs full circle will be in centerPos and the size given by radius. The arc will be drawn from the startDirection (a directional vector) and angle degrees (in radians) counter clockwise around the centerPos in the plane. The startDirection MUST be perpendicular to the normal.
The numSubDivisions parameter specifies the number of line segments in the arc. A higher number will give a more smooth arc, but will result in more line segments per arc and thus (somewhat) decreased performance.
Example:
cee::geo::Part* part = new cee::geo::Part(cee::geo::DataGenerator::createArc(cee::Vec3d(0, 0, 0), 1.0, cee::Vec3d(0, 0, 1), cee::Vec3d(0, 1, 0), 3.14/2, 30).get()); part->settings()->addEffect(new cee::geo::EffectColor(cee::Color3f(0.83f, 0.62f, 0.38f))); myGeometryModel->addPart(part);
-
static PtrRef<DataIndexedTriangles> createBox(const Vec3d ¢erPos, const Vec3d &totalExtent)
Returns a DataIndexedTriangles containing a box with the given settings.
The center of the box will be in centerPos and the totalExtent vector specifies the length of the box in x,y and z direction.
Example:
cee::geo::Part* part = new cee::geo::Part(cee::geo::DataGenerator::createBox(cee::Vec3d(1,1,1), cee::Vec3d(2, 2, 2)).get()); part->settings()->addEffect(new cee::geo::EffectColor(cee::Color3f(0.83f, 0.62f, 0.38f))); myGeometryModel->addPart(part);
-
static PtrRef<DataIndexedPolylines> createLineSegments(const std::vector<Vec3d> &vertices)
Returns a DataIndexedPolylines containing all the line segments specified.
The vertices array contain can contain any number of line segments. The array must have two entries for each line segment: start-pos and end-pos.
Example:
std::vector<cee::Vec3d> lines; lines.push_back(cee::Vec3d(0, 0, 0)); lines.push_back(cee::Vec3d(0, 1, 0); lines.push_back(cee::Vec3d(1, 0, 0)); lines.push_back(cee::Vec3d(1, 1, 0)); cee::geo::Part* part = new cee::geo::Part(cee::geo::DataGenerator::createLineSegments(lines).get()); part->settings()->addEffect(defaultColorEffect().get()); myGeometryModel->addPart(part);
-
static PtrRef<DataIndexedTriangles> createTriangles(const std::vector<Vec3d> &vertices, double creaseAngleDegrees = 0.0)
Returns a DataIndexedTriangles containing all the triangles specified.
The vertices array contain can any number of triangles. Each triangle is specified by three vertices in a counter clockwise order. A crease angle can be defined that duplicates nodes on edges where the normal of the two triangles on the edge differ more than the given crease angle. The new vertices are then compacted to contain Example:
std::vector<cee::Vec3d> tris; tris.push_back(cee::Vec3d(0, 0, 0)); tris.push_back(cee::Vec3d(1, 0, 0)); tris.push_back(cee::Vec3d(1, 1, 0)); double creaseAngle = 60.0; cee::geo::Part* part = new cee::geo::Part(cee::geo::DataGenerator::createTriangles(tris, creaseAngle).get()); part->settings()->addEffect(defaultColorEffect().get()); myGeometryModel->addPart(part);
-
static PtrRef<DataIndexedTriangles> createTriangles(const std::vector<Vec3d> &vertices, const std::vector<unsigned int> &indices, double creaseAngleDegrees = 0.0)
Returns a DataIndexedTriangles containing all the triangles specified.
The vertices array can contain any number of triangles. Each triangle is specified by the corresponding indices in a counter clockwise order. A crease angle can be defined that duplicates nodes on edges where the normal of the two triangles on the edge differ more than the given crease angle. The new vertices are then compacted to contain Example:
std::vector<cee::Vec3d> vertices; vertices.push_back(cee::Vec3d(3, 1, 0)); vertices.push_back(cee::Vec3d(4, 0, 1)); vertices.push_back(cee::Vec3d(4, 1, 1)); vertices.push_back(cee::Vec3d(5, 1, 0)); std::vector<unsigned int> indices = { 0, 2, 1, 2, 1, 3); double creaseAngle = 60; cee::geo::Part* part = new cee::geo::Part(cee::geo::DataGenerator::createTriangles(vertices, indices, creaseAngle).get()); part->settings()->addEffect(defaultColorEffect().get()); myGeometryModel->addPart(part);
-
static PtrRef<DataIndexedTriangles> createSphere(const Vec3d ¢erPos, double radius, size_t numSubDivisions)