diff --git a/deploy/data/bottle.mtl b/deploy/data/bottle.mtl new file mode 100644 index 0000000..edc86e8 --- /dev/null +++ b/deploy/data/bottle.mtl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:300b00c4ac5aa02f028e7325668f997802893b7f47374d02ffb28427f45e0ee9 +size 125 diff --git a/deploy/data/bottle.obj b/deploy/data/bottle.obj new file mode 100644 index 0000000..d19192f --- /dev/null +++ b/deploy/data/bottle.obj @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2d135ed2f4867ebce04ec2616c7f6fc81d400d78b723ede424f8ddff87b47f86 +size 87980 diff --git a/deploy/data/bottle_albedo.png b/deploy/data/bottle_albedo.png new file mode 100644 index 0000000..800135d --- /dev/null +++ b/deploy/data/bottle_albedo.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dd4c9df9578a81fdd69eab540d20f265c77b16377b7d2dbf5157fb84b72d3717 +size 549356 diff --git a/deploy/data/bottle_normal.png b/deploy/data/bottle_normal.png new file mode 100644 index 0000000..859b52c --- /dev/null +++ b/deploy/data/bottle_normal.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:727b088fa208a895623848b733e3f007ed956da5b7571969fdb840469d6f0d04 +size 496427 diff --git a/deploy/data/bottle_roughness.png b/deploy/data/bottle_roughness.png new file mode 100644 index 0000000..30c6fd0 --- /dev/null +++ b/deploy/data/bottle_roughness.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8e7af64046262494af9603a779f65f97b835f478ff0925a86a84f5bf7e29cc52 +size 8193 diff --git a/deploy/data/slipperystonework_albedo.png b/deploy/data/slipperystonework_albedo.png deleted file mode 100644 index 25807b0..0000000 --- a/deploy/data/slipperystonework_albedo.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:162ceea8b3cc087aa4bcb25db70a88b433649e6e8a7f491ba50cc2581585bf47 -size 7314341 diff --git a/deploy/data/slipperystonework_metallic.png b/deploy/data/slipperystonework_metallic.png deleted file mode 100644 index fa88b15..0000000 --- a/deploy/data/slipperystonework_metallic.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:16ab4394f49880fe64b2a6405592a0325367f184d4829d8219612aef91c05f18 -size 15009 diff --git a/deploy/data/slipperystonework_normal.png b/deploy/data/slipperystonework_normal.png deleted file mode 100644 index c88630f..0000000 --- a/deploy/data/slipperystonework_normal.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ce7fa8504ccc7ef77e9dcb16bd1e1043797de43783dfbe472bf52ffb6e65da56 -size 7533234 diff --git a/deploy/data/slipperystonework_roughness.png b/deploy/data/slipperystonework_roughness.png deleted file mode 100644 index 6bd8a2c..0000000 --- a/deploy/data/slipperystonework_roughness.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:3c3f730b52ba57e9b5f64490b27a702b38222d043264d3e414722dbe5bac6bd1 -size 4799103 diff --git a/src/test/potator.cpp b/src/test/potator.cpp index e342077..416508a 100644 --- a/src/test/potator.cpp +++ b/src/test/potator.cpp @@ -17,15 +17,14 @@ Potator::Potator(PlayerCharacterNode * player, int cube_action, - int sphere_action, + int bottle_action, int object_action) : m_player(player), m_throwCubeAction(cube_action), - m_throwSphereAction(sphere_action), + m_throwBottleAction(bottle_action), m_throwObjectAction(object_action) { glm::vec3 cubeDim(1); - float sphereRadius = 0.5f; glm::vec3 s = cubeDim*0.5f; float density = 1.f; @@ -88,28 +87,18 @@ Potator::Potator(PlayerCharacterNode * player, m_cubeMass = cubeDim.x*cubeDim.y*cubeDim.z*density; - // creating sphere - mat = new PBRMaterial(); - Image* img = Loader::loadImage("slipperystonework_albedo.png", 24); - mat->setTexture(PBRMaterial::ALBEDO_SLOT, new Texture(img)); - img = Loader::loadImage("slipperystonework_metallic.png", 8); - mat->setTexture(PBRMaterial::METALLIC_SLOT, new Texture(img)); - img = Loader::loadImage("slipperystonework_roughness.png", 8); - mat->setTexture(PBRMaterial::ROUGHNESS_SLOT, new Texture(img)); - img = Loader::loadImage("slipperystonework_normal.png", 24); - mat->setTexture(PBRMaterial::NORMALS_SLOT, new Texture(img)); + // creating bottle + m_bottleMeshes = Loader::loadMesh("bottle.obj"); + for(Mesh* m : m_bottleMeshes) + m->initGL(); - SphereGenerator sphereGen; - m_sphereMesh = sphereGen.generateParametricMesh(mat, 20, 20, sphereRadius); - m_sphereMesh->computeNormals(); - m_sphereMesh->computeTangents(); - m_sphereMesh->mergeVertices(); - m_sphereMesh->initGL(); + btCompoundShape* bottleShape = new btCompoundShape(); + btTransform bottleTransform = btTransform::getIdentity(); + bottleTransform.setOrigin(btVector3(0.f, 0.19f, 0.f)); + bottleShape->addChildShape(bottleTransform, new btConeShape(0.12+PHYSICS_OFFSET, 0.38+PHYSICS_OFFSET)); + m_bottleShape = bottleShape; - m_sphereShape = new btSphereShape(sphereRadius+PHYSICS_OFFSET); - - float sphereVolume = 4.18879020479f*(sphereRadius*sphereRadius*sphereRadius); // (4*pi)/3 = 4.18879020479 - m_sphereMass = sphereVolume*density; + m_bottleMass = 0.25f; // creating sword : m_swordMeshes = Loader::loadMesh("sword.obj"); @@ -143,7 +132,7 @@ void Potator::throwCube() createGib(new MeshNode(m_cubeMesh), m_cubeShape, m_cubeMass, pos, dir*throwForce, 30000); } -void Potator::throwSphere() +void Potator::throwBottle() { glm::vec3 pos(0, 10, 0); glm::vec3 dir(0, 1, 0); @@ -154,7 +143,10 @@ void Potator::throwSphere() } float throwForce = 5.f; - createGib(new MeshNode(m_sphereMesh), m_sphereShape, m_sphereMass, pos, dir*throwForce, 30000); + GraphicalContainerNode *node = new GraphicalContainerNode(); + for(Mesh * m : m_bottleMeshes) + node->addChild(new MeshNode(m)); + createGib(node, m_bottleShape, m_bottleMass, pos, dir*throwForce, 30000); } void Potator::throwSword() @@ -185,8 +177,8 @@ void Potator::update() { if(action.action == m_throwCubeAction) throwCube(); - else if(action.action == m_throwSphereAction) - throwSphere(); + else if(action.action == m_throwBottleAction) + throwBottle(); else if(action.action == m_throwObjectAction) throwSword(); } diff --git a/src/test/potator.h b/src/test/potator.h index bb08213..bbe48a7 100644 --- a/src/test/potator.h +++ b/src/test/potator.h @@ -11,23 +11,23 @@ class Potator : public GibGeneratorNode { PlayerCharacterNode *m_player; int m_throwCubeAction; - int m_throwSphereAction; + int m_throwBottleAction; int m_throwObjectAction; Mesh* m_cubeMesh; btCollisionShape* m_cubeShape; float m_cubeMass; - Mesh* m_sphereMesh; - btCollisionShape* m_sphereShape; - float m_sphereMass; + std::vector m_bottleMeshes; + btCollisionShape* m_bottleShape; + float m_bottleMass; std::vector m_swordMeshes; btCollisionShape* m_swordShape; float m_swordMass; void throwCube(); - void throwSphere(); + void throwBottle(); void throwSword(); public: @@ -39,7 +39,7 @@ public: void setPlayer(PlayerCharacterNode *player) { m_player = player; } void setCubeThrowingAction(int action) { m_throwCubeAction = action; } - void setSphereThrowingAction(int action) { m_throwSphereAction = action; } + void setSphereThrowingAction(int action) { m_throwBottleAction = action; } void setObjectThrowingAction(int action) { m_throwObjectAction = action; } virtual void update();