Edit collision detection scene
This commit is contained in:
parent
319cc72cde
commit
11589dbb2c
|
@ -72,7 +72,7 @@ CollisionDetectionScene::CollisionDetectionScene(const std::string& name)
|
||||||
mSphere2->setSleepingColor(mRedColorDemo);
|
mSphere2->setSleepingColor(mRedColorDemo);
|
||||||
|
|
||||||
// ---------- Capsule 1 ---------- //
|
// ---------- Capsule 1 ---------- //
|
||||||
openglframework::Vector3 position3(0, -12, 0);
|
openglframework::Vector3 position3(-6, 7, 0);
|
||||||
|
|
||||||
// Create a cylinder and a corresponding collision body in the dynamics world
|
// Create a cylinder and a corresponding collision body in the dynamics world
|
||||||
mCapsule1 = new Capsule(CAPSULE_RADIUS, CAPSULE_HEIGHT, position3, mCollisionWorld, mMeshFolderPath);
|
mCapsule1 = new Capsule(CAPSULE_RADIUS, CAPSULE_HEIGHT, position3, mCollisionWorld, mMeshFolderPath);
|
||||||
|
@ -83,7 +83,7 @@ CollisionDetectionScene::CollisionDetectionScene(const std::string& name)
|
||||||
mCapsule1->setSleepingColor(mRedColorDemo);
|
mCapsule1->setSleepingColor(mRedColorDemo);
|
||||||
|
|
||||||
// ---------- Capsule 2 ---------- //
|
// ---------- Capsule 2 ---------- //
|
||||||
openglframework::Vector3 position4(-8, 0, 0);
|
openglframework::Vector3 position4(11, -8, 0);
|
||||||
|
|
||||||
// Create a cylinder and a corresponding collision body in the dynamics world
|
// Create a cylinder and a corresponding collision body in the dynamics world
|
||||||
mCapsule2 = new Capsule(CAPSULE_RADIUS, CAPSULE_HEIGHT, position4, mCollisionWorld, mMeshFolderPath);
|
mCapsule2 = new Capsule(CAPSULE_RADIUS, CAPSULE_HEIGHT, position4, mCollisionWorld, mMeshFolderPath);
|
||||||
|
@ -115,38 +115,16 @@ CollisionDetectionScene::CollisionDetectionScene(const std::string& name)
|
||||||
mBox2->setColor(mGreyColorDemo);
|
mBox2->setColor(mGreyColorDemo);
|
||||||
mBox2->setSleepingColor(mRedColorDemo);
|
mBox2->setSleepingColor(mRedColorDemo);
|
||||||
|
|
||||||
// ---------- Cone ---------- //
|
|
||||||
//openglframework::Vector3 position4(0, 0, 0);
|
|
||||||
|
|
||||||
// Create a cone and a corresponding collision body in the dynamics world
|
|
||||||
//mCone = new Cone(CONE_RADIUS, CONE_HEIGHT, position4, mCollisionWorld,
|
|
||||||
// mMeshFolderPath);
|
|
||||||
|
|
||||||
// Set the color
|
|
||||||
//mCone->setColor(mGreyColorDemo);
|
|
||||||
//mCone->setSleepingColor(mRedColorDemo);
|
|
||||||
|
|
||||||
// ---------- Cylinder ---------- //
|
|
||||||
//openglframework::Vector3 position5(0, 0, 0);
|
|
||||||
|
|
||||||
// Create a cylinder and a corresponding collision body in the dynamics world
|
|
||||||
//mCylinder = new Cylinder(CYLINDER_RADIUS, CYLINDER_HEIGHT, position5,
|
|
||||||
// mCollisionWorld, mMeshFolderPath);
|
|
||||||
|
|
||||||
// Set the color
|
|
||||||
//mCylinder->setColor(mGreyColorDemo);
|
|
||||||
//mCylinder->setSleepingColor(mRedColorDemo);
|
|
||||||
|
|
||||||
|
|
||||||
// ---------- Convex Mesh ---------- //
|
// ---------- Convex Mesh ---------- //
|
||||||
//openglframework::Vector3 position7(0, 0, 0);
|
openglframework::Vector3 position7(-5, 0, 0);
|
||||||
|
|
||||||
// Create a convex mesh and a corresponding collision body in the dynamics world
|
// Create a convex mesh and a corresponding collision body in the dynamics world
|
||||||
//mConvexMesh = new ConvexMesh(position7, mCollisionWorld, mMeshFolderPath + "convexmesh.obj");
|
mConvexMesh = new ConvexMesh(position7, mCollisionWorld, mMeshFolderPath + "convexmesh.obj");
|
||||||
|
mAllShapes.push_back(mConvexMesh);
|
||||||
|
|
||||||
// Set the color
|
// Set the color
|
||||||
//mConvexMesh->setColor(mGreyColorDemo);
|
mConvexMesh->setColor(mGreyColorDemo);
|
||||||
//mConvexMesh->setSleepingColor(mRedColorDemo);
|
mConvexMesh->setSleepingColor(mRedColorDemo);
|
||||||
|
|
||||||
// ---------- Concave Mesh ---------- //
|
// ---------- Concave Mesh ---------- //
|
||||||
//openglframework::Vector3 position8(0, 0, 0);
|
//openglframework::Vector3 position8(0, 0, 0);
|
||||||
|
@ -202,6 +180,9 @@ CollisionDetectionScene::~CollisionDetectionScene() {
|
||||||
mCollisionWorld->destroyCollisionBody(mBox2->getCollisionBody());
|
mCollisionWorld->destroyCollisionBody(mBox2->getCollisionBody());
|
||||||
delete mBox2;
|
delete mBox2;
|
||||||
|
|
||||||
|
mCollisionWorld->destroyCollisionBody(mConvexMesh->getCollisionBody());
|
||||||
|
delete mConvexMesh;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// Destroy the corresponding rigid body from the dynamics world
|
// Destroy the corresponding rigid body from the dynamics world
|
||||||
mCollisionWorld->destroyCollisionBody(mCone->getCollisionBody());
|
mCollisionWorld->destroyCollisionBody(mCone->getCollisionBody());
|
||||||
|
@ -219,12 +200,6 @@ CollisionDetectionScene::~CollisionDetectionScene() {
|
||||||
// Destroy the sphere
|
// Destroy the sphere
|
||||||
delete mCapsule;
|
delete mCapsule;
|
||||||
|
|
||||||
// Destroy the corresponding rigid body from the dynamics world
|
|
||||||
mCollisionWorld->destroyCollisionBody(mConvexMesh->getCollisionBody());
|
|
||||||
|
|
||||||
// Destroy the convex mesh
|
|
||||||
delete mConvexMesh;
|
|
||||||
|
|
||||||
// Destroy the corresponding rigid body from the dynamics world
|
// Destroy the corresponding rigid body from the dynamics world
|
||||||
mCollisionWorld->destroyCollisionBody(mDumbbell->getCollisionBody());
|
mCollisionWorld->destroyCollisionBody(mDumbbell->getCollisionBody());
|
||||||
|
|
||||||
|
@ -280,13 +255,13 @@ void CollisionDetectionScene::renderSinglePass(openglframework::Shader& shader,
|
||||||
if (mCapsule2->getCollisionBody()->isActive()) mCapsule2->render(shader, worldToCameraMatrix, mIsWireframeEnabled);
|
if (mCapsule2->getCollisionBody()->isActive()) mCapsule2->render(shader, worldToCameraMatrix, mIsWireframeEnabled);
|
||||||
if (mBox1->getCollisionBody()->isActive()) mBox1->render(shader, worldToCameraMatrix, mIsWireframeEnabled);
|
if (mBox1->getCollisionBody()->isActive()) mBox1->render(shader, worldToCameraMatrix, mIsWireframeEnabled);
|
||||||
if (mBox2->getCollisionBody()->isActive()) mBox2->render(shader, worldToCameraMatrix, mIsWireframeEnabled);
|
if (mBox2->getCollisionBody()->isActive()) mBox2->render(shader, worldToCameraMatrix, mIsWireframeEnabled);
|
||||||
|
if (mConvexMesh->getCollisionBody()->isActive()) mConvexMesh->render(shader, worldToCameraMatrix, mIsWireframeEnabled);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (mBox->getCollisionBody()->isActive()) mBox->render(shader, worldToCameraMatrix);
|
if (mBox->getCollisionBody()->isActive()) mBox->render(shader, worldToCameraMatrix);
|
||||||
if (mCone->getCollisionBody()->isActive()) mCone->render(shader, worldToCameraMatrix);
|
if (mCone->getCollisionBody()->isActive()) mCone->render(shader, worldToCameraMatrix);
|
||||||
if (mCylinder->getCollisionBody()->isActive()) mCylinder->render(shader, worldToCameraMatrix);
|
if (mCylinder->getCollisionBody()->isActive()) mCylinder->render(shader, worldToCameraMatrix);
|
||||||
if (mCapsule->getCollisionBody()->isActive()) mCapsule->render(shader, worldToCameraMatrix);
|
if (mCapsule->getCollisionBody()->isActive()) mCapsule->render(shader, worldToCameraMatrix);
|
||||||
if (mConvexMesh->getCollisionBody()->isActive()) mConvexMesh->render(shader, worldToCameraMatrix);
|
|
||||||
if (mDumbbell->getCollisionBody()->isActive()) mDumbbell->render(shader, worldToCameraMatrix);
|
if (mDumbbell->getCollisionBody()->isActive()) mDumbbell->render(shader, worldToCameraMatrix);
|
||||||
if (mConcaveMesh->getCollisionBody()->isActive()) mConcaveMesh->render(shader, worldToCameraMatrix);
|
if (mConcaveMesh->getCollisionBody()->isActive()) mConcaveMesh->render(shader, worldToCameraMatrix);
|
||||||
if (mHeightField->getCollisionBody()->isActive()) mHeightField->render(shader, worldToCameraMatrix);
|
if (mHeightField->getCollisionBody()->isActive()) mHeightField->render(shader, worldToCameraMatrix);
|
||||||
|
|
|
@ -107,6 +107,8 @@ class ContactManager : public rp3d::CollisionCallback {
|
||||||
|
|
||||||
contactPoint = contactPoint->getNext();
|
contactPoint = contactPoint->getNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
manifoldElement = manifoldElement->getNext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,10 +145,7 @@ class CollisionDetectionScene : public SceneDemo {
|
||||||
Capsule* mCapsule2;
|
Capsule* mCapsule2;
|
||||||
Box* mBox1;
|
Box* mBox1;
|
||||||
Box* mBox2;
|
Box* mBox2;
|
||||||
//Cone* mCone;
|
ConvexMesh* mConvexMesh;
|
||||||
//Cylinder* mCylinder;
|
|
||||||
//Capsule* mCapsule;
|
|
||||||
//ConvexMesh* mConvexMesh;
|
|
||||||
//Dumbbell* mDumbbell;
|
//Dumbbell* mDumbbell;
|
||||||
//ConcaveMesh* mConcaveMesh;
|
//ConcaveMesh* mConcaveMesh;
|
||||||
//HeightField* mHeightField;
|
//HeightField* mHeightField;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user