Physics EXAMPLES need a fix?
Physics EXAMPLES need a fix?
Just one example:
The Bridge.pb Demo exists since a long time now ... meanwhile there have been at least 100 beta versions and 5 or more final versions released ... but no-one seems to complain that physics does work realistic at all.
It is slow motion and the balls move forever until they fall off the plane and never stop as long as they do not get blocked by at least 2 blocks. Which makes it a complete useless demo in my view.
I can make it look more realistic with (an unprofessional) time=RenderWorld(time*2) to reduce the slow motion effect ... but I can change the parameters EntityPhysicBody(Perso, #PB_Entity_SphereBody, Mass, Restitution, Friction) to whatever values I wish - the balls will never stop.
Changing friction of the plane does nothing either ...
Has anybody figured out how to get a realistic demo of the bridge?
Using PB 5.30 B4
The Bridge.pb Demo exists since a long time now ... meanwhile there have been at least 100 beta versions and 5 or more final versions released ... but no-one seems to complain that physics does work realistic at all.
It is slow motion and the balls move forever until they fall off the plane and never stop as long as they do not get blocked by at least 2 blocks. Which makes it a complete useless demo in my view.
I can make it look more realistic with (an unprofessional) time=RenderWorld(time*2) to reduce the slow motion effect ... but I can change the parameters EntityPhysicBody(Perso, #PB_Entity_SphereBody, Mass, Restitution, Friction) to whatever values I wish - the balls will never stop.
Changing friction of the plane does nothing either ...
Has anybody figured out how to get a realistic demo of the bridge?
Using PB 5.30 B4
Last edited by Thade on Sun Aug 03, 2014 3:27 am, edited 1 time in total.
--------------
Yes, its an Irish Wolfhound.
Height: 107 cm; Weight: 88 kg
Yes, its an Irish Wolfhound.
Height: 107 cm; Weight: 88 kg
Re: Physics need a fix?
I'm not sure why the spheres keep moving.
One reason for lack of realism when objects fall is there doesn't seem to be any gravitational acceleration.
Earth's gravity is approximately 9.8 meters per second. So, for every second an object is falling it should increase in speed by 9.8m/s, excluding air resistance.
I wonder if these problems/limitations are caused by bullet or if it's something on the purebasic side?

One reason for lack of realism when objects fall is there doesn't seem to be any gravitational acceleration.
Earth's gravity is approximately 9.8 meters per second. So, for every second an object is falling it should increase in speed by 9.8m/s, excluding air resistance.
I wonder if these problems/limitations are caused by bullet or if it's something on the purebasic side?
Re: Physics EXAMPLES need a fix?
That's why I thought its a good idea to start a discussion about that - if no-one else does.Samuel wrote: I wonder if these problems/limitations are caused by bullet or if it's something on the purebasic side?

Maybe adding some forgotten parameters could fix it in one of the coming betas. The present physics calculations are creating no realistic movements of entities at all.
And as long as it is so obvious it can unfortunately not really be used in games which are based on physics.
PS: I used ODE in the past with other programs and never noticed such obvious wrong behavior.
Last edited by Thade on Sun Aug 03, 2014 3:27 am, edited 1 time in total.
--------------
Yes, its an Irish Wolfhound.
Height: 107 cm; Weight: 88 kg
Yes, its an Irish Wolfhound.
Height: 107 cm; Weight: 88 kg
Re: Physics need a fix?
"the spheres never stop"
i have made this test now : in line 78, reduce the restitution which makes the sphere more active. increase the sphere friction. and replace #PB_Entity_SphereBody with #PB_Entity_ConvexHullBody.
EntityPhysicBody(Perso, #PB_Entity_ConvexHullBody , 1.0, 0.02, 1.0)
press space to let the bridge throw the spheres rapidly to the plane, we will see all the spheres will loose activity in short time. just a theory may be this is because #PB_Entity_ConvexHullBody gives the sphere tiny bumps to compensate the complete lack of bumps on the ideal plane which are not exist in real nature .
i have made this test now : in line 78, reduce the restitution which makes the sphere more active. increase the sphere friction. and replace #PB_Entity_SphereBody with #PB_Entity_ConvexHullBody.
EntityPhysicBody(Perso, #PB_Entity_ConvexHullBody , 1.0, 0.02, 1.0)
press space to let the bridge throw the spheres rapidly to the plane, we will see all the spheres will loose activity in short time. just a theory may be this is because #PB_Entity_ConvexHullBody gives the sphere tiny bumps to compensate the complete lack of bumps on the ideal plane which are not exist in real nature .
Re: Physics EXAMPLES need a fix?
CreateSphere(2, 2, 36, 36)
#PB_Entity_ConvexHullBody inside EntityPhysicBody(..) is a good idea, applePi
I'm still using time.f=RenderWorld(time*2) to reduce the slow motion effect. Needs optimization, too
Testing how the changes effect the framerate.
#PB_Entity_ConvexHullBody inside EntityPhysicBody(..) is a good idea, applePi

I'm still using time.f=RenderWorld(time*2) to reduce the slow motion effect. Needs optimization, too
Testing how the changes effect the framerate.
Last edited by Thade on Sun Aug 03, 2014 3:28 am, edited 1 time in total.
--------------
Yes, its an Irish Wolfhound.
Height: 107 cm; Weight: 88 kg
Yes, its an Irish Wolfhound.
Height: 107 cm; Weight: 88 kg
Re: Physics need a fix?
Thade, about what appears slow motion falling balls, i have remembered now my post here http://purebasic.fr/english/viewtopic.php?f=36&t=54518 about balls moving inside pipes.
in the first example i was obligated to set the gravity stronger by 10 times "WorldGravity(-100)" because the slow motion of the falling sphere. but Comtois refers to the link http://bulletphysics.org/mediawiki-1.5. ... _The_World
so when i scaled down all dimensions by 0.1 the sphere falls speedier without increasing the gravity. i have provided there 2 additional timing tests for a slow ball (big scale world) and a normal ball (smaller world)
what appears slow falling ball is like watching the moon slowly moving in the sky because we watch it inside a very big world while in reality it is moving in enormous speeds
in the bulletphysics wiki above they provide more info about how to scale the world
in the first example i was obligated to set the gravity stronger by 10 times "WorldGravity(-100)" because the slow motion of the falling sphere. but Comtois refers to the link http://bulletphysics.org/mediawiki-1.5. ... _The_World
so when i scaled down all dimensions by 0.1 the sphere falls speedier without increasing the gravity. i have provided there 2 additional timing tests for a slow ball (big scale world) and a normal ball (smaller world)
what appears slow falling ball is like watching the moon slowly moving in the sky because we watch it inside a very big world while in reality it is moving in enormous speeds
in the bulletphysics wiki above they provide more info about how to scale the world
Re: Physics EXAMPLES need a fix?
Thanks for the info and the links. Very helpful, indeed. 

Last edited by Thade on Sun Aug 03, 2014 3:28 am, edited 1 time in total.
--------------
Yes, its an Irish Wolfhound.
Height: 107 cm; Weight: 88 kg
Yes, its an Irish Wolfhound.
Height: 107 cm; Weight: 88 kg
Re: Physics need a fix?
Hi Thade ... See if this newer version looks better. I commented what I added or changed from the original. It's true when you are dealing with physics that the scale of the items plays an important role on how things interact accurately. Also you will need to tweak, tweak again, and then tweak some more, any settings in order to get it to look right. Hope this helps ... Bruce
Code: Select all
;
; ------------------------------------------------------------
;
; PureBasic - PointJoint (Bridge)
;
; (c) 2011 - Fantaisie Software
;
; Updated 06/27/2014
;
; ------------------------------------------------------------
;
IncludeFile "Screen3DRequester.pb"
#CameraSpeed = 1
#NbPlanks = 30
Define.f KeyX, KeyY, MouseX, MouseY
Dim Plank(#NbPlanks)
If InitEngine3D(#PB_Engine3D_DebugLog)
Add3DArchive("Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive("Data/Scripts",#PB_3DArchive_FileSystem)
Add3DArchive("Data/Packs/desert.zip", #PB_3DArchive_Zip)
Parse3DScripts()
InitSprite()
InitKeyboard()
InitMouse()
If Screen3DRequester()
; Let's change the gravity from the default value of -9.086 to a higher value
WorldGravity(-28) ;*** ADDED ***
WorldShadows(#PB_Shadow_Modulative, -1, RGB(127, 127, 127))
;Materials
;
CreateMaterial(0, LoadTexture(0, "Wood.jpg"))
GetScriptMaterial(1, "SphereMap/SphereMappedRustySteel")
CreateMaterial(2, LoadTexture(2, "Dirt.jpg"))
GetScriptMaterial(3, "Scene/GroundBlend")
; Ground
;
CreatePlane(3, 500, 500, 5, 5, 5, 5)
CreateEntity(3,MeshID(3),MaterialID(3), 0, -50, 0)
EntityRenderMode(3, 0)
EntityPhysicBody(3, #PB_Entity_BoxBody, 0, 1, 1)
; Bridge
CreateCube(1, 1.0)
For i = 1 To #NbPlanks
Plank(i)=CreateEntity(#PB_Any, MeshID(1), MaterialID(0))
ScaleEntity(Plank(i), 2.8, 0.8, 20)
MoveEntity(Plank(i), i * 3, 0, 0, #PB_Absolute)
EntityPhysicBody(Plank(i), #PB_Entity_BoxBody, 1.0)
Next i
Pas.f = 1.5
PointJoint(#PB_Any, EntityID(Plank(1)), -Pas, 0, -5)
For i= 1 To #NbPlanks-2
Joint=PointJoint(#PB_Any, EntityID(Plank(i+1)), -Pas, 0, -5, EntityID(Plank(i)), Pas, 0, -5)
Next i
PointJoint(#PB_Any, EntityID(Plank(#NbPlanks)), Pas, 0, -5)
PointJoint(#PB_Any, EntityID(Plank(#NbPlanks-1)), Pas, 0, -5, EntityID(Plank(#NbPlanks)), -Pas, 0, -5)
PointJoint(#PB_Any, EntityID(Plank(1)), -Pas, 0, 5)
For i= 1 To #NbPlanks-2
Joint=PointJoint(#PB_Any, EntityID(Plank(i+1)), -Pas, 0, 5, EntityID(Plank(i)), Pas, 0, 5)
Next i
PointJoint(#PB_Any, EntityID(Plank(#NbPlanks)), Pas, 0, 5)
toto=PointJoint(#PB_Any, EntityID(Plank(#NbPlanks-1)), Pas, 0, 5, EntityID(Plank(#NbPlanks)), -Pas, 0, 5)
; Objects
;
CreateSphere(2, 2, 30, 30)
C = Plank(1)
For i = 1 To #NbPlanks/2
Perso = CreateEntity(#PB_Any, MeshID(2), MaterialID(1), EntityX(C) +i * 5, EntityY(C)+ i * 2, EntityZ(C))
;EntityPhysicBody(Perso, #PB_Entity_SphereBody, 1.0, 0.3, 0.5)
; Let's adjust the MASS, RESTITUTION, and FRICTION to where it looks accurate for the BALLS
EntityPhysicBody(Perso, #PB_Entity_SphereBody, 1, 0.3, 0.025) ;*** CHANGED ***
; Let's now change the ANGULAR VELOCITY so that the BALLS will stop rolling after a certain time
EntityAngularFactor(Perso,0.03,0.03,0.03) ; *** ADDED ***
Next i
For i = 1 To #NbPlanks/2
Perso = CreateEntity(#PB_Any, MeshID(1), MaterialID(2), EntityX(C) +i * 5, EntityY(C)+ i * 4, EntityZ(C))
ScaleEntity(Perso, 3, 3, 3)
EntityPhysicBody(Perso, #PB_Entity_BoxBody, 1.0)
Next i
; Camera
;
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, -20, 30, -40, #PB_Absolute)
CameraLookAt(0, EntityX(C) + 25, EntityY(C) + 10, EntityZ(C))
; Skybox
;
SkyBox("desert07.jpg")
; Light
;
CreateLight(0, RGB(255, 255, 255), 100, 800, -500)
AmbientColor(RGB(20, 20, 20))
Plank = 1
Repeat
Screen3DEvents()
If ExamineMouse()
MouseX = -MouseDeltaX() * #CameraSpeed * 0.05
MouseY = -MouseDeltaY() * #CameraSpeed * 0.05
EndIf
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Space)
;ApplyEntityImpulse(Plank(#NbPlanks/2), 0, 9, 0)
ApplyEntityImpulse(Plank(#NbPlanks/2),0,27,0) ; Triple the original
EndIf
If KeyboardReleased(#PB_Key_Return)
If Plank <= #NbPlanks
DisableEntityBody(Plank(Plank), 0)
FreeEntityJoints(Plank(Plank))
Plank + 1
EndIf
EndIf
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()
Screen3DStats()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
End
Re: Physics EXAMPLES need a fix?
Hi bmon
The rolling and stopping comes closer to reality. But running the program long enough - you see them still falling off the plane when the slow motion effect is not there.
The slow motion effect is still visible. It seems that WorldGravity(-90) to WorldGravity(-100) comes closest to a more realistic behavior as reading through applePI's Links shows.
What brings us to another point.
ApplePi's idea using #PB_Entity_ConvexHullBody makes the spheres stop. But once they stop, they are released from physics calculations. When you now move the floor they do not start rolling again but hang in the air until they got pushed (get an impulse) again. Toggle ImpulseFlag to view.
See this code I am testing with.
Use [W][A][S][D] to move the Camera; Numpad [8][4][6][2] to tilt the plane; [N] to launch more spheres; to toggle ImpulseFlag
EDITED: Added Stringgadgets for Spheres and Cubes count.
It would be interesing to know when the framerate drops on different systems ... on mine the framerate drops below 60 when 105 Spheres + 15 Cubes are launched.
Well, what I do is try and error ... the manual does not explain what really happens behind the scene ...
Next will be using #PB_Entity_SphereBody again and bmon's stop-the-spheres-code.
.
The rolling and stopping comes closer to reality. But running the program long enough - you see them still falling off the plane when the slow motion effect is not there.
The slow motion effect is still visible. It seems that WorldGravity(-90) to WorldGravity(-100) comes closest to a more realistic behavior as reading through applePI's Links shows.
What brings us to another point.
ApplePi's idea using #PB_Entity_ConvexHullBody makes the spheres stop. But once they stop, they are released from physics calculations. When you now move the floor they do not start rolling again but hang in the air until they got pushed (get an impulse) again. Toggle ImpulseFlag to view.
See this code I am testing with.
Use [W][A][S][D] to move the Camera; Numpad [8][4][6][2] to tilt the plane; [N] to launch more spheres; to toggle ImpulseFlag
Code: Select all
ForEach Spheres()
ApplyEntityImpulse(Spheres(), 0, 1, 0)
Next
ForEach Cubes()
ApplyEntityImpulse(Cubes(), 0, 0.1, 0)
Next
Code: Select all
;
; ------------------------------------------------------------
;
; PureBasic - PointJoint (Bridge)
;
; (c) 2011 - Fantaisie Software
;
; Bridge02.pb
;
; Changes from me And users. See http://www.purebasic.fr/english/posting.php?mode=reply&f=36&t=59735
;
; Use [W][A][S][D] to move the Camera, Numpad [8][4][6][2] to tilt the plane [N] to launch more spheres [I] to toggle ImpulseFlag
; ------------------------------------------------------------
;
IncludeFile "Screen3DRequester.pb"
#CameraSpeed = 1
#NbPlanks = 30
Define.f KeyX, KeyY, MouseX, MouseY
Dim Plank(#NbPlanks)
NewList Spheres.l()
NewList Cubes.l()
ImpulseFlag=1
If InitEngine3D()
Add3DArchive("Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive("Data/Scripts",#PB_3DArchive_FileSystem)
Add3DArchive("Data/Packs/desert.zip", #PB_3DArchive_Zip)
Add3DArchive("Data/GUI", #PB_3DArchive_FileSystem)
Add3DArchive("Data/fonts", #PB_3DArchive_FileSystem)
Parse3DScripts()
InitSprite()
InitKeyboard()
InitMouse()
If Screen3DRequester()
WorldShadows(#PB_Shadow_Modulative, -1, RGB(127, 127, 127))
EnableWorldPhysics(#True)
WorldGravity(-100)
;Materials
;
Tex_Wood0=LoadTexture(-1, "Wood.jpg")
Mat_Wood0=CreateMaterial(-1, TextureID(Tex_Wood0))
Mat_SphereRustySteel1=GetScriptMaterial(-1, "SphereMap/SphereMappedRustySteel")
Tex_Dirt2=LoadTexture(-1, "Dirt.jpg")
Mat_Dirt2=CreateMaterial(-1, TextureID(Tex_Dirt2))
Mat_GroundBlend3=GetScriptMaterial(-1, "Scene/GroundBlend")
; Ground
;
Plane3=CreatePlane(-1, 500, 500, 5, 5, 20, 20)
Ground3=CreateEntity(-1,MeshID(Plane3),MaterialID(Mat_Dirt2), 0, -50, 0)
EntityRenderMode(Ground3, 0)
EntityPhysicBody(Ground3, #PB_Entity_BoxBody, 0, 0.1, 10)
; Bridge
Cube0=CreateCube(-1, 1.0)
For i = 1 To #NbPlanks
Plank(i)=CreateEntity(#PB_Any, MeshID(Cube0), MaterialID(Mat_Wood0))
ScaleEntity(Plank(i), 2.8, 0.8, 20)
MoveEntity(Plank(i), i * 3, 0, 0, #PB_Absolute)
EntityPhysicBody(Plank(i), #PB_Entity_BoxBody, 10)
Next i
Pas.f = 1.5
PointJoint(#PB_Any, EntityID(Plank(1)), -Pas, 0, -5)
For i= 1 To #NbPlanks-2
Joint=PointJoint(#PB_Any, EntityID(Plank(i+1)), -Pas, 0, -5, EntityID(Plank(i)), Pas, 0, -5)
Next i
PointJoint(#PB_Any, EntityID(Plank(#NbPlanks)), Pas, 0, -5)
PointJoint(#PB_Any, EntityID(Plank(#NbPlanks-1)), Pas, 0, -5, EntityID(Plank(#NbPlanks)), -Pas, 0, -5)
PointJoint(#PB_Any, EntityID(Plank(1)), -Pas, 0, 5)
For i= 1 To #NbPlanks-2
Joint=PointJoint(#PB_Any, EntityID(Plank(i+1)), -Pas, 0, 5, EntityID(Plank(i)), Pas, 0, 5)
Next i
PointJoint(#PB_Any, EntityID(Plank(#NbPlanks)), Pas, 0, 5)
toto=PointJoint(#PB_Any, EntityID(Plank(#NbPlanks-1)), Pas, 0, 5, EntityID(Plank(#NbPlanks)), -Pas, 0, 5)
; Objects
;
Sphere2=CreateSphere(-1, 2, 36, 36)
C = Plank(1)
For i = 1 To #NbPlanks/2
AddElement(Spheres())
Spheres() = CreateEntity(#PB_Any, MeshID(Sphere2), MaterialID(Mat_SphereRustySteel1), EntityX(C) +i * 5, EntityY(C)+ i * 2, EntityZ(C))
EntityPhysicBody(Spheres(), #PB_Entity_ConvexHullBody, 1.5, 0.02, 1.0)
Next i
For i = 1 To #NbPlanks/2
AddElement(Spheres())
Spheres() = CreateEntity(#PB_Any, MeshID(Sphere2), MaterialID(Mat_SphereRustySteel1), EntityX(C) +i * 5, EntityY(C)+ i * 6, EntityZ(C))
EntityPhysicBody(Spheres(), #PB_Entity_ConvexHullBody, 1.5, 0.02, 1.0)
Next i
For i = 1 To #NbPlanks/2
AddElement(Spheres())
Spheres() = CreateEntity(#PB_Any, MeshID(Sphere2), MaterialID(Mat_SphereRustySteel1), EntityX(C) +i * 5, EntityY(C)+ i * 8, EntityZ(C))
EntityPhysicBody(Spheres(), #PB_Entity_ConvexHullBody, 1.5, 0.02, 1.0)
Next i
For i = 1 To #NbPlanks/2
AddElement(Cubes())
Cubes() = CreateEntity(#PB_Any, MeshID(Cube0), MaterialID(Mat_SphereRustySteel1), EntityX(C) +i * 5, EntityY(C)+ i * 4, EntityZ(C))
ScaleEntity(Cubes(), 3, 3, 3)
EntityPhysicBody(Cubes(), #PB_Entity_BoxBody, 1.0)
Next i
; Camera
;
Camera1=CreateCamera(-1, 0, 0, 100, 100)
MoveCamera(Camera1, -20, 30, -40, #PB_Absolute)
CameraLookAt(Camera1, EntityX(C) + 25, EntityY(C) + 10, EntityZ(C))
; Skybox
;
SkyBox("desert07.jpg")
; Light
;
CreateLight(0, RGB(255, 255, 255), 100, 800, -500)
AmbientColor(RGB(20, 20, 20))
;-GUI
RatioX = CameraViewWidth(Camera1) / ScreenWidth()
RatioY = CameraViewHeight(Camera1) / ScreenHeight()
MainWindw1=OpenWindow3D(-1, 0, 0, 280 * RatioX, 150 * RatioY, "FPS-Check")
StFPS1=StringGadget3D(-1 , 10 * RatioX, 10 * RatioY, 240 * RatioX, 30 * RatioY, "FPS")
StCount1=StringGadget3D(-1 , 10 * RatioX, 30+10 * RatioY, 240 * RatioX, 30 * RatioY, "Spheres")
StCount2=StringGadget3D(-1 , 10 * RatioX, 60+10 * RatioY, 240 * RatioX, 30 * RatioY, "Cubes")
ShowGUI(128, 0) ; Display the GUI, semi-transparent and display the mouse cursor
Plank = 1
Repeat
Screen3DEvents()
If ExamineMouse()
MouseX = -MouseDeltaX() * #CameraSpeed * 0.05
MouseY = -MouseDeltaY() * #CameraSpeed * 0.05
EndIf
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Space)
ApplyEntityImpulse(Plank(#NbPlanks/2), 0, 100, -100)
EndIf
If KeyboardReleased(#PB_Key_Return)
If Plank <= #NbPlanks
DisableEntityBody(Plank(Plank), 0)
FreeEntityJoints(Plank(Plank))
Plank + 1
EndIf
EndIf
If KeyboardReleased(#PB_Key_N)
For i = 1 To #NbPlanks/2
AddElement(Spheres())
Spheres() = CreateEntity(#PB_Any, MeshID(Sphere2), MaterialID(Mat_SphereRustySteel1), EntityX(C) +i * 5, EntityY(C)+ i * 6, EntityZ(C))
EntityPhysicBody(Spheres(), #PB_Entity_ConvexHullBody, 1.5, 0.02, 1.0)
Next i
EndIf
If KeyboardPushed(#PB_Key_A)
KeyX = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_D)
KeyX = #CameraSpeed
Else
KeyX = 0
EndIf
If KeyboardPushed(#PB_Key_W)
KeyY = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_S)
KeyY = #CameraSpeed
Else
KeyY = 0
EndIf
If KeyboardPushed(#PB_Key_Pad5)
;RotateEntity(Ground3, 0,0,0)
EndIf
If KeyboardPushed(#PB_Key_Pad2)
If ImpulseFlag=1
ForEach Spheres()
ApplyEntityImpulse(Spheres(), 0, 1, 0)
Next
ForEach Cubes()
ApplyEntityImpulse(Cubes(), 0, 0.1, 0)
Next
EndIf
RotateEntity(Ground3, 0, 0, 0.1, #PB_Relative)
EndIf
If KeyboardPushed(#PB_Key_Pad8)
If ImpulseFlag=1
ForEach Spheres()
ApplyEntityImpulse(Spheres(), 0, 1, 0)
Next
ForEach Cubes()
ApplyEntityImpulse(Cubes(), 0, 0.1, 0)
Next
EndIf
RotateEntity(Ground3, 0, 0, -0.1, #PB_Relative)
EndIf
If KeyboardPushed(#PB_Key_Pad4)
If ImpulseFlag=1
ForEach Spheres()
ApplyEntityImpulse(Spheres(), 0, 1, 0)
Next
ForEach Cubes()
ApplyEntityImpulse(Cubes(), 0, 0.1, 0)
Next
EndIf
RotateEntity(Ground3, -0.1, 0, 0, #PB_Relative)
EndIf
If KeyboardPushed(#PB_Key_Pad6)
If ImpulseFlag=1
ForEach Spheres()
ApplyEntityImpulse(Spheres(), 0, 1, 0)
Next
ForEach Cubes()
ApplyEntityImpulse(Cubes(), 0, 0.1, 0)
Next
EndIf
RotateEntity(Ground3, 0.1, 0, 0, #PB_Relative)
EndIf
If KeyboardReleased(#PB_Key_I)
ImpulseFlag=1-ImpulseFlag
EndIf
EndIf
MoveCamera (Camera1, KeyX, 0, KeyY)
RotateCamera(Camera1, MouseY, MouseX, 0, #PB_Relative)
SetGadgetText3D(StFPS1, "FPS=" + Str(Engine3DStatus(#PB_Engine3D_CurrentFPS))+" I="+Str(ImpulseFlag))
SetGadgetText3D(StCount1, "Spheres=" + Str(ListSize(Spheres())))
SetGadgetText3D(StCount2, "Cubes=" + Str(ListSize(Cubes())))
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
Well, what I do is try and error ... the manual does not explain what really happens behind the scene ...
Next will be using #PB_Entity_SphereBody again and bmon's stop-the-spheres-code.
.
Last edited by Thade on Sun Aug 03, 2014 3:28 am, edited 1 time in total.
--------------
Yes, its an Irish Wolfhound.
Height: 107 cm; Weight: 88 kg
Yes, its an Irish Wolfhound.
Height: 107 cm; Weight: 88 kg
Re: Physics need a fix?
applying Thade code on my card geforce GT 520 the fps = 60, but if we increase the spheres to 300 it dropped to 30, it will return 60 when the spheres fall outside the whole scene.
we can use very small values for ApplyEntityImpulse so to awake the spheres (and the engine) like this: ApplyEntityImpulse(Spheres(), 0, 0.0001, 0)
also we can use
EntityLinearFactor(Perso,0,0,0)
EntityAngularFactor(Perso, 0, 0, 0)
after line 78 in the original Bridge.pb to freeze the spheres completely
change it to
EntityLinearFactor(Perso,1,1,1)
EntityAngularFactor(Perso, 1, 1, 1)
to enable it again
this is told by bmon here
http://www.purebasic.fr/english/viewtop ... 39#p419812
he used it in the game Drop-it Pock-it
i have not tried it after the balls reach the ground so to stop the balls, and then reactivate it again.
we can use very small values for ApplyEntityImpulse so to awake the spheres (and the engine) like this: ApplyEntityImpulse(Spheres(), 0, 0.0001, 0)
also we can use
EntityLinearFactor(Perso,0,0,0)
EntityAngularFactor(Perso, 0, 0, 0)
after line 78 in the original Bridge.pb to freeze the spheres completely
change it to
EntityLinearFactor(Perso,1,1,1)
EntityAngularFactor(Perso, 1, 1, 1)
to enable it again
this is told by bmon here
http://www.purebasic.fr/english/viewtop ... 39#p419812
he used it in the game Drop-it Pock-it
i have not tried it after the balls reach the ground so to stop the balls, and then reactivate it again.
- Bananenfreak
- Enthusiast
- Posts: 519
- Joined: Mon Apr 15, 2013 12:22 pm
Re: Physics need a fix?
Gravitation works perfect, there is nothing wrong with it. For testing purposes, you can use my code below. Fill in a height (It can take very Long!) and try it.
But there´s a Problem with your brain. If you take a look at our bridgeexample your brain scales entities up, caused by a simple thing: Bridges has to be bigger in size.
In virtuality, your brain doesn´t know size of things, it uses a fix (distance camera to object, a known size of object,...) to construct world, your size and other things.
Example: If your Standing in an miniaturworld, is your size very big or is this world small? It´s called theory of relativity by Einstein.
So if Bridge is bigger in brain, Gravitation is too small (Only in your brain).
Calculated with a simple formula:
But there´s a Problem with your brain. If you take a look at our bridgeexample your brain scales entities up, caused by a simple thing: Bridges has to be bigger in size.
In virtuality, your brain doesn´t know size of things, it uses a fix (distance camera to object, a known size of object,...) to construct world, your size and other things.
Example: If your Standing in an miniaturworld, is your size very big or is this world small? It´s called theory of relativity by Einstein.
So if Bridge is bigger in brain, Gravitation is too small (Only in your brain).
Calculated with a simple formula:
Here my code:x = 0.5 * g * t²
Code: Select all
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;>> >>
;>> Name: 3D-Physicstest >>
;>> >>
;>> Author: Bananenfreak >>
;>> >>
;>> Date: 28.06.2014 >>
;>> >>
;>> OS: Windows >>
;>> >>
;>> >>
;>> >>
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
EnableExplicit
#height = 1000 ;-Fill in your specified height here.
Define.f KeyX, KeyY, MouseX, MouseY
Define nx.f, nz.f, Boost.f = 1, Yaw.f, Pitch.f
Define.i Quit, boden, time1, ball, toggle1, toggle2, renderTime, plane
#kam_0 = 0
#window = 0
#plane = 0
#gravi = -9.80665
If InitEngine3D()
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Scripts", #PB_3DArchive_FileSystem)
Parse3DScripts()
InitSprite()
InitKeyboard()
InitMouse()
OpenWindow(#window, 0, 0, 1800, 1000, "3D-Template", #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(#window), 10, 10, 2000, 2000, 0, 10, 10, #PB_Screen_SmartSynchronization)
WorldShadows(#PB_Shadow_TextureAdditive, 200, RGB(255 * 0.2, 255 * 0.2, 255 * 0.2), 4096)
WorldGravity(#gravi)
AmbientColor(RGB(255 * 0.2, 255 * 0.2, 255 * 0.2))
CreatePlane(#plane, 100, 100, 100, 100, 100, 100)
boden = GetScriptMaterial(#PB_Any, "Scene/GroundBlend")
plane = CreateEntity(#PB_Any, MeshID(#plane), MaterialID(boden), 0, 0, 0)
EntityPhysicBody(plane, #PB_Entity_StaticBody)
CreateEntity(#PB_Any, MeshID(CreateSphere(#PB_Any, 1, 32, 32)), #PB_Material_None, 0, #height + 1, 0)
;-Camera
CreateCamera(#kam_0, 0, 0, 100, 100)
MoveCamera(#kam_0, 0, 20, 0, #PB_Absolute)
CameraLookAt(#kam_0, 20, 0, 20)
CameraRange (#kam_0, 2, 5000)
CameraFOV (#kam_0, 90)
CameraBackColor(#kam_0, RGB(0, 0, 0))
Repeat
Repeat
Until WindowEvent() = 0
If ExamineMouse()
Yaw = -MouseDeltaX() * 0.05
Pitch = -MouseDeltaY() * 0.05
EndIf
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Up)
MoveCamera(0, 0, 0, -1 * Boost)
ElseIf KeyboardPushed(#PB_Key_Down)
MoveCamera(0, 0, 0, 1 * Boost)
EndIf
If KeyboardPushed(#PB_Key_Left)
MoveCamera(0, -1 * Boost, 0, 0)
ElseIf KeyboardPushed(#PB_Key_Right)
MoveCamera(0, 1 * Boost, 0, 0)
EndIf
If KeyboardReleased(#PB_Key_Q)
If toggle1 = #False
ball = CreateEntity(#PB_Any, MeshID(CreateSphere(#PB_Any, 1, 32, 32)), #PB_Material_None, 0, #height + 1, 0)
EntityPhysicBody(ball, #PB_Entity_SphereBody)
time1 = ElapsedMilliseconds()
toggle1 = #True
EndIf
EndIf
EndIf
RotateCamera(0, Pitch, Yaw, 0, #PB_Relative)
If toggle1
If EntityCollide(ball, plane) And toggle2 = #False
Debug "Real Time:" + StrD(ElapsedMilliseconds() - time1)
Debug "Calculated Time:" + StrD(Sqr(#height * 2 / -#gravi) * 1000)
toggle2 = #True
EndIf
EndIf
renderTime = RenderWorld(renderTime)
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
Else
MessageRequester("Error", "The 3D Engine can't be initialized", 0)
EndIf
End
Re: Physics EXAMPLES need a fix?
Dear Bananenfreak
The one who has a brain problem is you! Because you should have noticed that the bridge demo is made by the makers of PureBasic an not by me. You insult them to have brain problems.
Edited after next post was read: Maybe it is a translation problem? Let's take it like that ...
.
The one who has a brain problem is you! Because you should have noticed that the bridge demo is made by the makers of PureBasic an not by me. You insult them to have brain problems.
Edited after next post was read: Maybe it is a translation problem? Let's take it like that ...
.
Last edited by Thade on Sun Aug 03, 2014 3:29 am, edited 2 times in total.
--------------
Yes, its an Irish Wolfhound.
Height: 107 cm; Weight: 88 kg
Yes, its an Irish Wolfhound.
Height: 107 cm; Weight: 88 kg
- Bananenfreak
- Enthusiast
- Posts: 519
- Joined: Mon Apr 15, 2013 12:22 pm
Re: Physics need a fix?
I'm sorry, I don't want to affront or insult someone.
I think I verbalized it in the wrong way. Every brain works that way.
My only interest was to test our gravitation and find a solution, why gravitation seems to be so slow.
PS.:Could a native english speaking person write me in a PM what's wrong verbalized in my last post, please?
I think I verbalized it in the wrong way. Every brain works that way.
My only interest was to test our gravitation and find a solution, why gravitation seems to be so slow.
PS.:Could a native english speaking person write me in a PM what's wrong verbalized in my last post, please?
Re: Physics need a fix?
Nothing wrong from what I can see.Bananenfreak wrote: PS.:Could a native english speaking person write me in a PM what's wrong verbalized in my last post, please?
Windows 11, Manjaro, Raspberry Pi OS


-
- User
- Posts: 12
- Joined: Sat Aug 11, 2007 8:58 pm
Re: Physics need a fix?
There is nothing wrong with your post. Put Thade on ignore and it will make your life easier.Bananenfreak wrote: PS.:Could a native english speaking person write me in a PM what's wrong verbalized in my last post, please?