1) Thanks Sledge !
2) "Can I specify values for physics in MAX? How does this export? Is it compatible with B3DPipeline? "
Of course ! you can define Mass, Rotation,Scale, Life etc ..
from 3DS max or other 3D softwares, and, it's of course
fully compatible with pipeline, giles etc... The scene
(screenshot number 7) is made directly under Max => Blitz
and loaded with only one line of code.
Is there an example of code :
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)
; -----------------------------
; 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
TOK_CreateABCube("Wall01",0,90,15,-20,0,0,15,1,15,"",255,255,255,1)
TOK_CreateABCube("Wall02",0,60,-15,20,0,0,15,1,15,"",255,255,255,1)
TOK_CreateABCube("Wall03",0,30,15,-20,0,0,15,1,15,"",255,255,255,1)
; -------------
; 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
TOK_CreateRBSphere("Toto1",False,0,120,10,0,0,0,2,3,"",255,Rnd(255),255,1,5)
TOK_CreateRBCylinder("Toto2",False,0,140,10,0,0,Rnd(-90,90),2,4,3,"",Rnd(255),255,255,1,5)
EndIf
If MouseHit(2) Then
TOK_ApplyImpulse("",Rnd(-5,5),Rnd(55,165),Rnd(-5,5))
EndIf
TOK_RefreshPhysic(1.7/AppFPS,10)
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
Only 9 lines of code are used to declare and use EasyTOK.
TOK_InitWorld(0,-40,0,1000,100)
TOK_CreateGround("Floor",150,255,150,10)
....
TOK_CreateABCube("Wall01",0,90,15,-20,0,0,15,1,15,"",255,255,255,1)
TOK_CreateABCube("Wall02",0,60,-15,20,0,0,15,1,15,"",255,255,255,1)
TOK_CreateABCube("Wall03",0,30,15,-20,0,0,15,1,15,"",255,255,255,1)
If MouseHit(1) Then
TOK_CreateRBSphere("Toto1",False,0,120,10,0,0,0,2,3,"",255,Rnd(255),255,1,5) TOK_CreateRBCylinder("Toto2",False,0,140,10,0,0,Rnd(-90,90),2,4,3,"",Rnd(255),255,255,1,5)
EndIf
....
TOK_RefreshEasyTOK()
....
If MouseHit(2) Then
TOK_ApplyImpulse("",Rnd(-5,5),Rnd(55,165),Rnd(-5,5))
EndIf
TOK_RefreshPhysic(1.7/AppFPS,10)