Notifications
Clear all

[Closed] Fast Ways to get .NET data into Maxscript?

Is there a fast way to get floating point image data out of .NET and into a TexMap/Bitmap?

The .NET CLR is obviously a million times faster than MXS but getting the data out of .NET into a usable form for Max to render and display seems to be a bottleneck.

I tried using an array but Maxscript really slows down when you use XNA.Vectors in an array. The fastest approach appears to be a direct array that you then split up into vector 4s with Maxscript but I’m hoping there is a more native C++ accelerated means of casting a C# object into Maxscript like the dotNetArray.Array property but for colors or other .NET objects.

4 Replies

This is the fastest code I could come up with for an #(#(Red),#(Green),#(Blue)) .net array (I might consider joining it into one big-array in C# with interleaved channels.

fn arrayToBitmap dNArray width height =
(
	jArray = #()
	for a in dNArray.array do (join jArray a.array)
	
	cArray = (
		for i = 1 to height collect	(
			offset = (i-1)*width*3
			for j = offset+1 to (width*3)+offset by 3 collect (point4 jArray[j] jArray[j+1] jArray[j+2] 1.0)
			)
		)
	
	map = bitmap width height hdr:true
	for i = 0 to (cArray.count-1) do setpixels map [0,i] cArray[i+1]
	return map
)

Still takes about 480ms though. So there is a lot of room for improvement IMO since the actual image processing only takes 100ms. Definitely not interactive.

it’s slow by idea… what do you want to do? do you want to convert binary chuck of data to mxs bitmap?

Yeah ideally you could just convert to like an EXR and have a C++ maxscript function which just read the bytestream object nearly instantly into a bitmap like the openbitmap function.