Hello all,I've set up some physics objects in DBPro and Newton. I go to run the program and there's no collision! Did I do something wrong?
Here's my source code:
Rem ***** Main Source File *****
`create the media # vars and arrays
dim objIdList(1000) : global objIDCounter = 1
dim imgIdList(100) : global imgIDCounter = 1
dim mshIdList(100) : global mshIDCounter = 1
dim fxIdList(100) : global fxIDCounter = 1
dim camIdList(100) : global camIDCounter = 1
dim sndIdList(100) : global sndIDCounter = 1
global syncrate : syncrate=60
for x=1 to 100
objIdList(x)=x
mshIdList(x)=x
fxIdList(x)=x
camIdList(x)=x
imgIdList(x)=x
sndIdList(x)=x
next x
init_Newton()
rock1=GetObj()
load object "media\meshes\scenery\rock1.dbo",rock1
position object rock1,0,100,0
rock1tex=GetImg()
load image "media\textures\scenery\rock1.png",rock1tex
texture object rock1,rock1tex
rock1colbox=make_Newton_colbox(rock1,10,0.0,0.0,0.0)
NDB_BuildMatrix 0,0,0,0,100,0
NDB_NewtonBodySetMatrix rock1colbox
NDB_BodySetDBProData rock1colbox,rock1
NDB_BodySetGravity rock1colbox,1
set_Newton_gravity( 0.0,-50.0,0.0)
flor=GetObj()
make object plain flor,1000,1000,5
rotate object flor,90,0,0
position object flor,0,-20,0
floorcolbox=make_Newton_colbox(flor,0,0.0,0.0,0.0)
NDB_BuildMatrix 0.0,0.0,0.0,0.0,-20.0,0.0
NDB_NewtonBodySetMatrix floorcolbox
NDB_NewtonBodySetDestructorCallback floorcolbox
NDB_BodySetDBProData floorcolbox,flor
NDB_NewtonSetMinimumFramerate 20
sync on : sync rate syncrate
do
time#=NDB_GetElapsedTimeinSec()
oldy=object position y(rock1)
if object position y(rock1)=oldy-1
point camera 0,object position x(rock1),object position y(rock1),object position z(rock1)
endif
NDB_NewtonUpdate time#
sync
loop
function GetObj()
local objNum as integer
objNum = objIdList(objIDCounter)
objIdList(objIDCounter) = 0 ` Not strictly necessary but helps conceptualize
inc objIDCounter
endfunction objNum
function ReleaseObj( objNum as integer )
dec objIdCounter
objIdList(objIDCounter) = objNum
endfunction
function GetImg()
local imgNum as integer
imgNum = imgIdList(imgIDCounter)
imgIdList(imgIDCounter) = 0
inc imgIDCounter
endfunction imgNum
function ReleaseImg( imgNum as integer )
dec imgIDCounter
imgIdList(imgIDCounter) = imgNum
endfunction
function GetMsh()
local mshNum as integer
mshNum = mshIdList(mshIDCounter)
mshIdList(mshIDCounter) = 0
inc mshIDCounter
endfunction mshNum
function ReleaseMsh( mshNum as integer )
dec mshIDCounter
mshIdList(mshIDCounter) = mshNum
endfunction
function GetFx()
local fxNum as integer
fxNum = fxIdList(fxIDCounter)
fxIdList(fxIDCounter) = 0
inc fxIDCounter
endfunction fxNum
function ReleaseFx( fxNum as integer )
dec fxIDCounter
fxIdList(fxIDCounter) = fxNum
endfunction
function GetCam()
local camNum as integer
camNum = camIdList(camIDCounter)
camIdList(camIDCounter) = 0
inc camIDCounter
endfunction camNum
function ReleaseCam( camNum as integer )
dec camIDCounter
camIdList(camIDCounter) = camNum
endfunction
function GetSnd()
local sndNum as integer
sndNum = camIdList(sndIDCounter)
sndIdList(sndIDCounter) = 0
inc sndIDCounter
endfunction sndNum
function ReleaseSnd( sndNum as integer )
dec sndIDCounter
sndIdList(sndIDCounter) = sndNum
endfunction
function calc_dist_cam_obj( camID as integer , objID as integer )
local xd as float : local yd as float : zd as float : local distance as float
xd = camera position x(camID)-object position x(objID)
yd = camera position y(camID)-object position y(objID)
zd = camera position z(camID)-object position z(objID)
distance = sqrt(xd*xd+yd*yd+zd*zd)
endfunction distance
function calc_dist_cam_cam( camID as integer , cam2ID as integer )
local xd as float : local yd as float : zd as float : local distance as float
xd = camera position x(camID)-camera position x(cam2ID)
yd = camera position y(camID)-camera position y(cam2ID)
zd = camera position z(camID)-camera position z(cam2ID)
distance = sqrt(xd*xd+yd*yd+zd*zd)
endfunction distance
function calc_dist_obj_obj( objID as integer , obj2ID as integer )
local xd as float : local yd as float : zd as float : local distance as float
xd = object position x(objID)-object position x(obj2ID)
yd = object position y(objID)-object position y(obj2ID)
zd = object position z(objID)-object position z(obj2ID)
distance = sqrt(xd*xd+yd*yd+zd*zd)
endfunction distance
function init_Newton()
NDB_NewtonCreate
endfunction
function set_Newton_rotatey( colID as integer , amt as float )
NDB_SetVector 0.0,amt,0.0
NDB_NewtonBodySetOmega colID
endfunction
function set_Newton_rotatex( colID as integer , amt as float )
NDB_SetVector amt,0.0,0.0
NDB_NewtonBodySetOmega colID
endfunction
function set_Newton_rotatez( colID as integer , amt as float )
NDB_SetVector 0.0,0.0,amt
NDB_NewtonBodySetOmega colID
endfunction
function set_Newton_rotate(colID as integer , amtx as float , amty as float , amtz as float )
NDB_SetVector amtx,amty,amtz
NDB_NewtonBodySetOmega colID
endfunction
function make_Newton_colbox( objID as integer ,mass as float ,resx as float ,resy as float ,resz as float )
col=NDB_NewtonCreateBox( object size x(objID),object size y(objID),object size z(objID))
colbox=NDB_NewtonCreateBody(col)
NDB_NewtonBodySetMassMatrix colbox,mass,resx,resy,resz
endfunction colbox
function set_Newton_gravity( amtx as float ,amty as float ,amtz as float )
NDB_SetVector amtx,amty,amtz
NDB_SetStandardGravity
endfunction
function GetColor()
repeat
r = rnd(1)*255
g = rnd(1)*255
b = rnd(1)*255
until r<>0 or g<>0 or b<> 0
color = rgb(r,g,b)
endfunction color
Thanks in advance.
-EDIT-Would the ODE command
set world step be equivalent to the Newton Command
NDB_SetMinimumFramerate? Thanks again.
...