Post by bleeding on Feb 24, 2007 21:00:54 GMT 1
I just refreshed my memories and installed DBPro and Newton wrapper, and did a little scene with a ball dropping on a plain-shaped box which can be rotated. The problem is that when I rotate the box, it goes through the ball unless the rotation is set REALLY slow. I'd like to have a nice "world" that can be rotated, but the objects - in this case, the sphere - goes through the world object.
Oh, and there was another problem. NDB_BodySetDBProData didn't apply the dbpro object to the newton body. I had to separately rotate the model.
I'll post the code here I used in my little test:
Oh, and there was another problem. NDB_BodySetDBProData didn't apply the dbpro object to the newton body. I had to separately rotate the model.
I'll post the code here I used in my little test:
sync on : sync rate 75
autocam off : hide mouse
NDB_NewtonCreate
NDB_SetVector 0.0, -980, 0.0
NDB_SetStandardGravity
position camera 0, 50, -120
point camera 0, 0, 0
make object box 1, 100, 5, 100
position object 1, 0, 0, 0
color object 1, RGB(255,32,32)
col_box = NDB_NewtonCreateBox(100, 5, 100)
body_box = NDB_NewtonCreateBody(col_box)
NDB_BuildMatrix 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
NDB_NewtonBodySetMatrix body_box
NDB_BodySetDBProData body_box, 1
NDB_NewtonReleaseCollision col_box
make object sphere 2, 5
color object 2, RGB(32,255,32)
col_sphere = NDB_NewtonCreateSphere(2.5)
body_sphere = NDB_NewtonCreateBody(col_sphere)
NDB_NewtonBodySetMassMatrix body_sphere, 100
NDB_BuildMatrix 0.0, 0.0, 0.0, 0.0, 100.0, 0.0
NDB_NewtonBodySetMatrix body_sphere
NDB_BodySetGravity body_sphere, 1
NDB_BodySetDBProData body_sphere, 2
NDB_NewtonReleaseCollision col_sphere
do
rot_x = object angle x(1)
rot_y = object angle y(1)
rot_z = object angle z(1)
rotate camera camera angle x(0)+(mousemovey()/2.0),camera angle y(0)+(mousemovex()/2.0),0
if upkey()=1
NDB_BuildMatrix rot_x+1.0, 0.0, 0.0, 0.0, 0.0, 0.0
NDB_NewtonBodySetMatrix body_box
rotate object 1, rot_x+1.0, 0, 0
endif
if downkey()=1
NDB_BuildMatrix rot_x-1.0, 0.0, 0.0, 0.0, 0.0, 0.0
NDB_NewtonBodySetMatrix body_box
rotate object 1, rot_x-1.0, 0, 0
endif
if controlkey()
obj = NDB_DebugMakeNewtonObject()
set object light obj, 0
else
obj = 0
endif
time# = NDB_GetElapsedTimeInSec()
time# = NDB_GetElapsedTimeInSec()
NDB_NewtonUpdate time#
sync
if obj <> 0
delete object obj
endif
loop
function NeverCalled()
if memblock exist(1) then delete memblock 1
endfunction