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