Code: Select all
AddSubEntity(Compound, torus1, #PB_Entity_StaticBody)
but the problem if we have compound_1 and compound_2 of the same specifications then they can't collide to each other, even they can collide (as a concave dynamical objects with any other convex object)
i have done tremendous efforts but no luck
i have used:
Code: Select all
SetEntityAttribute(Compound-1, #PB_Entity_DisableContactResponse, #False); enable collision
no luck
we have here a physics with a great and unexpected concave geometry (for free), but it works as concave collide with convex. but not concave with concave.
more info about collision filters:
http://bulletphysics.org/Bullet/phpBB3/ ... 4f2fc6265c look drleviathan
http://purebasic.fr/english/viewtopic.p ... er#p466157
Code: Select all
IncludeFile #PB_Compiler_Home + "examples/3d/Screen3DRequester.pb"
#CameraSpeed = 1
Define.f KeyX, KeyY, MouseX, MouseY
If InitEngine3D()
InitSprite()
InitKeyboard()
InitMouse()
If Screen3DRequester()
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/" , #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures" , #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Models" , #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Scripts" , #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/GUI" , #PB_3DArchive_FileSystem)
Parse3DScripts()
;WorldDebug(#PB_World_DebugBody)
;-------------------------------
; create material
CreateMaterial(1, LoadTexture(1, "wood.jpg"))
SetMaterialColor(1, #PB_Material_AmbientColor, #PB_Material_AmbientColors)
;
CreateMaterial(2, LoadTexture(2, "ground_diffuse.png"))
SetMaterialColor(2, #PB_Material_AmbientColor, #PB_Material_AmbientColors)
CreateMaterial(3, LoadTexture(3, "clouds.jpg"))
SetMaterialColor(3, #PB_Material_AmbientColor, #PB_Material_AmbientColors)
CreateMaterial(4, LoadTexture(4, "Geebee2.bmp"))
;-------------------------------
CreateSphere(3, 1)
CreateEntity(3, MeshID(3),MaterialID(4), 0, 5, 0)
CreateEntityBody(3, #PB_Entity_SphereBody, 1, 1, 0.5)
CreateCube(5, 1) ; for the ground
CreateTorus(1, 3, 1)
CreateTorus(2, 3, 1)
torus1 = CreateEntity(#PB_Any, MeshID(1),MaterialID(3), 0, 0, 0)
Global Comp1 = CreateEntity(#PB_Any,0,0)
Global Comp2 = CreateEntity(#PB_Any,0,0)
AddSubEntity(Comp1, torus1, #PB_Entity_StaticBody)
MoveEntity(Comp1, 0,15,0,#PB_Absolute)
CreateEntityBody(Comp1, #PB_Entity_CompoundBody, 1, 0.4, 0.5)
torus2 = CreateEntity(#PB_Any, MeshID(2),MaterialID(1), 0, 0, 0)
AddSubEntity(Comp2, torus2, #PB_Entity_StaticBody)
;RotateEntity(Comp2, 90,0,0)
CreateEntityBody(comp2, #PB_Entity_CompoundBody, 1, 0.3, 0.5)
;-------------------------------
;Ground
Ground = CreateEntity(#PB_Any, MeshID(5), MaterialID(2), 0, -7, 0)
ScaleEntity(Ground, 40, 0.4, 40)
CreateEntityBody(Ground, #PB_Entity_BoxBody, 0,0.4,1)
SetEntityAttribute(Comp1, #PB_Entity_DisableContactResponse, #False); enable collision
SetEntityAttribute(Comp2, #PB_Entity_DisableContactResponse, #False); enable collision
SetEntityAttribute(Ground, #PB_Entity_DisableContactResponse, 0); enable collision
;SetEntityCollisionFilter(Ground , 3 , 2 ) ; binary 11, 10
;SetEntityCollisionFilter(torus1 , 7, 1 ) ; binary 111, 1
; camera
CreateCamera(0, 0, 0, 100, 100, #True)
MoveCamera(0,0,10,30, #PB_Absolute)
CameraLookAt(0, 0,-5,0)
; GUI
OpenWindow3D(0, 0, 0, 50 , 10 , "")
HideWindow3D(0,1)
ShowGUI(128, 1) ; Display the GUI, semi-transparent and display the mouse cursor
WorldDebug(#PB_World_DebugBody)
Repeat
Screen3DEvents()
If ExamineMouse()
MouseX = -MouseDeltaX() * #CameraSpeed * 0.05
MouseY = -MouseDeltaY() * #CameraSpeed * 0.05
InputEvent3D(MouseX(), MouseY(),0)
BodyPick(CameraID(0), MouseButton(#PB_MouseButton_Left), MouseX(), MouseY(), 1)
EndIf
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
KeyX = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Right)
KeyX = #CameraSpeed
Else
KeyX = 0
EndIf
If KeyboardPushed(#PB_Key_Up)
KeyY = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY = #CameraSpeed
Else
KeyY = 0
EndIf
EndIf
MoveCamera (0, KeyX, 0, KeyY)
RotateCamera(0, MouseY, MouseX, 0, #PB_Relative)
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
End