
'
' Print the location of the vertices to the output window
'
Local found:int = False

' Go through all meshes in the selection
For Local m:TMesh = EachIn GetSelection()
	
	Print m.GetName()+" contains the following vertices:"
	Local matrix:TMat4 = m.GetMatrix()

	' Go through the surfaces of the mesh
	For Local s:TSurface = Eachin m.Surfaces()
		
		' Go through the vertices of the mesh
		For Local i:Int = 0 Until s.CountVertices()
			
			' Get the position of the vertex (Local space) and print it
			Local pos:TVec3 = s.GetVertexPosition(i)

			' To transform it into global space try uncommenting this...
			' pos = matrix.TimesVec3(pos)

			Rem
				'
				' More fun to try out:
				'

				' This will get the vertex normal
				Local nor:TVec3 = s.GetVertexNormal(i)
				nor = matrix.TimesVec3N(nor) ' transforms the normal to global space.. Notice: .TimesVec3N transforms without position

				' Tangent
				Local tng:TVec4 = s.GetVertexTangent(i) ' Notice TVec4, tng.w denotes the handedness of the tangent can be either -1.0 or 1.0

				' Color
				Local col:TColorRGB = s.GetVertexColor(i)

				' UV coordinates
				Local uv0:TVec3 = s.GetVertexUV(i,0) ' The second parameter selects the UV set
				Local uv1:TVec3 = s.GetVertexUV(i,1) ' Typically the lightmap coordinates
			EndRem

			' Print the position			
			Print pos.ToString()

		Next

	Next

	found = True
Next

'
' Check if there was a mesh selected
'
If found = False
	Notify( "Whoops!","Please select a mesh entity!", False )
End If