git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@159 92aac97c-a6ce-11dd-a772-7fcde58d38e6
This commit is contained in:
parent
045bd3d515
commit
c092040d35
|
@ -24,8 +24,30 @@
|
|||
using namespace reactphysics3d;
|
||||
|
||||
// Constructor
|
||||
OBB::OBB() {
|
||||
OBB::OBB(const Vector3D& center, const Vector3D& axis1, const Vector3D& axis2,
|
||||
const Vector3D& axis3, double extent1, double extent2, double extent3) {
|
||||
this->center = center;
|
||||
|
||||
this->axis[0] = axis1;
|
||||
this->axis[1] = axis2;
|
||||
this->axis[2] = axis3;
|
||||
|
||||
this->extent[0] = extent1;
|
||||
this->extent[1] = extent2;
|
||||
this->extent[2] = extent3;
|
||||
}
|
||||
|
||||
// Copy-Constructor
|
||||
OBB::OBB(const OBB& obb) {
|
||||
this->center = obb.center;
|
||||
|
||||
this->axis[0] = obb.axis[0];
|
||||
this->axis[1] = obb.axis[1];
|
||||
this->axis[2] = obb.axis[2];
|
||||
|
||||
this->extent[0] = obb.extent[0];
|
||||
this->extent[1] = obb.extent[1];
|
||||
this->extent[2] = obb.extent[2];
|
||||
}
|
||||
|
||||
// Destructor
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
#ifndef OBB_H
|
||||
#define OBB_H
|
||||
|
||||
// Libraries
|
||||
#include "BoundingVolume.h"
|
||||
#include "../mathematics/mathematics.h"
|
||||
|
||||
// ReactPhysics3D namespace
|
||||
namespace reactphysics3d {
|
||||
|
||||
|
@ -31,12 +35,86 @@ namespace reactphysics3d {
|
|||
*/
|
||||
class OBB : public BoundingVolume {
|
||||
private :
|
||||
Vector3D center; // Center point of the OBB
|
||||
Vector3D axis[3]; // Array that contains the three axis of the OBB
|
||||
double extent[3]; // Array that contains the three extents size of the OBB
|
||||
|
||||
public :
|
||||
OBB(); // Constructor
|
||||
OBB(const Vector3D& center, const Vector3D& axis1, const Vector3D& axis2,
|
||||
const Vector3D& axis3, double extent1, double extent2, double extent3); // Constructor
|
||||
OBB(const OBB& obb); // Copy-Constructor
|
||||
virtual ~OBB(); // Destructor
|
||||
|
||||
Vector3D getCenter() const; // Return the center point of the OBB
|
||||
void setCenter(const Vector3D& center); // Set the center point
|
||||
Vector3D getAxis(int index) const throw(std::invalid_argument); // Return an axis of the OBB
|
||||
void setAxis(int index, const Vector3D& axis) throw(std::invalid_argument); // Set an axis
|
||||
double getExtent(int index) const throw(std::invalid_argument); // Return an extent value
|
||||
void setExtent(int index, double extent) throw(std::invalid_argument); // Set an extent value
|
||||
};
|
||||
|
||||
// TODO : Don't forget that we need to code a way that a change in the orientation of a rigid body imply
|
||||
// a change in the orientation (center and axis) of the corresponding OBB.
|
||||
|
||||
// Return the center point of the OBB
|
||||
inline Vector3D OBB::getCenter() const {
|
||||
return center;
|
||||
}
|
||||
|
||||
// Set the center point
|
||||
inline void OBB::setCenter(const Vector3D& center) {
|
||||
this->center = center;
|
||||
}
|
||||
|
||||
// Return an axis of the OBB
|
||||
inline Vector3D OBB::getAxis(int index) const throw(std::invalid_argument) {
|
||||
// Check if the index value is valid
|
||||
if (index >= 0 && index <3) {
|
||||
return axis[index];
|
||||
}
|
||||
else {
|
||||
// The index value is not valid, we throw an exception
|
||||
throw std::invalid_argument("Exception : The index value has to be between 0 and 2");
|
||||
}
|
||||
}
|
||||
|
||||
// Set an axis
|
||||
inline void OBB::setAxis(int index, const Vector3D& axis) throw(std::invalid_argument) {
|
||||
// Check if the index value is valid
|
||||
if (index >= 0 && index <3) {
|
||||
this->axis[index] = axis;
|
||||
}
|
||||
else {
|
||||
// The index value is not valid, we throw an exception
|
||||
throw std::invalid_argument("Exception : The index value has to be between 0 and 2");
|
||||
}
|
||||
}
|
||||
|
||||
// Return an extent value
|
||||
inline double OBB::getExtent(int index) const throw(std::invalid_argument) {
|
||||
// Check if the index value is valid
|
||||
if (index >= 0 && index <3) {
|
||||
return extent[index];
|
||||
}
|
||||
else {
|
||||
// The index value is not valid, we throw an exception
|
||||
throw std::invalid_argument("Exception : The index value has to be between 0 and 2");
|
||||
}
|
||||
}
|
||||
|
||||
// Set an extent value
|
||||
inline void OBB::setExtent(int index, double extent) throw(std::invalid_argument) {
|
||||
// Check if the index value is valid
|
||||
if (index >= 0 && index <3) {
|
||||
this->extent[index] = extent;
|
||||
}
|
||||
else {
|
||||
// The index value is not valid, we throw an exception
|
||||
throw std::invalid_argument("Exception : The index value has to be between 0 and 2");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}; // End of the ReactPhysics3D namespace
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue
Block a user