A little demo of my Tokamak lib :)
http://www.blitz3dfr.com/tempo/TestTOKA.zip
I'm making a lib for make toka more easy to setup :)
This is the demo source, lib coming for free
Left mouse : Launch objet
Right Mouse ; Move Chain
Middle Mouse : Bullet Time :)
http://www.blitz3dfr.com/tempo/TestTOKA.zip
I'm making a lib for make toka more easy to setup :)
This is the demo source, lib coming for free
Left mouse : Launch objet
Right Mouse ; Move Chain
Middle Mouse : Bullet Time :)
;======================================================================================= ; Code : ; Project Title : ; Author : Philippe Agnisola ; Email : ; Version : 1.0.0 ; Date : ; Notes : ; ; ;======================================================================================= Include "Inc_TimeMachine.bb" Include "Inc_TOKA.bb" ; ------------------------ ; Freelook cam var ; ------------------------ Global Mouse_X_Speed# Global Mouse_Y_Speed# Global Camera_VelX# Global Camera_VelZ# Global Camera_Pitch Global Camera_Yaw ; ------------------------------ ; Nombre d'image MAX ; ------------------------------ Global AppFPS =30 ; --------------------------- ; Ouverture de l'ecran ; --------------------------- Graphics3D 640, 480,32,0 SetBuffer BackBuffer () ; --------------------------------- ; Changement de la fonte ; --------------------------------- AppFont=LoadFont("Arial",15,1,0,0) SetFont AppFont ; ------------------------------------------------- ; Setup de la camera et des lumières ; ------------------------------------------------- Global Cam=CreateCamera() PositionEntity Cam,0,20,-40 ; ---------------------------------- ; Construction de la scene ; ---------------------------------- MoveMouse GraphicsWidth()/2, GraphicsHeight()/2 Global Light1=CreateLight(2) PositionEntity Light1,-100,100,-100 LightRange Light1,200 Global Light2=CreateLight(2) PositionEntity Light2,100,100,100 LightRange Light2,200 TOK_InitWorld(0,-40,0,1000,100) TOK_CreateGround(150,255,150,10) Create_Chain("./samples/tore.b3d","./samples/boulet.b3d","Chain01",20,15,78,0,10) Create_Chain("./samples/tore.b3d","./samples/boulet.b3d","Chain02",20,-15,78,10,5) Create_Chain("./samples/tore.b3d","./samples/boulet.b3d","Chain03",30,0,88,-10,10) For J.TOK_ObjectJoin=Each TOK_ObjectJoin ;If Upper$(J\Name$)=Upper$("Chain02" TOKRB_ApplyImpulse J\Body,60,1250,-60 TOKRB_ApplyTwist J\Body,0,5,0 TOK_UpdatePhysic(0.05,5) ;EndIf Next Function Create_Chain(ChainFile$,BallFile$,Name$,Number,Px#,Py#,Pz#,Mass#) Tmp_Id=1 : Old=0 For i=1 To Number C.TOK_ObjectChain=New TOK_ObjectChain GoodPy#=Py-i*3.5 If i<Number C\Body=TOK_CreateRBJoin(ChainFile$,Name$,Old,Tmp_Id,Px#,GoodPy#,Pz#,i*45,Mass#/2,1,1,30) Else C\Body=TOK_CreateRBJoin(BallFile$,Name$,Old,Tmp_Id,Px#,GoodPy#-2,Pz#,i*45,Mass#,1,1,30) EndIf Old=C\Body Tmp_Id=2 Next End Function ; ----------------------------------------------- ; Boucle principale du programme ; ----------------------------------------------- FramePeriod = 1000 / AppFPS FrameTime = MilliSecs () - FramePeriod Repeat ; ---------------------------- ; On limite les frames ; ---------------------------- Repeat FrameElapsed = MilliSecs () - FrameTime Until FrameElapsed FrameTicks = FrameElapsed / FramePeriod FrameTween# = Float (FrameElapsed Mod FramePeriod) / Float (FramePeriod) ; ------------------------------------------------------ ; On update les monde et les animations ; ------------------------------------------------------ For FrameLimit = 1 To FrameTicks If FrameLimit = FrameTicks Then CaptureWorld EndIf FrameTime = FrameTime + FramePeriod UpdateGame () UpdateWorld Next If MouseHit(1) SeedRnd MilliSecs() Mass#=Rnd(1,4) Area=30 Size=Rnd(4,8) TOK_CreateRBCube(Rnd(-5,5),200,Rnd(-5,5),0,0,0,Size,Size,Size,Mass#,"",Rnd(255),Rnd(255),Rnd(255),1,35000) ;TOK_CreateRBCubeMesh("./samples/Boulet.b3d",0,160,0,0,0,0,Mass#,"",1,35000) ;TOK_CreateRBSphereMesh("./samples/Boulet.b3d",0,160,0,0,0,0,Mass#,"",1,35000) TOK_CreateRBSphere(Rnd(-5,5),160,Rnd(-5,5),Rnd(6,10),Mass#,"",Rnd(255),Rnd(255),Rnd(255),1,Rnd(20000,30000)) TOK_CreateRBCylinder(Rnd(-5,5),190,Rnd(-5,5),90,0,0,2,5,Mass#,"",Rnd(255),Rnd(255),Rnd(255)) EndIf If KeyHit(57) For G.TOK_ObjectStruct = Each TOK_ObjectStruct If G\RigidType%=TOK_IsRigidBody% TOKRB_ApplyImpulse2 G\Body,Rnd(-5.5,5.5),Rnd(-15,15.0),Rnd(-5,5.0),TOKRB_GetX#(G\Body)+30.5,TOKRB_GetY#(G\Body)+150.5,TOKRB_GetZ#(G\Body)+30.5 ;TOKRB_ApplyTwist G\ObjectBody,Rnd(-10,10),Rnd(-10,10),Rnd(-10,10) EndIf Next EndIf If MouseHit(2) Then For J.TOK_ObjectJoin=Each TOK_ObjectJoin ; If Upper$(J\Name$)=Upper$("Chain01" TOKRB_ApplyImpulse J\Body,Rnd(30,60),60,Rnd(30,60) TOKRB_ApplyTwist J\Body,0,5,0 ;EndIf Next EndIf ; --------------------------- ; On redraw la scene ; --------------------------- RenderWorld FrameTween ; ------------------------- ; Affichage des FPS ; ------------------------- Color 255,255,255 Text 10,10,Get_FPS()+" FPS"+" / Obj Num : "+TOK_NumStructObject%+" / Col ID : "+TOKSIM_GetCollisionCount()+" / PhysicTime : "+TOKSIM_GetPhysicsTime() ; ------------- ; Affichage ; ------------- Flip Until KeyHit (1) ; ------------------------------- ; On quitte l'application ; ------------------------------- TOK_FreePhysic() FreeFont AppFont End ; ------------------------------------------------ ; Permet d'updater votre programme ; ------------------------------------------------ Function UpdateGame () Proc_Freelook(Cam,1.05,0.3) TOK_UpdatePhysic(0.05,5) End Function 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