Accessing all point cloud points through the API?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The docs describes some possible uses that I haven't found direct reference to in the API reference.
(https://help.autodesk.com/view/MAXDEV/2024/ENU/?guid=new_point_cloud_api)
"Exporter plug-ins can get the point cloud vertices and other parameters via the point cloud object's parameter block, and export the data to the desired format."
If someone can point me toward how to access all of the vertices through the parameter block that'd be great.
Otherwise, the only way I see to access the points of a point cloud is through the IPointCloudVisibleVoxelNode class, which forces you to access visible voxels containing the cloud points, and then iterate over the points in the voxel.
The "visible" part is what's tripping me up. For my test I have a point cloud with 1.1 million points centered in the viewport and it's visibility set to 100%, but when I iterate over the voxels in IPointCloudVisibleVoxelNode, I only retrieve about 200k points.
I'm spitting the points, color and normals to a txt file using MaxSDK::Util::TextFile::Writer.
Maybe the way I outputting the text file is flawed?
Any ideas would be appreciated!
Here is part of the code handling the retrieval and output:
MaxSDK::Util::TextFile::Writer positionWriter, colorWriter, normalWriter;
TCHAR path[MAX_PATH];
const MCHAR* dirPath = GetCOREInterface()->GetDir(APP_EXPORT_DIR);
_tcscpy(path, dirPath);
TCHAR positionFilePath[MAX_PATH], colorFilePath[MAX_PATH], normalFilePath[MAX_PATH];
_stprintf(positionFilePath, _T("%sposition.txt"), path);
_stprintf(colorFilePath, _T("%scolor.txt"), path);
_stprintf(normalFilePath, _T("%snormal.txt"), path);
if (!positionWriter.Open(positionFilePath) || !colorWriter.Open(colorFilePath) || !normalWriter.Open(normalFilePath)) {
DebugPrint(_T("Error: Could not open one or more text files for writing.\n"));
return;
}
for (size_t i = 0; i < voxelNodesList.length(); ++i) {
const MaxSDK::Array<MaxSDK::PointCloud::PointCloudVertex>& visiblePoints = voxelNodesList[i]->GetVisiblePointsList();
// Loop through all the points in visiblePoints
for (size_t j = 0; j < visiblePoints.length(); ++j) {
const MaxSDK::PointCloud::PointCloudVertex& point = visiblePoints[j];
TCHAR positionStr[128], colorStr[128], normalStr[128];
_stprintf(positionStr, _T("%f, %f, %f\n"), point.mPosition.x, point.mPosition.y, point.mPosition.z);
_stprintf(colorStr, _T("%d, %d, %d, %d\n"), point.mColor.x, point.mColor.y, point.mColor.z, point.mColor.w);
_stprintf(normalStr, _T("%f, %f, %f\n"), point.mNormal.x, point.mNormal.y, point.mNormal.z);
positionWriter.Write(positionStr);
colorWriter.Write(colorStr);
normalWriter.Write(normalStr);
}
delete voxelNodesList[i]; // Remember to delete the voxel nodes after using them
}
positionWriter.Close();
colorWriter.Close();
normalWriter.Close();