The physics sample is working for me.
Here is a simple example I have come up with trying to figure out the linear velocity.
No media is required.
rem Init app
SetSyncRate(60,0)
//Set3dPhysicsGravity(100,100,100)
Create3dPhysicsWorld()
Set3dPhysicsGravity(0,-1,0)
setcamerarange(1,15,1000)
rem Setup camera
plrx#=0 : plrz#=-0 : plra#=0 : eyeheight#=100
SetCameraPosition(1,plrx#,eyeheight#,plrz#)
SetCameraRotation(1,0,plra#,0)
//Create the sphere and set dynamic physics on
CreateObjectSphere(1,20,20,20)
SetObjectColor (1,255,0,0,255)
SetObjectPosition(1,0,300,0)
Create3DPhysicsDynamicBody( 1 )
SetObjectShapeSphere(1)
SetObject3dPhysicsRestitution(1,100)
SetObject3dPhysicsFriction(1,100)
//Create the ground and set static physics on.
CreateObjectPlane(2,300,600)
SetObjectRotation(2,90,0,0)
Create3DPhysicStaticBody( 2 )
SetObjectColor(2,0,255,0,255)
//Create the walls and set static physics on.
CreateObjectBox(3,300,20,20)
SetObjectColor(3,255,255,255,255)
SetObjectPosition(3,-0,10,-300)
SetObjectColor(3,142,42,42,255)
Create3DPhysicStaticBody( 3 )
CreateObjectBox(4,300,20,20)
SetObjectColor(4,255,255,255,255)
SetObjectPosition(4,-0,10,300)
SetObjectColor(4,142,42,42,255)
Create3DPhysicStaticBody( 4 )
CreateObjectBox(5,20,20,620)
SetObjectColor(5,255,255,255,255)
SetObjectPosition(5,-150,10,0)
SetObjectColor(5,142,42,42,255)
Create3DPhysicStaticBody( 5 )
CreateObjectBox(6,20,20,620)
SetObjectColor(6,255,255,255,255)
SetObjectPosition(6,150,10,0)
SetObjectColor(6,142,42,42,255)
Create3DPhysicStaticBody( 6 )
//////////////////////////////////////////////
rem Main loop
do
//Set the linear velocity when wsad keys are pressed//
If getrawkeypressed(68) = 1 //right
SetObject3dPhysicsLinearVelocity(1,1000,0,0,100)
endif
If getrawkeypressed(65) = 1 //left
SetObject3dPhysicsLinearVelocity(1,-1000,0,0,100)
endif
If getrawkeypressed(87) = 1 //up
SetObject3dPhysicsLinearVelocity(1,0,0,1000,100)
endif
If getrawkeypressed(83) = 1 //left
SetObject3dPhysicsLinearVelocity(1,0,0,-1000,100)
endif
`
rem Move camera
if GetRawKeyState(38)=1 then MoveCameraLocalZ(1,4.0)
if GetRawKeyState(40)=1 then MoveCameraLocalZ(1,-4.0)
if GetRawKeyState(37)=1 then RotateCameraGlobalY(1,-4.0)
if GetRawKeyState(39)=1 then RotateCameraGlobalY(1,4.0)
Print(GetRawLastKey())
`
`
Print(GetCameraX(1))
`
rem Framerate prompt
Print(ScreenFPS())
`
Step3dphsyicsworld()
rem Update screen
Sync()
`
loop
I have yet to figure out how the restitution works...trying to make the ball bounce when it touches down with the ground. Also I have yet to figure out the friction
You will notice I have the ball positioned over the ground a good ways watching it fall (Was trying to make it bounce)....It will fall in the center of the ground if you do not press the wsad keys before touchdown.
Press the wsad keys to move the ball around inside the wall parameters using linear velocity (Im still figuring things out) I just decided to post another sample for us to play with.
Also something I have noticed.
Step3dphsyicsworld()
Physics is spelt wrong ^ it was throwing me off for a few
This is the only command I have noticed but there could be more
Edit: I have figured out how to work the restitution (Make a sphere bounce)
You must assign restitution too both the sphere and ground.
Assigning the restitution of 1 to the sphere and .5 to the ground. Will make the ball lose half its bounce every collision with the ground. (This is just a speculation without proper documentation who knows.)
Beta Test Age of Knights:https://play.google.com/apps/testing/com.CrazyProgrammerProductions.my_AgeOfKnights
Download JellyFish Dive:https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_JellyFishSwim