Thank for your help. The hidden cube is a good idea but it is not the solution. If the tray is very inclined the ball goes through walls.
insert WorldDebug(#PB_World_DebugEntity) and look at the results.
[PB 5.20] How apply physic on AttachEntityObject ?
Re: [PB 5.20] How apply physic on AttachEntityObject ?
➽ Windows 11 64-bit - PB 6.21 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti
Sorry for my bad english and the Dunning–Kruger effect
Re: [PB 5.20] How apply physic on AttachEntityObject ?
I know. It was the workaround of a desperate dudefalsam wrote:Thank for your help. The hidden cube is a good idea but it is not the solution. If the tray is very inclined the ball goes through walls.
insert WorldDebug(#PB_World_DebugEntity) and look at the results.
I've stumbled onto something new...If static entities touch on another, the Bullet physics goes haywire.
Try putting your borders so no entity touch anything.
I'm still testing my own example and are as of right now in the process of seperating all static object from each other.
My preliminary tests shows, that Bullet physics behave a bit differently. In my case the ball won't fall through the plane..
Anyway...Will get back to you, when I know more..
Edit: It's a 'no go'.
make the borders closer to the center, the plane a little bigger and put a sphere/cube as shown earlier, at least for now.
I tried to use a node to encapsulate it all, but the physics vanished so, that idea was so elequantly washed down the drains.
As of right now...I'm all out of ideas....There is one option, but it requires an extra function not currently present in PB.
Whether it works or not, that's for Comtois or Fred to find out. ( I describe the function in my post about physics parameters)..
For now...ApplePi's idea is the best one I have seen yet.
Best regards
Peter
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
Re: [PB 5.20] How apply physic on AttachEntityObject ?
i have found this:
using meshmanual.pb from 3D examples which are using AddSubMesh function to construct the mesh, let me call it a plane instead of pyramid, giving physics to it and to a ball, if we add 2 other copies of the same entity so the whole plan like this:

rotate the plane right or left it seems to me more robust than falsam first example. now attach the left and right planes to the main one and we have the same robust physics , but with a small problem they are hidden even they are active, if this problem can't be solved then we can add normal penetrable thin planes to cover the hidden active side planes
note that we should add ApplyEntityImpulse(ball, 0, 0.01, 0) with a left and right key press so to give tiny physics to the ball else it will penetrate the plane if it is inactive for some time and we begins to rotate the plane.
uncomment lines 110-111 to enable
AttachEntityObject(0, "", EntityID(1))
AttachEntityObject(0, "", EntityID(2))
but as i said the side planes somehow are now hidden
this is experimented using beta 13 , save the example to 3D sections
using meshmanual.pb from 3D examples which are using AddSubMesh function to construct the mesh, let me call it a plane instead of pyramid, giving physics to it and to a ball, if we add 2 other copies of the same entity so the whole plan like this:

rotate the plane right or left it seems to me more robust than falsam first example. now attach the left and right planes to the main one and we have the same robust physics , but with a small problem they are hidden even they are active, if this problem can't be solved then we can add normal penetrable thin planes to cover the hidden active side planes
note that we should add ApplyEntityImpulse(ball, 0, 0.01, 0) with a left and right key press so to give tiny physics to the ball else it will penetrate the plane if it is inactive for some time and we begins to rotate the plane.
uncomment lines 110-111 to enable
AttachEntityObject(0, "", EntityID(1))
AttachEntityObject(0, "", EntityID(2))
but as i said the side planes somehow are now hidden
this is experimented using beta 13 , save the example to 3D sections
Code: Select all
;
; ------------------------------------------------------------
;
; PureBasic - Manual Mesh
;
; (c) 2003 - Fantaisie Software
;
; ------------------------------------------------------------
;
#CameraSpeed = 2
Global rot.f
IncludeFile "Screen3DRequester.pb"
Define.f KeyX, KeyY, MouseX, MouseY
Define.f x, y, z, nx, ny, nz, u, v
Define.l Co
Define.w t1, t2, t3
If InitEngine3D()
Add3DArchive("Data/Textures", #PB_3DArchive_FileSystem)
InitSprite()
InitKeyboard()
InitMouse()
If Screen3DRequester()
; Create a pyramid, manually.. See the DataSection, for more precisions
;
Restore Pyramid
CreateMesh(0, #PB_Mesh_TriangleList)
;Base
For i = 0 To 3
Read.f x : Read.f y : Read.f z
Read.l Co
Read.f u : Read.f v
MeshVertexPosition(x, y, z)
MeshVertexNormal(0, 0, 0)
MeshVertexColor(Co)
MeshVertexTextureCoordinate(u, v)
Next
For i = 0 To 1
Read.w t1 : Read.w t2 : Read.w t3
MeshFace(t1, t2, t3)
Next
;Side
For k=0 To 3
If k = 8:Goto ext:EndIf
AddSubMesh(#PB_Mesh_TriangleList)
;ext:
For i = 0 To 2
Read.f x : Read.f y : Read.f z
Read.l Co
Read.f u : Read.f v
MeshVertexPosition(x, y, z)
MeshVertexNormal(0, 0, 0)
MeshVertexColor(Co)
MeshVertexTextureCoordinate(u, v)
Next i
Read.w t1 : Read.w t2 : Read.w t3
MeshFace(t1, t2, t3)
ext:
Next
FinishMesh(#True)
NormalizeMesh(0)
UpdateMeshBoundingBox(0)
CreateMaterial(0, LoadTexture(0, "Geebee2.bmp"))
CreateMaterial(1, LoadTexture(1, "MRAMOR6X6.jpg"))
SetMaterialColor(0, #PB_Material_AmbientColor, #PB_Material_AmbientColors)
MaterialCullingMode(0, #PB_Material_NoCulling)
CreateEntity(0, MeshID(0), MaterialID(0))
ScaleEntity(0, 400, 200, 400)
EntityPhysicBody(0, #PB_Entity_StaticBody , 1, 0.2, 1)
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 0, 300, 3000, #PB_Absolute)
CreateLight(0, RGB(255,255,255), 300, 600, -100)
AmbientColor(RGB(80, 80, 80))
ScaleEntity(0,5,1,5)
RotateEntity(0,180,0,0)
Mesh = CreateSphere(#PB_Any, 150)
ball = CreateEntity(#PB_Any, MeshID(Mesh), MaterialID(1), 600, 600, -50)
EntityPhysicBody(ball, #PB_Entity_SphereBody , 1, 0.2, 0.1)
CopyEntity(0,1)
CopyEntity(0,2)
MoveEntity(1,-1100,-300,0)
RotateEntity(1,0,0,-270)
MoveEntity(2,1100,-300,0)
RotateEntity(2,0,0,270)
EntityPhysicBody(1, #PB_Entity_StaticBody , 1, 0.2, 1)
EntityPhysicBody(2, #PB_Entity_StaticBody , 1, 0.2, 1)
;AttachEntityObject(0, "", EntityID(1))
;AttachEntityObject(0, "", EntityID(2))
WorldGravity(-2000)
Repeat
Screen3DEvents()
If ExamineMouse()
MouseX = -MouseDeltaX() * #CameraSpeed * 0.05
MouseY = -MouseDeltaY() * #CameraSpeed * 0.05
EndIf
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
ApplyEntityImpulse(ball, 0, 0.01, 0)
rot = rot-0.01
ElseIf KeyboardPushed(#PB_Key_Right)
ApplyEntityImpulse(ball, 0, 0.01, 0)
rot = rot+0.01
Else
KeyX = 0
EndIf
If KeyboardPushed(#PB_Key_Up)
KeyY = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY = #CameraSpeed
Else
KeyY = 0
EndIf
EndIf
RotateEntity(0, 0, 0, rot, #PB_Relative)
RotateCamera(0, MouseY, MouseX, 0, #PB_Relative)
MoveCamera (0, KeyX, 0, KeyY)
RenderWorld()
Screen3DStats()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized", 0)
EndIf
End
DataSection
Pyramid:
;Base
Data.f -0.5,-0.5,0.5 ; position
Data.l $FF0000 ; color
Data.f 0,0 ; UVCoordinate
Data.f 0.5,-0.5,0.5 ; position
Data.l $FF0000 ; color
Data.f 0,1 ; UVCoordinate
Data.f 0.5,-0.5,-0.5 ; position
Data.l $FF0000 ; color
Data.f 1,1 ; UVCoordinate
Data.f -0.5,-0.5,-0.5 ; position
Data.l $FF0000 ; color
Data.f 1,0 ; UVCoordinate
Data.w 2,1,0 ; Face
Data.w 0,3,2 ; Face
;-Front
Data.f 0.5,-0.5,0.5 ; position
Data.l $FFFFFF ; color
Data.f 1,0 ; UVCoordinate
Data.f 0.0,0.5,0.0
Data.l $FFFFFF
Data.f 0.5,0.5
Data.f -0.5,-0.5,0.5
Data.l $FFFFFF
Data.f 0,0
Data.w 0,1,2 ; Face
;-Back
Data.f -0.5,-0.5,-0.5
Data.l $FFFFFF
Data.f 0,1
Data.f 0.0,0.5,0.0
Data.l $FFFFFF
Data.f 0.5,0.5
Data.f 0.5,-0.5,-0.5
Data.l $FFFFFF
Data.f 1,1
Data.w 0,1,2
;-Left
Data.f -0.5,-0.5,0.5
Data.l $FFFFFF
Data.f 0,0
Data.f 0.0,0.5,0.0
Data.l $FFFFFF
Data.f 0.5,0.5
Data.f -0.5,-0.5,-0.5
Data.l $FFFFFF
Data.f 0,1
Data.w 0,1,2
;-Right
Data.f 0.5,-0.5,-0.5
Data.l $FFFFFF
Data.f 1,1
Data.f 0.0,0.5,0.0
Data.l $FFFFFF
Data.f 0.5,0.5
Data.f 0.5,-0.5,0.5
Data.l $FFFFFF
Data.f 1,0
Data.w 0,1,2
EndDataSection
