123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- #ifndef __CC_OBB_H__
- #define __CC_OBB_H__
- #include "3d/CCAABB.h"
- NS_CC_BEGIN
- class CC_DLL OBB
- {
- public:
- OBB();
-
- OBB(const AABB& aabb);
-
-
- OBB(const Vec3* verts, int num);
-
-
- bool containPoint(const Vec3& point) const;
-
- void set(const Vec3& center, const Vec3& _xAxis, const Vec3& _yAxis, const Vec3& _zAxis, const Vec3& _extents);
-
-
-
- void reset();
-
- void getCorners(Vec3* verts) const;
-
-
- bool intersects(const OBB& box) const;
-
-
- void transform(const Mat4& mat);
-
- protected:
-
- void computeExtAxis()
- {
- _extentX = _xAxis * _extents.x;
- _extentY = _yAxis * _extents.y;
- _extentZ = _zAxis * _extents.z;
- }
-
-
- float projectPoint(const Vec3& point, const Vec3& axis) const;
-
-
- void getInterval(const OBB& box, const Vec3& axis, float &min, float &max) const;
-
-
- Vec3 getEdgeDirection(int index) const;
-
-
- Vec3 getFaceDirection(int index) const;
- public:
- Vec3 _center;
- Vec3 _xAxis;
- Vec3 _yAxis;
- Vec3 _zAxis;
- Vec3 _extentX;
- Vec3 _extentY;
- Vec3 _extentZ;
- Vec3 _extents;
- };
- NS_CC_END
- #endif
|