Exemple #1
0
static bool IsClockwise(const DirectX::XMFLOAT3 *vertex, int num_verts, const FbxVector4 &polygon_normal)
{
  // Compute a normal using two edges of the triangle
  FbxVector4 edge_1(vertex[1].x - vertex[0].x, vertex[1].y - vertex[0].y, vertex[1].z - vertex[0].z);
  FbxVector4 edge_2(vertex[2].x - vertex[0].x, vertex[2].y - vertex[0].y, vertex[2].z - vertex[0].z);
  FbxVector4 normal = edge_1.CrossProduct(edge_2);
  // Dot product between computed normal and supplied normal will reveal winding
  double dot = polygon_normal.DotProduct(normal);
  return dot < 0;
}
void LabelToolPlugin::mouseReleaseEventOnGraphicsView(QGraphicsSceneMouseEvent *e)
{
  if(e->button() == Qt::LeftButton)
  {
    selecting_ = false;
    selected_points_.clear();
    selected_points_.push_back(start_point_);
    QPointF edge(start_point_.x(), e->scenePos().y());
    selected_points_.push_back(edge);
    selected_points_.push_back(e->scenePos());
    QPointF edge_2(e->scenePos().x(), start_point_.y());
    selected_points_.push_back(edge_2);
    drawQtPolygon(true);
    if(!img_with_polygons_.empty())
      setNewPolygonEdges();
    selected_points_.clear();
  }
}