You must modify the linear damping to see mass effect try this :
Because mass define only the object mass value ! but the
visual effect is a mix between : Worl gravity / Damping / RB Material / Mass
And of course ! the floor material is important too !
There is not magic value ! you must make test.
Because mass define only the object mass value ! but the
visual effect is a mix between : Worl gravity / Damping / RB Material / Mass
And of course ! the floor material is important too !
There is not magic value ! you must make test.
;======================================================================================= ; Code : ; Project Title : ; Author : Philippe Agnisola ; Email : ; Version : 1.0.0 ; Date : ; Notes : ; ; ;======================================================================================= Include "Inc_TimeMachine.bb" Include "Inc_EasyTOK.bb" ; ------------------------ ; Freelook cam var ; ------------------------ Global Mouse_X_Speed# Global Mouse_Y_Speed# Global Camera_VelX# Global Camera_VelZ# Global Camera_Pitch Global Camera_Yaw ; ------------------------------- ; Refresh frame number ; ------------------------------- Global AppFPS =60 ; ------------------ ; Open screen ; ------------------ Graphics3D 1024, 768,32,0 SetBuffer BackBuffer () ; ---------------------- ; Change font text ; ---------------------- AppFont=LoadFont("Arial",15,1,0,0) SetFont AppFont ; ------------------------------------- ; Setup camera and Easytok ; ------------------------------------- Global Cam=CreateCamera() PositionEntity Cam,10,40,-40 Proc_CreateVisor() TOK_InitWorld(0,-40,0,1000,100) TOK_CreateGround("Floor",150,255,150,10) TOK_ApplyMaterial("Floor",TOK_TypeAnimBody%,"Rubber") ; ----------------------------- ; Creating demo world ; ----------------------------- Global Light1=CreateLight(2) PositionEntity Light1,-50,50,-50 LightColor Light1,250,150,50 LightRange Light1,100 Global Light2=CreateLight(2) PositionEntity Light2,50,50,50 LightColor Light2,50,150,250 LightRange Light2,100 AmbientLight 80,90,100 ; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ; Object mass effect is a mix between Object mass => Object material => Object damping and of course the floor material ! ; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- TOK_CreateRBSphere("Toto1",False,-20,60,10,0,0,0,2,3,"",255,Rnd(255),255,1,50) TOK_SetRBLinearDamping("Toto1",0.00001) TOK_ApplyMaterial("Toto1",TOK_TypeRigidBody%,"Metal") TOK_CreateRBSphere("Toto2",False,-10,60,10,0,0,0,2,0.001,"",255,Rnd(255),255,1,50) TOK_SetRBLinearDamping("Toto2",0.00001) TOK_ApplyMaterial("Toto2",TOK_TypeRigidBody%,"Rubber") TOK_CreateRBSphere("Toto3",False,0,60,10,0,0,0,2,0.2,"",255,Rnd(255),255,1,50) TOK_SetRBLinearDamping("Toto3",0.00001) TOK_ApplyMaterial("Toto3",TOK_TypeRigidBody%,"Wood") TOK_CreateRBSphere("Toto4",False,10,60,10,0,0,0,2,2,"",255,Rnd(255),255,1,50) TOK_SetRBLinearDamping("Toto4",0.00001) TOK_ApplyMaterial("Toto4",TOK_TypeRigidBody%,"Plastic") TOK_CreateRBSphere("Toto5",False,20,60,10,0,0,0,2,6,"",255,Rnd(255),255,1,50) TOK_SetRBLinearDamping("Toto5",0.00001) TOK_ApplyMaterial("Toto5",TOK_TypeRigidBody%,"Ice") Global Start=False ; ------------- ; Main loop ; ------------- FramePeriod = 1000 / AppFPS FrameTime = MilliSecs () - FramePeriod MoveMouse GraphicsWidth()/2, GraphicsHeight()/2 Repeat ; -------------------------- ; Frame rate limiting ; -------------------------- Repeat FrameElapsed = MilliSecs () - FrameTime Until FrameElapsed FrameTicks = FrameElapsed / FramePeriod FrameTween# = Float (FrameElapsed Mod FramePeriod) / Float (FramePeriod) ; ----------------------- ; Update tweening ; ----------------------- For FrameLimit = 1 To FrameTicks If FrameLimit = FrameTicks Then CaptureWorld EndIf FrameTime = FrameTime + FramePeriod UpdateGame () UpdateWorld Next ; ------------------- ; Redraw world ; ------------------- TOK_RefreshEasyTOK() RenderWorld FrameTween ; ----------------------- ; FPS Displaying ; ----------------------- Proc_CinemaStrip() Color 255,255,255 Information$="<"+Get_FPS()+" FPS> / "+"<Arrow key to move> / <Mouse left to launch objecst> / <Mouse right to apply impulse Y>" Text GraphicsWidth()/2,GraphicsHeight()-30,Information$,True,True Flip Until KeyHit (1) ; ----------- ; End App ; ----------- TOK_FreePhysic() FreeFont AppFont End ; ----------------------------------- ; Tweening update function ; ----------------------------------- Function UpdateGame () Proc_Freelook(Cam,1.05,0.05) If MouseHit(1) Then Start=True EndIf If MouseHit(2) Then TOK_ApplyImpulse("",0,3,0) EndIf If Start=True Then TOK_RefreshPhysic(1.7/AppFPS,10) EndIf End Function ; ----------------------- ; Create the visor ; ----------------------- Function Proc_CreateVisor() Visor=LoadSprite("./ETOK_Medias/Target.png") PositionEntity Visor,EntityX(Cam),EntityY(Cam),EntityZ(Cam)+2 ScaleSprite Visor,0.1,0.1 EntityParent Visor,Cam EntityOrder Visor,-1 End Function ; ---------------------------------- ; Create the cinema strip ; ---------------------------------- Function Proc_CinemaStrip(Size=60) Color 1,1,1 Rect 0,0,GraphicsWidth(),Size Rect 0,GraphicsHeight()-Size,GraphicsWidth(),Size End Function ; ---------------------- ; Camera freelook ; ---------------------- Function Proc_Freelook(CamEntity,Velocity#,Speed#) Mouse_X_Speed#=MouseXSpeed()*0.5 Mouse_Y_Speed#=MouseYSpeed()*0.5 MoveMouse GraphicsWidth()/2,GraphicsHeight()/2 Camera_Pitch=Camera_Pitch+Mouse_Y_Speed# Camera_Yaw=Camera_Yaw+Mouse_X_Speed# RotateEntity CamEntity,Camera_Pitch,-Camera_Yaw,0 If KeyDown(203) Then Camera_VelX=Camera_VelX-Speed# ElseIf KeyDown(205) Camera_VelX=Camera_VelX+Speed# EndIf If KeyDown(208) Then Camera_VelZ=Camera_VelZ-Speed# ElseIf KeyDown(200) Camera_VelZ=Camera_VelZ+Speed# EndIf Camera_VelX=Camera_VelX/velocity# Camera_VelZ=Camera_VelZ/velocity# MoveEntity CamEntity,Camera_VelX,0,Camera_VelZ If KeyDown(200) Then MoveEntity CamEntity,0,0,Speed# EndIf If KeyDown(208) Then MoveEntity CamEntity,0,0,-Speed# EndIf If KeyDown(205) Then MoveEntity CamEntity,Speed#,0,0 EndIf If KeyDown(203) Then MoveEntity CamEntity,-Speed#,0,0 EndIf End Function