Do you already have some sort of raycasting engine that you are trying to modify?