Creating boxes of child's size

Blitz3D Forums/Blitz3D Programming/Creating boxes of child's size

Hi all,

I'm trying to create a box of the same
child and with the same orientation that a child
read from an animated meshed.

I have a scenario in which there are a lot of wood boxes.
I'm trying to create cubes (with 'createcube') of the same
size that the boxes, but I'm obtaining bizarre results..
I've tried a lot if things, but I don't obtain the desired
results.

Please, please, someone have a piece of code to do that!???

Thanks in advance!

Here you have, my own function for mesh size calculation:

Usage Example:

xsize# = MeshSize(child1,0)
ysize# = MeshSize(child1,1)
zsize# = MeshSize(child1,2)

Note: Function ChildSize (above) is needed too.

Function MeshSize#(mesh,axis)

min# = 999999
max# = -999999
n = CountChildren(mesh)

If (n>0)
	;Father
	If (Lower(EntityClass(mesh)) = "mesh")
		vmin# = ChildSize(mesh,axis,0)
		vmax# = ChildSize(mesh,axis,1)
		If (vmin#<min#) min = vmin#
		If (vmax#>max#) max = vmax#		
	EndIf
	
	;Children
	For i=1 To CountChildren(mesh)
		child = GetChild(mesh,i)
		vmin# = ChildSize(child,axis,0)
		vmax# = ChildSize(child,axis,1)
		If (vmin#<min#) min = vmin#
		If (vmax#>max#) max = vmax#		
	Next

	Return (max - min)
Else
	If (axis = 0) Return MeshWidth(mesh)	
	If (axis = 1) Return MeshHeight(mesh)	
	If (axis = 2) Return MeshDepth(mesh)	
EndIf

End Function

;Max Axis Coordinate Value
;0 - x
;1 - y
;2 - z

Function ChildSize#(child,axis,minmax)
min# = 999999
max# = -999999

For k=1 To CountSurfaces(child)
	surface = GetSurface(child,k)
	For m = 0 To CountVertices(surface)-1
		x# = VertexX(surface,m)
		y# = VertexY(surface,m)
		z# = VertexZ(surface,m)
		TFormPoint x,y,z,child,0
		If (axis = 0) v1# = TFormedX()
		If (axis = 1) v1# = TFormedY()
		If (axis = 2) v1# = TFormedZ()
		If (v1#<min#) min = v1#
		If (v1#>max#) max = v1#
	Next
Next

If (minmax = 0)
	Return min
Else
	Return max
	EndIf
End Function



Muchas gracias machote!
;)

(Thanks a lot mate!)