Raycasting

Theory

Raycasting is really simple, you got three forms:
height = ObjectGetGroundHeight(object, start); 
This is a SceneRaycast, but always on the Y axis, downwards.
Object indicates which XYZ position to use, and start which scene objects to use (use your master scene object for all)
But if you want to raycast in any direction (for example, collision checking, bullet trajectory or object picking), it comes down to two choices:
result = ObjectRaycast( object, object );
This shoots a ray from the first object, along the Z axis, and checks it with the second object. This works a lot like collision_line, except of defining 6 points, it takes the rotation of an object to make an vector with infinite length.
result = ObjectSceneRaycast( object, start );
This shoots a ray from the first object, along the Z axis, and checks it start, and any childs of start. This function is a lot slower, but more usefull, since you can shoot one ray, and then check the returned value with the object X3D ID's of any other object.
The more interesting stuff starts here, because, whenever you done one of the last two raycasts, the collision point and vector are stored. You can for example add a bullet hole on that place, or let the bullet ricochet with a little math.
The collision point and vector are retrieved with the following code, you must use them after a raycast, and they will return 0 if either you didn't raycasted before, or the last raycast didn't intersect.
result = ObjectGetCollisionPosition( index )  
result = ObjectGetCollisionNormal( index ) 
Both functions work sort of the same, the first function returns the X, Y and Z of the point where the collision occured, put in 0 in the index for X, 1 in the index for Y and 2 in the index for Z. Same happens with the Normal function, except it returns the normal, displayed in an -1 to 1 range for XY and Z, describing a vector of length 1.
You can exclude objects who are a child of the start objects, by hiding them before you raycast.

How would you use it?

Imagine you got yourself an FPS. When you left click, you want the gun to fire. You got that all done, except for colission checking.
First, you will need an object that is a child of your camera object. This will be our raycast dummy, you can then finetune it a bit to include stuff like feedback from the gun.
The scene raycast function then goes into the mouse click event (global, otherwise it won't pick up), and save the result to a variable.
Now check that result against any other object in the scene, and when you have your match, deduct health or something.

Downloads

Raycast Example (needs the Xtreme3D (v2.0) dll to run).