Notifications
Clear all

[Closed] Convert 3D coordinates to 2D

Am trying to export 3D points to 2D coordinates xml file. So far I’ve only found the following solution which involves taking screen coordinates directly from viewport. With tracking several points (often in hundreds) cycling through using slidertime loops for each individual point is very time consuming. Is there an easier less time consuming solution which involved simply supplying an array of points to export and camera?

http://forums.cgsociety.org/showthread.php?f=98&t=705504
http://forums.cgsociety.org/showthread.php?f=98&t=592854

7 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

does it mean you have a specific view to get 2D points?

fn storeMeshPoints node range:animationrange =
(	
	local data = #()
	append data (getviewtm())
	append data range
	append data node

	point_data = #()
	for t = range.start to range.end by 1f do at time t
	(
		gw.setTransform (matrix3 1)
		mesh = snapshotasmesh node
		points = for v=1 to mesh.numverts collect
		(
			gw.hTransPoint (getvert mesh v)
		)
		append point_data points
		free mesh
	)
	append data point_data
)
/*
a = storeMeshPoints $
*/


it’s the basic idea. i hope it will help.

(just using pure MXS it’’s a pretty quick way to do these kind of things)

of course you can use projection matrix and multiply a 3D point on it, but hTransPoint is doing almost the same.

using of at time context doesn’t need redraw instead of shifting timeslider

at time context forces both camera and mesh validating (i hope that but i’ve not tested). so an animatable mesh deformation and camera transform has to be taken into account

1 Reply
(@gandhics)
Joined: 11 months ago

Posts: 0

I badly want to know how to do this with projection matrix.
Since maxscript can not handle 4×4 matrix, I have no idea how to approaches it.

Am actually only wanting to export an array of Point helpers rather than geometry points. Found code here that I think might work: http://www.scriptspot.com/bobo/mxs3/illusion/ . Not sure if this requires camera to be selected in viewport that has points to be exported.

Just in case added the following:

				
viewport.setCamera camera_out
displaySafeFrames = true


					in coordsys camera_out a = (pick_array[p].pos)
					zero_origin = mapScreenToView [0,0] (a.z) [renderwidth,renderheight]
					end_screen  = mapScreenToView [renderwidth,renderheight] (a.z) [renderwidth,renderheight]
					world_size = zero_origin-end_screen
					x_aspect = renderwidth/(abs world_size.x)
					y_aspect = renderheight/(abs world_size.y)
					a_screen = point2 (x_aspect*(a.x-zero_origin.x)) (abs(y_aspect*(a.y-zero_origin.y)))

Doesn’t BigMatrix allow for user defined matrices?

-Eric

1 Reply
(@gandhics)
Joined: 11 months ago

Posts: 0

I can define. But, that’s it. I can not multiply.