diff --git a/assets/meshes/ghost.bcosm b/assets/meshes/ghost.bcosm new file mode 100644 index 0000000..83b3348 Binary files /dev/null and b/assets/meshes/ghost.bcosm differ diff --git a/assets/meshes/kart-vehicle.bcosm b/assets/meshes/kart-vehicle.bcosm index 46d272b..1a1a737 100644 Binary files a/assets/meshes/kart-vehicle.bcosm and b/assets/meshes/kart-vehicle.bcosm differ diff --git a/assets/meshes/static-platform.bcosm b/assets/meshes/static-platform.bcosm new file mode 100644 index 0000000..cf423a6 Binary files /dev/null and b/assets/meshes/static-platform.bcosm differ diff --git a/assets/meshes/static-platform.bcosps b/assets/meshes/static-platform.bcosps new file mode 100644 index 0000000..cf423a6 Binary files /dev/null and b/assets/meshes/static-platform.bcosps differ diff --git a/assets/textures/ghost-red-diffuse.png b/assets/textures/ghost-red-diffuse.png new file mode 100644 index 0000000..366e84f Binary files /dev/null and b/assets/textures/ghost-red-diffuse.png differ diff --git a/assets/textures/ghost-white-diffuse.png b/assets/textures/ghost-white-diffuse.png new file mode 100644 index 0000000..96deb46 Binary files /dev/null and b/assets/textures/ghost-white-diffuse.png differ diff --git a/assets/textures/static-platform-diffuse.png b/assets/textures/static-platform-diffuse.png new file mode 100644 index 0000000..d4b7829 Binary files /dev/null and b/assets/textures/static-platform-diffuse.png differ diff --git a/src/JamSpookGame.cpp b/src/JamSpookGame.cpp index 8766bef..877d0e7 100644 --- a/src/JamSpookGame.cpp +++ b/src/JamSpookGame.cpp @@ -41,7 +41,8 @@ JamSpookGame::JamSpookGame(): addSystem(make_shared()); // Add physics related asset loaders - assetSystem->addLoader(make_shared(assetPath), "CollisionShapeLoader"); + assetSystem->addLoader(make_shared(assetPath), "CollisionShapeLoader"); + assetSystem->addLoader(make_shared(assetPath), "StaticCollisionShapeLoader"); // Create animation system addSystem(make_shared()); @@ -66,11 +67,11 @@ JamSpookGame::JamSpookGame(): addSystem(make_shared()); // Add graphics related asset loaders - assetSystem->addLoader(make_shared(assetPath), "MeshLoader"); - assetSystem->addLoader(make_shared(assetPath), "ShaderLoader"); + assetSystem->addLoader(make_shared(assetPath), "MeshLoader"); + assetSystem->addLoader(make_shared(assetPath), "ShaderLoader"); assetSystem->addLoader(make_shared(assetPath), "ShaderProgramLoader"); - assetSystem->addLoader(make_shared(assetPath), "TextureFileLoader"); - assetSystem->addLoader(make_shared(assetPath), "TextureBlankLoader"); + assetSystem->addLoader(make_shared(assetPath), "TextureFileLoader"); + assetSystem->addLoader(make_shared(assetPath), "TextureBlankLoader"); // Add render layer compositor shader ShaderProgramFactory* shaderProgramFactory = new ShaderProgramFactory(assetSystem); @@ -200,9 +201,9 @@ void JamSpookGame::set() dynamic_pointer_cast(findSystem(IDCache::get("InteractionSystem")))); lightingFactory->createSun(10.0f, - vec3(0,0,0), + vec3(45,-45,0), vec3(1,1,1), - 0.1f, + 0.5f, renderLayerGame); lightingFactory.reset(); @@ -234,8 +235,8 @@ void JamSpookGame::set() dynamic_pointer_cast(findSystem(IDCache::get("PhysicsSystem"))), renderLayerGame); - jump180Factory->createJump180(vec3(0, 0, 0), vec3(0, 0, 0)); - jump180Factory->createJump180(vec3(25,-15, 14), vec3(0, 180, 0)); + jump180Factory->createJump180(vec3(0, -1, 0), vec3(0, 0, 0)); + jump180Factory->createJump180(vec3(25,-16, 14), vec3(0, 180, 0)); jump180Factory.reset(); @@ -246,7 +247,7 @@ void JamSpookGame::set() dynamic_pointer_cast(findSystem(IDCache::get("PhysicsSystem"))), renderLayerGame); - goalFactory->createGoal(vec3(-1, -30, -12)); + goalFactory->createGoal(vec3(-1, -31, -12)); // goalFactory->createGoal(vec3(0, 0, 0)); goalFactory.reset(); @@ -261,6 +262,31 @@ void JamSpookGame::set() // trackPieceFactory->createRoad(); // trackPieceFactory->createTunnel(); // trackPieceFactory->createMountain(); + +// trackPieceFactory->createStaticPlatform(); + + trackPieceFactory->createGhost("SadGhost", + "ghost-white-diffuse.png", + vec3(20, -15, 10), + quat(vec3(radians(0.0f), radians(45.0f), radians(0.0f))), + 5.0f); + + trackPieceFactory->createGhost("AngryGhost", + "ghost-red-diffuse.png", + vec3(-8, -25, -18), + quat(vec3(radians(0.0f), radians(15.0f), radians(0.0f))), + 5.0f); + + + + + + // End scene entities + trackPieceFactory->createGhost("SadGhost", + "ghost-white-diffuse.png", + vec3(1005, 4, 1001), + quat(vec3(radians(0.0f), radians(45.0f), radians(0.0f)))); + trackPieceFactory->createSign("ThankYouSign", "sign-thanks-diffuse.png", vec3(994, 0, 1000), @@ -326,7 +352,7 @@ void JamSpookGame::set() renderLayerGame); shared_ptr endGameEntity = resetTriggerFactory-> - createResetTrigger(vec3(-1, -30, -12), + createResetTrigger(vec3(-1, -31, -12), vec3(1)); // shared_ptr endGameEntity = resetTriggerFactory-> diff --git a/src/JamSpookGame.h b/src/JamSpookGame.h index 7a495c0..6f57fff 100644 --- a/src/JamSpookGame.h +++ b/src/JamSpookGame.h @@ -36,6 +36,7 @@ #include #include +#include #include @@ -116,6 +117,7 @@ using ecos::asset::DataManagementMode; using ecos::physics::PhysicsSystem; using ecos::physics::CollisionShapeLoader; +using ecos::physics::StaticCollisionShapeLoader; using ecos::animation::AnimationSystem; diff --git a/src/entities/KartPhysicsComponent.cpp b/src/entities/KartPhysicsComponent.cpp index c25e89a..a34b8c3 100644 --- a/src/entities/KartPhysicsComponent.cpp +++ b/src/entities/KartPhysicsComponent.cpp @@ -76,7 +76,8 @@ void KartPhysicsComponent::onICCMessage(shared_ptr message) void KartPhysicsComponent::onCollision(const string& tag) { - if (tag == "goal") + if (tag == "goal" + || tag == "jump180") { ICCBroadcast(make_shared(IDCache::get("GroundCollisionMessage"))); } @@ -92,7 +93,8 @@ void KartPhysicsComponent::onCollision(const string& tag) void KartPhysicsComponent::onSeparation(const string& tag) { - if (tag == "goal") + if (tag == "goal" + || tag == "jump180") { ICCBroadcast(make_shared(IDCache::get("GroundSeparationMessage"))); } diff --git a/src/entities/TrackPieceFactory.cpp b/src/entities/TrackPieceFactory.cpp index 64d0762..d877c09 100644 --- a/src/entities/TrackPieceFactory.cpp +++ b/src/entities/TrackPieceFactory.cpp @@ -218,4 +218,95 @@ shared_ptr TrackPieceFactory::createSign( return entity; } +shared_ptr TrackPieceFactory::createGhost( + const string name, + const string diffuseTextureFilePath, + vec3 position, + quat orientation, + float scaling) +{ + // Create instance + shared_ptr entity = make_shared(); + entity->setEntityTag(name + "_ghost"); + SceneGraph::addEntity(entity); + + // Create transform + mat4 translationMatrix = translate(mat4(1.0f), position); + mat4 rotationMatrix = glm::toMat4(orientation); + mat4 scalingMatrix = glm::scale(mat4(1), vec3(scaling)); + + + mat4 transform = translationMatrix * rotationMatrix * scalingMatrix;// * rotateToCenter; + + // Add graphics component + shared_ptr graphicsComponent = make_shared(transform, + entity, + getShared(mGraphicsSystem), + mRenderLayer); + entity->addComponent(graphicsComponent); + + // Add the ModelRenderable + ModelRenderableFactory* modelFactory = new ModelRenderableFactory(mAssetSystem); + shared_ptr modelRenderable = modelFactory->createModel("ghost.bcosm", + diffuseTextureFilePath, + name + "-model"); + delete modelFactory; + graphicsComponent->addRenderable(modelRenderable); + + // Return instance + return entity; +} + +shared_ptr TrackPieceFactory::createStaticPlatform() +{ + // Create instance + shared_ptr entity = make_shared(); + entity->setEntityTag("staticPlatform"); + SceneGraph::addEntity(entity); + + // Create transform + mat4 transform = mat4(1); + + // Add physics component + ColliderFactory* colliderFactory = new ColliderFactory(mPhysicsSystem, mAssetSystem); + shared_ptr physicsComponent = + make_shared( + transform, + entity, + getShared(mPhysicsSystem), + getShared(mPhysicsSystem), + getShared(mPhysicsSystem), + colliderFactory->createStaticMeshCollider(vec3(0), + quat_cast(mat4(1)), + "static-platform.bcosps", // filePath + "static-platform-shape", // name + 100.0f, // mass + entity, + entity->getEntityTag())); + delete colliderFactory; + // Note: Editing of rigid body params, maybe only has effect is it has been added to the world. + physicsComponent->getCollider()->getRigidBody()->setLinearFactor(btVector3(0, 0, 0)); // deny positional movement movement in any axis + physicsComponent->getCollider()->getRigidBody()->setAngularFactor(btVector3(0, 0, 0)); // deny rotational movement movement in any axis + physicsComponent->getCollider()->getRigidBody()->setRestitution(1); + entity->addComponent(physicsComponent); + + // Add graphics component + shared_ptr graphicsComponent = make_shared(transform, + entity, + getShared(mGraphicsSystem), + mRenderLayer); + entity->addComponent(graphicsComponent); + + // Add the ModelRenderable of a ball + ModelRenderableFactory* modelFactory = new ModelRenderableFactory(mAssetSystem); + shared_ptr modelRenderable = modelFactory->createModel("static-platform.bcosm", + "static-platform-diffuse.png", + "static-platform-model"); + delete modelFactory; + graphicsComponent->addRenderable(modelRenderable); + + // Return instance + return entity; +} + } // namespace JamSpook diff --git a/src/entities/TrackPieceFactory.h b/src/entities/TrackPieceFactory.h index 1769c5b..0ef6faa 100644 --- a/src/entities/TrackPieceFactory.h +++ b/src/entities/TrackPieceFactory.h @@ -140,6 +140,15 @@ public: const string diffuseTextureFilePath, vec3 position, quat orientation); + + /// Compose a ghost entity + shared_ptr createGhost(const string name, + const string diffuseTextureFilePath, + vec3 position, + quat orientation, + float scaling = 1.0f); + + shared_ptr createStaticPlatform(); }; } // namespace JamSpook