hi!
hope someone will find it usefull!
if u are using 3dws to create levels and u want to use dark physics in your game u may find some difficulties. if u will create a wall and cut it into pieces there is no easy way to use it with db and dark physics so this code may be usefull for u!
all you have to do is to export your "wall" (or whatever) to single X file ( don't export whole level STATIC mesh). now if u have your breakable object in one X file u may use code below to blend it into DB with Dark Physics!
` file_path$ should point your X file
`this is temp object!
load object file_path$,999
`to get all "small" objects
perform checklist for object limbs 999
`count of objects
co= checklist quantity ()
`create each object from your X file!
for t=1 to co-1
`create object from temp object!
make object from limb ind_dyna,999,t
`recalculating vertex positions!
lock vertexdata for limb ind_dyna,0
verts = get vertexdata vertex count ()
add_x#=0
add_y#=0
add_z#=0
for tt=0 to verts-1
add_x#=add_x# + get vertexdata position x(tt)
add_y#=add_y# + get vertexdata position y(tt)
add_z#=add_z# + get vertexdata position z(tt)
next tt
`calculate offset of pivot point
sr_x# = add_x# / (verts)
sr_y# = add_y# / (verts)
sr_z# = add_z# / (verts)
`set centre of object (pivot) in position 0,0,0
for tt=0 to verts-1
px# = get vertexdata position x(tt)
py# = get vertexdata position y(tt)
pz# = get vertexdata position z(tt)
set vertexdata position tt,px#-sr_x#,py#-sr_y#,pz#-sr_z#
next tt
`update object changes
unlock vertexdata
`now place object in the same position as it was in X file!
position object ind_dyna, sr_x#,sr_y#,sr_z#
`fix object bounds to display prop.
calculate object bounds ind_dyna
`create dynamic body
phy make rigid body dynamic convex IND_DYNA
`put it to sleep
phy sleep rigid body IND_DYNA
`inc. index for next object if it isn't over
inc IND_DYNA
next t
`temp object not needed any more!
delete object 999
if someone knows easier way to do it i will be happy to any feedbacks!
thanks!