Please take a look to the following code:
Graphics3D 640,480
SetBuffer BackBuffer()
Global minx#, miny#, minz#
Global maxx#, maxy#, maxz#
camera=CreateCamera()
light=CreateLight()
RotateEntity light,90,0,0
modelname$ = "mak_robotic.3ds"
staticmesh% = LoadMesh(modelname$)
If staticmesh <> 0 Then PositionEntity camera,0,MeshHeight(staticmesh)/2,-MeshDepth(staticmesh)*3
FreeEntity staticmesh
; Load mesh
animmesh% = LoadAnimMesh(modelname$)
; alpha entity
ent = animmesh
notinit%=True
While ent
If EntityClass(ent)="Mesh"
For si=1 To CountSurfaces(ent)
surf% = GetSurface(ent, si)
For vi=0 To CountVertices(surf)-1
x# = VertexX(surf, vi)
y# = VertexY(surf, vi)
z# = VertexZ(surf, vi)
If notinit=True
minx = x
miny = y
minz = z
maxx = x
maxy = y
maxz = z
notinit = False
Else
If x < minx Then minx = x
If y < miny Then miny = y
If z < minz Then minz = z
If x > maxx Then maxx = x
If y > maxy Then maxy = y
If z > maxz Then maxz = z
EndIf
Next ; vi
Next ; si
EndIf
ent = NextChild(ent)
Wend
Animate animmesh
While Not KeyDown( 1 )
RenderWorld
UpdateWorld
If CameraPick(camera, MouseX(), MouseY()) Then Text 0,0, "Picked"
Text 0,20,"min: "+minx+","+miny+","+minz
Text 0,40,"max: "+maxx+","+maxy+","+maxz
Flip
Wend
FreeEntity animmesh
End
Function NextChild(ent)
Local siblingcnt
If CountChildren(ent)>0
Return GetChild(ent,1)
EndIf
Local foundunused=False
Local foundent = 0, parent,sibling
While foundunused=False And ent<>0
parent = GetParent(ent)
If parent<>0
If CountChildren(parent)>1
If GetChild(parent,CountChildren(parent))<>ent
For siblingcnt = 1 To CountChildren(parent)
sibling = GetChild(parent,siblingcnt)
If sibling=ent
foundunused = True
foundent = GetChild(parent,siblingcnt+1)
EndIf
Next
EndIf
EndIf
EndIf
ent = parent
Wend
Return foundent
End Function
Ultimate Unwrap3D gives me different values: min: -11.717, -0.697, -9.948 max: 9.026, 47.521, 12.299
I suppose somewhere I make a mistake. But I don't know where
|