323 line->setVertex(2, v2); |
323 line->setVertex(2, v2); |
324 line->setVertex(3, v3); |
324 line->setVertex(3, v3); |
325 } |
325 } |
326 } |
326 } |
327 |
327 |
328 void PrimitiveModel::generateBody(Model& model) const |
328 /* |
329 { |
329 * Builds a circle primitive. |
330 if (this->type == Cylinder) |
330 */ |
331 { |
331 void PrimitiveModel::generateCircle(Model& model) const |
332 this->generateCylinder(model); |
332 { |
333 return; |
|
334 } |
|
335 |
|
336 QVector<int> conditionalLineSegments; |
|
337 QVector<QLineF> circle = makeCircle(segments, divisions, 1); |
333 QVector<QLineF> circle = makeCircle(segments, divisions, 1); |
338 |
334 |
339 for (int i = 0; i < segments; ++i) |
335 for (int i = 0; i < segments; ++i) |
340 { |
336 { |
341 double x0 = circle[i].x1(); |
337 double x0 = circle[i].x1(); |
342 double x1 = circle[i].x2(); |
338 double x1 = circle[i].x2(); |
343 double z0 = circle[i].y1(); |
339 double z0 = circle[i].y1(); |
344 double z1 = circle[i].y2(); |
340 double z1 = circle[i].y2(); |
345 |
341 |
|
342 LDEdgeLine* line = model.emplace<LDEdgeLine>(); |
|
343 line->setVertex(0, Vertex {x0, 0.0f, z0}); |
|
344 line->setVertex(1, Vertex {x1, 0.0f, z1}); |
|
345 line->setColor(EdgeColor); |
|
346 } |
|
347 } |
|
348 |
|
349 void PrimitiveModel::generateBody(Model& model) const |
|
350 { |
|
351 switch (type) |
|
352 { |
|
353 case Cylinder: |
|
354 generateCylinder(model); |
|
355 return; |
|
356 |
|
357 case Circle: |
|
358 generateCircle(model); |
|
359 return; |
|
360 |
|
361 default: |
|
362 break; |
|
363 } |
|
364 |
|
365 QVector<int> conditionalLineSegments; |
|
366 QVector<QLineF> circle = makeCircle(segments, divisions, 1); |
|
367 |
|
368 for (int i = 0; i < segments; ++i) |
|
369 { |
|
370 double x0 = circle[i].x1(); |
|
371 double x1 = circle[i].x2(); |
|
372 double z0 = circle[i].y1(); |
|
373 double z1 = circle[i].y2(); |
|
374 |
346 switch (type) |
375 switch (type) |
347 { |
376 { |
348 case Circle: |
|
349 { |
|
350 LDEdgeLine* line = model.emplace<LDEdgeLine>(); |
|
351 line->setVertex(0, Vertex {x0, 0.0f, z0}); |
|
352 line->setVertex(1, Vertex {x1, 0.0f, z1}); |
|
353 line->setColor(EdgeColor); |
|
354 } |
|
355 break; |
|
356 |
|
357 case Ring: |
377 case Ring: |
358 case Cone: |
378 case Cone: |
359 { |
379 { |
360 double x2, x3, z2, z3; |
380 double x2, x3, z2, z3; |
361 double y0, y1, y2, y3; |
381 double y0, y1, y2, y3; |