I found a possible bug. When Worldcollisions are used the values for the applied Impulses received via GetX/Y/Z() are always equal.
Even if there´s only an applied Impulse in one direction (In my code it´s X).
Please try my code and tell my your result. With "Q" you can apply an Impulse on one ball:
Code: Select all
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;>> >>
;>> Name: GetX/Y/Z()-Error >>
;>> >>
;>> Author: Bananenfreak >>
;>> >>
;>> Date: 14.02.2016 >>
;>> >>
;>> OS: Windows >>
;>> >>
;>> >>
;>> >>
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
EnableExplicit
Define.f KeyX, KeyY, MouseX, MouseY
Define nx.f, nz.f, Boost.f = 1, Yaw.f, Pitch.f
Define.i Quit
Global.i boden, ball
#kam_0 = 0
#window = 0
#plane = 0
#planent = 0
Procedure BuildUp()
Protected.i mesh, ent
mesh = CreateSphere(#PB_Any, 0.25, 16, 16)
ball = CreateEntity(#PB_Any, MeshID(mesh), MaterialID(boden), -5, 10.25, 0)
EntityPhysicBody(ball, #PB_Entity_SphereBody, 5, 0, 0)
ent = CreateEntity(#PB_Any, MeshID(mesh), MaterialID(boden), 5, 10.25, 0)
EntityPhysicBody(ent, #PB_Entity_SphereBody, 5, 0, 0)
mesh = CreateCube(#PB_Any, 1)
TransformMesh(mesh, 0,0,0, 11, 0.1, 1, 0, 0, 0)
ent = CreateEntity(#PB_Any, MeshID(mesh), #PB_Material_None, 0, 9.9, 0)
EntityPhysicBody(ent, #PB_Entity_StaticBody, 5, 0, 0)
mesh = CreateCube(#PB_Any, 1)
TransformMesh(mesh, 0,0,0, 11, 1, 0.2, 0, 0, 0)
ent = CreateEntity(#PB_Any, MeshID(mesh), #PB_Material_None, 0, 10.4, -0.4)
EntityPhysicBody(ent, #PB_Entity_StaticBody, 5, 0, 0)
mesh = CreateCube(#PB_Any, 1)
TransformMesh(mesh, 0,0,0, 11, 1, 0.2, 0, 0, 0)
ent = CreateEntity(#PB_Any, MeshID(mesh), #PB_Material_None, 0, 10.4, 0.4)
EntityPhysicBody(ent, #PB_Entity_StaticBody, 5, 0, 0)
mesh = CreateCube(#PB_Any, 1)
TransformMesh(mesh, 0,0,0, 0.2, 1, 0.6, 0, 0, 0)
ent = CreateEntity(#PB_Any, MeshID(mesh), #PB_Material_None, 5.6, 10.4, 0)
EntityPhysicBody(ent, #PB_Entity_StaticBody, 5, 0, 0)
mesh = CreateCube(#PB_Any, 1)
TransformMesh(mesh, 0,0,0, 0.2, 1, 0.6, 0, 0, 0)
ent = CreateEntity(#PB_Any, MeshID(mesh), #PB_Material_None, -5.6, 10.4, 0)
EntityPhysicBody(ent, #PB_Entity_StaticBody, 5, 0, 0)
EndProcedure
Procedure PhysikWorker()
Protected.i first, sec
ExamineWorldCollisions(#True)
While NextWorldCollision()
first = FirstWorldCollisionEntity()
sec = SecondWorldCollisionEntity()
WorldCollisionAppliedImpulse()
Debug "X: " + GetX()
Debug "Y: " + GetY()
Debug "Z: " + GetZ()
Wend
EndProcedure
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, "GetX/Y/Z-Bug", #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(#window), 10, 10, 2000, 2000, 1, 10, 10, #PB_Screen_SmartSynchronization)
WorldShadows(#PB_Shadow_TextureAdditive, 200, RGB(255 * 0.2, 255 * 0.2, 255 * 0.2), 4096)
AmbientColor(RGB(255 * 0.2, 255 * 0.2, 255 * 0.2))
EnableWorldPhysics(#True)
EnableWorldCollisions(#True)
CreatePlane(#plane, 100, 100, 100, 100, 100, 100)
boden = GetScriptMaterial(#PB_Any, "Scene/GroundBlend")
CreateEntity(#planent, MeshID(#plane), MaterialID(boden), 0, 0, 0)
EntityPhysicBody(#planent, #PB_Entity_StaticBody)
;-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))
BuildUp()
Repeat
Debug "---------------------------------------"
Repeat
Until WindowEvent() = 0
PhysikWorker()
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)
ApplyEntityImpulse(ball, 100, 0, 0)
EndIf
EndIf
RotateCamera(0, Pitch, Yaw, 0, #PB_Relative)
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
Else
MessageRequester("Error", "The 3D Engine can't be initialized", 0)
EndIf
End
