示例#1
0
//-------------------------------------------------------------------------------------------------------------------------------------------
void transferPolygons(FbxMesh* fbxMesh, Mesh* mesh){
    // Transfer all UV array in fbxMesh to mesh
    int uvSize = fbxMesh->GetElementUV(0)->GetDirectArray().GetCount();
    mesh->InitEmptyCoordinates(uvSize);
    for (int uvId = 0; uvId < uvSize; uvId++){
        FbxVector2 uv = fbxMesh->GetElementUV(0)->GetDirectArray().GetAt(uvId);
            mesh->Push_back(Mesh::MeshType::COORDINATE, &Vector2s((double)uv[0], (double)uv[1]));
    }

    int polygonSize = fbxMesh->GetPolygonCount();
    mesh->InitEmptyFaces(polygonSize);
    for (int polyId = 0; polyId < polygonSize; polyId++){
        vector<int> triangle;   triangle.clear();

        int polyNumPoints = fbxMesh->GetPolygonSize(polyId);
        for (int pointId = 0; pointId < polyNumPoints; pointId++){
            // Add Vertex index of current point (in polygon)
            int vertexId = fbxMesh->GetPolygonVertex(polyId, pointId);
            triangle.push_back(vertexId);

            // Add UV index of current point (in polygon)
            int uvId = fbxMesh->GetTextureUVIndex(polyId, pointId);            
            triangle.push_back(uvId);
        }

        mesh->Push_back(Mesh::MeshType::FACE, &ITriangle(triangle[0], triangle[2], triangle[4],
                                                         triangle[1], triangle[3], triangle[5]));
    }

    LOG_DEBUG << "Transfer polygons (triangle mode) successfully! ";
}
void BallSpotPatchesProvider::update(ImagePatches& imagePatches)
{
  imagePatches.imageWidth = static_cast<short>(theImage.width);
  imagePatches.imageHeight = static_cast<short>(theImage.height);
  imagePatches.patches.clear();
  for(const Vector2i& spot : theBallSpots.ballSpots)
  {
    const int scanRegionDimension = theCameraInfo.camera == CameraInfo::Camera::lower ? 48 * spot.y() / 185 + 48 : std::max(2 * theImage.neuralNetImageRadius, 259 * spot.y() / 1000 - 3);
    const int offsetX = spot.x() - scanRegionDimension / 2, offsetY = spot.y() - scanRegionDimension / 2;
    imagePatches.patches.emplace_back(
      theImage,
      Vector2s(
        static_cast<short>(std::max(0, std::min(theImage.width - 1, offsetX))),
        static_cast<short>(std::max(0, std::min(theImage.height - 1, offsetY)))
      ),
      static_cast<short>(std::min(scanRegionDimension, theImage.width - offsetX)),
      static_cast<short>(std::min(scanRegionDimension, theImage.height - offsetY))
    );
  }
}
示例#3
0
 //Get the current mouse position
 const Vector2s& Input::mouseCoords() {
   if (m_handled) return Vector2s(-1, -1); //:D
   return m_coords;
 }