replaced the sphere by a potion

This commit is contained in:
Anselme 2017-08-31 00:56:02 +02:00
parent 36d5b79c9f
commit 467a50139a
11 changed files with 40 additions and 45 deletions

3
deploy/data/bottle.mtl Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:300b00c4ac5aa02f028e7325668f997802893b7f47374d02ffb28427f45e0ee9
size 125

3
deploy/data/bottle.obj Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2d135ed2f4867ebce04ec2616c7f6fc81d400d78b723ede424f8ddff87b47f86
size 87980

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:dd4c9df9578a81fdd69eab540d20f265c77b16377b7d2dbf5157fb84b72d3717
size 549356

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:727b088fa208a895623848b733e3f007ed956da5b7571969fdb840469d6f0d04
size 496427

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8e7af64046262494af9603a779f65f97b835f478ff0925a86a84f5bf7e29cc52
size 8193

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:162ceea8b3cc087aa4bcb25db70a88b433649e6e8a7f491ba50cc2581585bf47
size 7314341

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:16ab4394f49880fe64b2a6405592a0325367f184d4829d8219612aef91c05f18
size 15009

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ce7fa8504ccc7ef77e9dcb16bd1e1043797de43783dfbe472bf52ffb6e65da56
size 7533234

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3c3f730b52ba57e9b5f64490b27a702b38222d043264d3e414722dbe5bac6bd1
size 4799103

View File

@ -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();
}

View File

@ -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<Mesh*> m_bottleMeshes;
btCollisionShape* m_bottleShape;
float m_bottleMass;
std::vector<Mesh*> 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();