Am I doing something wrong with SetEntityCollisionFilter or anything else, perhaps it is a bug.
If #sc in row 36 changes to 15 or higher ,it works after a while for me.
Code: Select all
Declare OpenWindow_3D(c.i)
If InitEngine3D()=0 : End : EndIf
InitSprite()
InitKeyboard()
InitMouse()
IncludeFile #PB_Compiler_Home + "examples/3d/Screen3DRequester.pb"
If Screen3DRequester()=0 : End : EndIf
EnableExplicit
Global.f change,height,dist,angle
Global.i Isw,w_frame,c_body,cha
Isw=Sign(IsWindow(0))
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures/", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Packs/desert.zip", #PB_3DArchive_Zip)
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/GUI", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Scripts", #PB_3DArchive_FileSystem)
Parse3DScripts()
;- ------------- Material -----------------------------------------
GetScriptMaterial(2, "Color/Red")
CreateMaterial(6, LoadTexture(2, "MRAMOR6X6.jpg"))
;- ------------- Camera -----------------------------------------
#camera =3
CreateCamera(#Camera, 0, 0, 100, 100)
;- ------------- Light ---------------------------------------------
CreateLight(0, $FFFFFF, 1560, 900, 500)
AmbientColor($330000)
;- ------------- World -------------------------------------------
WorldGravity(-50)
SkyBox("desert07.jpg")
OpenWindow_3D(13)
;- ------------- constants ---------------------------------------
#floor=0
#chassi=1
#axel=2
#sc=13.0 ;scale
#chassis_x =#sc *13
#chassis_y =#sc *2
#chassis_z =#sc *21
#axle_x =#sc *(11/2.0)
#axle_t =#sc *3
#axle_pos =#sc *14
;- ------------- meshes -----------------------------------------
CreateCube(1, 1)
;- ------------- entitys -------------------------------------------
CreateEntity(#floor, MeshID(1), MaterialID(6), 0, -40, 0)
ScaleEntity( #floor, 1500, 0.5, 1500)
CreateEntity(#chassi , MeshID(1), MaterialID(2))
ScaleEntity( #chassi , #chassis_x , #chassis_y , #chassis_z ) ;chassis
CreateEntity(#axel, MeshID(1), MaterialID(6),-0.25-(#axle_x/2),0,-(#axle_pos/2))
ScaleEntity( #axel,#axle_x,#axle_t,#axle_t)
;- ------------- PhysicBody -----------------------------------
EntityPhysicBody(#floor, #PB_Entity_StaticBody,0,0,4)
EntityPhysicBody(#chassi,#PB_Entity_BoxBody ,1,1,0)
EntityPhysicBody(#axel, #PB_Entity_BoxBody,0.1,0,0)
;- ------------- CollisionFilter ---------------------------------
SetEntityCollisionFilter(#chassi, 64 , 512 ) ; chassi
SetEntityCollisionFilter(#axel, 128 , 0 ) ; axel (unneeded)
SetEntityCollisionFilter(#floor, 512 , 64 | 256) ; floor
;- ------------- joints ---------------------------------------------
HingeJoint(1,EntityID(#chassi),
-0.1, 3, -(#axle_pos/2),
0, 0, 1,
EntityID(#axel),
(#axle_x/2), 0, 0,
0, 0, 1)
;- ------------- not sleep ---------------------------------------
SetEntityAttribute(#chassi, #PB_Entity_LinearSleeping, 0)
SetEntityAttribute(#axel, #PB_Entity_LinearSleeping, 0)
;- ------------- Loop ----------------------------------------------
height = 25
dist= -315
Repeat
If Isw And WindowEvent()=#PB_Event_CloseWindow:End:EndIf
ExamineKeyboard()
;bumpers
EnableHingeJointAngularMotor(1, #True, 0, 100)
HingeJointMotorTarget(1, -2, 0.1)
If KeyboardReleased(#PB_Key_F1):w_frame+1:If w_frame = 3:w_frame=0:EndIf:CameraRenderMode(#camera,w_frame):EndIf
If KeyboardReleased(#PB_Key_F2): c_body+1:If c_body = 4 :c_body=0 :EndIf:WorldDebug(c_body):EndIf
cha=0
If KeyboardPushed(#PB_Key_Pad4):cha=1:angle-change: EndIf
If KeyboardPushed(#PB_Key_Pad6):cha=1:angle+change: EndIf
If KeyboardPushed(#PB_Key_Pad7):cha=1:height+change:EndIf
If KeyboardPushed(#PB_Key_Pad1):cha=1:height-change:EndIf
If KeyboardPushed(#PB_Key_Pad8):cha=1:dist+change:EndIf
If KeyboardPushed(#PB_Key_Pad2):cha=1:dist-change:EndIf
If cha : change * 0.995+0.1 : Else : change=0 : EndIf
CameraFollow( #camera, EntityID(#chassi), angle, Height+EntityY(#chassi) , dist, 0.5, 0.5,1)
SetGadgetText3D(1, " ch"+ #LF$+" "+StrF(change,1))
SetGadgetText3D(3, "cam"+ #LF$+StrF(angle,2)+ #LF$+StrF(height,2)+ #LF$+StrF(dist,2))
SetGadgetText3D(8, "Speed "+#LF$+StrF((GetEntityAttribute(#chassi, #PB_Entity_LinearVelocity)/12.6*4),1))
SetGadgetText3D(10, " x"+#LF$+" y"+#LF$+" z")
SetGadgetText3D(11, Str(EntityX(#chassi))+#LF$+StrF(EntityY(#chassi),3)+#LF$+Str(EntityZ(#chassi)))
SetGadgetText3D(13,Str(Engine3DStatus(#PB_Engine3D_CurrentFPS))+#LF$+Str(Engine3DStatus(#PB_Engine3D_NbRenderedTriangles))+#LF$+Str(Engine3DStatus(#PB_Engine3D_NbRenderedBatches)))
RenderWorld()
FlipBuffers()
Until KeyboardReleased(#PB_Key_Escape)
Procedure OpenWindow_3D(c)
Protected.i a , b , sc_h
sc_h=ScreenHeight()*0.12
OpenWindow3D(1, 4, 3, ScreenWidth()-8, sc_h, "",#PB_Window3D_Borderless)
ShowGUI(200, 0)
b=ScreenWidth()/((c+1)*1.03)
For a=0 To c
TextGadget3D(a, 10+a * b, 0, 152, sc_h, "")
Next a
EndProcedure