Interesting and curious natural effect against intuition
Posted: Tue Jun 25, 2019 1:18 pm
Found an issue in the physics engine.
Probably this is also in other engines.
There is a function to apply a torque to the bodies, but this function 'ApplyEntityTorque()' does not allow to input the center of the torque; instead, the center is always the center of the body.
So, I tried to perform a torque in a body, not centered in its center, but in other different point.
The result is not the expected one by intuition: when the actions are done like in the code below, the center of mass should move, but it doesn't.
Still not completely sure this is the correct beaviour.
Probably this is also in other engines.
There is a function to apply a torque to the bodies, but this function 'ApplyEntityTorque()' does not allow to input the center of the torque; instead, the center is always the center of the body.
So, I tried to perform a torque in a body, not centered in its center, but in other different point.
The result is not the expected one by intuition: when the actions are done like in the code below, the center of mass should move, but it doesn't.
Still not completely sure this is the correct beaviour.
Code: Select all
RX.u=1024:RY.u=768
InitEngine3D()
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures", #PB_3DArchive_FileSystem)
Parse3DScripts()
InitSprite():InitKeyboard():InitMouse()
OpenWindow(0,0,0,RX,RY,"tip",#PB_Window_BorderLess|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,RX,RY,0,0,0,#PB_Screen_WaitSynchronization)
CreateLight(0,$EEEEEE,4,4,2,#PB_Light_Point)
CreateCamera(0,0,0,100,100)
MoveCamera(0,0,0,3,#PB_Absolute)
LoadTexture(0,"terrain_detail.jpg")
CreateMaterial(0,TextureID(0))
CreateCylinder(0,0.2,1.4)
CreateEntity(0,MeshID(0),MaterialID(0),0,0,0)
WorldGravity(0.0)
CreateEntityBody(0,#PB_Entity_CylinderBody)
Repeat
WindowEvent()
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Right); the center of mass should move ??, but it doesn't
ApplyEntityForce(0,0.1,0,0,0,2,0,#PB_World)
ApplyEntityForce(0,-0.1,0,0,0,1,0,#PB_World)
ElseIf KeyboardPushed(#PB_Key_Left); the center of mass should move ??, but it doesn't
ApplyEntityForce(0,-0.1,0,0,0,2,0,#PB_World)
ApplyEntityForce(0,0.1,0,0,0,1,0,#PB_World)
EndIf
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)