Refactor testbed application
This commit is contained in:
parent
d1cb0d9275
commit
a9da0d6d3c
|
@ -39,8 +39,7 @@ int Box::totalNbBoxes = 0;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Box::Box(const openglframework::Vector3& size, const openglframework::Vector3 &position,
|
Box::Box(const openglframework::Vector3& size, const openglframework::Vector3 &position,
|
||||||
reactphysics3d::CollisionWorld* world, const std::string& meshFolderPath)
|
reactphysics3d::CollisionWorld* world, const std::string& meshFolderPath) {
|
||||||
: openglframework::Mesh() {
|
|
||||||
|
|
||||||
// Load the mesh from a file
|
// Load the mesh from a file
|
||||||
openglframework::MeshReaderWriter::loadMeshFromFile(meshFolderPath + "cube.obj", *this);
|
openglframework::MeshReaderWriter::loadMeshFromFile(meshFolderPath + "cube.obj", *this);
|
||||||
|
@ -94,8 +93,7 @@ Box::Box(const openglframework::Vector3& size, const openglframework::Vector3 &p
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Box::Box(const openglframework::Vector3& size, const openglframework::Vector3& position,
|
Box::Box(const openglframework::Vector3& size, const openglframework::Vector3& position,
|
||||||
float mass, reactphysics3d::DynamicsWorld* world, const std::string& meshFolderPath)
|
float mass, reactphysics3d::DynamicsWorld* world, const std::string& meshFolderPath) {
|
||||||
: openglframework::Mesh() {
|
|
||||||
|
|
||||||
// Load the mesh from a file
|
// Load the mesh from a file
|
||||||
openglframework::MeshReaderWriter::loadMeshFromFile(meshFolderPath + "cube.obj", *this);
|
openglframework::MeshReaderWriter::loadMeshFromFile(meshFolderPath + "cube.obj", *this);
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include "PhysicsObject.h"
|
#include "PhysicsObject.h"
|
||||||
|
|
||||||
// Class Box
|
// Class Box
|
||||||
class Box : public openglframework::Mesh, public PhysicsObject {
|
class Box : public PhysicsObject {
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ int Capsule::totalNbCapsules = 0;
|
||||||
Capsule::Capsule(float radius, float height, const openglframework::Vector3& position,
|
Capsule::Capsule(float radius, float height, const openglframework::Vector3& position,
|
||||||
reactphysics3d::CollisionWorld* world,
|
reactphysics3d::CollisionWorld* world,
|
||||||
const std::string& meshFolderPath)
|
const std::string& meshFolderPath)
|
||||||
: openglframework::Mesh(), mRadius(radius), mHeight(height) {
|
: mRadius(radius), mHeight(height) {
|
||||||
|
|
||||||
// Load the mesh from a file
|
// Load the mesh from a file
|
||||||
openglframework::MeshReaderWriter::loadMeshFromFile(meshFolderPath + "capsule.obj", *this);
|
openglframework::MeshReaderWriter::loadMeshFromFile(meshFolderPath + "capsule.obj", *this);
|
||||||
|
@ -86,7 +86,7 @@ Capsule::Capsule(float radius, float height, const openglframework::Vector3& pos
|
||||||
Capsule::Capsule(float radius, float height, const openglframework::Vector3& position,
|
Capsule::Capsule(float radius, float height, const openglframework::Vector3& position,
|
||||||
float mass, reactphysics3d::DynamicsWorld* dynamicsWorld,
|
float mass, reactphysics3d::DynamicsWorld* dynamicsWorld,
|
||||||
const std::string& meshFolderPath)
|
const std::string& meshFolderPath)
|
||||||
: openglframework::Mesh(), mRadius(radius), mHeight(height) {
|
: mRadius(radius), mHeight(height) {
|
||||||
|
|
||||||
// Load the mesh from a file
|
// Load the mesh from a file
|
||||||
openglframework::MeshReaderWriter::loadMeshFromFile(meshFolderPath + "capsule.obj", *this);
|
openglframework::MeshReaderWriter::loadMeshFromFile(meshFolderPath + "capsule.obj", *this);
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include "PhysicsObject.h"
|
#include "PhysicsObject.h"
|
||||||
|
|
||||||
// Class Sphere
|
// Class Sphere
|
||||||
class Capsule : public openglframework::Mesh, public PhysicsObject {
|
class Capsule : public PhysicsObject {
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
ConcaveMesh::ConcaveMesh(const openglframework::Vector3 &position,
|
ConcaveMesh::ConcaveMesh(const openglframework::Vector3 &position,
|
||||||
reactphysics3d::CollisionWorld* world,
|
reactphysics3d::CollisionWorld* world,
|
||||||
const std::string& meshPath)
|
const std::string& meshPath)
|
||||||
: openglframework::Mesh(), mVBOVertices(GL_ARRAY_BUFFER),
|
: mVBOVertices(GL_ARRAY_BUFFER),
|
||||||
mVBONormals(GL_ARRAY_BUFFER), mVBOTextureCoords(GL_ARRAY_BUFFER),
|
mVBONormals(GL_ARRAY_BUFFER), mVBOTextureCoords(GL_ARRAY_BUFFER),
|
||||||
mVBOIndices(GL_ELEMENT_ARRAY_BUFFER) {
|
mVBOIndices(GL_ELEMENT_ARRAY_BUFFER) {
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ ConcaveMesh::ConcaveMesh(const openglframework::Vector3 &position,
|
||||||
ConcaveMesh::ConcaveMesh(const openglframework::Vector3 &position, float mass,
|
ConcaveMesh::ConcaveMesh(const openglframework::Vector3 &position, float mass,
|
||||||
reactphysics3d::DynamicsWorld* dynamicsWorld,
|
reactphysics3d::DynamicsWorld* dynamicsWorld,
|
||||||
const std::string& meshPath)
|
const std::string& meshPath)
|
||||||
: openglframework::Mesh(), mVBOVertices(GL_ARRAY_BUFFER),
|
: mVBOVertices(GL_ARRAY_BUFFER),
|
||||||
mVBONormals(GL_ARRAY_BUFFER), mVBOTextureCoords(GL_ARRAY_BUFFER),
|
mVBONormals(GL_ARRAY_BUFFER), mVBOTextureCoords(GL_ARRAY_BUFFER),
|
||||||
mVBOIndices(GL_ELEMENT_ARRAY_BUFFER) {
|
mVBOIndices(GL_ELEMENT_ARRAY_BUFFER) {
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include "PhysicsObject.h"
|
#include "PhysicsObject.h"
|
||||||
|
|
||||||
// Class ConcaveMesh
|
// Class ConcaveMesh
|
||||||
class ConcaveMesh : public openglframework::Mesh, public PhysicsObject {
|
class ConcaveMesh : public PhysicsObject {
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ int Cone::totalNbCones = 0;
|
||||||
Cone::Cone(float radius, float height, const openglframework::Vector3 &position,
|
Cone::Cone(float radius, float height, const openglframework::Vector3 &position,
|
||||||
reactphysics3d::CollisionWorld* world,
|
reactphysics3d::CollisionWorld* world,
|
||||||
const std::string& meshFolderPath)
|
const std::string& meshFolderPath)
|
||||||
: openglframework::Mesh(), mRadius(radius), mHeight(height) {
|
: mRadius(radius), mHeight(height) {
|
||||||
|
|
||||||
// Load the mesh from a file
|
// Load the mesh from a file
|
||||||
openglframework::MeshReaderWriter::loadMeshFromFile(meshFolderPath + "cone.obj", *this);
|
openglframework::MeshReaderWriter::loadMeshFromFile(meshFolderPath + "cone.obj", *this);
|
||||||
|
@ -85,7 +85,7 @@ Cone::Cone(float radius, float height, const openglframework::Vector3 &position,
|
||||||
Cone::Cone(float radius, float height, const openglframework::Vector3 &position,
|
Cone::Cone(float radius, float height, const openglframework::Vector3 &position,
|
||||||
float mass, reactphysics3d::DynamicsWorld* dynamicsWorld,
|
float mass, reactphysics3d::DynamicsWorld* dynamicsWorld,
|
||||||
const std::string& meshFolderPath)
|
const std::string& meshFolderPath)
|
||||||
: openglframework::Mesh(), mRadius(radius), mHeight(height) {
|
: mRadius(radius), mHeight(height) {
|
||||||
|
|
||||||
// Load the mesh from a file
|
// Load the mesh from a file
|
||||||
openglframework::MeshReaderWriter::loadMeshFromFile(meshFolderPath + "cone.obj", *this);
|
openglframework::MeshReaderWriter::loadMeshFromFile(meshFolderPath + "cone.obj", *this);
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include "PhysicsObject.h"
|
#include "PhysicsObject.h"
|
||||||
|
|
||||||
// Class Cone
|
// Class Cone
|
||||||
class Cone : public openglframework::Mesh, public PhysicsObject {
|
class Cone : public PhysicsObject {
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
ConvexMesh::ConvexMesh(const openglframework::Vector3 &position,
|
ConvexMesh::ConvexMesh(const openglframework::Vector3 &position,
|
||||||
reactphysics3d::CollisionWorld* world,
|
reactphysics3d::CollisionWorld* world,
|
||||||
const std::string& meshPath)
|
const std::string& meshPath)
|
||||||
: openglframework::Mesh(), mVBOVertices(GL_ARRAY_BUFFER),
|
: mVBOVertices(GL_ARRAY_BUFFER),
|
||||||
mVBONormals(GL_ARRAY_BUFFER), mVBOTextureCoords(GL_ARRAY_BUFFER),
|
mVBONormals(GL_ARRAY_BUFFER), mVBOTextureCoords(GL_ARRAY_BUFFER),
|
||||||
mVBOIndices(GL_ELEMENT_ARRAY_BUFFER) {
|
mVBOIndices(GL_ELEMENT_ARRAY_BUFFER) {
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ ConvexMesh::ConvexMesh(const openglframework::Vector3 &position,
|
||||||
ConvexMesh::ConvexMesh(const openglframework::Vector3 &position, float mass,
|
ConvexMesh::ConvexMesh(const openglframework::Vector3 &position, float mass,
|
||||||
reactphysics3d::DynamicsWorld* dynamicsWorld,
|
reactphysics3d::DynamicsWorld* dynamicsWorld,
|
||||||
const std::string& meshPath)
|
const std::string& meshPath)
|
||||||
: openglframework::Mesh(), mVBOVertices(GL_ARRAY_BUFFER),
|
: mVBOVertices(GL_ARRAY_BUFFER),
|
||||||
mVBONormals(GL_ARRAY_BUFFER), mVBOTextureCoords(GL_ARRAY_BUFFER),
|
mVBONormals(GL_ARRAY_BUFFER), mVBOTextureCoords(GL_ARRAY_BUFFER),
|
||||||
mVBOIndices(GL_ELEMENT_ARRAY_BUFFER) {
|
mVBOIndices(GL_ELEMENT_ARRAY_BUFFER) {
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include "PhysicsObject.h"
|
#include "PhysicsObject.h"
|
||||||
|
|
||||||
// Class ConvexMesh
|
// Class ConvexMesh
|
||||||
class ConvexMesh : public openglframework::Mesh, public PhysicsObject {
|
class ConvexMesh : public PhysicsObject {
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ int Cylinder::totalNbCylinders = 0;
|
||||||
Cylinder::Cylinder(float radius, float height, const openglframework::Vector3& position,
|
Cylinder::Cylinder(float radius, float height, const openglframework::Vector3& position,
|
||||||
reactphysics3d::CollisionWorld* world,
|
reactphysics3d::CollisionWorld* world,
|
||||||
const std::string& meshFolderPath)
|
const std::string& meshFolderPath)
|
||||||
: openglframework::Mesh(), mRadius(radius), mHeight(height) {
|
: mRadius(radius), mHeight(height) {
|
||||||
|
|
||||||
// Load the mesh from a file
|
// Load the mesh from a file
|
||||||
openglframework::MeshReaderWriter::loadMeshFromFile(meshFolderPath + "cylinder.obj", *this);
|
openglframework::MeshReaderWriter::loadMeshFromFile(meshFolderPath + "cylinder.obj", *this);
|
||||||
|
@ -85,7 +85,7 @@ Cylinder::Cylinder(float radius, float height, const openglframework::Vector3& p
|
||||||
Cylinder::Cylinder(float radius, float height, const openglframework::Vector3& position,
|
Cylinder::Cylinder(float radius, float height, const openglframework::Vector3& position,
|
||||||
float mass, reactphysics3d::DynamicsWorld* dynamicsWorld,
|
float mass, reactphysics3d::DynamicsWorld* dynamicsWorld,
|
||||||
const std::string& meshFolderPath)
|
const std::string& meshFolderPath)
|
||||||
: openglframework::Mesh(), mRadius(radius), mHeight(height) {
|
: mRadius(radius), mHeight(height) {
|
||||||
|
|
||||||
// Load the mesh from a file
|
// Load the mesh from a file
|
||||||
openglframework::MeshReaderWriter::loadMeshFromFile(meshFolderPath + "cylinder.obj", *this);
|
openglframework::MeshReaderWriter::loadMeshFromFile(meshFolderPath + "cylinder.obj", *this);
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include "PhysicsObject.h"
|
#include "PhysicsObject.h"
|
||||||
|
|
||||||
// Class Cylinder
|
// Class Cylinder
|
||||||
class Cylinder : public openglframework::Mesh, public PhysicsObject {
|
class Cylinder : public PhysicsObject {
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,7 @@ int Dumbbell::totalNbDumbbells = 0;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Dumbbell::Dumbbell(const openglframework::Vector3 &position,
|
Dumbbell::Dumbbell(const openglframework::Vector3 &position,
|
||||||
reactphysics3d::DynamicsWorld* dynamicsWorld, const std::string& meshFolderPath)
|
reactphysics3d::DynamicsWorld* dynamicsWorld, const std::string& meshFolderPath) {
|
||||||
: openglframework::Mesh() {
|
|
||||||
|
|
||||||
// Load the mesh from a file
|
// Load the mesh from a file
|
||||||
openglframework::MeshReaderWriter::loadMeshFromFile(meshFolderPath + "dumbbell.obj", *this);
|
openglframework::MeshReaderWriter::loadMeshFromFile(meshFolderPath + "dumbbell.obj", *this);
|
||||||
|
@ -106,8 +105,7 @@ Dumbbell::Dumbbell(const openglframework::Vector3 &position,
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Dumbbell::Dumbbell(const openglframework::Vector3 &position,
|
Dumbbell::Dumbbell(const openglframework::Vector3 &position,
|
||||||
reactphysics3d::CollisionWorld* world, const std::string& meshFolderPath)
|
reactphysics3d::CollisionWorld* world, const std::string& meshFolderPath) {
|
||||||
: openglframework::Mesh() {
|
|
||||||
|
|
||||||
// Load the mesh from a file
|
// Load the mesh from a file
|
||||||
openglframework::MeshReaderWriter::loadMeshFromFile(meshFolderPath + "dumbbell.obj", *this);
|
openglframework::MeshReaderWriter::loadMeshFromFile(meshFolderPath + "dumbbell.obj", *this);
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include "PhysicsObject.h"
|
#include "PhysicsObject.h"
|
||||||
|
|
||||||
// Class Sphere
|
// Class Sphere
|
||||||
class Dumbbell : public openglframework::Mesh, public PhysicsObject {
|
class Dumbbell : public PhysicsObject {
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
// Constructor
|
// Constructor
|
||||||
HeightField::HeightField(const openglframework::Vector3 &position,
|
HeightField::HeightField(const openglframework::Vector3 &position,
|
||||||
reactphysics3d::CollisionWorld* world)
|
reactphysics3d::CollisionWorld* world)
|
||||||
: openglframework::Mesh(), mVBOVertices(GL_ARRAY_BUFFER),
|
: mVBOVertices(GL_ARRAY_BUFFER),
|
||||||
mVBONormals(GL_ARRAY_BUFFER), mVBOTextureCoords(GL_ARRAY_BUFFER),
|
mVBONormals(GL_ARRAY_BUFFER), mVBOTextureCoords(GL_ARRAY_BUFFER),
|
||||||
mVBOIndices(GL_ELEMENT_ARRAY_BUFFER) {
|
mVBOIndices(GL_ELEMENT_ARRAY_BUFFER) {
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ HeightField::HeightField(const openglframework::Vector3 &position,
|
||||||
// Constructor
|
// Constructor
|
||||||
HeightField::HeightField(const openglframework::Vector3 &position, float mass,
|
HeightField::HeightField(const openglframework::Vector3 &position, float mass,
|
||||||
reactphysics3d::DynamicsWorld* dynamicsWorld)
|
reactphysics3d::DynamicsWorld* dynamicsWorld)
|
||||||
: openglframework::Mesh(), mVBOVertices(GL_ARRAY_BUFFER),
|
: mVBOVertices(GL_ARRAY_BUFFER),
|
||||||
mVBONormals(GL_ARRAY_BUFFER), mVBOTextureCoords(GL_ARRAY_BUFFER),
|
mVBONormals(GL_ARRAY_BUFFER), mVBOTextureCoords(GL_ARRAY_BUFFER),
|
||||||
mVBOIndices(GL_ELEMENT_ARRAY_BUFFER) {
|
mVBOIndices(GL_ELEMENT_ARRAY_BUFFER) {
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
|
|
||||||
// Class HeightField
|
// Class HeightField
|
||||||
class HeightField : public openglframework::Mesh, public PhysicsObject {
|
class HeightField : public PhysicsObject {
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include "PhysicsObject.h"
|
#include "PhysicsObject.h"
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
PhysicsObject::PhysicsObject() {
|
PhysicsObject::PhysicsObject() : openglframework::Mesh() {
|
||||||
|
|
||||||
mColor = openglframework::Color(1, 1, 1, 1);
|
mColor = openglframework::Color(1, 1, 1, 1);
|
||||||
mSleepingColor = openglframework::Color(1, 0, 0, 1);
|
mSleepingColor = openglframework::Color(1, 0, 0, 1);
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#include "reactphysics3d.h"
|
#include "reactphysics3d.h"
|
||||||
|
|
||||||
// Class PhysicsObject
|
// Class PhysicsObject
|
||||||
class PhysicsObject {
|
class PhysicsObject : public openglframework::Mesh {
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ int Sphere::totalNbSpheres = 0;
|
||||||
Sphere::Sphere(float radius, const openglframework::Vector3 &position,
|
Sphere::Sphere(float radius, const openglframework::Vector3 &position,
|
||||||
reactphysics3d::CollisionWorld* world,
|
reactphysics3d::CollisionWorld* world,
|
||||||
const std::string& meshFolderPath)
|
const std::string& meshFolderPath)
|
||||||
: openglframework::Mesh(), mRadius(radius) {
|
: mRadius(radius) {
|
||||||
|
|
||||||
// Load the mesh from a file
|
// Load the mesh from a file
|
||||||
openglframework::MeshReaderWriter::loadMeshFromFile(meshFolderPath + "sphere.obj", *this);
|
openglframework::MeshReaderWriter::loadMeshFromFile(meshFolderPath + "sphere.obj", *this);
|
||||||
|
@ -86,7 +86,7 @@ Sphere::Sphere(float radius, const openglframework::Vector3 &position,
|
||||||
Sphere::Sphere(float radius, const openglframework::Vector3 &position,
|
Sphere::Sphere(float radius, const openglframework::Vector3 &position,
|
||||||
float mass, reactphysics3d::DynamicsWorld* world,
|
float mass, reactphysics3d::DynamicsWorld* world,
|
||||||
const std::string& meshFolderPath)
|
const std::string& meshFolderPath)
|
||||||
: openglframework::Mesh(), mRadius(radius) {
|
: mRadius(radius) {
|
||||||
|
|
||||||
// Load the mesh from a file
|
// Load the mesh from a file
|
||||||
openglframework::MeshReaderWriter::loadMeshFromFile(meshFolderPath + "sphere.obj", *this);
|
openglframework::MeshReaderWriter::loadMeshFromFile(meshFolderPath + "sphere.obj", *this);
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include "PhysicsObject.h"
|
#include "PhysicsObject.h"
|
||||||
|
|
||||||
// Class Sphere
|
// Class Sphere
|
||||||
class Sphere : public openglframework::Mesh, public PhysicsObject {
|
class Sphere : public PhysicsObject {
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
|
|
|
@ -195,19 +195,19 @@ void CubesScene::reset() {
|
||||||
|
|
||||||
float radius = 2.0f;
|
float radius = 2.0f;
|
||||||
|
|
||||||
for (int i=0; i<NB_CUBES; i++) {
|
// for (int i=0; i<NB_CUBES; i++) {
|
||||||
|
|
||||||
// Position of the cubes
|
// // Position of the cubes
|
||||||
float angle = i * 30.0f;
|
// float angle = i * 30.0f;
|
||||||
openglframework::Vector3 position(radius * cos(angle),
|
// openglframework::Vector3 position(radius * cos(angle),
|
||||||
10 + i * (BOX_SIZE.y + 0.3f),
|
// 10 + i * (BOX_SIZE.y + 0.3f),
|
||||||
0);
|
// 0);
|
||||||
|
|
||||||
// Initial position and orientation of the rigid body
|
// // Initial position and orientation of the rigid body
|
||||||
rp3d::Vector3 initPosition(position.x, position.y, position.z);
|
// rp3d::Vector3 initPosition(position.x, position.y, position.z);
|
||||||
rp3d::Quaternion initOrientation = rp3d::Quaternion::identity();
|
// rp3d::Quaternion initOrientation = rp3d::Quaternion::identity();
|
||||||
rp3d::Transform transform(initPosition, initOrientation);
|
// rp3d::Transform transform(initPosition, initOrientation);
|
||||||
|
|
||||||
mBoxes[i]->resetTransform(transform);
|
// mBoxes[i]->resetTransform(transform);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user