Placing 3d objects on a rotating/tilting map

Blitz3D Forums/Blitz3D Beginners Area/Placing 3d objects on a rotating/tilting map

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.

Objects rotate around their own centre, so their own (0, 0, 0). To change this (on static objects), use PositionMesh/FitMesh. For animated objects, I believe a pivot it best. There is a routine in the archives: http://www.blitzbasic.com/codearcs/codearcs.php?code=732
or you could use this:
Function CenterMesh(mesh)

	a_minx# = 100000
	a_maxx# = -100000
	a_miny# = 100000
	a_maxy# = -100000
	a_minz# = 100000
	a_maxz# = -100000

	validmesh = (mesh <> 0)
	If validmesh Then validmesh = EntityClass$(mesh) = "Mesh"
	If validmesh Then
		For i = 1 To CountSurfaces(mesh)
			s = GetSurface(mesh, i)
			For v = 0 To CountVertices(s) - 1
				TFormPoint VertexX(s, v), VertexY(s, v), VertexZ(s, v), mesh, 0
				If TFormedX() < a_minx Then a_minx = TFormedX()
				If TFormedX() > a_maxx Then a_maxx = TFormedX()
				If TFormedY() < a_miny Then a_miny = TFormedY()
				If TFormedY() > a_maxy Then a_maxy = TFormedY()
				If TFormedZ() < a_minz Then a_minz = TFormedZ()
				If TFormedZ() > a_maxz Then a_maxz = TFormedZ()
			Next
		Next
	End If
	
	PositionMesh mesh, -(a_minx+a_maxx)/2, -(a_miny+a_maxy)/2, -(a_minz + a_maxz)/2
	
End Function