Move around the model until one of the extremes of the pelvis capsule touch the ground, then the pelvis produce strange movements, like rebounding or sliding,
Any idea of why this happens?
Any idea of why this happens?
Graphics3D 640,480,16,2 AmbientLight 100,100,100 l=CreateLight(2) LightRange l,16 PositionEntity l,-4,4,-4 cam=CreateCamera() CameraRange cam,.01,50 PositionEntity cam,6,6,-6 RotateEntity cam,20,45,0 Function CreateCapsule(r#,h#) ent=CreateCylinder(8) ScaleMesh ent,r,h*.5,r s=CreateSphere(4):ScaleMesh s,r,r,r:PositionMesh s,0,h*.5,0:AddMesh s,ent:FreeEntity s s=CreateSphere(4):ScaleMesh s,r,r,r:PositionMesh s,0,-h*.5,0:AddMesh s,ent:FreeEntity s Return ent End Function TOKSIM_CreateSimulator(0,-10,0) ;Animated body f=CreateCube() ScaleMesh f,10,.1,10 EntityColor f,255,150,0 f=TOKAB_Create() TOKAB_AddBox f,20,.2,20 ;----------------- ;Rigid Bodys ;Pelvis cap=CreateCapsule(.3,.5) RotateMesh cap,0,0,80 rb=TOKRB_Create() geo=TOKRB_AddCylinder(rb,.6,.5) TOKGEOM_SetPositionAndRotation geo,0,0,0,0,0,90 TOKRB_SetPosition rb,-.25,5.4,0 ;TOKRB_SetRotation rb,0,0,20 TOKRB_SetLinearDamping rb,.004 TOKRB_SetAngularDamping rb,.02 TOKRB_SetMass rb,2 TOKRB_SetCylinderInertiaTensor rb,.6,.5,2 TOKRB_GravityEnable rb,1 joint0=TOKJOINT_Create(1,rb,0) TOKJOINT_SetPositionAndRotationWorld joint0,-.25,5.4,0,0,0,90 TOKJOINT_SetType joint0,1 TOKJOINT_SetLowerLimit joint0,0 TOKJOINT_SetUpperLimit joint0,3.14/4 TOKJOINT_EnableLimit joint0,1 TOKJOINT_Enable joint0,1 cap1=CreateCapsule(.25,1.5) EntityColor cap1,0,100,255 rb1=TOKRB_Create() TOKRB_AddCylinder rb1,.5,1.5 TOKRB_SetPosition rb1,.2,4,0 ;TOKRB_SetRotation rb1,0,0,20 TOKRB_SetLinearDamping rb1,.004 TOKRB_SetAngularDamping rb1,.02 TOKRB_SetMass rb1,1 TOKRB_SetCylinderInertiaTensor rb1,.5,1.5,1 joint1=TOKJOINT_Create(2,rb,rb1) TOKJOINT_SetPositionAndRotationWorld joint1,.2,4.75,0,0,0,90 TOKJOINT_SetType joint1,3 TOKJOINT_SetLowerLimit joint1,-3.14/2 TOKJOINT_SetUpperLimit joint1,0 TOKJOINT_EnableLimit joint1,1 TOKJOINT_Enable joint1,1 cap2=CreateCapsule(.25,1.5) EntityColor cap2,0,255,100 rb2=TOKRB_Create() TOKRB_AddCylinder rb2,.5,1.5 TOKRB_SetPosition rb2,.2,2.5,0 ;TOKRB_SetRotation rb2,0,0,20 TOKRB_SetLinearDamping rb2,.004 TOKRB_SetAngularDamping rb2,.02 TOKRB_SetMass rb2,1 TOKRB_SetCylinderInertiaTensor rb2,.5,1.5,1 joint2=TOKJOINT_Create(2,rb1,rb2) TOKJOINT_SetPositionAndRotationWorld joint2,.2,3.25,0,0,0,90 TOKJOINT_SetType joint2,3 TOKJOINT_SetLowerLimit joint2,0 TOKJOINT_SetUpperLimit joint2,3.14/1.5 TOKJOINT_EnableLimit joint2,1 TOKJOINT_SetDampingFactor joint2,.2 TOKJOINT_Enable joint2,1 cap1b=CreateCapsule(.25,1.5) EntityColor cap1b,0,100,255 rb1b=TOKRB_Create() TOKRB_AddCylinder rb1b,.5,1.5 TOKRB_SetPosition rb1b,-.65,4,0 TOKRB_SetLinearDamping rb1b,.004 TOKRB_SetAngularDamping rb1b,.02 TOKRB_SetMass rb1b,1 TOKRB_SetCylinderInertiaTensor rb1b,.5,1.5,1 joint1b=TOKJOINT_Create(2,rb,rb1b) TOKJOINT_SetPositionAndRotationWorld joint1b,-.65,4.75,0,0,0,90 TOKJOINT_SetType joint1b,3 TOKJOINT_SetLowerLimit joint1b,-3.14/2 TOKJOINT_SetUpperLimit joint1b,0 TOKJOINT_EnableLimit joint1b,1 TOKJOINT_Enable joint1b,1 cap2b=CreateCapsule(.25,1.5) EntityColor cap2b,0,255,100 rb2b=TOKRB_Create() TOKRB_AddCylinder rb2b,.5,1.5 TOKRB_SetPosition rb2b,-.65,2.5,0 TOKRB_SetLinearDamping rb2b,.004 TOKRB_SetAngularDamping rb2b,.02 TOKRB_SetMass rb2b,1 TOKRB_SetCylinderInertiaTensor rb2b,.5,1.5,1 joint2b=TOKJOINT_Create(2,rb1b,rb2b) TOKJOINT_SetPositionAndRotationWorld joint2b,-.65,3.25,0,0,0,90 TOKJOINT_SetType joint2b,3 TOKJOINT_SetLowerLimit joint2b,0 TOKJOINT_SetUpperLimit joint2b,3.14/1.5 TOKJOINT_EnableLimit joint2b,1 TOKJOINT_SetDampingFactor joint2,.2 TOKJOINT_Enable joint2b,1 ;------------- While Not KeyDown(1) If KeyDown(200) TOKRB_ApplyImpulse rb2,0,0,1 EndIf If KeyDown(208) TOKRB_ApplyImpulse rb2,0,0,-1 EndIf If KeyDown(203) TOKRB_ApplyImpulse rb2,-1,0,0 EndIf If KeyDown(205) TOKRB_ApplyImpulse rb2,1,0,0 EndIf If KeyDown(30) TOKRB_ApplyImpulse rb2,0,2,0 EndIf If KeyDown(31) TOKRB_ApplyTwist rb1,0,1,0 EndIf If KeyHit(57) If TOKJOINT_IsEnabled(joint0) TOKJOINT_Enable joint0,0 Else TOKJOINT_Enable joint0,1 EndIf EndIf ;Pelvis PositionEntity cap,TOKRB_GetX(rb),TOKRB_GetY(rb),TOKRB_GetZ(rb) RotateEntity cap,TOKRB_GetPitch(rb),TOKRB_GetYaw(rb),TOKRB_GetRoll(rb) PositionEntity cap1,TOKRB_GetX(rb1),TOKRB_GetY(rb1),TOKRB_GetZ(rb1) RotateEntity cap1,TOKRB_GetPitch(rb1),TOKRB_GetYaw(rb1),TOKRB_GetRoll(rb1) PositionEntity cap2,TOKRB_GetX(rb2),TOKRB_GetY(rb2),TOKRB_GetZ(rb2) RotateEntity cap2,TOKRB_GetPitch(rb2),TOKRB_GetYaw(rb2),TOKRB_GetRoll(rb2) PositionEntity cap1b,TOKRB_GetX(rb1b),TOKRB_GetY(rb1b),TOKRB_GetZ(rb1b) RotateEntity cap1b,TOKRB_GetPitch(rb1b),TOKRB_GetYaw(rb1b),TOKRB_GetRoll(rb1b) PositionEntity cap2b,TOKRB_GetX(rb2b),TOKRB_GetY(rb2b),TOKRB_GetZ(rb2b) RotateEntity cap2b,TOKRB_GetPitch(rb2b),TOKRB_GetYaw(rb2b),TOKRB_GetRoll(rb2b) TOKSIM_Advance(.03,4) UpdateWorld RenderWorld If KeyHit(17) w=Not w WireFrame w Text 10,10,"W to wireframe" Text 10,25,"ARROWS - A - S to apply force and twist" Text 10,40,"SPACE to enable/disable pelvis joint" Flip Wend TOKSIM_DestroySimulator() MoveMouse 400,300:End