cant get x,y,z co-ords of child

Blitz3D Forums/Blitz3D Programming/cant get x,y,z co-ords of child

I created a level in wings3d, exported to OBJ then imported into UU3D and exported to B3D format.
When I click on a child entity (like a barrel or crate) I can get it to move using moveentity but when I use entityX it always returns the position of the level mesh itself.
can anyone help?

EntityX has a parameter to return the global position.

EntityX# ( entity[,global] )



It defaults to false, so you'll need to specify true for a global position.

sorry, forgot to mention, I tried that,
but it always returns 10,10,10 - the position of the parent

Its most likely a problem with the way wings has exported the model. Had similar problems using .X format meshes exported from lightwave.

it seems that wings puts the child's entity at 0,0,0,
and the child's mesh at the co-ordinates specified

does anyone know of a program that places the child's entity at the same location as its mesh?
ill try UU3d

I'd imagine UU3D should work.. if not try milkshape?

Ah yes, I've had this problem with meshes exported from 3dsMax too. I can't remember if I was exporting via UU3D or B3D Pipeline at the time, but yep, it's definitely an export issue, and it seems to be a common one.

You could try this function. It might not work in all circumstances, but maybe you can tweak it a bit:
Function ReplacePos(mesh)

	If EntityClass(mesh) = "Mesh" Then
		minx# = 10000
		miny# = 10000
		minz# = 10000
		maxx# = -10000
		maxy# = -10000
		maxz# = -10000
		For i = 1 To CountSurfaces(mesh)
			surf = GetSurface(mesh, i)
			For j = 0 To CountVertices(surf) - 1
				x# = VertexX(surf, j)
				y# = VertexY(surf, j)
				z# = VertexZ(surf, j)
				If x < minx Then minx = x
				If x > maxx Then maxx = x
				If y < miny Then minx = y
				If y > maxy Then maxx = y
				If z < minz Then minx = z
				If z > maxz Then maxx = z
			Next
		Next
		midx# = (minx + maxx) / 2
		midy# = (miny + maxy) / 2
		midz# = (minz + maxz) / 2
		PositionMesh mesh, -midx, -midy, -midz
		PositionEntity mesh, midx, midy, midz
	End If

	For i = 1 To CountChildren(mesh)
		ReplacePos(GetChild(mesh, i))
	Next
	
End Function


Yep, that's how I did it in the end. It's fine if all your objects are generally centered around their geometric center.

great thanks, ill check it out

				x# = VertexX(surf, j)
				y# = VertexX(surf, j)
				z# = VertexX(surf, j)

should be
				x# = VertexX(surf, j)
				y# = VertexY(surf, j)
				z# = VertexZ(surf, j)

?

Erm .. yes .. sorry, I will edit it. Thanks!