Kinematic objects
DO interact with all DarkPhysics controlled geometry.
The Rigid Body/kinematic demo that comes with DarkPhysics shows this.
DarkPhysics Rigid Body/Kinematic Demo Code:
` this example demonstrates the use of kinematic objects
` set up the program
sync on
sync rate 60
phy start
autocam off
position camera -20,20,-25
point camera 0,10,0
make light 1
set directional light 1, -5,-5,5
` create the background
load image "stripe5.png",1000
make object sphere 1000,400,48,48
texture object 1000,1000
scale object texture 1000,6,6
set object cull 1000,0
rotate object 1000,0,0,90
` make the floor
load image "stripe6.png", 3
make object box 1,40,1,40
phy make rigid body static box 1
texture object 1, 3
` create first dynamic box
make object box 2,5,5,5
position object 2,-12,3,0
phy make rigid body dynamic box 2
` create second dynamic box
make object box 3,5,5,5
position object 3,12,3,0
phy make rigid body dynamic box 3
` create third dynamic box and make this one kinematic
make object box 4,5,5,5
position object 4,0,6,0
phy make rigid body dynamic box 4
phy set rigid body kinematic 4, 1
` create fourth dynamic box
make object box 5,5,5,5
position object 5,0,24,0
phy make rigid body dynamic box 5
` colour all of our objects
for i = 2 to 6
if object exist ( i )
color object i, rgb ( rnd ( 255 ), rnd ( 255 ), rnd ( 255 ) )
set object specular i, rgb ( rnd ( 255 ), rnd ( 255 ), rnd ( 255 ) )
set object specular power i, 255
set object ambient i,0
endif
next i
` display the Dark Physics logo
load image "logo.png", 10000
sprite 1, 0, 600 - 60, 10000
` some variables we use in the main loop
x# = 0
move = 0
` main program loop
do
` adjust the position of the kinematic object on the x axis
if move = 0
x# = x# - 0.1
if x# < -10
move = 1
endif
endif
if move = 1
x# = x# + 0.1
if x# > 10
move = 0
endif
endif
` control the position of the kinematic object
phy set rigid body kinematic position 4, x#, 6, 0
` rotate the background
rotate object 1000, 0, object angle y( 1000 ) + 0.3, 0
` update the simulation and screen
phy update
sync
loop