Вполне возможно что не правильно.

Include "xors3d.bb"
xGraphics3D 800,600,32,0,0
xSetBuffer xBackBuffer()
pxCreateWorld(1,"http://forum.boolean.name/")
Log=xCreateLog(1,0,"log.html")
cam = xCreateCamera()
xPositionEntity cam,0,100,-200
xCameraClsColor cam,128,128,128
xCreateLight()
plane =xCreateCube()
xScaleEntity plane,1000,1,1000
xPositionEntity plane,0,0,0
xEntityColor plane, 0,128,128
Global Spetsnaz = xLoadAnimMesh("Spetsnaz.b3d")
Global Walk = xLoadAnimSeq(Spetsnaz, "Walk.b3d")
Global SpetsnazPX = xLoadAnimMesh("SpetsnazPX.b3d")
xHideEntity Spetsnaz
xHideEntity SpetsnazPX
Global Kalash = xLoadSound("ak47-1.wav")
Repeat
If xKeyHit(57) Then CreateMan(Spetsnaz, SpetsnazPX,Rand(-100,100),50,Rand(0,100))
If xKeyHit(42) Then RagDollAllMen()
If xMouseHit(1) Then Shoot(cam, xMouseX(), xMouseY())
pxRenderPhysic(30,0)
UpdateRagdolls()
xUpdateWorld()
xRenderWorld()
xFlip
Until xKeyHit(1)
End
Type Ragdoll
Field Mesh ; Ìîäåëüêà
Field Joints[100] ; Õåíäëû äæîéíòîâ
Field Bodies[100] ; Õåíäëû òåë
Field Bones[100] ; Õåíäëû êîñòåé
End Type
Function CreateRagdoll(man, px)
xAnimate man,0,0,1
R.Ragdoll = New Ragdoll
R\Mesh = xGetChild(man,0)
xEntityParent R\Mesh,0
xFreeEntity man
CreateHullsForAllChilds(R\Mesh, px, R)
DeparentAllChilds(R\Mesh)
End Function
Function DeparentAllChilds(mesh)
Repeat
If xCountChildren(mesh)-1 = 0 Then Exit
DeparentAllChilds(xGetChild(mesh,0))
Forever
xEntityParent mesh,0
End Function
Function UpdateRagdolls()
For R.Ragdoll = Each Ragdoll
For i= 0 To 100
If R\Bodies[i] = 0 Then Exit
pxBodySetEntity R\Bones[i], R\Bodies[i]
Next
Next
End Function
Function CreateHullsForAllChilds(mesh, pxmesh, R.Ragdoll, batya=0)
HullMesh = xFindChild(pxmesh, xEntityName(mesh)+"px")
If HullMesh Then
Hull = BodyCreateHull(HullMesh, 10);pxBodyCreateSphere(1,10)
pxBodySetPosition Hull, xEntityX(Mesh,1), xEntityY(Mesh,1), xEntityZ(Mesh,1)
pxBodySetRotation Hull, xEntityPitch(Mesh,1), xEntityYaw(Mesh,1), xEntityRoll(Mesh,1)
For i=0 To 100
If R\Bodies[i] = 0 Then
R\Bodies[i] = Hull
R\Bones[i] = Mesh
Exit
End If
Next
If Batya Then
Joint = pxJointCreateSpherical (batya,Hull,pxBodyGetPositionX(Hull),pxBodyGetPositionY(Hull),pxBodyGetPositionZ(Hull),0,1,0)
pxJointSphericalSetLimitAngle(Joint, 30,1, 0)
pxJointSphericalSetLimitTwist(Joint,-10,10,10,1,0)
pxJointSphericalSetLimitSpring(Joint, 10, 1, 0)
For i=0 To 100
If R\Joints[i] = 0 Then
R\Joints[i] = Joint
Exit
End If
Next
End If
End If
For i=1 To xCountChildren(mesh)-1
CreateHullsForAllChilds(xGetChild(mesh,i), pxmesh, R, Hull)
Next
End Function
Function BodyCreateHull%(mesh,mass)
VB = xGetMeshVB(mesh)
VB_size = xGetMeshVBSize(mesh)
in_mesh%=pxBodyCreateHull(VB,VB_size,mass)
xDeleteMeshVB(VB)
Return in_mesh
End Function
Type Man
Field Mesh
Field pxMesh
Field PickPivot
End Type
Function CreateMan(Mesh, pxMesh, x#,y#,z#)
M.Man = New Man
M\Mesh = xCopyEntity(Mesh)
xPositionEntity M\Mesh,x,y,z
xAnimate M\Mesh,1,.5,1
M\PXMesh = PXMesh
M\PickPivot = xCreatePivot()
xPositionEntity M\PickPivot,x,y+35,z
xEntityPickMode M\PickPivot, 1
xEntityRadius M\PickPivot,15,40
End Function
Function RagDollAllMen()
For M.Man = Each Man
CreateRagdoll(M\Mesh, M\pxMesh)
xFreeEntity M\PickPivot
Delete M
Next
End Function
Function Shoot(cam, x,y)
xPlaySound Kalash
xCameraPick cam, x,y
If xPickedEntity() Then
For M.Man = Each Man
If M\PickPivot = xPickedEntity() Then
CreateRagdoll(M\Mesh, M\pxMesh)
xFreeEntity M\PickPivot
Delete M
Exit
End If
Next
End If
End Function