here is a sample program for you. it will detect collisions between the camera (which has an invisible sphere around it) and 2 sydney models. when the camera collides, it will draw a white box at the point of collision.
Strict
Framework gg.IrrB3D
ib3d_Graphics3D(640,480)
Local cam2:CAMERA=ib3d_CreateCamera()
ib3d_PositionEntity(cam2,30,30,30)
Local syd:MESH=ib3d_LoadAnimMesh("sydney.md2")
Local syd2:MESH=ib3d_LoadAnimMesh("sydney.md2")
ib3d_EntityTexture(syd,ib3d_LoadTexture("sydney.bmp"))
ib3d_EntityTexture(syd2,ib3d_LoadTexture("sydney.bmp"))
Local LIGHT:LIGHT=ib3d_CreateLight()
ib3d_LightColor(LIGHT,255,255,0)
ib3d_LightRange(LIGHT,1000)
ib3d_LightCastShadows(LIGHT,True)
' NOTE, if no light, need to set EMF_LIGHTING to false in order to show up
'syd._node.setMaterialFlag(EMF_LIGHTING,True)
' animation support is not there yet so reverting to Irrlicht by casting the internal _node pointer
T_irrIAnimatedMeshSceneNode(syd._node).setFrameLoop(0,320)
T_irrIAnimatedMeshSceneNode(syd._node).setAnimationSpeed(30)
T_irrIAnimatedMeshSceneNode(syd2._node).setFrameLoop(0,320)
T_irrIAnimatedMeshSceneNode(syd2._node).setAnimationSpeed(30)
ib3d_CameraClsColor(200,200,200)
ib3d_ShadowColor(150,0,0,0)
ib3d_EntityDebugDataVisible(syd,True)
ib3d_EntityDebugDataVisible(syd2,True)
ib3d_NameEntity(syd,"SYD")
ib3d_NameEntity(syd2,"SYD2")
ib3d_NameEntity(cam2,"CAM2")
ib3d_AddZipFileArchive("map-20kdm2.pk3")
Local quake:MESH=ib3d_LoadOctTreeMesh("20kdm2.bsp")
ib3d_PositionEntity(quake,-1300,-144,-1249)
ib3d_PositionEntity(syd2,ib3d_EntityX(syd),ib3d_EntityY(syd),ib3d_EntityZ(syd)+50)
' setting up some collision info
ib3d_EntityRadius(cam2,30)
ib3d_EntityOffset(cam2,0,10,0)
' setting the collision type for the entity. each entity can have multiple types.
ib3d_EntityType(cam2,1)
ib3d_EntityType(syd,2)
ib3d_EntityType(syd,1)
ib3d_EntityType(syd2,2)
ib3d_EntityType(syd2,1)
ib3d_EntityType(quake,3)
' setup collision detection. type 1s can collide with type 2s.
ib3d_Collisions(1,2,CD_ELLIPSOID_POLY_IRRLICHT,CR_STOP,"TEST")
' MapIncludeinCounts is specific to gg.IrrB3D. this tells the collision system to ignore this collision detection
' when checking to see if a collision has been made. this is mainly used for object/terrain collision.
ib3d_MapIncludeInCounts(ib3d_Collisions(1,3,CD_ELLIPSOID_POLY_STATIC_IRRLICHT,CR_SLIDE_LIMITED_IRRLICHT,"TEST2"),False)
' we are going to use a box to show where the camera is colliding.
Local box:T_irrISceneNode=_g_ib3d_engine.smgr.addTestSceneNode()
box.setPosition(T_irrVector3df.createFromVals(30,-70,60))
Local zoom:Float=1.0
While Not ib3d_KeyDown(EKEY_ESCAPE)
' zoom in/out
If ib3d_KeyDown(EKEY_KEY_Z) Then zoom:+0.005
If ib3d_KeyDown(EKEY_KEY_X) Then zoom:-0.005
' move the camera
If ib3d_KeyDown(EKEY_NUMPAD9) Then ib3d_MoveEntity(cam2,0,50,0)
If ib3d_KeyDown(EKEY_NUMPAD3) Then ib3d_MoveEntity(cam2,0,-50,0)
If ib3d_KeyDown(EKEY_NUMPAD6) Then ib3d_MoveEntity(cam2,50,0,0)
If ib3d_KeyDown(EKEY_NUMPAD4) Then ib3d_MoveEntity(cam2,-50,0,0)
If ib3d_KeyDown(EKEY_NUMPAD8) Then ib3d_MoveEntity(cam2,0,0,50)
If ib3d_KeyDown(EKEY_NUMPAD2) Then ib3d_MoveEntity(cam2,0,0,-50)
' turn the camera
If ib3d_KeyDown(EKEY_LEFT) Then ib3d_TurnEntity(cam2,0,-50,0)
If ib3d_KeyDown(EKEY_RIGHT) Then ib3d_TurnEntity(cam2,0,50,0)
If ib3d_KeyDown(EKEY_UP) Then ib3d_TurnEntity(cam2,50,0,0)
If ib3d_KeyDown(EKEY_DOWN) Then ib3d_TurnEntity(cam2,-50,0,0)
If ib3d_KeyDown(EKEY_SPACE) Then ib3d_TurnEntity(cam2,0,0,50)
' perform collisions and reposition entities based on collisions
ib3d_UpdateWorld()
' render the current world
ib3d_RenderWorld()
' check to see if a collision happened
Local coltest:COLLISION=ib3d_MapGetEntityCollision(ib3d_GetTypeMapping("TEST"),cam2,0)
' set the box to the point of collision
If coltest And coltest._point And coltest._point.isvalid() Then box.setPosition(T_irrVector3df.createFromVals(coltest._point.getX(),coltest._point.getY(),coltest._point.getZ()))
Wend
ib3d_FreeEntity(syd)
ib3d_FreeEntity(syd2)
ib3d_EndGraphics()