Skip to main content
GameDev.net gamedev.net
🔒 Locked

Max script help

Started by CPPNick Oct 22, 2010 at 4:10 PM 1 replies 2.2k views
Original Post
CPPNick
CPPNick
I need some help with this thing that I am making for a school project.

I need to get a map of edges out of max to use for collision detection in our game. This is what I have so far.

rollout new "Edgemap Exporter"(	label lab "Export Edgemap"	button btn_export "Export"	on btn_export pressed do	(		out_name = getSaveFileName types: "Edge Map(*.emap) |*.emap|"		out_file = createfile out_name						edgemap = snapshotAsMesh selection[1]		--I need to get a list of the edges of the object here		--num_verts = edgemap.numEdges				--format "%\n" num_verts to:out_file				--vert1 = getVert tmesh num_verts		--vert2 = getVert tmesh 1				--format "% % % %\n" (vert1.x) (vert1.y) (vert2.x) (vert2.y) to:out_file				--for v = 2 to num_verts do		--(			--vert1 = getVert tmesh v - 1			--vert2 = getVert tmesh v			--format "% % % %\n" (vert1.x) (vert1.y) (vert2.x) (vert2.y) to:out_file		--)				close out_file	))CreateDialog new



I have got the thing saving a file properly and everything, but I need a way to get a list of all the edges of a spline(with all corners).

can anyone point me in the right direction?

thanks for any help on this.
CPPNick
CPPNick
getting closer!

rollout new "Edgemap Exporter"(	label lab "Export Edgemap"	button btn_export "Export"		on btn_export pressed do	(		s = objects as array				theLines = for o in s where classof o == Line collect o		theCircles = for o in s where classof o == Circle collect o		nLines = theLines.count		nCirlces = theCircles.count				if(nLines != 0 or nCircles != 0) then		(//-- 			out_name = getSaveFileName types: "Edge Map(*.emap) |*.emap|"//-- 			out_file = createfile out_name						//			-- make an array to hold all the line segments// 			--segArray = #()						for aLine = 1 to nLines do			(//				-- for each spline in the Line object				thisSpline =  theLines[aLine]								nSplines = numSplines thisSpline				for aSpline = 1 to nSplines do				( 					nSegments = numSegments thisSpline aSpline										for aSeg = 1 to nSegments do					( 						print "This is a segment!"					)				)			)			//-- 			if(nCircles != 0) then//-- 			(//-- 				format "%\n" nCirlces to:out_file//-- 				for i = 1 to nCirlces do//-- 				(//-- 					Circle1 = theCircles//-- 					format "% % %\n" (Circle1.center.x) (Circle1.center.y) (Circle1.radius) to:out_file//-- 				)//-- 			)			//-- 			close out_file		)	))CreateDialog new


just cant figure out how to retrieve the vertices from the segment =/
CPPNick
CPPNick
Phew!
done.

here is the code if anyone wants to take a look.

rollout new "Edgemap Exporter"(	label lab "Export Edgemap"	button btn_export "Export"		on btn_export pressed do	(		s = objects as array				theLines = for o in s where classof o == Line collect o		theCircles = for o in s where classof o == Circle collect o		nLines = theLines.count		nCirlces = theCircles.count				if(nLines != 0 or nCircles != 0) then		(			out_name = getSaveFileName types: "Edge Map(*.emap) |*.emap|"			out_file = createfile out_name						-- make an array to hold all the line segments 			segArray = #()						if(nLines > 0) then			(				for aLine = 1 to nLines do				(					-- for each spline in the Line object					thisLine =  theLines[aLine]										nSplines = numSplines thisLine					for aSpline = 1 to nSplines do					(												nKnots = numKnots thisLine aSpline												if(isClosed thisLine aSpline) then						(							if(nKnots > 1) then							(								pt1 = getKnotPoint thisLine aSpline nKnots								pt2 = getKnotPoint thisLine aSpline 1																append segArray  #(pt1, pt2)																if(nKnots > 2) then								(									for aKnot = 2 to nKnots do									(										pt1 = getKnotPoint thisLine aSpline (aKnot - 1)										pt2 = getKnotPoint thisLine aSpline aKnot																				append segArray #(pt1, pt2)									)								)							)						)						else						(							if(nKnots > 1) then							(								for aKnot = 2 to nKnots do								(									pt1 = getKnotPoint thisLine aSpline (aKnot - 1)									pt2 = getKnotPoint thisLine aSpline aKnot																		append segArray #(pt1, pt2)								)							)						)					)				)								format "%\n" segArray.count to:out_file				for thisSeg = 1 to segArray.count do				(					format "% % % %\n" (segArray[thisSeg][1].x) (segArray[thisSeg][1].y) (segArray[thisSeg][2].x) (segArray[thisSeg][2].y) to:out_file				)			)						if(nCircles != 0) then			(				format "%\n" nCirlces to:out_file				for i = 1 to nCirlces do				(					Circle1 = theCircles					format "% % %\n" (Circle1.center.x) (Circle1.center.y) (Circle1.radius) to:out_file				)			)-- 						close out_file		)	))CreateDialog new

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.