New MeshWidth() comand

Blitz3D Forums/Blitz3D Programming/New MeshWidth() comand

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

This adds a global parameter! :D

Function MeshWidth#(mesh,globl=False)
start=True
For s=1 To CountSurfaces(mesh)
	surf=GetSurface(mesh,s)
	For v=0 To CountVertices(surf)-1
		x#=VertexX(surf,v)
		y#=VertexY(surf,v)
		z#=VertexZ(surf,v)
		If globl
			TFormPoint x,y,z,mesh,0
			x=TFormedX()
			y=TFormedY()
			z=TFormedZ()
			EndIf
		If x<minx# Or start=True minx=x
		If y<miny# Or start=True miny=y
		If z<minz# Or start=True minz=z
		If x>maxx# Or start=True maxx=x
		If y>maxy# Or start=True maxy=y
		If z>maxz# Or start=True maxz=z
		start=False
		Next
	Next
w#=maxx-minx
h#=maxy-miny
d#=maxz-minz
Return w
End Function

Function MeshHeight#(mesh,globl=False)
start=True
For s=1 To CountSurfaces(mesh)
	surf=GetSurface(mesh,s)
	For v=0 To CountVertices(surf)-1
		x#=VertexX(surf,v)
		y#=VertexY(surf,v)
		z#=VertexZ(surf,v)
		If globl
			TFormPoint x,y,z,mesh,0
			x=TFormedX()
			y=TFormedY()
			z=TFormedZ()
			EndIf
		If x<minx# Or start=True minx=x
		If y<miny# Or start=True miny=y
		If z<minz# Or start=True minz=z
		If x>maxx# Or start=True maxx=x
		If y>maxy# Or start=True maxy=y
		If z>maxz# Or start=True maxz=z
		start=False
		Next
	Next
w#=maxx-minx
h#=maxy-miny
d#=maxz-minz
Return h
End Function

Function MeshDepth#(mesh,globl=False)
start=True
For s=1 To CountSurfaces(mesh)
	surf=GetSurface(mesh,s)
	For v=0 To CountVertices(surf)-1
		x#=VertexX(surf,v)
		y#=VertexY(surf,v)
		z#=VertexZ(surf,v)
		If globl
			TFormPoint x,y,z,mesh,0
			x=TFormedX()
			y=TFormedY()
			z=TFormedZ()
			EndIf
		If x<minx# Or start=True minx=x
		If y<miny# Or start=True miny=y
		If z<minz# Or start=True minz=z
		If x>maxx# Or start=True maxx=x
		If y>maxy# Or start=True maxy=y
		If z>maxz# Or start=True maxz=z
		start=False
		Next
	Next
w#=maxx-minx
h#=maxy-miny
d#=maxz-minz
Return d
End Function