BTW: Any example or idea using tokamak with water?
Here is a demo with faked buoyancy
[Edit]
I improved it a bit.
Fixed inertiatensor and added rotationaldamping in water
/Edit]
Const FPS=90 Graphics3D 800,600,0,2 SetBuffer BackBuffer() WireFrame False camera = CreateCamera() PositionEntity camera,0,5,-15 TOKSIM_CreateSimulator(0,-10,0) ; Create a bank to hold collisioninfo ColBank=CreateBank(104*2) TOKSIM_SetCInfoBank ColBank TOKSIM_SetCollisionResponse 1,2,2 ; Feedback only TOKSIM_SetCollisionResponse 2,1,2 TOKSIM_SetCollisionResponse 0,2,0 ; Nada TOKSIM_SetCollisionResponse 2,0,0 water = CreateCube() EntityColor water,55,55,175 ScaleEntity water,50,5,50 PositionEntity water,0,-5,0 abwater = TOKAB_Create() TOKAB_AddBox(abwater,100.0,100.0,100.0) TOKAB_SetPosition(abwater,0.0,-50.0,0.0) TOKAB_SetCollisionID abwater,2 EntityAlpha water,0.5 obj = CreateCube() rb = TOKRB_Create() TOKRB_AddBox rb,2,2,2 TOKRB_SetPosition rb,0,5,0 TOKRB_SetRotation rb,0,0,0 TOKRB_SetAngularDamping rb,0.01 TOKRB_SetLinearDamping rb,0.001 TOKRB_SetMass rb,0.5 TOKRB_SetBoxInertiaTensor rb,2,2,2,0.5 TOKRB_SetCollisionID rb,1 obj2 = CreateSphere() ScaleEntity obj2,0.25,0.25,0.25 rb2 = TOKRB_Create() TOKRB_AddSphere rb2,0.5 TOKRB_SetPosition rb2,1.25,5.0,0 TOKRB_SetAngularDamping rb2,0.01 TOKRB_SetLinearDamping rb2,0.001 TOKRB_SetMass rb2,0.3 TOKRB_SetSphereInertiaTensor rb2,0.5,0.3 joint = TOKJOINT_Create(2,rb,rb2) TOKJOINT_SetType joint,1 TOKJOINT_SetPositionAndRotationWorld joint,1.25,5.0,0,0,0,0 TOKJOINT_Enable joint,True Centerpivot = CreatePivot() light=CreateLight() PositionEntity light,7,15,-5 PointEntity light,Centerpivot PointEntity camera,centerpivot period=1000/FPS time=MilliSecs()-period ; MainLoop While Not KeyHit(1) Repeat elapsed=MilliSecs()-time Until elapsed ticks=elapsed/period tween#=Float(elapsed Mod period)/Float(period) For k=1 To ticks time=time+period If k=ticks Then CaptureWorld TOKSIM_Advance(1.5/FPS,1) ;Check Collision Ccount=TOKSIM_GetCollisionCount() InWater#=TOKRB_GetY#(rb)-1 If Ccount=0 Then InContact=False If Ccount>0 Then InContact=True ;Determine how much of the sphere's volume is in the water... If InWater#<-2 Then InWater#=-2 Vol#=(1.0/2.0)*Abs(InWater#) TOKRB_SetForce rb,0,(10+Rnd(-2.0,2.0))*Vol#,0 TOKRB_SetLinearDamping rb,0.03 TOKRB_SetAngularDamping rb,0.1 Else TOKRB_SetForce rb,0,0,0 TOKRB_SetLinearDamping rb,0.01 TOKRB_SetAngularDamping rb,0.001 EndIf If KeyDown(200) Then TOKRB_ApplyImpulse RB,0,1.0,0 TOKRB_ApplyTwist RB,1,2,3 EndIf If KeyDown(208) Then TOKRB_ApplyImpulse RB,0,-0.5,0 EndIf PositionEntity obj,TOKRB_GetX#(rb),TOKRB_GetY#(rb),TOKRB_GetZ#(rb) RotateEntity obj,TOKRB_GetPitch#(rb),TOKRB_GetYaw#(rb),TOKRB_GetRoll#(rb),False PositionEntity obj2,TOKRB_GetX#(rb2),TOKRB_GetY#(rb2),TOKRB_GetZ#(rb2) RotateEntity obj2,TOKRB_GetPitch#(rb2),TOKRB_GetYaw#(rb2),TOKRB_GetRoll#(rb2),False UpdateWorld Next RenderWorld tween Text 0,10,"Render Time:"+Str(elapsed)+ " milliseconds" Text 0,20,"InWater"+Str(InWater#) Flip Wend TOKSIM_DestroySimulator() End