Accessing all point cloud points through the API?

Accessing all point cloud points through the API?

onitreb
Enthusiast Enthusiast
1,024 Views
8 Replies
Message 1 of 9

Accessing all point cloud points through the API?

onitreb
Enthusiast
Enthusiast

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();

 

0 Likes
1,025 Views
8 Replies
Replies (8)
Message 2 of 9

denist.dts
Explorer
Explorer

@onitreb wrote:

 

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. 

 


This is a fundamental class and its methods for handling PointClouds in 3DS MAX. I've encountered no issues when using it. To have a productive discussion, we should operate on the same data. Please share a sample point cloud file, and I will attempt to read the object, inspect its contents, and assess its performance.

0 Likes
Message 3 of 9

onitreb
Enthusiast
Enthusiast

Thanks for the reply. I've attached the .e57 I'm testing with zipped. Once loaded into 3ds max it is obviously converted into a rcp file.

0 Likes
Message 4 of 9

denist.dts
Explorer
Explorer

deleted...

 

 
0 Likes
Message 5 of 9

denisT.MaxDoctor
Advisor
Advisor
@onitreb wrote:

Thanks for the reply. I've attached the .e57 I'm testing with zipped. Once loaded into 3ds max it is obviously converted into a rcp file.


 

I regret to report that I am unable to get a correct result with this data. The SDK produces very strange and obviously incorrect voxel nodes... and there is no idea how to solve this yet.

 

BTW... PointCloud object makes wrong rcp file (with wrong data) using this e57 file. 

0 Likes
Message 6 of 9

istan
Advisor
Advisor

I also played around with different point cloud files, but I gave up this idea. There were so many weird issues that I decided to convert PLY to mesh by external software before (meshlab, cloudcompare,..). I rather have the feeling that AD does not really care on the point cloud integration in Max.

0 Likes
Message 7 of 9

onitreb
Enthusiast
Enthusiast
How have you determined that the RCP created has "wrong" data?

The RCP loads into Max fine. I'm just having trouble accessing all of the points. I've been thinking my issues are from my limited understanding of how to define the viewmatrix and projectmatrix in the CreateIPointCloudVisibleVoxelNodes() function.

I was able to retrieve all (most) of the points if I fiddled with level of detail of the point cloud.
0 Likes
Message 8 of 9

onitreb
Enthusiast
Enthusiast
I know what you mean. The API doesn't offer many interactions with point cloud objects. I'm not giving up yet, though!
0 Likes
Message 9 of 9

istan
Advisor
Advisor

@onitreb wrote:
I know what you mean. The API doesn't offer many interactions with point cloud objects. I'm not giving up yet, though!

I was also fighting with different industrial 3D Sensors. They all create different output and I was not able to import them neither in Max nor with their standalone ReCap API properly. Additionally the stitching was also an issue..

0 Likes