00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef PHYSXUTILLIB_H
00016 #define PHYSXUTILLIB_H
00017
00018 #include "pandabase.h"
00019 #include "luse.h"
00020
00021 #include "config_physx.h"
00022
00023 class PhysxBounds3;
00024 class PhysxBox;
00025 class PhysxCapsule;
00026 class PhysxPlane;
00027 class PhysxRay;
00028 class PhysxSegment;
00029 class PhysxSphere;
00030
00031
00032
00033
00034
00035 class EXPCL_PANDAPHYSX PhysxUtilLib {
00036
00037 PUBLISHED:
00038 INLINE PhysxUtilLib();
00039 INLINE ~PhysxUtilLib();
00040
00041 bool box_contains_point(const PhysxBox &box, const LPoint3f &p);
00042 PhysxBox create_box(const PhysxBounds3 &aabb, const LMatrix4f &mat);
00043 LVector3f compute_box_world_edge_normal(const PhysxBox &box, unsigned int edge_index);
00044 PhysxCapsule compute_capsule_around_box(const PhysxBox &box);
00045 bool is_box_a_inside_box_b(const PhysxBox &a, const PhysxBox &b);
00046 PhysxBox compute_box_around_capsule(const PhysxCapsule &capsule);
00047 void set_fpu_exceptions(bool b);
00048 void set_fpu_precision24();
00049 void set_fpu_precision53();
00050 void set_fpu_precision64();
00051 void set_fpu_rounding_chop();
00052 void set_fpu_rounding_down();
00053 void set_fpu_rounding_near();
00054 void set_fpu_rounding_up();
00055 int int_ceil(const float &f);
00056 int int_chop(const float &f);
00057 int int_floor(const float &f);
00058 float compute_distance_squared(const PhysxRay &ray, const LPoint3f &point);
00059 float compute_square_distance(const PhysxSegment &seg, const LPoint3f &point);
00060 PhysxSphere merge_spheres(const PhysxSphere &sphere0, const PhysxSphere &sphere1);
00061 void normal_to_tangents(const LVector3f &n, LVector3f &t1, LVector3f &t2);
00062 LMatrix3f find_rotation_matrix(const LVector3f &x, const LVector3f &b);
00063 float compute_sphere_mass(float radius, float density);
00064 float compute_sphere_density(float radius, float mass);
00065 float compute_box_mass(const LVector3f &extents, float density);
00066 float compute_box_density(const LVector3f &extents, float mass);
00067 float compute_ellipsoid_mass(const LVector3f &extents, float density);
00068 float compute_ellipsoid_density(const LVector3f &extents, float mass);
00069 float compute_cylinder_mass(float radius, float length, float density);
00070 float compute_cylinder_density(float radius, float length, float mass);
00071 float compute_cone_mass(float radius, float length, float density);
00072 float compute_cone_density(float radius, float length, float mass);
00073 LVector3f compute_box_inertia_tensor(float mass, float xlength, float ylength, float zlength);
00074 LVector3f compute_sphere_inertia_tensor(float mass, float radius, bool hollow);
00075 bool box_box_intersect(const LVector3f &extents0, const LPoint3f ¢er0, const LMatrix3f &rotation0, const LVector3f &extents1, const LPoint3f ¢er1, const LMatrix3f &rotation1, bool full_test);
00076 bool tri_box_intersect(const LPoint3f &vertex0, const LPoint3f &vertex1, const LPoint3f &vertex2, const LPoint3f ¢er, const LVector3f &extents);
00077 bool ray_plane_intersect(const PhysxRay &ray, const PhysxPlane &plane, LPoint3f &point_on_plane);
00078 bool ray_sphere_intersect(const LPoint3f &origin, const LVector3f &dir, float length, const LPoint3f ¢er, float radius, LPoint3f &hit_pos);
00079 bool segment_box_intersect(const LPoint3f &p1, const LPoint3f &p2, const LPoint3f &bbox_min, const LPoint3f &bbox_max, LPoint3f &intercept);
00080 bool ray_aabb_intersect(const LPoint3f &min, const LPoint3f &max, const LPoint3f &origin, const LVector3f &dir, LPoint3f &coord);
00081 bool segment_obb_intersect(const LPoint3f &p0, const LPoint3f &p1, const LPoint3f ¢er, const LVector3f &extents, const LMatrix3f &rot);
00082 bool segment_aabb_intersect(const LPoint3f &p0, const LPoint3f &p1, const LPoint3f &min, const LPoint3f &max);
00083 bool ray_obb_intersect(const PhysxRay &ray, const LPoint3f ¢er, const LVector3f &extents, const LMatrix3f &rot);
00084 unsigned int ray_capsule_intersect(const LPoint3f &origin, const LVector3f &dir, const PhysxCapsule &capsule);
00085 bool swept_spheres_intersect(const PhysxSphere &sphere0, const LVector3f &velocity0, const PhysxSphere &sphere1, const LVector3f &velocity1);
00086 bool ray_tri_intersect(const LPoint3f &orig, const LVector3f &dir, const LPoint3f &vert0, const LPoint3f &vert1, const LPoint3f &vert2, LVector3f &hit, bool cull);
00087 bool sweep_box_capsule(const PhysxBox &box, const PhysxCapsule &lss, const LVector3f &dir, float length, LVector3f &normal);
00088 bool sweep_box_sphere(const PhysxBox &box, const PhysxSphere &sphere, const LVector3f &dir, float length, LVector3f &normal);
00089 bool sweep_capsule_capsule(const PhysxCapsule &lss0, const PhysxCapsule &lss1, const LVector3f &dir, float length, LPoint3f &ip, LVector3f &normal);
00090 bool sweep_sphere_capsule(const PhysxSphere &sphere, const PhysxCapsule &lss, const LVector3f &dir, float length, LPoint3f &ip, LVector3f &normal);
00091 bool sweep_box_box(const PhysxBox &box0, const PhysxBox &box1, const LVector3f &dir, float length, LPoint3f &ip, LVector3f &normal);
00092 float point_obb_sqr_dist(const LPoint3f &point, const LPoint3f ¢er, const LVector3f &extents, const LMatrix3f &rot, LPoint3f ¶ms);
00093
00094 public:
00095 NxUtilLib *_ptr;
00096 };
00097
00098 #include "physxUtilLib.I"
00099
00100 #endif // PHYSUTILLIB_H
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125