Here is the replacement command for instance object that allows you to use instanced objects with polygon and ellip collision with NGC without crashing. What's the chance of us getting a code snippet's type box on the NGC forum so posting code doesn't take up as much room?
`****************************************************************************
`****************************************************************************
rem replacement for DBP instance object command and adds to collision system
rem to fix crash when using instances as polygon collision
function CollInstanceTypePRO( newobject, sourceobject, collID )
rem if source object does not exist then exit with an error
if not object exist(sourceobject)
if NGC_debug
exit prompt "CollisionInstanceTypePRO source object does not exist: "+str$(sourceobject)+" Type Setting: "+str$(collID),"Collision DLL"
end
endif
endif
rem if new object does exist then exit with an error
if object exist(newobject)
if NGC_debug
exit prompt "CollisionInstanceTypePRO new object already exists: "+str$(newobject)+" Type Setting: "+str$(collID),"Collision DLL"
end
endif
endif
instance object newobject, sourceobject
ok = call dll( NGC_dll, "NewCollObjPRO", newobject, collID )
rem if collID is positive, then add collision shapes for this object
if collID > 0
rem Checks/Adds ellipsoid shape to object
retval = call dll( NGC_dll, "CheckShapePRO", newobject, 1 )
if retval
ok = call dll( NGC_dll, "AddObjShapePRO", newobject, 1 )
endif
retval = call dll( NGC_dll, "CheckShapePRO", newobject, 2 )
if retval
rem Get object position
xpos# = object position x(sourceobject)
ypos# = object position y(sourceobject)
zpos# = object position z(sourceobject)
rem Get object rotation
xrot# = object angle x(sourceobject)
yrot# = object angle y(sourceobject)
zrot# = object angle z(sourceobject)
rem Places object at 0,0,0 so vert data is local
position object sourceobject, 0, 0, 0
rotate object sourceobject, 0, 0, 0
rem Resets the object scale so it's local
rem (important for dynamic scale later!)
scale object sourceobject, 100, 100, 100
rem Places the mesh into collision memory
ok = call dll( NGC_dll, "AddObjShapePRO", newobject, 2 )
mesh = 99 : make mesh from object mesh,sourceobject
memb = 99 : make memblock from mesh memb, mesh
MeshPtr = Get Memblock Ptr(memb)
ok = call dll( NGC_dll, "AddMeshPRO", newobject, MeshPtr )
delete memblock memb
delete mesh mesh
rem Put object back to avoid angry developers
position object sourceobject, xpos#, ypos#, zpos#
rotate object sourceobject, xrot#, yrot#, zrot#
endif
rem endif collID is positive
endif
rem Activates the object
ActivateObjPRO( newobject )
rem Sets the scale for the object
SetObjScalePRO( sourceobject, 100, 100, 100 )
rem Updates the object
ResetObjPRO(newobject)
endfunction
`****************************************************************************
`****************************************************************************