raytrace.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_RAYTRACE_H
00033 #define LL_RAYTRACE_H
00034 
00035 class LLVector3;
00036 class LLQuaternion;
00037 
00038 // All functions produce results in the same reference frame as the arguments.
00039 //
00040 // Any arguments of the form "foo_direction" or "foo_normal" are assumed to
00041 // be normalized, or normalized vectors are stored in them.
00042 //
00043 // Vector arguments of the form "shape_scale" represent the scale of the
00044 // object along the three axes.
00045 //
00046 // All functions return the expected TRUE or FALSE, unless otherwise noted.
00047 // When FALSE is returned, any resulting values that might have been stored 
00048 // are undefined.
00049 //
00050 // Rays are defined by a "ray_point" and a "ray_direction" (unit).
00051 //
00052 // Lines are defined by a "line_point" and a "line_direction" (unit).
00053 //
00054 // Line segements are defined by "point_a" and "point_b", and for intersection
00055 // purposes are assumed to point from "point_a" to "point_b".
00056 //
00057 // A ray is different from a line in that it starts at a point and extends
00058 // in only one direction.
00059 //
00060 // Intersection normals always point outside the object, normal to the object's
00061 // surface at the point of intersection.
00062 //
00063 // Object rotations passed as quaternions are expected to rotate from the 
00064 // object's local frame to the absolute frame.  So, if "foo" is a vector in
00065 // the object's local frame, then "foo * object_rotation" is in the absolute
00066 // frame.
00067 
00068 
00069 // returns TRUE iff line is not parallel to plane.
00070 BOOL line_plane(const LLVector3 &line_point, const LLVector3 &line_direction, 
00071                                 const LLVector3 &plane_point, const LLVector3 plane_normal, 
00072                                 LLVector3 &intersection);
00073 
00074 
00075 // returns TRUE iff line is not parallel to plane.
00076 BOOL ray_plane(const LLVector3 &ray_point, const LLVector3 &ray_direction, 
00077                            const LLVector3 &plane_point, const LLVector3 plane_normal, 
00078                            LLVector3 &intersection);
00079 
00080 
00081 BOOL ray_circle(const LLVector3 &ray_point, const LLVector3 &ray_direction, 
00082                                 const LLVector3 &circle_center, const LLVector3 plane_normal, F32 circle_radius,
00083                                 LLVector3 &intersection);
00084 
00085 // point_0 through point_2 define the plane_normal via the right-hand rule:
00086 // circle from point_0 to point_2 with fingers ==> thumb points in direction of normal
00087 BOOL ray_triangle(const LLVector3 &ray_point, const LLVector3 &ray_direction, 
00088                                   const LLVector3 &point_0, const LLVector3 &point_1, const LLVector3 &point_2, 
00089                                   LLVector3 &intersection, LLVector3 &intersection_normal);
00090 
00091 
00092 // point_0 is the lower-left corner, point_1 is the lower-right, point_2 is the upper-right
00093 // right-hand-rule... curl fingers from lower-left toward lower-right then toward upper-right
00094 // ==> thumb points in direction of normal
00095 // assumes a parallelogram, so point_3 is determined by the other points
00096 BOOL ray_quadrangle(const LLVector3 &ray_point, const LLVector3 &ray_direction, 
00097                                         const LLVector3 &point_0, const LLVector3 &point_1, const LLVector3 &point_2, 
00098                                         LLVector3 &intersection, LLVector3 &intersection_normal);
00099 
00100 
00101 BOOL ray_sphere(const LLVector3 &ray_point, const LLVector3 &ray_direction,
00102                                 const LLVector3 &sphere_center, F32 sphere_radius,
00103                                 LLVector3 &intersection, LLVector3 &intersection_normal);
00104 
00105 
00106 // finite right cylinder is defined by end centers: "cyl_top", "cyl_bottom", 
00107 // and by the cylinder radius "cyl_radius"
00108 BOOL ray_cylinder(const LLVector3 &ray_point, const LLVector3 &ray_direction,
00109                           const LLVector3 &cyl_center, const LLVector3 &cyl_scale, const LLQuaternion &cyl_rotation,
00110                                   LLVector3 &intersection, LLVector3 &intersection_normal);
00111 
00112 
00113 // this function doesn't just return a BOOL because the return is currently
00114 // used to decide how to break up boxes that have been hit by shots... 
00115 // a hack that will probably be changed later
00116 //
00117 // returns a number representing the side of the box that was hit by the ray,
00118 // or NO_SIDE if intersection test failed.
00119 U32 ray_box(const LLVector3 &ray_point, const LLVector3 &ray_direction,
00120                     const LLVector3 &box_center, const LLVector3 &box_scale, const LLQuaternion &box_rotation,
00121                         LLVector3 &intersection, LLVector3 &intersection_normal);
00122 
00123 
00124 /* TODO
00125 BOOL ray_ellipsoid(const LLVector3 &ray_point, const LLVector3 &ray_direction,
00126                                    const LLVector3 &e_center, const LLVector3 &e_scale, const LLQuaternion &e_rotation,
00127                                    LLVector3 &intersection, LLVector3 &intersection_normal);
00128 
00129 
00130 BOOL ray_cone(const LLVector3 &ray_point, const LLVector3 &ray_direction,
00131                           const LLVector3 &cone_tip, const LLVector3 &cone_bottom, 
00132                           const LLVector3 &cone_scale, const LLQuaternion &cone_rotation,
00133                           LLVector3 &intersection, LLVector3 &intersection_normal);
00134 */
00135 
00136 
00137 BOOL ray_prism(const LLVector3 &ray_point, const LLVector3 &ray_direction,
00138                            const LLVector3 &prism_center, const LLVector3 &prism_scale, const LLQuaternion &prism_rotation,
00139                            LLVector3 &intersection, LLVector3 &intersection_normal);
00140 
00141 
00142 BOOL ray_tetrahedron(const LLVector3 &ray_point, const LLVector3 &ray_direction,
00143                                          const LLVector3 &t_center, const LLVector3 &t_scale, const LLQuaternion &t_rotation,
00144                                          LLVector3 &intersection, LLVector3 &intersection_normal);
00145 
00146 
00147 BOOL ray_pyramid(const LLVector3 &ray_point, const LLVector3 &ray_direction,
00148                                  const LLVector3 &p_center, const LLVector3 &p_scale, const LLQuaternion &p_rotation,
00149                                  LLVector3 &intersection, LLVector3 &intersection_normal);
00150 
00151 
00152 
00153 /* TODO
00154 BOOL ray_hemiellipsoid(const LLVector3 &ray_point, const LLVector3 &ray_direction,
00155                                            const LLVector3 &e_center, const LLVector3 &e_scale, const LLQuaternion &e_rotation,
00156                                            const LLVector3 &e_cut_normal,
00157                                            LLVector3 &intersection, LLVector3 &intersection_normal);
00158 
00159 
00160 BOOL ray_hemisphere(const LLVector3 &ray_point, const LLVector3 &ray_direction,
00161                                         const LLVector3 &sphere_center, F32 sphere_radius, const LLVector3 &sphere_cut_normal, 
00162                                         LLVector3 &intersection, LLVector3 &intersection_normal);
00163 
00164 
00165 BOOL ray_hemicylinder(const LLVector3 &ray_point, const LLVector3 &ray_direction,
00166                                           const LLVector3 &cyl_top, const LLVector3 &cyl_bottom, F32 cyl_radius, 
00167                                           const LLVector3 &cyl_cut_normal,
00168                                           LLVector3 &intersection, LLVector3 &intersection_normal);
00169 
00170 
00171 BOOL ray_hemicone(const LLVector3 &ray_point, const LLVector3 &ray_direction,
00172                                   const LLVector3 &cone_tip, const LLVector3 &cone_bottom, 
00173                                   const LLVector3 &cone_scale, const LLVector3 &cyl_cut_normal,
00174                                   LLVector3 &intersection, LLVector3 &intersection_normal);
00175 */
00176 
00177 
00178 BOOL linesegment_circle(const LLVector3 &point_a, const LLVector3 &point_b, 
00179                                                 const LLVector3 &circle_center, const LLVector3 plane_normal, F32 circle_radius,
00180                                                 LLVector3 &intersection);
00181 
00182 // point_0 through point_2 define the plane_normal via the right-hand rule:
00183 // circle from point_0 to point_2 with fingers ==> thumb points in direction of normal
00184 BOOL linesegment_triangle(const LLVector3 &point_a, const LLVector3 &point_b, 
00185                                                   const LLVector3 &point_0, const LLVector3 &point_1, const LLVector3 &point_2, 
00186                                                   LLVector3 &intersection, LLVector3 &intersection_normal);
00187 
00188 
00189 // point_0 is the lower-left corner, point_1 is the lower-right, point_2 is the upper-right
00190 // right-hand-rule... curl fingers from lower-left toward lower-right then toward upper-right
00191 // ==> thumb points in direction of normal
00192 // assumes a parallelogram, so point_3 is determined by the other points
00193 BOOL linesegment_quadrangle(const LLVector3 &point_a, const LLVector3 &point_b, 
00194                                                         const LLVector3 &point_0, const LLVector3 &point_1, const LLVector3 &point_2, 
00195                                                         LLVector3 &intersection, LLVector3 &intersection_normal);
00196 
00197 
00198 BOOL linesegment_sphere(const LLVector3 &point_a, const LLVector3 &point_b,
00199                                 const LLVector3 &sphere_center, F32 sphere_radius,
00200                                 LLVector3 &intersection, LLVector3 &intersection_normal);
00201 
00202 
00203 // finite right cylinder is defined by end centers: "cyl_top", "cyl_bottom", 
00204 // and by the cylinder radius "cyl_radius"
00205 BOOL linesegment_cylinder(const LLVector3 &point_a, const LLVector3 &point_b,
00206                                                   const LLVector3 &cyl_center, const LLVector3 &cyl_scale, const LLQuaternion &cyl_rotation,
00207                                                   LLVector3 &intersection, LLVector3 &intersection_normal);
00208 
00209 
00210 // this function doesn't just return a BOOL because the return is currently
00211 // used to decide how to break up boxes that have been hit by shots... 
00212 // a hack that will probably be changed later
00213 //
00214 // returns a number representing the side of the box that was hit by the ray,
00215 // or NO_SIDE if intersection test failed.
00216 U32 linesegment_box(const LLVector3 &point_a, const LLVector3 &point_b, 
00217                                         const LLVector3 &box_center, const LLVector3 &box_scale, const LLQuaternion &box_rotation,
00218                                         LLVector3 &intersection, LLVector3 &intersection_normal);
00219 
00220 
00221 BOOL linesegment_prism(const LLVector3 &point_a, const LLVector3 &point_b,
00222                                            const LLVector3 &prism_center, const LLVector3 &prism_scale, const LLQuaternion &prism_rotation,
00223                                            LLVector3 &intersection, LLVector3 &intersection_normal);
00224 
00225 
00226 BOOL linesegment_tetrahedron(const LLVector3 &point_a, const LLVector3 &point_b,
00227                                                          const LLVector3 &t_center, const LLVector3 &t_scale, const LLQuaternion &t_rotation,
00228                                                          LLVector3 &intersection, LLVector3 &intersection_normal);
00229 
00230 
00231 BOOL linesegment_pyramid(const LLVector3 &point_a, const LLVector3 &point_b,
00232                                                  const LLVector3 &p_center, const LLVector3 &p_scale, const LLQuaternion &p_rotation,
00233                                                  LLVector3 &intersection, LLVector3 &intersection_normal);
00234 
00235 
00236 #endif
00237 

Generated on Thu Jul 1 06:09:59 2010 for Second Life Viewer by  doxygen 1.4.7