changes in the code structure
git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@431 92aac97c-a6ce-11dd-a772-7fcde58d38e6
This commit is contained in:
parent
1d5a8e2491
commit
5b30979de9
|
@ -49,13 +49,13 @@ AABB::~AABB() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VISUAL_DEBUG
|
#ifdef VISUAL_DEBUG
|
||||||
// Draw the OBB (only for testing purpose)
|
// Draw the AABB (only for testing purpose)
|
||||||
void AABB::draw() const {
|
void AABB::draw() const {
|
||||||
|
|
||||||
// Draw in red
|
// Draw in red
|
||||||
glColor3f(1.0, 0.0, 0.0);
|
glColor3f(1.0, 0.0, 0.0);
|
||||||
|
|
||||||
// Draw the OBB
|
// Draw the AABB
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
glVertex3f(maxCoordinates.getX(), minCoordinates.getY(), minCoordinates.getZ());
|
glVertex3f(maxCoordinates.getX(), minCoordinates.getY(), minCoordinates.getZ());
|
||||||
glVertex3f(maxCoordinates.getX(), maxCoordinates.getY(), minCoordinates.getZ());
|
glVertex3f(maxCoordinates.getX(), maxCoordinates.getY(), minCoordinates.getZ());
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
/********************************************************************************
|
|
||||||
* ReactPhysics3D physics library, http://code.google.com/p/reactphysics3d/ *
|
|
||||||
* Copyright (c) 2010 Daniel Chappuis *
|
|
||||||
*********************************************************************************
|
|
||||||
* *
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy *
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal *
|
|
||||||
* in the Software without restriction, including without limitation the rights *
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is *
|
|
||||||
* furnished to do so, subject to the following conditions: *
|
|
||||||
* *
|
|
||||||
* The above copyright notice and this permission notice shall be included in *
|
|
||||||
* all copies or substantial portions of the Software. *
|
|
||||||
* *
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN *
|
|
||||||
* THE SOFTWARE. *
|
|
||||||
********************************************************************************/
|
|
||||||
|
|
||||||
// Libraries
|
|
||||||
#include "BoundingVolume.h"
|
|
||||||
|
|
||||||
// We want to use the ReactPhysics3D namespace
|
|
||||||
using namespace reactphysics3d;
|
|
||||||
|
|
||||||
// Constructor
|
|
||||||
BoundingVolume::BoundingVolume() {
|
|
||||||
this->body = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Destructor
|
|
||||||
BoundingVolume::~BoundingVolume() {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,75 +0,0 @@
|
||||||
/********************************************************************************
|
|
||||||
* ReactPhysics3D physics library, http://code.google.com/p/reactphysics3d/ *
|
|
||||||
* Copyright (c) 2010 Daniel Chappuis *
|
|
||||||
*********************************************************************************
|
|
||||||
* *
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy *
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal *
|
|
||||||
* in the Software without restriction, including without limitation the rights *
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is *
|
|
||||||
* furnished to do so, subject to the following conditions: *
|
|
||||||
* *
|
|
||||||
* The above copyright notice and this permission notice shall be included in *
|
|
||||||
* all copies or substantial portions of the Software. *
|
|
||||||
* *
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN *
|
|
||||||
* THE SOFTWARE. *
|
|
||||||
********************************************************************************/
|
|
||||||
|
|
||||||
#ifndef BOUNDING_VOLUME_H
|
|
||||||
#define BOUNDING_VOLUME_H
|
|
||||||
|
|
||||||
// Libraries
|
|
||||||
#include "Body.h"
|
|
||||||
#include "../mathematics/mathematics.h"
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
|
|
||||||
// ReactPhysics3D namespace
|
|
||||||
namespace reactphysics3d {
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------
|
|
||||||
Class BoundingVolume :
|
|
||||||
This class represents the volume that contains a rigid body.
|
|
||||||
This volume will be used to compute the collisions with others
|
|
||||||
bodies.
|
|
||||||
-------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
class BoundingVolume {
|
|
||||||
protected :
|
|
||||||
Body* body; // Pointer to the body
|
|
||||||
|
|
||||||
public :
|
|
||||||
BoundingVolume(); // Constructor
|
|
||||||
virtual ~BoundingVolume(); // Destructor
|
|
||||||
|
|
||||||
Body* getBodyPointer() const; // Return the body pointer
|
|
||||||
void setBodyPointer(Body* body); // Set the body pointer
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef VISUAL_DEBUG
|
|
||||||
virtual void draw() const=0; // Display the bounding volume (only for testing purpose)
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
// Return the body pointer
|
|
||||||
inline Body* BoundingVolume::getBodyPointer() const {
|
|
||||||
assert(body != NULL);
|
|
||||||
return body;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the body pointer
|
|
||||||
inline void BoundingVolume::setBodyPointer(Body* bodyPointer) {
|
|
||||||
this->body = bodyPointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // End of the ReactPhysics3D namespace
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -23,7 +23,7 @@
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
// Libraries
|
// Libraries
|
||||||
#include "OBB.h"
|
#include "BoxShape.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
@ -36,18 +36,18 @@ using namespace reactphysics3d;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
OBB::OBB(const Vector3D& extent) : extent(extent) {
|
BoxShape::BoxShape(const Vector3D& extent) : extent(extent) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
OBB::~OBB() {
|
BoxShape::~BoxShape() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VISUAL_DEBUG
|
#ifdef VISUAL_DEBUG
|
||||||
// Draw the OBB (only for testing purpose)
|
// Draw the Box (only for testing purpose)
|
||||||
void OBB::draw() const {
|
void BoxShape::draw() const {
|
||||||
double e1 = extent.getX();
|
double e1 = extent.getX();
|
||||||
double e2 = extent.getY();
|
double e2 = extent.getY();
|
||||||
double e3 = extent.getZ();
|
double e3 = extent.getZ();
|
||||||
|
@ -55,7 +55,7 @@ void OBB::draw() const {
|
||||||
// Draw in red
|
// Draw in red
|
||||||
glColor3f(1.0, 0.0, 0.0);
|
glColor3f(1.0, 0.0, 0.0);
|
||||||
|
|
||||||
// Draw the OBB
|
// Draw the Box
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
glVertex3f(e1, -e2, -e3);
|
glVertex3f(e1, -e2, -e3);
|
||||||
glVertex3f(e1, e2, -e3);
|
glVertex3f(e1, e2, -e3);
|
|
@ -22,8 +22,8 @@
|
||||||
* THE SOFTWARE. *
|
* THE SOFTWARE. *
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
#ifndef OBB_H
|
#ifndef BOX_SHAPE_H
|
||||||
#define OBB_H
|
#define BOX_SHAPE_H
|
||||||
|
|
||||||
// Libraries
|
// Libraries
|
||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
|
@ -34,20 +34,20 @@
|
||||||
namespace reactphysics3d {
|
namespace reactphysics3d {
|
||||||
|
|
||||||
/* -------------------------------------------------------------------
|
/* -------------------------------------------------------------------
|
||||||
Class OBB :
|
Class BoxShape :
|
||||||
This class represents a 3D box. Those axis are unit length.
|
This class represents a 3D box. Those axis are unit length.
|
||||||
The three extents are half-widths of the box along the three
|
The three extents are half-widths of the box along the three
|
||||||
axis x, y, z local axis. The "transform" of the corresponding
|
axis x, y, z local axis. The "transform" of the corresponding
|
||||||
rigid body given an orientation and a position to the box
|
rigid body given an orientation and a position to the box
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
class OBB : public Shape {
|
class BoxShape : public Shape {
|
||||||
private :
|
private :
|
||||||
Vector3D extent; // Extent sizes of the box
|
Vector3D extent; // Extent sizes of the box
|
||||||
|
|
||||||
public :
|
public :
|
||||||
OBB(const Vector3D& extent); // Constructor
|
BoxShape(const Vector3D& extent); // Constructor
|
||||||
virtual ~OBB(); // Destructor
|
virtual ~BoxShape(); // Destructor
|
||||||
|
|
||||||
const Vector3D& getExtent() const; // Return the extents of the box
|
const Vector3D& getExtent() const; // Return the extents of the box
|
||||||
void setExtent(const Vector3D& extent); // Set the extents of the box
|
void setExtent(const Vector3D& extent); // Set the extents of the box
|
||||||
|
@ -55,28 +55,28 @@ class OBB : public Shape {
|
||||||
virtual Vector3D getSupportPoint(const Vector3D& direction, double margin=0.0) const; // Return a support point in a given direction
|
virtual Vector3D getSupportPoint(const Vector3D& direction, double margin=0.0) const; // Return a support point in a given direction
|
||||||
|
|
||||||
#ifdef VISUAL_DEBUG
|
#ifdef VISUAL_DEBUG
|
||||||
virtual void draw() const; // Draw the OBB (only for testing purpose)
|
virtual void draw() const; // Draw the Box (only for testing purpose)
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
// Return the extents of the box
|
// Return the extents of the box
|
||||||
inline const Vector3D& OBB::getExtent() const {
|
inline const Vector3D& BoxShape::getExtent() const {
|
||||||
return extent;
|
return extent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the extents of the box
|
// Set the extents of the box
|
||||||
inline void OBB::setExtent(const Vector3D& extent) {
|
inline void BoxShape::setExtent(const Vector3D& extent) {
|
||||||
this->extent = extent;
|
this->extent = extent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the local extents of the shape (half-width) in x,y and z local direction
|
// Return the local extents of the shape (half-width) in x,y and z local direction
|
||||||
// This method is used to compute the AABB of the box
|
// This method is used to compute the AABB of the box
|
||||||
inline Vector3D OBB::getLocalExtents() const {
|
inline Vector3D BoxShape::getLocalExtents() const {
|
||||||
return extent;
|
return extent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a support point in a given direction
|
// Return a support point in a given direction
|
||||||
inline Vector3D OBB::getSupportPoint(const Vector3D& direction, double margin) const {
|
inline Vector3D BoxShape::getSupportPoint(const Vector3D& direction, double margin) const {
|
||||||
assert(margin >= 0.0);
|
assert(margin >= 0.0);
|
||||||
|
|
||||||
return Vector3D(direction.getX() < 0.0 ? -extent.getX()-margin : extent.getX()+margin,
|
return Vector3D(direction.getX() < 0.0 ? -extent.getX()-margin : extent.getX()+margin,
|
|
@ -22,8 +22,8 @@
|
||||||
* THE SOFTWARE. *
|
* THE SOFTWARE. *
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
#ifndef BOUNDING_CONE_H
|
#ifndef CONE_SHAPE_H
|
||||||
#define BOUNDING_CONE_H
|
#define CONE_SHAPE_H
|
||||||
|
|
||||||
// Libraries
|
// Libraries
|
||||||
#include "Shape.h"
|
#include "Shape.h"
|
||||||
|
@ -61,33 +61,33 @@ class ConeShape : public Shape {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Return the center point of the sphere
|
// Return the center point of the sphere
|
||||||
inline Vector3D BoundingSphere::getCenter() const {
|
inline Vector3D SphereShape::getCenter() const {
|
||||||
return center;
|
return center;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the center point of the sphere
|
// Set the center point of the sphere
|
||||||
inline void BoundingSphere::setCenter(const Vector3D& center) {
|
inline void SphereShape::setCenter(const Vector3D& center) {
|
||||||
this->center = center;
|
this->center = center;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the radius of the sphere
|
// Get the radius of the sphere
|
||||||
inline double BoundingSphere::getRadius() const {
|
inline double SphereShape::getRadius() const {
|
||||||
return radius;
|
return radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the radius of the sphere
|
// Set the radius of the sphere
|
||||||
inline void BoundingSphere::setRadius(double radius) {
|
inline void SphereShape::setRadius(double radius) {
|
||||||
this->radius = radius;
|
this->radius = radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the orientation of the shere according to the orientation of the rigid body
|
// Update the orientation of the shere according to the orientation of the rigid body
|
||||||
inline void BoundingSphere::update(const Vector3D& newCenter, const Quaternion& rotationQuaternion) {
|
inline void SphereShape::update(const Vector3D& newCenter, const Quaternion& rotationQuaternion) {
|
||||||
// Update the center of the sphere
|
// Update the center of the sphere
|
||||||
center = newCenter;
|
center = newCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a support point in a given direction
|
// Return a support point in a given direction
|
||||||
inline Vector3D BoundingSphere::getSupportPoint(const Vector3D& direction, double margin) const {
|
inline Vector3D SphereShape::getSupportPoint(const Vector3D& direction, double margin) const {
|
||||||
assert(margin >= 0.0);
|
assert(margin >= 0.0);
|
||||||
double length = direction.length();
|
double length = direction.length();
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
// Libraries
|
// Libraries
|
||||||
#include "BoundingSphere.h"
|
#include "SphereShape.h"
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#ifdef VISUAL_DEBUG
|
#ifdef VISUAL_DEBUG
|
||||||
|
@ -36,19 +36,19 @@ using namespace reactphysics3d;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
BoundingSphere::BoundingSphere(const Vector3D& center, double radius) {
|
SphereShape::SphereShape(const Vector3D& center, double radius) {
|
||||||
this->center = center;
|
this->center = center;
|
||||||
this->radius = radius;
|
this->radius = radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
BoundingSphere::~BoundingSphere() {
|
SphereShape::~SphereShape() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VISUAL_DEBUG
|
#ifdef VISUAL_DEBUG
|
||||||
// Draw the sphere (only for testing purpose)
|
// Draw the sphere (only for testing purpose)
|
||||||
void BoundingSphere::draw() const {
|
void SphereShape::draw() const {
|
||||||
|
|
||||||
// Draw in red
|
// Draw in red
|
||||||
glColor3f(1.0, 0.0, 0.0);
|
glColor3f(1.0, 0.0, 0.0);
|
|
@ -22,8 +22,8 @@
|
||||||
* THE SOFTWARE. *
|
* THE SOFTWARE. *
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
#ifndef BOUNDING_SPHERE_H
|
#ifndef SPHERE_SHAPE_H
|
||||||
#define BOUNDING_SPHERE_H
|
#define SPHERE_SHAPE_H
|
||||||
|
|
||||||
// Libraries
|
// Libraries
|
||||||
#include "Shape.h"
|
#include "Shape.h"
|
||||||
|
@ -33,18 +33,18 @@
|
||||||
namespace reactphysics3d {
|
namespace reactphysics3d {
|
||||||
|
|
||||||
/* -------------------------------------------------------------------
|
/* -------------------------------------------------------------------
|
||||||
Class BoundingSphere :
|
Class SphereShape :
|
||||||
This class represents a sphere bounding volume.
|
This class represents a sphere bounding volume.
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
class BoundingSphere : public Shape {
|
class SphereShape : public Shape {
|
||||||
protected :
|
protected :
|
||||||
Vector3D center; // Center point of the sphere
|
Vector3D center; // Center point of the sphere
|
||||||
double radius; // Radius of the sphere
|
double radius; // Radius of the sphere
|
||||||
|
|
||||||
public :
|
public :
|
||||||
BoundingSphere(const Vector3D& center, double radius); // Constructor
|
SphereShape(const Vector3D& center, double radius); // Constructor
|
||||||
virtual ~BoundingSphere(); // Destructor
|
virtual ~SphereShape(); // Destructor
|
||||||
|
|
||||||
Vector3D getCenter() const; // Return the center point of the sphere
|
Vector3D getCenter() const; // Return the center point of the sphere
|
||||||
void setCenter(const Vector3D& center); // Set the center point of the sphere
|
void setCenter(const Vector3D& center); // Set the center point of the sphere
|
||||||
|
@ -62,33 +62,33 @@ class BoundingSphere : public Shape {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Return the center point of the sphere
|
// Return the center point of the sphere
|
||||||
inline Vector3D BoundingSphere::getCenter() const {
|
inline Vector3D SphereShape::getCenter() const {
|
||||||
return center;
|
return center;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the center point of the sphere
|
// Set the center point of the sphere
|
||||||
inline void BoundingSphere::setCenter(const Vector3D& center) {
|
inline void SphereShape::setCenter(const Vector3D& center) {
|
||||||
this->center = center;
|
this->center = center;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the radius of the sphere
|
// Get the radius of the sphere
|
||||||
inline double BoundingSphere::getRadius() const {
|
inline double SphereShape::getRadius() const {
|
||||||
return radius;
|
return radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the radius of the sphere
|
// Set the radius of the sphere
|
||||||
inline void BoundingSphere::setRadius(double radius) {
|
inline void SphereShape::setRadius(double radius) {
|
||||||
this->radius = radius;
|
this->radius = radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the orientation of the shere according to the orientation of the rigid body
|
// Update the orientation of the shere according to the orientation of the rigid body
|
||||||
inline void BoundingSphere::update(const Vector3D& newCenter, const Quaternion& rotationQuaternion) {
|
inline void SphereShape::update(const Vector3D& newCenter, const Quaternion& rotationQuaternion) {
|
||||||
// Update the center of the sphere
|
// Update the center of the sphere
|
||||||
center = newCenter;
|
center = newCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a support point in a given direction
|
// Return a support point in a given direction
|
||||||
inline Vector3D BoundingSphere::getSupportPoint(const Vector3D& direction, double margin) const {
|
inline Vector3D SphereShape::getSupportPoint(const Vector3D& direction, double margin) const {
|
||||||
assert(margin >= 0.0);
|
assert(margin >= 0.0);
|
||||||
double length = direction.length();
|
double length = direction.length();
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ inline Vector3D BoundingSphere::getSupportPoint(const Vector3D& direction, doubl
|
||||||
|
|
||||||
// Return the local extents of the shape (half-width) in x,y and z local direction
|
// Return the local extents of the shape (half-width) in x,y and z local direction
|
||||||
// This method is used to compute the AABB of the box
|
// This method is used to compute the AABB of the box
|
||||||
inline Vector3D BoundingSphere::getLocalExtents() const {
|
inline Vector3D SphereShape::getLocalExtents() const {
|
||||||
return Vector3D(radius, radius, radius);
|
return Vector3D(radius, radius, radius);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user